diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/math/vector3.h | 30 | ||||
-rw-r--r-- | core/variant_call.cpp | 18 |
2 files changed, 29 insertions, 19 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h index d27b611379..8a3cca8f33 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -40,11 +40,11 @@ struct Vector3 { enum Axis { AXIS_X, AXIS_Y, - AXIS_Z, + AXIS_Z, }; union { - + #ifdef USE_QUAD_VECTORS struct { @@ -52,7 +52,7 @@ struct Vector3 { real_t y; real_t z; real_t _unused; - }; + }; real_t coord[4]; #else @@ -61,18 +61,18 @@ struct Vector3 { real_t y; real_t z; }; - + real_t coord[3]; #endif }; _FORCE_INLINE_ const real_t& operator[](int p_axis) const { - + return coord[p_axis]; } _FORCE_INLINE_ real_t& operator[](int p_axis) { - + return coord[p_axis]; } @@ -84,7 +84,7 @@ struct Vector3 { _FORCE_INLINE_ real_t length() const; _FORCE_INLINE_ real_t length_squared() const; - + _FORCE_INLINE_ void normalize(); _FORCE_INLINE_ Vector3 normalized() const; _FORCE_INLINE_ Vector3 inverse() const; @@ -107,6 +107,8 @@ struct Vector3 { _FORCE_INLINE_ real_t dot(const Vector3& p_b) const; _FORCE_INLINE_ Vector3 abs() const; + _FORCE_INLINE_ Vector3 floor() const; + _FORCE_INLINE_ Vector3 ceil() const; _FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const; _FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const; @@ -172,7 +174,17 @@ real_t Vector3::dot(const Vector3& p_b) const { Vector3 Vector3::abs() const { return Vector3( Math::abs(x), Math::abs(y), Math::abs(z) ); -} +} + +Vector3 Vector3::floor() const { + + return Vector3( Math::floor(x), Math::floor(y), Math::floor(z) ); +} + +Vector3 Vector3::ceil() const { + + return Vector3( Math::ceil(x), Math::ceil(y), Math::ceil(z) ); +} Vector3 Vector3::linear_interpolate(const Vector3& p_b,float p_t) const { @@ -301,7 +313,7 @@ bool Vector3::operator<(const Vector3& p_v) const { return y<p_v.y; } else return x<p_v.x; - + } bool Vector3::operator<=(const Vector3& p_v) const { diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 4cca3420a1..222618ffa0 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -359,6 +359,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector3, dot); VCALL_LOCALMEM1R(Vector3, cross); VCALL_LOCALMEM0R(Vector3, abs); + VCALL_LOCALMEM0R(Vector3, floor); + VCALL_LOCALMEM0R(Vector3, ceil); VCALL_LOCALMEM1R(Vector3, distance_to); VCALL_LOCALMEM1R(Vector3, distance_squared_to); VCALL_LOCALMEM1R(Vector3, slide); @@ -753,7 +755,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var } static void Matrix32_init2(Variant& r_ret,const Variant** p_args) { - + Matrix32 m(*p_args[0], *p_args[1]); r_ret=m; } @@ -1133,7 +1135,7 @@ void Variant::get_method_list(List<MethodInfo> *p_list) const { if (fd.returns) ret.name="ret"; mi.return_val=ret; -#endif +#endif p_list->push_back(mi); } @@ -1336,6 +1338,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(VECTOR3,REAL,Vector3,dot,VECTOR3,"b",varray()); ADDFUNC1(VECTOR3,VECTOR3,Vector3,cross,VECTOR3,"b",varray()); ADDFUNC0(VECTOR3,VECTOR3,Vector3,abs,varray()); + ADDFUNC0(VECTOR3,VECTOR3,Vector3,floor,varray()); + ADDFUNC0(VECTOR3,VECTOR3,Vector3,ceil,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()); @@ -1535,10 +1539,10 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(TRANSFORM,NIL,Transform,xform,NIL,"v",varray()); ADDFUNC1(TRANSFORM,NIL,Transform,xform_inv,NIL,"v",varray()); -#ifdef DEBUG_ENABLED +#ifdef DEBUG_ENABLED _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform"].returns=true; _VariantCall::type_funcs[Variant::TRANSFORM].functions["xform_inv"].returns=true; -#endif +#endif ADDFUNC0(INPUT_EVENT,BOOL,InputEvent,is_pressed,varray()); ADDFUNC1(INPUT_EVENT,BOOL,InputEvent,is_action,STRING,"action",varray()); @@ -1635,9 +1639,3 @@ void unregister_variant_methods() { } - - - - - - |