Browse Source

[CORE] Fix MSVC warnings/errors and raymath.h in C++ (#4125)

* Update raylib_api.* by CI

* Fix MSVC warnings.
Make raymath.h work in C++ in MSVC

* whitespace cleanup

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Jeffery Myers 1 year ago
parent
commit
9d3bd43c6e
2 changed files with 9 additions and 5 deletions
  1. 7 3
      src/raymath.h
  2. 2 2
      src/rtextures.c

+ 7 - 3
src/raymath.h

@@ -2549,9 +2549,13 @@ 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 scaley = Vector3Length((Vector3){ d, e, f });
-    float scalez = Vector3Length((Vector3){ g, h, i });
+    Vector3 abc = { a, b, c };
+    Vector3 def = { d, e, f };
+    Vector3 ghi = { g, h, i };
+
+    float scalex = Vector3Length(abc);
+    float scaley = Vector3Length(def);
+    float scalez = Vector3Length(ghi);
     Vector3 s = { scalex, scaley, scalez };
     Vector3 s = { scalex, scaley, scalez };
 
 
     if (det < 0) s = Vector3Negate(s);
     if (det < 0) s = Vector3Negate(s);

+ 2 - 2
src/rtextures.c

@@ -3658,7 +3658,7 @@ void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, int thick, Color co
     {
     {
         // Line is more horizontal
         // Line is more horizontal
         // Calculate half the width of the line
         // Calculate half the width of the line
-        int wy = (thick - 1)*sqrtf(dx*dx + dy*dy)/(2*abs(dx));
+        int wy = (thick - 1)*(int)sqrtf((float)(dx*dx + dy*dy))/(2*abs(dx));
 
 
         // Draw additional lines above and below the main line
         // Draw additional lines above and below the main line
         for (int i = 1; i <= wy; i++)
         for (int i = 1; i <= wy; i++)
@@ -3671,7 +3671,7 @@ void ImageDrawLineEx(Image *dst, Vector2 start, Vector2 end, int thick, Color co
     {
     {
         // Line is more vertical or perfectly horizontal
         // Line is more vertical or perfectly horizontal
         // Calculate half the width of the line
         // Calculate half the width of the line
-        int wx = (thick - 1)*sqrtf(dx*dx + dy*dy)/(2*abs(dy));
+        int wx = (thick - 1)*(int)sqrtf((float)(dx*dx + dy*dy))/(2*abs(dy));
 
 
         // Draw additional lines to the left and right of the main line
         // Draw additional lines to the left and right of the main line
         for (int i = 1; i <= wx; i++)
         for (int i = 1; i <= wx; i++)