[raymath.h] use CLITERAL for MSVC

This commit is contained in:
Bruno Cabral 2024-07-01 19:25:08 -07:00
parent 9f47e562d9
commit 9b13f0f418

View File

@ -77,6 +77,17 @@
#endif #endif
#endif #endif
// NOTE: MSVC C++ compiler does not support compound literals (C99 feature)
// Plain structures in C++ (without constructors) can be initialized with { }
// This is called aggregate initialization (C++11 feature)
#ifndef CLITERAL
#if defined(__cplusplus)
#define CLITERAL(type) type
#else
#define CLITERAL(type) (type)
#endif
#endif
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Defines and Macros // Defines and Macros
@ -2549,9 +2560,9 @@ RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotatio
// Extract scale // Extract scale
const float det = a*A + b*B + c*C; const float det = a*A + b*B + c*C;
float scalex = Vector3Length((Vector3){ a, b, c }); float scalex = Vector3Length(CLITERAL(Vector3){ a, b, c });
float scaley = Vector3Length((Vector3){ d, e, f }); float scaley = Vector3Length(CLITERAL(Vector3){ d, e, f });
float scalez = Vector3Length((Vector3){ g, h, i }); float scalez = Vector3Length(CLITERAL(Vector3){ g, h, i });
Vector3 s = { scalex, scaley, scalez }; Vector3 s = { scalex, scaley, scalez };
if (det < 0) s = Vector3Negate(s); if (det < 0) s = Vector3Negate(s);