|
@@ -4,29 +4,28 @@
|
|
|
#include "core/Matrix.h"
|
|
|
|
|
|
#ifdef IMPORT_CORE
|
|
|
+#define GENERIC_PAIR(type, name) \
|
|
|
+ type: \
|
|
|
+ name, const type : name
|
|
|
+
|
|
|
#define GENERIC_FLOAT_VECTOR(a, name) \
|
|
|
_Generic((a), \
|
|
|
- Vector2 *: name##V2, \
|
|
|
- const Vector2*: name##V2, \
|
|
|
- Vector3*: name##V3, \
|
|
|
- const Vector3*: name##V3, \
|
|
|
- Vector4*: name##V4, \
|
|
|
- const Vector4*: name##V4)
|
|
|
+ GENERIC_PAIR(Vector2*, name##V2), \
|
|
|
+ GENERIC_PAIR(Vector3*, name##V3), \
|
|
|
+ GENERIC_PAIR(Vector4*, name##V4))
|
|
|
|
|
|
#define GENERIC_VECTOR(a, name) \
|
|
|
_Generic((a), \
|
|
|
- Vector2 *: name##V2, \
|
|
|
- const Vector2*: name##V2, \
|
|
|
- Vector3*: name##V3, \
|
|
|
- const Vector3*: name##V3, \
|
|
|
- Vector4*: name##V4, \
|
|
|
- const Vector4*: name##V4, \
|
|
|
- IntVector2*: name##IV2, \
|
|
|
- const IntVector2*: name##IV2, \
|
|
|
- IntVector3*: name##IV3, \
|
|
|
- const IntVector3*: name##IV3, \
|
|
|
- IntVector4*: name##IV4, \
|
|
|
- const IntVector4*: name##IV4)
|
|
|
+ GENERIC_PAIR(Vector2*, name##V2), \
|
|
|
+ GENERIC_PAIR(Vector3*, name##V3), \
|
|
|
+ GENERIC_PAIR(Vector4*, name##V4), \
|
|
|
+ GENERIC_PAIR(IntVector2*, name##IV2), \
|
|
|
+ GENERIC_PAIR(IntVector3*, name##IV3), \
|
|
|
+ GENERIC_PAIR(IntVector4*, name##IV4))
|
|
|
+
|
|
|
+#define GENERIC_FACTOR(b, type, base, factor) \
|
|
|
+ type: \
|
|
|
+ _Generic((b), GENERIC_PAIR(type, base), default: factor)
|
|
|
|
|
|
#define addSet(a, b) GENERIC_VECTOR(a, addSet)(a, b)
|
|
|
#define add(a, b, c) GENERIC_VECTOR(a, add)(a, b, c)
|
|
@@ -37,62 +36,46 @@
|
|
|
_Generic((a), \
|
|
|
Matrix *: mulSetMatrix, \
|
|
|
Quaternion *: mulSetQ, \
|
|
|
- Vector2 *: _Generic((b), Vector2 *: mulSetV2, default: mulSetV2F), \
|
|
|
- Vector3 *: _Generic((b), Vector3 *: mulSetV3, default: mulSetV3F), \
|
|
|
- Vector4 *: _Generic((b), Vector4 *: mulSetV4, default: mulSetV4F), \
|
|
|
- IntVector2 *: _Generic((b), \
|
|
|
- IntVector2 *: mulSetIV2, \
|
|
|
- default: mulSetIV2F), \
|
|
|
- IntVector3 *: _Generic((b), \
|
|
|
- IntVector3 *: mulSetIV3, \
|
|
|
- default: mulSetIV3F), \
|
|
|
- IntVector4 *: _Generic((b), \
|
|
|
- IntVector4 *: mulSetIV4, \
|
|
|
- default: mulSetIV4F))(a, b)
|
|
|
+ GENERIC_FACTOR(b, Vector2*, mulSetV2, mulSetV2F), \
|
|
|
+ GENERIC_FACTOR(b, Vector3*, mulSetV3, mulSetV3F), \
|
|
|
+ GENERIC_FACTOR(b, Vector4*, mulSetV4, mulSetV4F), \
|
|
|
+ GENERIC_FACTOR(b, IntVector2*, mulSetIV2, mulSetIV2F), \
|
|
|
+ GENERIC_FACTOR(b, IntVector3*, mulSetIV3, mulSetIV3F), \
|
|
|
+ GENERIC_FACTOR(b, IntVector4*, mulSetIV4, mulSetIV4F))(a, b)
|
|
|
|
|
|
#define mul(a, b, c) \
|
|
|
_Generic((a), \
|
|
|
Matrix *: mulMatrix, \
|
|
|
Quaternion *: mulQ, \
|
|
|
- Vector2 *: _Generic((c), Vector2 *: mulV2, default: mulV2F), \
|
|
|
+ GENERIC_FACTOR(c, Vector2*, mulV2, mulV2F), \
|
|
|
Vector3 *: _Generic((c), \
|
|
|
Vector3 *: _Generic((b), \
|
|
|
- Quaternion *: mulQV3, \
|
|
|
- const Quaternion*: mulQV3, \
|
|
|
- const Matrix*: mulMatrixV3, \
|
|
|
- Matrix*: mulMatrixV3, \
|
|
|
+ GENERIC_PAIR(Quaternion*, mulQV3), \
|
|
|
+ GENERIC_PAIR(Matrix*, mulMatrixV3), \
|
|
|
default: mulV3), \
|
|
|
default: mulV3F), \
|
|
|
- Vector4 *: _Generic((c), Vector4 *: mulV4, default: mulV4F), \
|
|
|
- IntVector2 *: _Generic((c), IntVector2 *: mulIV2, default: mulIV2F), \
|
|
|
- IntVector3 *: _Generic((c), IntVector3 *: mulIV3, default: mulIV3F), \
|
|
|
- IntVector4 *: _Generic((c), IntVector4 *: mulIV4, default: mulIV4F))( \
|
|
|
- a, b, c)
|
|
|
+ GENERIC_FACTOR(c, Vector4*, mulV4, mulV4F), \
|
|
|
+ GENERIC_FACTOR(c, IntVector2*, mulIV2, mulIV2F), \
|
|
|
+ GENERIC_FACTOR(c, IntVector3*, mulIV3, mulIV3F), \
|
|
|
+ GENERIC_FACTOR(c, IntVector4*, mulIV4, mulIV4F))(a, b, c)
|
|
|
|
|
|
#define divSet(a, b) \
|
|
|
_Generic((a), \
|
|
|
- Vector2 *: _Generic((b), Vector2 *: divSetV2, default: divSetV2F), \
|
|
|
- Vector3 *: _Generic((b), Vector3 *: divSetV3, default: divSetV3F), \
|
|
|
- Vector4 *: _Generic((b), Vector4 *: divSetV4, default: divSetV4F), \
|
|
|
- IntVector2 *: _Generic((b), \
|
|
|
- IntVector2 *: divSetIV2, \
|
|
|
- default: divSetIV2F), \
|
|
|
- IntVector3 *: _Generic((b), \
|
|
|
- IntVector3 *: divSetIV3, \
|
|
|
- default: divSetIV3F), \
|
|
|
- IntVector4 *: _Generic((b), \
|
|
|
- IntVector4 *: divSetIV4, \
|
|
|
- default: divSetIV4F))(a, b)
|
|
|
+ GENERIC_FACTOR(b, Vector2*, divSetV2, divSetV2F), \
|
|
|
+ GENERIC_FACTOR(b, Vector3*, divSetV3, divSetV3F), \
|
|
|
+ GENERIC_FACTOR(b, Vector4*, divSetV4, divSetV4F), \
|
|
|
+ GENERIC_FACTOR(b, IntVector2*, divSetIV2, divSetIV2F), \
|
|
|
+ GENERIC_FACTOR(b, IntVector3*, divSetIV3, divSetIV3F), \
|
|
|
+ GENERIC_FACTOR(b, IntVector4*, divSetIV4, divSetIV4F))(a, b)
|
|
|
|
|
|
#define div(a, b, c) \
|
|
|
_Generic((a), \
|
|
|
- Vector2 *: _Generic((c), Vector2 *: divV2, default: divV2F), \
|
|
|
- Vector3 *: _Generic((c), Vector3 *: divV3, default: divV3F), \
|
|
|
- Vector4 *: _Generic((c), Vector4 *: divV4, default: divV4F), \
|
|
|
- IntVector2 *: _Generic((c), IntVector2 *: divIV2, default: divIV2F), \
|
|
|
- IntVector3 *: _Generic((c), IntVector3 *: divIV3, default: divIV3F), \
|
|
|
- IntVector4 *: _Generic((c), IntVector4 *: divIV4, default: divIV4F))( \
|
|
|
- a, b, c)
|
|
|
+ GENERIC_FACTOR(c, Vector2*, divV2, divV2F), \
|
|
|
+ GENERIC_FACTOR(c, Vector3*, divV3, divV3F), \
|
|
|
+ GENERIC_FACTOR(c, Vector4*, divV4, divV4F), \
|
|
|
+ GENERIC_FACTOR(c, IntVector2*, divIV2, divIV2F), \
|
|
|
+ GENERIC_FACTOR(c, IntVector3*, divIV3, divIV3F), \
|
|
|
+ GENERIC_FACTOR(c, IntVector4*, divIV4, divIV4F))(a, b, c)
|
|
|
|
|
|
#define invertSet(a) GENERIC_VECTOR(a, invertSet)(a)
|
|
|
#define invert(a, b) GENERIC_VECTOR(a, invert)(a, b)
|