diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-09-02 23:13:40 -0300 |
---|---|---|
committer | Dana Olson <dana@shineuponthee.com> | 2014-09-15 17:43:28 -0400 |
commit | 247e7ed716a4c0bd5140c2b2a938f7118e84fb14 (patch) | |
tree | 2487f84d19ea60c4140c085164219a893a4f8566 /core | |
parent | dbae857b293231882307c52217e9569a17da0f23 (diff) |
3D Physics and Other Stuff
-=-=-=-=-=-=-=-=-=-=-=-=-=
-New Vehicle (Based on Bullet's RaycastVehicle) - Vehiclebody/VehicleWheel. Demo will come soon, old vehicle (CarBody) will go away soon too.
-A lot of fixes to the 3D physics engine
-Added KinematicBody with demo
-Fixed the space query API for 2D (demo will come soon). 3D is WIP.
-Fixed long-standing bug with body_enter/body_exit for Area and Area2D
-Performance variables now includes physics (active bodies, collision pairs and islands)
-Ability to see what's inside of instanced scenes!
-Fixed Blend Shapes (no bs+skeleton yet)
-Added an Android JavaClassWrapper singleton for using Android native classes directly from GDScript. This is very Alpha!
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 efa72b6547..ae4abc627d 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 959f7cd0a8..d2f2408829 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 2697e6f7a7..8fbccc87ae 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 6c2667c7e9..9c489c5ef2 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; |