rgx.legacy
rgx.legacy copied to clipboard
Proper matrix transformations for sprites
Solves #16. This is the first introduction of proper matrix transformations for the sprite rendering. It includes scale, translation and rotation with origin. Also a new, simple example is included.
Please note, this pull request has a lot of cleaning to do, so I am waiting for your first review!
Thanks! I will take a look soon.
To merge this, the first thing we would have to do is take out the ultraviolet dependency -- if there's anything missing from the built-in math library, I'm happy to add it in there.
Removed the ultraviolet dependency, had to add a matrix rotation function to the default implementation as well (copied it from cgmath in a simplified manner). Everything seems to work, however, when you enable the cgmath feature flag, then things are not compiling anymore, even inside the core libraries this pull request doesn't touch. Any ideas on that matter? Is it ok on this stage?
Also, I think it might be a good option to incorporate ultraviolet itself as a math library as it seems to be the fastest one at the moment, according to my benchmarks.
You might want to keep an eye out for nalgebra now, too, because with nalgebra 0.21 and the new SIMD optimizations it is competitive with ultraviolet according to the posted benchmarks:
https://rustsim.org/blog/2020/03/23/simd-aosoa-in-nalgebra/
nalgebra's biggest disadvantage to me seems to be it's complication in the documentation and such, but nalgebra-glm seems like it helps with that a lot. The post above has a good comparison between nalgebra and ultraviolet.
Personally I could go with either and I don't have a particular suggestion. They both are interesting for their own reasons. :)
@zicklag, hmm, interesting, in some benchmarks it is more than 2 or 3 times faster than the ultraviolet counterpart. Also, giving some options to decide between more precise 64-bit floats and faster 16-bit floats might be a good idea, however, I might imagine there are more low-hanging optimisations rgx can achieve before we will need 16-bit floats.
Thanks! I've pushed a fix to master regarding the cgmath compilation, maybe this will solve the problem.
With regards to third party algebra libraries, rgx used to depend on cgmath, but when it went unmaintained, I decided to copy the parts I needed into rgx, make certain improvements, and make the dependency optional. nalgebra is too big of a dependency to pull in for simple 2D math. As for all the other libraries, they are good, but they come and go, so I'd rather wait and see which ones are still around in a year.
@cloudhead, did the changes you mentioned, can you have a look?
@cloudhead, did the changes you mentioned, can you have a look?
Yup, we're getting there! Don't forget to fix the examples when you've finalized the library code.
@cloudhead, finally got some time away from work and studying - so here are a couple of commits that should solve all the discussed issues.
Additionally, https://github.com/cloudhead/rgx/pull/19#discussion_r420379790 was not addressed properly.