|
@@ -9,14 +9,10 @@
|
|
* If not defined, the library is in header only mode and can be included in other headers
|
|
* If not defined, the library is in header only mode and can be included in other headers
|
|
* or source files without problems. But only ONE file should hold the implementation.
|
|
* or source files without problems. But only ONE file should hold the implementation.
|
|
*
|
|
*
|
|
-* #define RAYMATH_HEADER_ONLY
|
|
|
|
|
|
+* #define RAYMATH_STATIC_INLINE
|
|
* Define static inline functions code, so #include header suffices for use.
|
|
* Define static inline functions code, so #include header suffices for use.
|
|
* This may use up lots of memory.
|
|
* This may use up lots of memory.
|
|
*
|
|
*
|
|
-* #define RAYMATH_STANDALONE
|
|
|
|
-* Avoid raylib.h header inclusion in this file.
|
|
|
|
-* Vector3 and Matrix data types are defined internally in raymath module.
|
|
|
|
-*
|
|
|
|
*
|
|
*
|
|
* LICENSE: zlib/libpng
|
|
* LICENSE: zlib/libpng
|
|
*
|
|
*
|
|
@@ -42,15 +38,8 @@
|
|
#ifndef RAYMATH_H
|
|
#ifndef RAYMATH_H
|
|
#define RAYMATH_H
|
|
#define RAYMATH_H
|
|
|
|
|
|
-//#define RAYMATH_STANDALONE // NOTE: To use raymath as standalone lib, just uncomment this line
|
|
|
|
-//#define RAYMATH_HEADER_ONLY // NOTE: To compile functions as static inline, uncomment this line
|
|
|
|
-
|
|
|
|
-#ifndef RAYMATH_STANDALONE
|
|
|
|
- #include "raylib.h" // Required for: Vector3, Matrix structs definition
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_HEADER_ONLY)
|
|
|
|
- #error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_HEADER_ONLY is contradictory"
|
|
|
|
|
|
+#if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_STATIC_INLINE)
|
|
|
|
+ #error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_STATIC_INLINE is contradictory"
|
|
#endif
|
|
#endif
|
|
|
|
|
|
#if defined(RAYMATH_IMPLEMENTATION)
|
|
#if defined(RAYMATH_IMPLEMENTATION)
|
|
@@ -61,7 +50,7 @@
|
|
#else
|
|
#else
|
|
#define RMDEF extern inline // Provide external definition
|
|
#define RMDEF extern inline // Provide external definition
|
|
#endif
|
|
#endif
|
|
-#elif defined(RAYMATH_HEADER_ONLY)
|
|
|
|
|
|
+#elif defined(RAYMATH_STATIC_INLINE)
|
|
#define RMDEF static inline // Functions may be inlined, no external out-of-line definition
|
|
#define RMDEF static inline // Functions may be inlined, no external out-of-line definition
|
|
#else
|
|
#else
|
|
#if defined(__TINYC__)
|
|
#if defined(__TINYC__)
|
|
@@ -100,38 +89,51 @@
|
|
// Types and Structures Definition
|
|
// Types and Structures Definition
|
|
//----------------------------------------------------------------------------------
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
-#if defined(RAYMATH_STANDALONE)
|
|
|
|
- // Vector2 type
|
|
|
|
- typedef struct Vector2 {
|
|
|
|
- float x;
|
|
|
|
- float y;
|
|
|
|
- } Vector2;
|
|
|
|
-
|
|
|
|
- // Vector3 type
|
|
|
|
- typedef struct Vector3 {
|
|
|
|
- float x;
|
|
|
|
- float y;
|
|
|
|
- float z;
|
|
|
|
- } Vector3;
|
|
|
|
-
|
|
|
|
- // Vector4 type
|
|
|
|
- typedef struct Vector4 {
|
|
|
|
- float x;
|
|
|
|
- float y;
|
|
|
|
- float z;
|
|
|
|
- float w;
|
|
|
|
- } Vector4;
|
|
|
|
-
|
|
|
|
- // Quaternion type
|
|
|
|
- typedef Vector4 Quaternion;
|
|
|
|
-
|
|
|
|
- // Matrix type (OpenGL style 4x4 - right handed, column major)
|
|
|
|
- typedef struct Matrix {
|
|
|
|
- float m0, m4, m8, m12;
|
|
|
|
- float m1, m5, m9, m13;
|
|
|
|
- float m2, m6, m10, m14;
|
|
|
|
- float m3, m7, m11, m15;
|
|
|
|
- } Matrix;
|
|
|
|
|
|
+#if !defined(RL_VECTOR2_TYPE)
|
|
|
|
+// Vector2 type
|
|
|
|
+typedef struct Vector2 {
|
|
|
|
+ float x;
|
|
|
|
+ float y;
|
|
|
|
+} Vector2;
|
|
|
|
+#define RL_VECTOR2_TYPE
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#if !defined(RL_VECTOR3_TYPE)
|
|
|
|
+// Vector3 type
|
|
|
|
+typedef struct Vector3 {
|
|
|
|
+ float x;
|
|
|
|
+ float y;
|
|
|
|
+ float z;
|
|
|
|
+} Vector3;
|
|
|
|
+#define RL_VECTOR3_TYPE
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#if !defined(RL_VECTOR4_TYPE)
|
|
|
|
+// Vector4 type
|
|
|
|
+typedef struct Vector4 {
|
|
|
|
+ float x;
|
|
|
|
+ float y;
|
|
|
|
+ float z;
|
|
|
|
+ float w;
|
|
|
|
+} Vector4;
|
|
|
|
+#define RL_VECTOR4_TYPE
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#if !defined(RL_QUATERNION_TYPE)
|
|
|
|
+// Quaternion type
|
|
|
|
+typedef Vector4 Quaternion;
|
|
|
|
+#define RL_QUATERNION_TYPE
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#if !defined(RL_MATRIX_TYPE)
|
|
|
|
+// Matrix type (OpenGL style 4x4 - right handed, column major)
|
|
|
|
+typedef struct Matrix {
|
|
|
|
+ float m0, m4, m8, m12; // Matrix first row (4 components)
|
|
|
|
+ float m1, m5, m9, m13; // Matrix second row (4 components)
|
|
|
|
+ float m2, m6, m10, m14; // Matrix third row (4 components)
|
|
|
|
+ float m3, m7, m11, m15; // Matrix fourth row (4 components)
|
|
|
|
+} Matrix;
|
|
|
|
+#define RL_MATRIX_TYPE
|
|
#endif
|
|
#endif
|
|
|
|
|
|
// NOTE: Helper types to be used instead of array return types for *ToFloat functions
|
|
// NOTE: Helper types to be used instead of array return types for *ToFloat functions
|