New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use System.Numerics instead of custom vector types #31
Comments
@sbarisic That sounds interesting though I don't plan to change the vector and matrix types at the moment. Ideally a feature like this would be optional for those who want it. |
I have looked into this feature but I am currently unsure on the best way to proceed.
This is a pain to do especially in a larger project so I looked to see if there was a easier way to make this a optional/non breaking change. The only possible solution I found is to wrap the System.Numerics types in my own types and provide properties for access. This "might" work but I feel that defeats the idea of it as you need to convert/access the type manually when using external code that uses System.Numerics. Another possible concern is with the Matrix. I need to look into the ordering of the fields to see if conflicts with how the raylib Matrix works. I do not think it makes sense to add System.Numerics only for Vector types but not Matrices as that will just make things more confusing for new users. |
The order of the matrix elements should match OpenGL as far as i know, for anything else it would be enough to just transpose them before doing calculations. Another way to make this less painful is to add an implicit cast to/from System.Numerics vectors. |
It would be possible to create a wrapper over System.Numerics types and use implicit casts to automatically return internal type, but that pretty much defeats the purpose and makes it slower. |
@ChrisDill I Wouldn't too much about adding/chaning |
@sbarisic There is now a numerics branch for this feature. I discussed it with @9ParsonsB and we decided that keeping this feature compatible is not possible so it is being tested as a breaking change. So far Vector2, Vector3 and Vector4 have been replaced. Matrix4x4 has a different layout but transposing the matrix works for going from the numerics layout to the raymath and vice versa. |
I'm undecided on the switch to the standard |
What should I do when using |
It would be a wise idea to use System.Numerics for vector and matrix types, as it would be more compatible with other libraries. They're also SIMD accelerated, and marshalling them works fine.
The text was updated successfully, but these errors were encountered: