123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- #ifndef CORE_GENERIC_H
- #define CORE_GENERIC_H
- #include "core/Matrix.h"
- #ifdef IMPORT_CORE
- #define addSet(a, b) \
- _Generic((a), \
- Vector2 *: addSetV2, \
- Vector3 *: addSetV3, \
- Vector4 *: addSetV4, \
- IntVector2 *: addSetIV2, \
- IntVector3 *: addSetIV3, \
- IntVector4 *: addSetIV4)(a, b)
- #define add(a, b, c) \
- _Generic((a), \
- Vector2 *: addV2, \
- Vector3 *: addV3, \
- Vector4 *: addV4, \
- IntVector2 *: addIV2, \
- IntVector3 *: addIV3, \
- IntVector4 *: addIV4)(a, b, c)
- #define subSet(a, b) \
- _Generic((a), \
- Vector2 *: subSetV2, \
- Vector3 *: subSetV3, \
- Vector4 *: subSetV4, \
- IntVector2 *: subSetIV2, \
- IntVector3 *: subSetIV3, \
- IntVector4 *: subSetIV4)(a, b)
- #define sub(a, b, c) \
- _Generic((a), \
- Vector2 *: subV2, \
- Vector3 *: subV3, \
- Vector4 *: subV4, \
- IntVector2 *: subIV2, \
- IntVector3 *: subIV3, \
- IntVector4 *: subIV4)(a, b, c)
- #define mulSet(a, b) \
- _Generic((a), \
- 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)
- #define mul(a, b, c) \
- _Generic((a), \
- Vector2 *: _Generic((c), Vector2 *: mulV2, default: mulV2F), \
- Vector3 *: _Generic((c), \
- Vector3 *: _Generic((b), \
- const Quaternion*: mulQV3, \
- 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)
- #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)
- #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)
- #define invertSet(a) \
- _Generic((a), \
- Vector2 *: invertSetV2, \
- Vector3 *: invertSetV3, \
- Vector4 *: invertSetV4, \
- IntVector2 *: invertSetIV2, \
- IntVector3 *: invertSetIV3, \
- IntVector4 *: invertSetIV4)(a)
- #define invert(a, b) \
- _Generic((a), \
- Vector2 *: invertV2, \
- Vector3 *: invertV3, \
- Vector4 *: invertV4, \
- IntVector2 *: invertIV2, \
- IntVector3 *: invertIV3, \
- IntVector4 *: invertIV4)(a, b)
- #define dot(a, b) \
- _Generic((a), \
- Vector2 *: dotV2, \
- const Vector2*: dotV2, \
- Vector3*: dotV3, \
- const Vector3*: dotV3, \
- Vector4*: dotV4, \
- const Vector4*: dotV4)(a, b)
- #define squareLength(a) \
- _Generic((a), \
- Vector2 *: squareLengthV2, \
- Vector3 *: squareLengthV3, \
- Vector4 *: squareLengthV4)(a)
- #define length(a) \
- _Generic((a), \
- Vector2 *: lengthV2, \
- Vector3 *: lengthV3, \
- Vector4 *: lengthV4)(a)
- #define normalize(a) \
- _Generic((a), \
- Vector2 *: normalizeV2, \
- Vector3 *: normalizeV3, \
- Vector4 *: normalizeV4)(a)
- #define convert(a, b) \
- _Generic((a), \
- Vector2 *: convertIV2, \
- Vector3 *: convertIV3, \
- Vector4 *: convertIV4, \
- IntVector2 *: convertV2, \
- IntVector3 *: convertV3, \
- IntVector4 *: convertV4)(a, b)
- // #define toStringV2 coreToStringV2
- #endif
- #endif
|