[raymath] Add C++ constexpr support and Matrix scalar multiplication#5606
[raymath] Add C++ constexpr support and Matrix scalar multiplication#5606lamweilun wants to merge 2 commits intoraysan5:masterfrom
constexpr support and Matrix scalar multiplication#5606Conversation
- Make RMAPI functions constexpr in C++ mode - Add constexpr to all C++ math operators - Add MatrixMultiplyValue() and scalar operators - Add MatrixZeros and MatrixUnit constants
|
@JeffM2501 please, could you review this change? I'm not a C++ expert. |
constexpr support and Matrix scalar multiplication
|
There are two considerations here, though they might not matter at all.
@lamweilun Do you have examples of actual use cases where This gets us a very long way from the anchoring of raylib on C89. I suspect this is better handled, if at all, in a C++ binding or supplementary header, not in @JeffM2501 is this consistent with your understanding? |
|
So just based on my testing so far, it definitely needs at least C++14 to compile due to the fact that variable declaration inside a constexpr function body was only added then. To be fair, I have not extensively tested as to how much of a performance boost it would have. This PR is also lacking certain things such as replacing Actually the separation of the functions into a separate header sounds reasonable. I might work on that actually. And perhaps I could also add on a build define option to enable/disable the constexpr stuffs, with disabled being the default I suppose. Perhaps we can continue discussing once I have made those changes? EDIT: Just to add on, actually all I wanted was to add on more constants for the Quaternion type 😆, I just thought the constexpr would be a helpful addon |
Other considerations here also involve the use of intrinsics, which is another tendency for improvement of the array operations and also the use of hardware-provided implementations of trig functions and some array/vector operations. This seems particularly useful for x64 builds. (I must remind myself of this for a project I'm doing using VC/C++ where intrinsics are a compiler option.) |
raymath: Add C++ constexpr support and Matrix scalar multiplication