diff options
| author | Juan Linietsky | 2014-09-02 23:13:40 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2014-09-02 23:13:40 -0300 |
| commit | 1a2cb755e2d8b9d59178f36702f6dff7235b9088 (patch) | |
| tree | 4a88f47c8b984522e36ac973accb34bdcb00363b /core | |
| parent | 89fa70706f9166765c3ac3f799225a467800f065 (diff) | |
| download | godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.tar.gz godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.tar.zst godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.zip | |
Diffstat (limited to 'core')
| -rw-r--r-- | core/global_constants.cpp | 29 | ||||
| -rw-r--r-- | core/math/vector3.h | 16 | ||||
| -rw-r--r-- | core/variant_call.cpp | 5 | ||||
| -rw-r--r-- | core/variant_op.cpp | 34 |
4 files changed, 75 insertions, 9 deletions
diff --git a/core/global_constants.cpp b/core/global_constants.cpp index efa72b654..ae4abc627 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -445,15 +445,26 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( ERR_BUG ), ///< a bug in the software certainly happened ), due to a double check failing or unexpected behavior. BIND_GLOBAL_CONSTANT( ERR_WTF ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_NONE ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RANGE ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_EXP_RANGE ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_ENUM ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_LENGTH ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FLAGS ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FILE ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_DIR ), - BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RESOURCE_TYPE ), + + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_NONE ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RANGE ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_EXP_RANGE ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_ENUM ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_EXP_EASING ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_LENGTH ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_KEY_ACCEL ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FLAGS ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_ALL_FLAGS ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_FILE ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_DIR ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_GLOBAL_FILE ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_GLOBAL_DIR ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_RESOURCE_TYPE ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_MULTILINE_TEXT ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_COLOR_NO_ALPHA ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_IMAGE_COMPRESS_LOSSY ), + BIND_GLOBAL_CONSTANT( PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS ), + BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ), BIND_GLOBAL_CONSTANT( PROPERTY_USAGE_STORAGE ), diff --git a/core/math/vector3.h b/core/math/vector3.h index 959f7cd0a..d2f240882 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -111,6 +111,12 @@ struct Vector3 { _FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const; _FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const; + + + _FORCE_INLINE_ Vector3 slide(const Vector3& p_vec) const; + _FORCE_INLINE_ Vector3 reflect(const Vector3& p_vec) const; + + /* Operators */ _FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v); @@ -368,6 +374,16 @@ void Vector3::zero() { x=y=z=0; } +Vector3 Vector3::slide(const Vector3& p_vec) const { + + return p_vec - *this * this->dot(p_vec); +} +Vector3 Vector3::reflect(const Vector3& p_vec) const { + + return p_vec - *this * this->dot(p_vec) * 2.0; + +} + #endif #endif // VECTOR3_H diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 2697e6f7a..8fbccc87a 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -331,6 +331,9 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0R(Vector3, abs); VCALL_LOCALMEM1R(Vector3, distance_to); VCALL_LOCALMEM1R(Vector3, distance_squared_to); + VCALL_LOCALMEM1R(Vector3, slide); + VCALL_LOCALMEM1R(Vector3, reflect); + VCALL_LOCALMEM0R(Plane,normalized); VCALL_LOCALMEM0R(Plane,center); @@ -1236,6 +1239,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(VECTOR3,VECTOR3,Vector3,abs,varray()); ADDFUNC1(VECTOR3,REAL,Vector3,distance_to,VECTOR3,"b",varray()); ADDFUNC1(VECTOR3,REAL,Vector3,distance_squared_to,VECTOR3,"b",varray()); + ADDFUNC1(VECTOR3,VECTOR3,Vector3,slide,VECTOR3,"by",varray()); + ADDFUNC1(VECTOR3,VECTOR3,Vector3,reflect,VECTOR3,"by",varray()); ADDFUNC0(PLANE,PLANE,Plane,normalized,varray()); ADDFUNC0(PLANE,VECTOR3,Plane,center,varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 6c2667c7e..9c489c5ef 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -1145,6 +1145,7 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) if (p_value.type!=Variant::VECTOR3) return; + if (p_index.get_type()==Variant::STRING) { //scalar name @@ -1181,6 +1182,24 @@ void Variant::set(const Variant& p_index, const Variant& p_value, bool *r_valid) v->set_axis(index,p_value); return; } + } else if (p_index.get_type()==Variant::STRING) { + + const String *str=reinterpret_cast<const String*>(p_index._data._mem); + Matrix3 *v=_data._matrix3; + + if (*str=="x") { + valid=true; + v->set_axis(0,p_value); + return; + } else if (*str=="y" ) { + valid=true; + v->set_axis(1,p_value); + return; + } else if (*str=="z" ) { + valid=true; + v->set_axis(2,p_value); + return; + } } } break; @@ -2021,6 +2040,21 @@ Variant Variant::get(const Variant& p_index, bool *r_valid) const { valid=true; return v->get_axis(index); } + } else if (p_index.get_type()==Variant::STRING) { + + const String *str=reinterpret_cast<const String*>(p_index._data._mem); + const Matrix3 *v=_data._matrix3; + + if (*str=="x") { + valid=true; + return v->get_axis(0); + } else if (*str=="y" ) { + valid=true; + return v->get_axis(1); + } else if (*str=="z" ) { + valid=true; + return v->get_axis(2); + } } } break; |
