Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Thor 2.0 released!  (Read 282582 times)

0 Members and 1 Guest are viewing this topic.

Kojay

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Thor 2.0 released!
« Reply #465 on: January 20, 2016, 06:47:25 am »
You are correct. This reproduces the issue

if (event.type == sf::Event::KeyPressed){
    if (event.key.code == sf::Keyboard::Tab){
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::LShift))
            std::cout << "ShiftTab" << std::endl;
    }
}
if (event.type == sf::Event::KeyPressed){
    if (event.key.code == sf::Keyboard::Tab){
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::LControl))
            std::cout << "CtrlTab" << std::endl;
    }
}
 

I will test this on other OS/desktop. However, Shift+Tab does work fine for other applications (ie Firefox).

Edit: I will also add that the issue persists with this code
if (event.type == sf::Event::KeyPressed){
    if (event.key.code == sf::Keyboard::Tab){
        if (event.key.control)
            std::cout << "CtrlTab" << std::endl;
        if (event.key.shift)
            std::cout << "ShiftTab" << std::endl;
    }
}
 

Update: this was an SFML problem (didn't return the correct code) which has been fixed for a while

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10150
    • View Profile
    • development blog
    • Email
Re: Thor 2.0 released!
« Reply #466 on: March 11, 2016, 10:24:18 am »
Have you ever thought about adding asynchronous resource loading?
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6274
  • Thor Developer
    • View Profile
    • Bromeon
A promising future
« Reply #467 on: March 11, 2016, 02:04:27 pm »
I have, but not in detail yet... At the moment, the thor::ResourceHolder is not really designed for asynchronous loading, as it returns resources instantly. I think the nicest asynchronous implementation would base on promises and futures, so that a client can asynchronously request the loading at startup, and access the loaded resource at a later stage, as well as check the state in between.

Aren't there several issues with SFML resources being loaded from other threads, especially textures? Since Thor is almost always used together with SFML, this is something I have to keep in mind.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10150
    • View Profile
    • development blog
    • Email
Re: A promising future
« Reply #468 on: March 11, 2016, 02:18:32 pm »
I think the nicest asynchronous implementation would base on promises and futures, so that a client can asynchronously request the loading at startup, and access the loaded resource at a later stage, as well as check the state in between.
That what I've been thinking of as well.

Aren't there several issues with SFML resources being loaded from other threads, especially textures? Since Thor is almost always used together with SFML, this is something I have to keep in mind.
I guess sf::Texture can't/shouldn't be used directly. It would be nice to just load the image from disk into RAM and when used first or so, you move the image data from RAM to VRAM. This would be good enough in most cases since loading from disk is usually the bottleneck.
For sf::Font I just had a look at the implementation and it seems like loadFrom* doesn't use OpenGL, so this may work without problems.
I assume sf::SoundBuffer would work fine too, but I don't know what the threading restraints are.
sf::Image, no problem.
And for sf::Shader I have no idea.
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

DurtyFree

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Thor 2.0 released!
« Reply #469 on: May 15, 2016, 02:32:34 am »
I have some questions regarding the animations library.

It seems like I am not able to play differrent animations for different sprites at the same time.
I have 2 entities ( 1 Player, 1 NPC ), the players movement is triggered by user input. The NPC just moves to random coordinates. Both entities call a function from my AnimationHandler => PlayAnimation(string animationId, Sprite sprite, bool loop = false), where animationId is the id of the animation to play on the given sprite.
This function runs PlayAnimation(animationId, loop) on the animator and adds the given Sprite to a list.

Then in the game loop I call the animate and the update function of my AnimationHandler, the update function triggers the update of the animator, the animate function runs trough a list of sprites and animates them.

This works perfect for 1 entity, but as i try to handle 2 entities with different animations running, it doesnt seem to work. How am I able to build an working AnimationHandler for more than 1 entity?

//Edit:
I already fixed my problem.
« Last Edit: May 16, 2016, 07:37:13 pm by DurtyFree »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6274
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 released!
« Reply #470 on: May 20, 2016, 11:40:48 pm »
//Edit:
I already fixed my problem.
You should explain how, for future readers.

In general, you're supposed to use one thor::Animator instance per object you want to animate. Every animator stores its own independent state of the animation. The animations themselves are stored in a thor::AnimationMap object, which is referenced by thor::Animator.

-> Documentation
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10150
    • View Profile
    • development blog
    • Email
Re: Thor 2.0 released!
« Reply #471 on: July 14, 2016, 05:25:55 pm »
We need updated tutorials for the in-development version! ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

Ungod

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: A promising future
« Reply #472 on: July 15, 2016, 09:55:43 pm »
Aren't there several issues with SFML resources being loaded from other threads, especially textures? Since Thor is almost always used together with SFML, this is something I have to keep in mind.

I use (my own) multithreaded-ressource loader for (sfml-)textures and it works quiet well until now, but its unfinished. It works with callbacks, instead of futures, means that the method that requests a resources gets a lambda-expression that is invoked for the texture once its loaded (you can attach the texture to a sprite in there or something like that).

Post any progress in terms of multitreading you may make here, if you like. I would appreciate it. :)

Kojay

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Re: Thor 2.0 released!
« Reply #473 on: July 30, 2016, 03:17:51 pm »
Used Thor to make an animation between two points. This brought up some thoughts:

- Interpolation schemes - I think you have talked about including such in Thor. Is this something we could expect in the short-term, or should we be looking elsewhere?

- Parallel animations - It doesn't look like a single animator can play animations in parallel (only in internal edge cases). Is the only way to do this to compose them manually? Would using two animators be reliable enough?

- Inability to query animator status - The docs state this is by design, however the rationale behind this design isn't so clear. In the example in my post, I wished to ignore the keypress while the animation was playing; so this had to be tracked externally and updated with the callback mechanism. A lot of verbosity that would be eliminated by querying whether there's an active animationn. Meanwhile, internally this looks to be as simple as returning mPlayingAnimations.empty().

I realise the example is simple, however in a larger application one could keep distinct animators - according to the role - and thus still obtain useful information from this query.

Other animation APIs do offer such functionality. Could you clarify why you deem it best not to provide it? Do you have a better design in mind to achieve the intention in the example?

Zentropy

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: A promising future
« Reply #474 on: August 19, 2016, 07:38:44 am »
Aren't there several issues with SFML resources being loaded from other threads, especially textures? Since Thor is almost always used together with SFML, this is something I have to keep in mind.

I use (my own) multithreaded-ressource loader for (sfml-)textures and it works quiet well until now, but its unfinished. It works with callbacks, instead of futures, means that the method that requests a resources gets a lambda-expression that is invoked for the texture once its loaded (you can attach the texture to a sprite in there or something like that).

Post any progress in terms of multitreading you may make here, if you like. I would appreciate it. :)

Are you using the current release version of SFML?  I'm curious how you're getting multithreading to work if so.  There's a pretty gnarly bug that causes SFML to overflow the stack recursively creating openGL contexts if you try using a background thread to load textures (or do anything else OpenGL-related).

I ran into it a couple days ago and ended up having to use the dev branch of SFML from pending pull requests that removes the nested contexts entirely.  I'd rather use the official source though if you have a good solution to the problem!

Hapax

  • Hero Member
  • *****
  • Posts: 3050
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Thor 2.0 released!
« Reply #475 on: August 19, 2016, 02:19:21 pm »
Are you using the current release version of SFML? [...] There's a pretty gnarly bug that causes SFML to overflow the stack recursively creating openGL contexts if you try using a background thread to load textures (or do anything else OpenGL-related).

I ran into it a couple days ago and ended up having to use the dev branch of SFML from pending pull requests that removes the nested contexts entirely.
Is this bug official and there an issue for it? If not, have you reported it?

p.s. I'm not sure why you changed the thread's subject.
« Last Edit: August 19, 2016, 02:35:30 pm by Hapax »
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

Zentropy

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Thor 2.0 released!
« Reply #476 on: August 19, 2016, 07:09:07 pm »

Is this bug official and there an issue for it? If not, have you reported it?

p.s. I'm not sure why you changed the thread's subject.

Yep there's all of that as well as a fixed branch already up, the 2.4.0 version just released may have already fixed it too.

p.s. I'm not sure how that happened either.  It was late and I guess I accidentally pasted over that field without realizing it, sorry!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6274
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0 released!
« Reply #477 on: September 05, 2016, 09:37:03 pm »
Post any progress in terms of multitreading you may make here, if you like. I would appreciate it. :)
I will. The reason why this hasn't happen is not that I'm doing it in a secret underground facility, but rather since it has (once more) been difficult to allocate enough time to the project... And sorry for the delay in my answer.


- Interpolation schemes - I think you have talked about including such in Thor. Is this something we could expect in the short-term, or should we be looking elsewhere?
If I remember correctly, plans were related to animations, not functionality of a generic tweener library. But nothing in that direction is planned for the near future.


- Parallel animations - It doesn't look like a single animator can play animations in parallel (only in internal edge cases). Is the only way to do this to compose them manually? Would using two animators be reliable enough?
Depending on what you want to do, you can just use an animation that plays two other animations (if progress aligns):
auto anim = [=] (sf::Sprite& animated, float progress)
{
    anim1(animated, progress);
    anim2(animated, progress);
};

Using two animators should work too, but it's a bit overkill if the progress is changed in the same way for both.

Parallel animations have been on my list for ages, it's a shame I haven't done them yet ::)


In the example in my post, I wished to ignore the keypress while the animation was playing; so this had to be tracked externally and updated with the callback mechanism. A lot of verbosity that would be eliminated by querying whether there's an active animationn. Meanwhile, internally this looks to be as simple as returning mPlayingAnimations.empty().

I realise the example is simple, however in a larger application one could keep distinct animators - according to the role - and thus still obtain useful information from this query.

Other animation APIs do offer such functionality. Could you clarify why you deem it best not to provide it? Do you have a better design in mind to achieve the intention in the example?
Yup, it's mainly the reason outlined in the docs:
Quote
This class does not provide any methods to query the state and progress of the animations, by design. On one hand, there is not always an unambiguous animation playing – there may be none, or there may be multiple (when the delta time passed to update() has exceeded one). On the other hand, the intent of animators is to abstract such information from the user, and attempts to retrieve it nonetheless indicate a misunderstanding of Animator's capabilities (e.g. the need to know when an animation has finished, in order to start another). Sequential actions can be queued using play() and queue(); it's even possible to notify the user through callbacks.

The fact that your console example is simple can be important -- from my experience, things may look differently in bigger contexts. You want: "ignore keypress while animation is playing", but this is a short-cut that makes input directly dependent from graphics, a design that could be done differently. In a game, the actual condition might be: "when the guy presses the fire button (input), play the fire animation (graphics), launch a bullet (logic) and wait half a second before you accept further input (logic)". It would then rather be the logic that determines whether your input is processed, and graphics are only a result (you could say mapping/function) of the current game logic state. Wiring dependencies this way has many advantages: you can completely reconstruct a graphical scene from the current logic state, you can change graphics (fire animation duration) without affecting the cooldown time -- but still do it vice versa if you wanted, and so on.

By the way, thanks a lot for having a closer look at Thor and giving feedback based on usage in another project, this is very valuable. Thanks also for the blog post! :)
« Last Edit: September 05, 2016, 09:43:24 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10150
    • View Profile
    • development blog
    • Email
Re: Thor 2.0 released!
« Reply #478 on: December 11, 2016, 10:11:58 pm »
Edit: Never mind, I figured it out:
system.connect("ACTION", std::bind(&ClassName::function, class_pointer, std::placeholders::_1));

How do you pass a context to an action callback? All I can see is that one example where you have a fixed function signature for a free function, but how do you do it for class functions? Not even using the fixed function signature works for those.
« Last Edit: December 11, 2016, 10:26:19 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10150
    • View Profile
    • development blog
    • Email
Re: Thor 2.0 released!
« Reply #479 on: December 13, 2016, 05:19:19 pm »
After having tried to use Thor's actions for the LD Jam, I've ran into some issues that I'm not sure of whether I'm just missing the solution or whether it's a limit of the system.

For simple key presses one action is enough and you can build useful action maps, however when it comes to events that provide specific data, like for example the TextEntered event or MouseMove event, you need to have a context which then will provide you that information. From reading the tutorials and the documentation I saw only one way to get the context and that is by defining a function with the fixed signature void(thor::ActionContext<ActionId>). This is rather limiting as one sometimes would want to use different functions or no function at all. How is the isActive function useful for such events? "Okay text has been entered, but what exactly?"

Am I missing a way to get a specific context or is this really just a limitation of the system?
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

 

anything