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

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

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #405 on: May 14, 2015, 01:55:34 pm »
Okay, thanks! Out of interest, which APIs in Thor are you using?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Thor 2.0
« Reply #406 on: May 14, 2015, 02:10:24 pm »
In my current project I'm using these modules:
 Animations
 Particles
 Resources
 Vectors

I've been considering the Input module as well since it could probably simplify my curent input handling, but I have not yet gotten around to playing with it.
« Last Edit: May 14, 2015, 02:15:31 pm by Jesper Juhl »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
VS 2015 users needed!
« Reply #407 on: June 14, 2015, 05:22:23 pm »
A Thor user reported a problem inside thor::ResourceHolder on Visual Studio 2015 Community RC. More clearly, an internal STL assertion occurs in ResourceHolder.inl (line 130) during the destruction of an iterator.

Since I don't have this compiler version and would prefer not to install it just for a single issue, I wanted to ask whether a VS 2015 user would be willing to test the code and see if the error can be reproduced, and if there's an obvious problem? Thanks in advance :)
#include <Thor/Resources.hpp>

struct Resource {};

int main()
{
        auto lambda = [] () { return std::make_unique<Resource>(); };
        thor::ResourceLoader<Resource> loader(lambda, "some info");

        thor::ResourceHolder<Resource, int> holder;
        holder.acquire(3, loader);
}
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Thor 2.0
« Reply #408 on: June 14, 2015, 07:50:33 pm »
I can confirm that the error can be reproduced.
I used latest git version for both sfml and thor to test it out.
Doesn't seem like an obvious problem for me at least.

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: Thor 2.0
« Reply #409 on: June 14, 2015, 08:03:30 pm »
I've seen bits and pieces of the changelog for 2015. They've done a fair amount of changes with templates and such... Could be a bug. It is just a release candidate after all.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #410 on: June 14, 2015, 08:12:19 pm »
Thanks! Might be worth investigating then.

It's much worse if there's a bug in the VS 2015 compiler or the standard library than in Thor.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Thor 2.0
« Reply #411 on: June 14, 2015, 08:16:50 pm »
If you need anything else, just say so. Now that I installed it and compiled all libraries I prefer to make it worthwhile xD

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: Thor 2.0
« Reply #412 on: June 14, 2015, 08:55:35 pm »
I know of a user on Reddit who works on the VS compiler/standard library (may just be the standard library, can't remember exactly). I could try messaging him to ask about it, if you like.

He'll prolly want a sscce.

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Thor 2.0
« Reply #413 on: June 14, 2015, 09:00:35 pm »
My guess would be that you are referring to STL(not the library) :D

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #414 on: June 14, 2015, 09:45:33 pm »
SpeCter, that's really nice of you, thanks! :)

I'd like to track down the problem to a minimal complete example with just a main() function, and without Thor. So if it is indeed a VS 2015 problem, I could report it at Microsoft Connect, and they can hopefully fix it for the full release.

The original code in thor::ResourceHolder::load() is a bit convoluted because of genericity with multiple ownership strategies. Simplified, it's roughly equivalent to these lines:
#include <map>
#include <memory>

struct R {};
typedef std::map<int, std::unique_ptr<R>> Map;

R& load(Map& map, int id)
{
        std::unique_ptr<R> original = std::make_unique<R>();
        auto inserted = map.insert(std::make_pair(id, nullptr)).first;

        std::unique_ptr<R> loaded = std::move(original);
        R& returned = *loaded;

        inserted->second = std::move(loaded);

        return returned;
}

int main()
{
        Map map;
        load(map, 3);
}

Can you tell me if this still reproduces the error (I guess not :D). If it does, can you further minimize it? That is, try as many of the following omissions as possible, as long as the code still reproduces the error:
  • std::move()
  • std::unique_ptr
  • Use basic type (e.g. short) instead of R
  • load() function -> everything in main()
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

dabbertorres

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • website/blog
Re: Thor 2.0
« Reply #415 on: June 14, 2015, 09:49:36 pm »
My guess would be that you are referring to STL(not the library) :D

You would be correct! Haha.

If that indeed does reproduce, SpeCter or I could message him then I guess. He may be able to fast-forward a fix, that's why I mentioned him as a possibility. Haha.

SpeCter

  • Full Member
  • ***
  • Posts: 151
    • View Profile
Re: Thor 2.0
« Reply #416 on: June 14, 2015, 10:02:06 pm »
Your guess was right,it does not reproduce the error  :(

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #417 on: June 15, 2015, 03:54:11 pm »
Of course, would have been too easy ;)

I eventually decided to install VS 2015 RC myself, tried this code, and could reproduce the issue. It seems to be a bug in the debug iterator checks of the STL implementation. The following code shows the problem (for std::vector as well as for std::map):
#include <vector>
typedef std::vector<int> Vector;

struct Wrapper
{
        Vector::iterator itr;
};

Wrapper BadWrap(Vector::iterator itr) // triggers issue
{
        return {itr};
}

Wrapper GoodWrap(Vector::iterator itr) // works fine
{
        Wrapper w = {itr};
        return w;
}

int main()
{
        Vector v = {1};
        Wrapper w = BadWrap(v.begin());
} // access violation during destruction of v

I filed a bug report at Microsoft Connect
. If anybody of you wants to inform Stephan T. Lavavej, feel free to do so :)

Thanks to both of you (and the guy who originally reported the problem) for your assistance!
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

omnomasaur

  • Newbie
  • *
  • Posts: 8
    • View Profile
    • http://www.omnomasaur.com
Re: Thor 2.0
« Reply #418 on: June 23, 2015, 03:04:37 am »
Is it possible to set up the particle color on an emitter to pull randomly from a gradient?

UniversalEmitter::setParticleColor takes a Distribution<sf::Color>, but I can't figure out how to actually use that to get different colors. 

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Thor 2.0
« Reply #419 on: June 23, 2015, 01:10:28 pm »
Yes, it's possible. A distribution is just a function returning a value.
thor::ColorGradient gradient = ...;
thor::Distribution<sf::Color> dist = [gradient] () -> sf::Color
{
    return gradient.sampleColor(thor::random(0.f, 1.f));
};

It may be worthwhile to not use the global random number generator, and instead store a Distribution<float> within the function object.
« Last Edit: June 24, 2015, 12:54:10 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: