TheCherno / Sparky

Cross-Platform High Performance 2D/3D game engine for people like me who like to write code.
Apache License 2.0
1.1k stars 222 forks source link

Order of Transformation stack #38

Open MunWolf opened 9 years ago

MunWolf commented 9 years ago

I was using the engine to make a demo when I came accross a problem. I had a map object that contained tile objects that each could contain a single entity. I then used the transformation stack in map to position the tiles and in tiles to position the entity.

However when I wanted to rotate the entity on the spot I was unable to since it rotated around the origin point, aka the point the sprite would be in before the translation of the map and the tile.

A fix for this is changing

                m_TransformationStack.push_back(m_TransformationStack.back() * matrix);

to

                m_TransformationStack.push_back(matrix * m_TransformationStack.back());

in renderer2d.h