summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Haas <liu.gam3@gmail.com>2016-06-21 23:26:38 +0200
committerAndreas Haas <liu.gam3@gmail.com>2016-06-21 23:26:38 +0200
commitd08092e113bd878f8d3eb4a4f67f305b82df470d (patch)
tree27690f3c9604891cab4260dba6c75c9d1b5cf933
parent6d09183c44e6db0ca1896f50f8727e55716dd85c (diff)
Expose missing Quaternion operators.
Scripts can now evaluate the following cases: - (quat * real) and (quat / real) - (quat + quat) and (quat - quat)
-rw-r--r--core/variant_op.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 9f706e75cf..e549161de9 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<const Quat*>(p_a._data._mem) * *reinterpret_cast<const Quat*>(p_b._data._mem) );
} break;
+ case REAL: {
+ _RETURN( *reinterpret_cast<const Quat*>(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<const Quat*>(p_a._data._mem) / p_b._data._real);
+ } break;
DEFAULT_OP_FAIL(_AABB);
DEFAULT_OP_FAIL(MATRIX3);
DEFAULT_OP_FAIL(TRANSFORM);