From d08092e113bd878f8d3eb4a4f67f305b82df470d Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Tue, 21 Jun 2016 23:26:38 +0200 Subject: [PATCH] Expose missing Quaternion operators. Scripts can now evaluate the following cases: - (quat * real) and (quat / real) - (quat + quat) and (quat - quat) --- core/variant_op.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 9f706e75cf4..e549161de92 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -477,7 +477,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& DEFAULT_OP_FAIL(MATRIX32); DEFAULT_OP_LOCALMEM(+,VECTOR3,Vector3); DEFAULT_OP_FAIL(PLANE); - DEFAULT_OP_FAIL(QUAT); + DEFAULT_OP_LOCALMEM(+, QUAT, Quat); DEFAULT_OP_FAIL(_AABB); DEFAULT_OP_FAIL(MATRIX3); DEFAULT_OP_FAIL(TRANSFORM); @@ -535,7 +535,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& DEFAULT_OP_FAIL(MATRIX32); DEFAULT_OP_LOCALMEM(-,VECTOR3,Vector3); DEFAULT_OP_FAIL(PLANE); - DEFAULT_OP_FAIL(QUAT); + DEFAULT_OP_LOCALMEM(-, QUAT, Quat); DEFAULT_OP_FAIL(_AABB); DEFAULT_OP_FAIL(MATRIX3); DEFAULT_OP_FAIL(TRANSFORM); @@ -597,6 +597,9 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& _RETURN( *reinterpret_cast(p_a._data._mem) * *reinterpret_cast(p_b._data._mem) ); } break; + case REAL: { + _RETURN( *reinterpret_cast(p_a._data._mem) * p_b._data._real); + } break; }; r_valid=false; return; @@ -699,7 +702,13 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& DEFAULT_OP_FAIL(MATRIX32); DEFAULT_OP_LOCALMEM_NUM(/,VECTOR3,Vector3); DEFAULT_OP_FAIL(PLANE); - DEFAULT_OP_FAIL(QUAT); + case QUAT: { + if (p_b.type != REAL) { + r_valid = false; + return; + } + _RETURN( *reinterpret_cast(p_a._data._mem) / p_b._data._real); + } break; DEFAULT_OP_FAIL(_AABB); DEFAULT_OP_FAIL(MATRIX3); DEFAULT_OP_FAIL(TRANSFORM);