diff options
Diffstat (limited to 'servers')
55 files changed, 450 insertions, 450 deletions
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index 2f859a4ed4..ceeeafe04a 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -43,8 +43,8 @@ void BodySW::_update_transform_dependant() { principal_inertia_axes = get_transform().basis * principal_inertia_axes_local; // update inertia tensor - Matrix3 tb = principal_inertia_axes; - Matrix3 tbt = tb.transposed(); + Basis tb = principal_inertia_axes; + Basis tbt = tb.transposed(); tb.scale(_inv_inertia); _inv_inertia_tensor = tb * tbt; @@ -81,7 +81,7 @@ void BodySW::update_inertias() { center_of_mass_local /= mass; // Recompute the inertia tensor - Matrix3 inertia_tensor; + Basis inertia_tensor; inertia_tensor.set_zero(); for (int i=0;i<get_shape_count();i++) { @@ -92,15 +92,15 @@ void BodySW::update_inertias() { float mass = area * this->mass / total_area; - Matrix3 shape_inertia_tensor=shape->get_moment_of_inertia(mass).to_diagonal_matrix(); + Basis shape_inertia_tensor=shape->get_moment_of_inertia(mass).to_diagonal_matrix(); Transform shape_transform=get_shape_transform(i); - Matrix3 shape_basis = shape_transform.basis.orthonormalized(); + Basis shape_basis = shape_transform.basis.orthonormalized(); // NOTE: we don't take the scale of collision shapes into account when computing the inertia tensor! shape_inertia_tensor = shape_basis * shape_inertia_tensor * shape_basis.transposed(); Vector3 shape_origin = shape_transform.origin - center_of_mass_local; - inertia_tensor += shape_inertia_tensor + (Matrix3()*shape_origin.dot(shape_origin)-shape_origin.outer(shape_origin))*mass; + inertia_tensor += shape_inertia_tensor + (Basis()*shape_origin.dot(shape_origin)-shape_origin.outer(shape_origin))*mass; } @@ -497,7 +497,7 @@ void BodySW::integrate_forces(real_t p_step) { linear_velocity = (new_transform.origin - get_transform().origin)/p_step; //compute a FAKE angular velocity, not so easy - Matrix3 rot=new_transform.basis.orthonormalized().transposed() * get_transform().basis.orthonormalized(); + Basis rot=new_transform.basis.orthonormalized().transposed() * get_transform().basis.orthonormalized(); Vector3 axis; float angle; @@ -609,8 +609,8 @@ void BodySW::integrate_velocities(real_t p_step) { if (ang_vel!=0.0) { Vector3 ang_vel_axis = total_angular_velocity / ang_vel; - Matrix3 rot( ang_vel_axis, -ang_vel*p_step ); - Matrix3 identity3(1, 0, 0, 0, 1, 0, 0, 0, 1); + Basis rot( ang_vel_axis, -ang_vel*p_step ); + Basis identity3(1, 0, 0, 0, 1, 0, 0, 0, 1); transform.origin += ((identity3 - rot) * transform.basis).xform(center_of_mass_local); transform.basis = rot * transform.basis; transform.orthonormalize(); diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h index acdd84d259..e6ed3e75e5 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics/body_sw.h @@ -60,12 +60,12 @@ class BodySW : public CollisionObjectSW { Vector3 _inv_inertia; // Relative to the principal axes of inertia // Relative to the local frame of reference - Matrix3 principal_inertia_axes_local; + Basis principal_inertia_axes_local; Vector3 center_of_mass_local; // In world orientation with local origin - Matrix3 _inv_inertia_tensor; - Matrix3 principal_inertia_axes; + Basis _inv_inertia_tensor; + Basis principal_inertia_axes; Vector3 center_of_mass; Vector3 gravity; @@ -198,7 +198,7 @@ public: _FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration=p_omit_force_integration; } _FORCE_INLINE_ bool get_omit_force_integration() const { return omit_force_integration; } - _FORCE_INLINE_ Matrix3 get_principal_inertia_axes() const { return principal_inertia_axes; } + _FORCE_INLINE_ Basis get_principal_inertia_axes() const { return principal_inertia_axes; } _FORCE_INLINE_ Vector3 get_center_of_mass() const { return center_of_mass; } _FORCE_INLINE_ Vector3 xform_local_to_principal(const Vector3& p_pos) const { return principal_inertia_axes_local.xform(p_pos - center_of_mass_local); } @@ -272,7 +272,7 @@ public: _FORCE_INLINE_ real_t get_inv_mass() const { return _inv_mass; } _FORCE_INLINE_ Vector3 get_inv_inertia() const { return _inv_inertia; } - _FORCE_INLINE_ Matrix3 get_inv_inertia_tensor() const { return _inv_inertia_tensor; } + _FORCE_INLINE_ Basis get_inv_inertia_tensor() const { return _inv_inertia_tensor; } _FORCE_INLINE_ real_t get_friction() const { return friction; } _FORCE_INLINE_ Vector3 get_gravity() const { return gravity; } _FORCE_INLINE_ real_t get_bounce() const { return bounce; } @@ -381,11 +381,11 @@ public: virtual float get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area virtual Vector3 get_center_of_mass() const { return body->get_center_of_mass(); } - virtual Matrix3 get_principal_inertia_axes() const { return body->get_principal_inertia_axes(); } + virtual Basis get_principal_inertia_axes() const { return body->get_principal_inertia_axes(); } virtual float get_inverse_mass() const { return body->get_inv_mass(); } // get the mass virtual Vector3 get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space - virtual Matrix3 get_inverse_inertia_tensor() const { return body->get_inv_inertia_tensor(); } // get density of this body space + virtual Basis get_inverse_inertia_tensor() const { return body->get_inv_inertia_tensor(); } // get density of this body space virtual void set_linear_velocity(const Vector3& p_velocity) { body->set_linear_velocity(p_velocity); } virtual Vector3 get_linear_velocity() const { return body->get_linear_velocity(); } diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp index 30b5978594..f1c22caae3 100644 --- a/servers/physics/broad_phase_basic.cpp +++ b/servers/physics/broad_phase_basic.cpp @@ -47,7 +47,7 @@ BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object_, int p_sub return current; } -void BroadPhaseBasic::move(ID p_id, const AABB& p_aabb) { +void BroadPhaseBasic::move(ID p_id, const Rect3& p_aabb) { Map<ID,Element>::Element *E=element_map.find(p_id); ERR_FAIL_COND(!E); @@ -115,7 +115,7 @@ int BroadPhaseBasic::cull_segment(const Vector3& p_from, const Vector3& p_to,Col for (Map<ID,Element>::Element *E=element_map.front();E;E=E->next()) { - const AABB aabb=E->get().aabb; + const Rect3 aabb=E->get().aabb; if (aabb.intersects_segment(p_from,p_to)) { p_results[rc]=E->get().owner; @@ -129,13 +129,13 @@ int BroadPhaseBasic::cull_segment(const Vector3& p_from, const Vector3& p_to,Col return rc; } -int BroadPhaseBasic::cull_aabb(const AABB& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices) { +int BroadPhaseBasic::cull_aabb(const Rect3& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices) { int rc=0; for (Map<ID,Element>::Element *E=element_map.front();E;E=E->next()) { - const AABB aabb=E->get().aabb; + const Rect3 aabb=E->get().aabb; if (aabb.intersects(p_aabb)) { p_results[rc]=E->get().owner; diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h index 423ff0a6a8..9f07e896c4 100644 --- a/servers/physics/broad_phase_basic.h +++ b/servers/physics/broad_phase_basic.h @@ -38,7 +38,7 @@ class BroadPhaseBasic : public BroadPhaseSW { CollisionObjectSW *owner; bool _static; - AABB aabb; + Rect3 aabb; int subindex; }; @@ -78,7 +78,7 @@ public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object_, int p_subindex=0); - virtual void move(ID p_id, const AABB& p_aabb); + virtual void move(ID p_id, const Rect3& p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); @@ -87,7 +87,7 @@ public: virtual int get_subindex(ID p_id) const; virtual int cull_segment(const Vector3& p_from, const Vector3& p_to,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL); - virtual int cull_aabb(const AABB& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL); + virtual int cull_aabb(const Rect3& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL); virtual void set_pair_callback(PairCallback p_pair_callback,void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback,void *p_userdata); diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp index 60fbf926bd..89581997a2 100644 --- a/servers/physics/broad_phase_octree.cpp +++ b/servers/physics/broad_phase_octree.cpp @@ -31,11 +31,11 @@ BroadPhaseSW::ID BroadPhaseOctree::create(CollisionObjectSW *p_object, int p_subindex) { - ID oid = octree.create(p_object,AABB(),p_subindex,false,1<<p_object->get_type(),0); + ID oid = octree.create(p_object,Rect3(),p_subindex,false,1<<p_object->get_type(),0); return oid; } -void BroadPhaseOctree::move(ID p_id, const AABB& p_aabb){ +void BroadPhaseOctree::move(ID p_id, const Rect3& p_aabb){ octree.move(p_id,p_aabb); } @@ -71,7 +71,7 @@ int BroadPhaseOctree::cull_segment(const Vector3& p_from, const Vector3& p_to,Co return octree.cull_segment(p_from,p_to,p_results,p_max_results,p_result_indices); } -int BroadPhaseOctree::cull_aabb(const AABB& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices) { +int BroadPhaseOctree::cull_aabb(const Rect3& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices) { return octree.cull_AABB(p_aabb,p_results,p_max_results,p_result_indices); diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h index 43005812e7..29f1123edf 100644 --- a/servers/physics/broad_phase_octree.h +++ b/servers/physics/broad_phase_octree.h @@ -50,7 +50,7 @@ public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object_, int p_subindex=0); - virtual void move(ID p_id, const AABB& p_aabb); + virtual void move(ID p_id, const Rect3& p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); @@ -59,7 +59,7 @@ public: virtual int get_subindex(ID p_id) const; virtual int cull_segment(const Vector3& p_from, const Vector3& p_to,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL); - virtual int cull_aabb(const AABB& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL); + virtual int cull_aabb(const Rect3& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL); virtual void set_pair_callback(PairCallback p_pair_callback,void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback,void *p_userdata); diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h index 736b674185..2cc2d7d45e 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics/broad_phase_sw.h @@ -50,7 +50,7 @@ public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object_, int p_subindex=0)=0; - virtual void move(ID p_id, const AABB& p_aabb)=0; + virtual void move(ID p_id, const Rect3& p_aabb)=0; virtual void set_static(ID p_id, bool p_static)=0; virtual void remove(ID p_id)=0; @@ -59,7 +59,7 @@ public: virtual int get_subindex(ID p_id) const=0; virtual int cull_segment(const Vector3& p_from, const Vector3& p_to,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL)=0; - virtual int cull_aabb(const AABB& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL)=0; + virtual int cull_aabb(const Rect3& p_aabb,CollisionObjectSW** p_results,int p_max_results,int *p_result_indices=NULL)=0; virtual void set_pair_callback(PairCallback p_pair_callback,void *p_userdata)=0; virtual void set_unpair_callback(UnpairCallback p_unpair_callback,void *p_userdata)=0; diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp index 2b2b73738a..88aa737579 100644 --- a/servers/physics/collision_object_sw.cpp +++ b/servers/physics/collision_object_sw.cpp @@ -138,7 +138,7 @@ void CollisionObjectSW::_update_shapes() { } //not quite correct, should compute the next matrix.. - AABB shape_aabb=s.shape->get_aabb(); + Rect3 shape_aabb=s.shape->get_aabb(); Transform xform = transform * s.xform; shape_aabb=xform.xform(shape_aabb); s.aabb_cache=shape_aabb; @@ -167,10 +167,10 @@ void CollisionObjectSW::_update_shapes_with_motion(const Vector3& p_motion) { } //not quite correct, should compute the next matrix.. - AABB shape_aabb=s.shape->get_aabb(); + Rect3 shape_aabb=s.shape->get_aabb(); Transform xform = transform * s.xform; shape_aabb=xform.xform(shape_aabb); - shape_aabb=shape_aabb.merge(AABB( shape_aabb.pos+p_motion,shape_aabb.size)); //use motion + shape_aabb=shape_aabb.merge(Rect3( shape_aabb.pos+p_motion,shape_aabb.size)); //use motion s.aabb_cache=shape_aabb; space->get_broadphase()->move(s.bpid,shape_aabb); diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index f3e43c98db..c46a7f4a5f 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -60,7 +60,7 @@ private: Transform xform; Transform xform_inv; BroadPhaseSW::ID bpid; - AABB aabb_cache; //for rayqueries + Rect3 aabb_cache; //for rayqueries real_t area_cache; ShapeSW *shape; bool trigger; @@ -123,7 +123,7 @@ public: _FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; } _FORCE_INLINE_ const Transform& get_shape_transform(int p_index) const { return shapes[p_index].xform; } _FORCE_INLINE_ const Transform& get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; } - _FORCE_INLINE_ const AABB& get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } + _FORCE_INLINE_ const Rect3& get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } _FORCE_INLINE_ const real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; } _FORCE_INLINE_ Transform get_transform() const { return transform; } diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp index 886d93c4b4..91ef7913cf 100644 --- a/servers/physics/collision_solver_sw.cpp +++ b/servers/physics/collision_solver_sw.cpp @@ -160,7 +160,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A,const Transform& //quickly compute a local AABB - AABB local_aabb; + Rect3 local_aabb; for(int i=0;i<3;i++) { Vector3 axis( p_transform_B.basis.get_axis(i) ); @@ -313,7 +313,7 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A,const Tran return collided; } -bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B,const AABB& p_concave_hint,Vector3 *r_sep_axis) { +bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B,const Rect3& p_concave_hint,Vector3 *r_sep_axis) { if (p_shape_A->is_concave()) return false; @@ -351,14 +351,14 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A,const Transform& //quickly compute a local AABB - bool use_cc_hint=p_concave_hint!=AABB(); - AABB cc_hint_aabb; + bool use_cc_hint=p_concave_hint!=Rect3(); + Rect3 cc_hint_aabb; if (use_cc_hint) { cc_hint_aabb=p_concave_hint; cc_hint_aabb.pos-=p_transform_B.origin; } - AABB local_aabb; + Rect3 local_aabb; for(int i=0;i<3;i++) { Vector3 axis( p_transform_B.basis.get_axis(i) ); diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h index 82ac77f73d..16d2b92d70 100644 --- a/servers/physics/collision_solver_sw.h +++ b/servers/physics/collision_solver_sw.h @@ -48,7 +48,7 @@ public: static bool solve_static(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,CallbackResult p_result_callback,void *p_userdata,Vector3 *r_sep_axis=NULL,float p_margin_A=0,float p_margin_B=0); - static bool solve_distance(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B,const AABB& p_concave_hint,Vector3 *r_sep_axis=NULL); + static bool solve_distance(const ShapeSW *p_shape_A,const Transform& p_transform_A,const ShapeSW *p_shape_B,const Transform& p_transform_B,Vector3& r_point_A,Vector3& r_point_B,const Rect3& p_concave_hint,Vector3 *r_sep_axis=NULL); }; diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp index 3c0119971a..5824de0127 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.cpp +++ b/servers/physics/joints/generic_6dof_joint_sw.cpp @@ -38,8 +38,8 @@ See corresponding header file for licensing info. #define GENERIC_D6_DISABLE_WARMSTARTING 1 -real_t btGetMatrixElem(const Matrix3& mat, int index); -real_t btGetMatrixElem(const Matrix3& mat, int index) +real_t btGetMatrixElem(const Basis& mat, int index); +real_t btGetMatrixElem(const Basis& mat, int index) { int i = index%3; int j = index/3; @@ -47,8 +47,8 @@ real_t btGetMatrixElem(const Matrix3& mat, int index) } ///MatrixToEulerXYZ from http://www.geometrictools.com/LibFoundation/Mathematics/Wm4Matrix3.inl.html -bool matrixToEulerXYZ(const Matrix3& mat,Vector3& xyz); -bool matrixToEulerXYZ(const Matrix3& mat,Vector3& xyz) +bool matrixToEulerXYZ(const Basis& mat,Vector3& xyz); +bool matrixToEulerXYZ(const Basis& mat,Vector3& xyz) { // // rot = cy*cz -cy*sz sy // // cz*sx*sy+cx*sz cx*cz-sx*sy*sz -cy*sx @@ -296,7 +296,7 @@ Generic6DOFJointSW::Generic6DOFJointSW(BodySW* rbA, BodySW* rbB, const Transform void Generic6DOFJointSW::calculateAngleInfo() { - Matrix3 relative_frame = m_calculatedTransformA.basis.inverse()*m_calculatedTransformB.basis; + Basis relative_frame = m_calculatedTransformA.basis.inverse()*m_calculatedTransformB.basis; matrixToEulerXYZ(relative_frame,m_calculatedAxisAngleDiff); diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp index 23e00a9e7f..2f07779131 100644 --- a/servers/physics/joints/hinge_joint_sw.cpp +++ b/servers/physics/joints/hinge_joint_sw.cpp @@ -112,7 +112,7 @@ HingeJointSW::HingeJointSW(BodySW* rbA,BodySW* rbB, const Vector3& pivotInA,cons rbAxisA1 = rbAxisA2.cross(axisInA); } - m_rbAFrame.basis=Matrix3( rbAxisA1.x,rbAxisA2.x,axisInA.x, + m_rbAFrame.basis=Basis( rbAxisA1.x,rbAxisA2.x,axisInA.x, rbAxisA1.y,rbAxisA2.y,axisInA.y, rbAxisA1.z,rbAxisA2.z,axisInA.z ); @@ -121,7 +121,7 @@ HingeJointSW::HingeJointSW(BodySW* rbA,BodySW* rbB, const Vector3& pivotInA,cons Vector3 rbAxisB2 = axisInB.cross(rbAxisB1); m_rbBFrame.origin = pivotInB; - m_rbBFrame.basis=Matrix3( rbAxisB1.x,rbAxisB2.x,-axisInB.x, + m_rbBFrame.basis=Basis( rbAxisB1.x,rbAxisB2.x,-axisInB.x, rbAxisB1.y,rbAxisB2.y,-axisInB.y, rbAxisB1.z,rbAxisB2.z,-axisInB.z ); diff --git a/servers/physics/joints/jacobian_entry_sw.h b/servers/physics/joints/jacobian_entry_sw.h index 1a54859956..cd85162ba5 100644 --- a/servers/physics/joints/jacobian_entry_sw.h +++ b/servers/physics/joints/jacobian_entry_sw.h @@ -56,8 +56,8 @@ public: JacobianEntrySW() {}; //constraint between two different rigidbodies JacobianEntrySW( - const Matrix3& world2A, - const Matrix3& world2B, + const Basis& world2A, + const Basis& world2B, const Vector3& rel_pos1,const Vector3& rel_pos2, const Vector3& jointAxis, const Vector3& inertiaInvA, @@ -77,8 +77,8 @@ public: //angular constraint between two different rigidbodies JacobianEntrySW(const Vector3& jointAxis, - const Matrix3& world2A, - const Matrix3& world2B, + const Basis& world2A, + const Basis& world2B, const Vector3& inertiaInvA, const Vector3& inertiaInvB) :m_linearJointAxis(Vector3(real_t(0.),real_t(0.),real_t(0.))) @@ -110,7 +110,7 @@ public: //constraint on one rigidbody JacobianEntrySW( - const Matrix3& world2A, + const Basis& world2A, const Vector3& rel_pos1,const Vector3& rel_pos2, const Vector3& jointAxis, const Vector3& inertiaInvA, diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index c853dcff35..59ade71475 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -35,7 +35,7 @@ #define _FACE_IS_VALID_SUPPORT_TRESHOLD 0.9998 -void ShapeSW::configure(const AABB& p_aabb) { +void ShapeSW::configure(const Rect3& p_aabb) { aabb=p_aabb; configured=true; for (Map<ShapeOwnerSW*,int>::Element *E=owners.front();E;E=E->next()) { @@ -133,7 +133,7 @@ Vector3 PlaneShapeSW::get_moment_of_inertia(float p_mass) const { void PlaneShapeSW::_setup(const Plane& p_plane) { plane=p_plane; - configure(AABB(Vector3(-1e4,-1e4,-1e4),Vector3(1e4*2,1e4*2,1e4*2))); + configure(Rect3(Vector3(-1e4,-1e4,-1e4),Vector3(1e4*2,1e4*2,1e4*2))); } void PlaneShapeSW::set_data(const Variant& p_data) { @@ -204,7 +204,7 @@ Vector3 RayShapeSW::get_moment_of_inertia(float p_mass) const { void RayShapeSW::_setup(float p_length) { length=p_length; - configure(AABB(Vector3(0,0,0),Vector3(0.1,0.1,length))); + configure(Rect3(Vector3(0,0,0),Vector3(0.1,0.1,length))); } void RayShapeSW::set_data(const Variant& p_data) { @@ -271,7 +271,7 @@ void SphereShapeSW::_setup(real_t p_radius) { radius=p_radius; - configure(AABB( Vector3(-radius,-radius,-radius), Vector3(radius*2.0,radius*2.0,radius*2.0))); + configure(Rect3( Vector3(-radius,-radius,-radius), Vector3(radius*2.0,radius*2.0,radius*2.0))); } @@ -412,7 +412,7 @@ void BoxShapeSW::get_supports(const Vector3& p_normal,int p_max,Vector3 *r_suppo bool BoxShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const { - AABB aabb(-half_extents,half_extents*2.0); + Rect3 aabb(-half_extents,half_extents*2.0); return aabb.intersects_segment(p_begin,p_end,&r_result,&r_normal); @@ -432,7 +432,7 @@ void BoxShapeSW::_setup(const Vector3& p_half_extents) { half_extents=p_half_extents.abs(); - configure(AABB(-half_extents,half_extents*2)); + configure(Rect3(-half_extents,half_extents*2)); } @@ -604,7 +604,7 @@ void CapsuleShapeSW::_setup(real_t p_height,real_t p_radius) { height=p_height; radius=p_radius; - configure(AABB(Vector3(-radius,-radius,-height*0.5-radius),Vector3(radius*2,radius*2,height+radius*2.0))); + configure(Rect3(Vector3(-radius,-radius,-height*0.5-radius),Vector3(radius*2,radius*2,height+radius*2.0))); } @@ -818,7 +818,7 @@ Vector3 ConvexPolygonShapeSW::get_moment_of_inertia(float p_mass) const { void ConvexPolygonShapeSW::_setup(const Vector<Vector3>& p_vertices) { Error err = QuickHull::build(p_vertices,mesh); - AABB _aabb; + Rect3 _aabb; for(int i=0;i<mesh.vertices.size();i++) { @@ -965,7 +965,7 @@ Vector3 FaceShapeSW::get_moment_of_inertia(float p_mass) const { FaceShapeSW::FaceShapeSW() { - configure(AABB()); + configure(Rect3()); } @@ -1175,13 +1175,13 @@ void ConcavePolygonShapeSW::_cull(int p_idx,_CullParams *p_params) const { } } -void ConcavePolygonShapeSW::cull(const AABB& p_local_aabb,Callback p_callback,void* p_userdata) const { +void ConcavePolygonShapeSW::cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const { // make matrix local to concave if (faces.size()==0) return; - AABB local_aabb=p_local_aabb; + Rect3 local_aabb=p_local_aabb; // unlock data PoolVector<Face>::Read fr=faces.read(); @@ -1219,7 +1219,7 @@ Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(float p_mass) const { struct _VolumeSW_BVH_Element { - AABB aabb; + Rect3 aabb; Vector3 center; int face_index; }; @@ -1251,7 +1251,7 @@ struct _VolumeSW_BVH_CompareZ { struct _VolumeSW_BVH { - AABB aabb; + Rect3 aabb; _VolumeSW_BVH *left; _VolumeSW_BVH *right; @@ -1276,7 +1276,7 @@ _VolumeSW_BVH* _volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements,int p_size bvh->face_index=-1; } - AABB aabb; + Rect3 aabb; for(int i=0;i<p_size;i++) { if (i==0) @@ -1351,7 +1351,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { int src_face_count=p_faces.size(); if (src_face_count==0) { - configure(AABB()); + configure(Rect3()); return; } ERR_FAIL_COND(src_face_count%3); @@ -1488,7 +1488,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { PoolVector<Vector3>::Write vw = vertices.write(); Vector3 *verticesw=vw.ptr(); - AABB _aabb; + Rect3 _aabb; for(int i=0;i<src_face_count;i++) { @@ -1593,7 +1593,7 @@ bool HeightMapShapeSW::intersect_segment(const Vector3& p_begin,const Vector3& p } -void HeightMapShapeSW::cull(const AABB& p_local_aabb,Callback p_callback,void* p_userdata) const { +void HeightMapShapeSW::cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const { @@ -1623,7 +1623,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights,int p_width,int p_dep PoolVector<real_t>::Read r = heights. read(); - AABB aabb; + Rect3 aabb; for(int i=0;i<depth;i++) { diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index 2298be7530..3cbd1c9609 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -59,14 +59,14 @@ public: class ShapeSW : public RID_Data { RID self; - AABB aabb; + Rect3 aabb; bool configured; real_t custom_bias; Map<ShapeOwnerSW*,int> owners; protected: - void configure(const AABB& p_aabb); + void configure(const Rect3& p_aabb); public: enum { @@ -80,7 +80,7 @@ public: virtual PhysicsServer::ShapeType get_type() const=0; - _FORCE_INLINE_ AABB get_aabb() const { return aabb; } + _FORCE_INLINE_ Rect3 get_aabb() const { return aabb; } _FORCE_INLINE_ bool is_configured() const { return configured; } virtual bool is_concave() const { return false; } @@ -116,7 +116,7 @@ public: typedef void (*Callback)(void* p_userdata,ShapeSW *p_convex); virtual void get_supports(const Vector3& p_normal,int p_max,Vector3 *r_supports,int & r_amount) const { r_amount=0; } - virtual void cull(const AABB& p_local_aabb,Callback p_callback,void* p_userdata) const=0; + virtual void cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const=0; ConcaveShapeSW() {} }; @@ -293,7 +293,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { struct BVH { - AABB aabb; + Rect3 aabb; int left; int right; @@ -304,7 +304,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { struct _CullParams { - AABB aabb; + Rect3 aabb; Callback callback; void *userdata; const Face *faces; @@ -347,7 +347,7 @@ public: virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const; - virtual void cull(const AABB& p_local_aabb,Callback p_callback,void* p_userdata) const; + virtual void cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const; virtual Vector3 get_moment_of_inertia(float p_mass) const; @@ -383,7 +383,7 @@ public: virtual Vector3 get_support(const Vector3& p_normal) const; virtual bool intersect_segment(const Vector3& p_begin,const Vector3& p_end,Vector3 &r_result, Vector3 &r_normal) const; - virtual void cull(const AABB& p_local_aabb,Callback p_callback,void* p_userdata) const; + virtual void cull(const Rect3& p_local_aabb,Callback p_callback,void* p_userdata) const; virtual Vector3 get_moment_of_inertia(float p_mass) const; @@ -455,7 +455,7 @@ struct MotionShapeSW : public ShapeSW { virtual void set_data(const Variant& p_data) {} virtual Variant get_data() const { return Variant(); } - MotionShapeSW() { configure(AABB()); } + MotionShapeSW() { configure(Rect3()); } }; diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 596c7af214..d73d5f140e 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -146,7 +146,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transfo ShapeSW *shape = static_cast<PhysicsServerSW*>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape,0); - AABB aabb = p_xform.xform(shape->get_aabb()); + Rect3 aabb = p_xform.xform(shape->get_aabb()); int amount = space->broadphase->cull_aabb(aabb,space->intersection_query_results,SpaceSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results); @@ -200,8 +200,8 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform& ShapeSW *shape = static_cast<PhysicsServerSW*>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape,false); - AABB aabb = p_xform.xform(shape->get_aabb()); - aabb=aabb.merge(AABB(aabb.pos+p_motion,aabb.size)); //motion + Rect3 aabb = p_xform.xform(shape->get_aabb()); + aabb=aabb.merge(Rect3(aabb.pos+p_motion,aabb.size)); //motion aabb=aabb.grow(p_margin); //if (p_motion!=Vector3()) @@ -329,7 +329,7 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform& p_sh ShapeSW *shape = static_cast<PhysicsServerSW*>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape,0); - AABB aabb = p_shape_xform.xform(shape->get_aabb()); + Rect3 aabb = p_shape_xform.xform(shape->get_aabb()); aabb=aabb.grow(p_margin); int amount = space->broadphase->cull_aabb(aabb,space->intersection_query_results,SpaceSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results); @@ -412,7 +412,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform& p_shape_ ShapeSW *shape = static_cast<PhysicsServerSW*>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape,0); - AABB aabb = p_shape_xform.xform(shape->get_aabb()); + Rect3 aabb = p_shape_xform.xform(shape->get_aabb()); aabb=aabb.grow(p_margin); int amount = space->broadphase->cull_aabb(aabb,space->intersection_query_results,SpaceSW::INTERSECTION_QUERY_MAX,space->intersection_query_subindex_results); diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp index 5ee983d706..8ccdd51067 100644 --- a/servers/physics_2d/area_2d_sw.cpp +++ b/servers/physics_2d/area_2d_sw.cpp @@ -38,7 +38,7 @@ void Area2DSW::_shapes_changed() { } -void Area2DSW::set_transform(const Matrix32& p_transform) { +void Area2DSW::set_transform(const Transform2D& p_transform) { if (!moved_list.in_list() && get_space()) get_space()->area_add_to_moved_list(&moved_list); diff --git a/servers/physics_2d/area_2d_sw.h b/servers/physics_2d/area_2d_sw.h index ea991e8f6c..6e79b28afc 100644 --- a/servers/physics_2d/area_2d_sw.h +++ b/servers/physics_2d/area_2d_sw.h @@ -162,7 +162,7 @@ public: void set_monitorable(bool p_monitorable); _FORCE_INLINE_ bool is_monitorable() const { return monitorable; } - void set_transform(const Matrix32& p_transform); + void set_transform(const Transform2D& p_transform); void set_space(Space2DSW *p_space); diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 9d859c1107..a32e024fe9 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -68,7 +68,7 @@ void Body2DSW::update_inertias() { float mass = area * this->mass / total_area; - Matrix32 mtx = get_shape_transform(i); + Transform2D mtx = get_shape_transform(i); Vector2 scale = mtx.get_scale(); _inertia += shape->get_moment_of_inertia(mass,scale) + mass * mtx.get_origin().length_squared(); //Rect2 ab = get_shape_aabb(i); @@ -287,7 +287,7 @@ void Body2DSW::set_state(Physics2DServer::BodyState p_state, const Variant& p_va _set_inv_transform(get_transform().affine_inverse()); wakeup_neighbours(); } else { - Matrix32 t = p_variant; + Transform2D t = p_variant; t.orthonormalize(); new_transform=get_transform(); //used as old to compute motion if (t==new_transform) @@ -560,7 +560,7 @@ void Body2DSW::integrate_velocities(real_t p_step) { real_t angle = get_transform().get_rotation() + total_angular_velocity * p_step; Vector2 pos = get_transform().get_origin() + total_linear_velocity * p_step; - _set_transform(Matrix32(angle,pos),continuous_cd_mode==Physics2DServer::CCD_MODE_DISABLED); + _set_transform(Transform2D(angle,pos),continuous_cd_mode==Physics2DServer::CCD_MODE_DISABLED); _set_inv_transform(get_transform().inverse()); if (continuous_cd_mode!=Physics2DServer::CCD_MODE_DISABLED) diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index 59e88f5640..bf9dcaa9b0 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -86,7 +86,7 @@ class Body2DSW : public CollisionObject2DSW { bool using_one_way_cache; void _update_inertia(); virtual void _shapes_changed(); - Matrix32 new_transform; + Transform2D new_transform; Map<Constraint2DSW*,int> constraint_map; @@ -373,8 +373,8 @@ public: virtual void set_angular_velocity(real_t p_velocity) { body->set_angular_velocity(p_velocity); } virtual real_t get_angular_velocity() const { return body->get_angular_velocity(); } - virtual void set_transform(const Matrix32& p_transform) { body->set_state(Physics2DServer::BODY_STATE_TRANSFORM,p_transform); } - virtual Matrix32 get_transform() const { return body->get_transform(); } + virtual void set_transform(const Transform2D& p_transform) { body->set_state(Physics2DServer::BODY_STATE_TRANSFORM,p_transform); } + virtual Transform2D get_transform() const { return body->get_transform(); } virtual void set_sleep_state(bool p_enable) { body->set_active(!p_enable); } virtual bool is_sleeping() const { return !body->is_active(); } diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 7c00f22dfd..72ae221c39 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -175,7 +175,7 @@ void BodyPair2DSW::_validate_contacts() { } -bool BodyPair2DSW::_test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Matrix32& p_xform_A,Body2DSW *p_B, int p_shape_B,const Matrix32& p_xform_B,bool p_swap_result) { +bool BodyPair2DSW::_test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Transform2D& p_xform_A,Body2DSW *p_B, int p_shape_B,const Transform2D& p_xform_B,bool p_swap_result) { @@ -202,7 +202,7 @@ bool BodyPair2DSW::_test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Mat Vector2 from = p_xform_A.xform(s[0]); Vector2 to = from + motion; - Matrix32 from_inv = p_xform_B.affine_inverse(); + Transform2D from_inv = p_xform_B.affine_inverse(); Vector2 local_from = from_inv.xform(from-mnormal*mlen*0.1); //start from a little inside the bounding box Vector2 local_to = from_inv.xform(to); @@ -245,12 +245,12 @@ bool BodyPair2DSW::setup(float p_step) { _validate_contacts(); Vector2 offset_A = A->get_transform().get_origin(); - Matrix32 xform_Au = A->get_transform().untranslated(); - Matrix32 xform_A = xform_Au * A->get_shape_transform(shape_A); + Transform2D xform_Au = A->get_transform().untranslated(); + Transform2D xform_A = xform_Au * A->get_shape_transform(shape_A); - Matrix32 xform_Bu = B->get_transform(); + Transform2D xform_Bu = B->get_transform(); xform_Bu.translate(-A->get_transform().get_origin()); - Matrix32 xform_B = xform_Bu * B->get_shape_transform(shape_B); + Transform2D xform_B = xform_Bu * B->get_shape_transform(shape_B); Shape2DSW *shape_A_ptr=A->get_shape(shape_A); Shape2DSW *shape_B_ptr=B->get_shape(shape_B); diff --git a/servers/physics_2d/body_pair_2d_sw.h b/servers/physics_2d/body_pair_2d_sw.h index a219b99fd8..b9ff1bd758 100644 --- a/servers/physics_2d/body_pair_2d_sw.h +++ b/servers/physics_2d/body_pair_2d_sw.h @@ -80,7 +80,7 @@ class BodyPair2DSW : public Constraint2DSW { int cc; - bool _test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Matrix32& p_xform_A,Body2DSW *p_B, int p_shape_B,const Matrix32& p_xform_B,bool p_swap_result=false); + bool _test_ccd(float p_step,Body2DSW *p_A, int p_shape_A,const Transform2D& p_xform_A,Body2DSW *p_B, int p_shape_B,const Transform2D& p_xform_B,bool p_swap_result=false); void _validate_contacts(); static void _add_contact(const Vector2& p_point_A,const Vector2& p_point_B,void *p_self); _FORCE_INLINE_ void _contact_added_callback(const Vector2& p_point_A,const Vector2& p_point_B); diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp index 94e5d668b1..9ae0e40417 100644 --- a/servers/physics_2d/collision_object_2d_sw.cpp +++ b/servers/physics_2d/collision_object_2d_sw.cpp @@ -29,7 +29,7 @@ #include "collision_object_2d_sw.h" #include "space_2d_sw.h" -void CollisionObject2DSW::add_shape(Shape2DSW *p_shape,const Matrix32& p_transform) { +void CollisionObject2DSW::add_shape(Shape2DSW *p_shape,const Transform2D& p_transform) { Shape s; s.shape=p_shape; @@ -63,7 +63,7 @@ void CollisionObject2DSW::set_shape_metadata(int p_index,const Variant& p_metada } -void CollisionObject2DSW::set_shape_transform(int p_index,const Matrix32& p_transform){ +void CollisionObject2DSW::set_shape_transform(int p_index,const Transform2D& p_transform){ ERR_FAIL_INDEX(p_index,shapes.size()); @@ -149,7 +149,7 @@ void CollisionObject2DSW::_update_shapes() { //not quite correct, should compute the next matrix.. Rect2 shape_aabb=s.shape->get_aabb(); - Matrix32 xform = transform * s.xform; + Transform2D xform = transform * s.xform; shape_aabb=xform.xform(shape_aabb); s.aabb_cache=shape_aabb; s.aabb_cache=s.aabb_cache.grow( (s.aabb_cache.size.x + s.aabb_cache.size.y)*0.5*0.05 ); @@ -176,7 +176,7 @@ void CollisionObject2DSW::_update_shapes_with_motion(const Vector2& p_motion) { //not quite correct, should compute the next matrix.. Rect2 shape_aabb=s.shape->get_aabb(); - Matrix32 xform = transform * s.xform; + Transform2D xform = transform * s.xform; shape_aabb=xform.xform(shape_aabb); shape_aabb=shape_aabb.merge(Rect2( shape_aabb.pos+p_motion,shape_aabb.size)); //use motion s.aabb_cache=shape_aabb; diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index cf26a28ec4..0f77e9b426 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -51,8 +51,8 @@ private: struct Shape { - Matrix32 xform; - Matrix32 xform_inv; + Transform2D xform; + Transform2D xform_inv; BroadPhase2DSW::ID bpid; Rect2 aabb_cache; //for rayqueries Shape2DSW *shape; @@ -63,8 +63,8 @@ private: Vector<Shape> shapes; Space2DSW *space; - Matrix32 transform; - Matrix32 inv_transform; + Transform2D transform; + Transform2D inv_transform; uint32_t collision_mask; uint32_t layer_mask; bool _static; @@ -77,8 +77,8 @@ protected: void _update_shapes_with_motion(const Vector2& p_motion); void _unregister_shapes(); - _FORCE_INLINE_ void _set_transform(const Matrix32& p_transform, bool p_update_shapes=true) { transform=p_transform; if (p_update_shapes) {_update_shapes();} } - _FORCE_INLINE_ void _set_inv_transform(const Matrix32& p_transform) { inv_transform=p_transform; } + _FORCE_INLINE_ void _set_transform(const Transform2D& p_transform, bool p_update_shapes=true) { transform=p_transform; if (p_update_shapes) {_update_shapes();} } + _FORCE_INLINE_ void _set_inv_transform(const Transform2D& p_transform) { inv_transform=p_transform; } void _set_static(bool p_static); virtual void _shapes_changed()=0; @@ -96,21 +96,21 @@ public: void _shape_changed(); _FORCE_INLINE_ Type get_type() const { return type; } - void add_shape(Shape2DSW *p_shape,const Matrix32& p_transform=Matrix32()); + void add_shape(Shape2DSW *p_shape,const Transform2D& p_transform=Transform2D()); void set_shape(int p_index,Shape2DSW *p_shape); - void set_shape_transform(int p_index,const Matrix32& p_transform); + void set_shape_transform(int p_index,const Transform2D& p_transform); void set_shape_metadata(int p_index,const Variant& p_metadata); _FORCE_INLINE_ int get_shape_count() const { return shapes.size(); } _FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const { return shapes[p_index].shape; } - _FORCE_INLINE_ const Matrix32& get_shape_transform(int p_index) const { return shapes[p_index].xform; } - _FORCE_INLINE_ const Matrix32& get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; } + _FORCE_INLINE_ const Transform2D& get_shape_transform(int p_index) const { return shapes[p_index].xform; } + _FORCE_INLINE_ const Transform2D& get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; } _FORCE_INLINE_ const Rect2& get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } _FORCE_INLINE_ const Variant& get_shape_metadata(int p_index) const { return shapes[p_index].metadata; } - _FORCE_INLINE_ Matrix32 get_transform() const { return transform; } - _FORCE_INLINE_ Matrix32 get_inv_transform() const { return inv_transform; } + _FORCE_INLINE_ Transform2D get_transform() const { return transform; } + _FORCE_INLINE_ Transform2D get_inv_transform() const { return inv_transform; } _FORCE_INLINE_ Space2DSW* get_space() const { return space; } _FORCE_INLINE_ void set_shape_as_trigger(int p_idx,bool p_enable) { shapes[p_idx].trigger=p_enable; } diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp index d4ab2c3bc6..2e7b0d8835 100644 --- a/servers/physics_2d/collision_solver_2d_sat.cpp +++ b/servers/physics_2d/collision_solver_2d_sat.cpp @@ -343,8 +343,8 @@ class SeparatorAxisTest2D { const ShapeA *shape_A; const ShapeB *shape_B; - const Matrix32 *transform_A; - const Matrix32 *transform_B; + const Transform2D *transform_A; + const Transform2D *transform_B; real_t best_depth; Vector2 best_axis; int best_axis_count; @@ -560,7 +560,7 @@ public: } - _FORCE_INLINE_ SeparatorAxisTest2D(const ShapeA *p_shape_A,const Matrix32& p_transform_a, const ShapeB *p_shape_B,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_A=Vector2(), const Vector2& p_motion_B=Vector2(),real_t p_margin_A=0,real_t p_margin_B=0) { + _FORCE_INLINE_ SeparatorAxisTest2D(const ShapeA *p_shape_A,const Transform2D& p_transform_a, const ShapeB *p_shape_B,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_A=Vector2(), const Vector2& p_motion_B=Vector2(),real_t p_margin_A=0,real_t p_margin_B=0) { margin_A=p_margin_A; margin_B=p_margin_B; @@ -594,11 +594,11 @@ public: (castA && castB && !separator.test_axis(((m_a)+p_motion_a-((m_b)+p_motion_b)).normalized())) ) -typedef void (*CollisionFunc)(const Shape2DSW*,const Matrix32&,const Shape2DSW*,const Matrix32&,_CollectorCallback2D *p_collector,const Vector2&,const Vector2&,float,float); +typedef void (*CollisionFunc)(const Shape2DSW*,const Transform2D&,const Shape2DSW*,const Transform2D&,_CollectorCallback2D *p_collector,const Vector2&,const Vector2&,float,float); template<bool castA, bool castB,bool withMargin> -static void _collision_segment_segment(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_segment_segment(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a); const SegmentShape2DSW *segment_B = static_cast<const SegmentShape2DSW*>(p_b); @@ -641,7 +641,7 @@ static void _collision_segment_segment(const Shape2DSW* p_a,const Matrix32& p_tr } template<bool castA, bool castB,bool withMargin> -static void _collision_segment_circle(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_segment_circle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a); @@ -674,7 +674,7 @@ static void _collision_segment_circle(const Shape2DSW* p_a,const Matrix32& p_tra } template<bool castA, bool castB,bool withMargin> -static void _collision_segment_rectangle(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_segment_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a); const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b); @@ -698,7 +698,7 @@ static void _collision_segment_rectangle(const Shape2DSW* p_a,const Matrix32& p_ if (withMargin) { - Matrix32 inv = p_transform_b.affine_inverse(); + Transform2D inv = p_transform_b.affine_inverse(); Vector2 a = p_transform_a.xform(segment_A->get_a()); Vector2 b = p_transform_a.xform(segment_A->get_b()); @@ -739,7 +739,7 @@ static void _collision_segment_rectangle(const Shape2DSW* p_a,const Matrix32& p_ } template<bool castA, bool castB,bool withMargin> -static void _collision_segment_capsule(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_segment_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a); const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b); @@ -771,7 +771,7 @@ static void _collision_segment_capsule(const Shape2DSW* p_a,const Matrix32& p_tr } template<bool castA, bool castB,bool withMargin> -static void _collision_segment_convex_polygon(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_segment_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const SegmentShape2DSW *segment_A = static_cast<const SegmentShape2DSW*>(p_a); const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b); @@ -811,7 +811,7 @@ static void _collision_segment_convex_polygon(const Shape2DSW* p_a,const Matrix3 ///////// template<bool castA, bool castB,bool withMargin> -static void _collision_circle_circle(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_circle_circle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a); const CircleShape2DSW *circle_B = static_cast<const CircleShape2DSW*>(p_b); @@ -834,7 +834,7 @@ static void _collision_circle_circle(const Shape2DSW* p_a,const Matrix32& p_tran } template<bool castA, bool castB,bool withMargin> -static void _collision_circle_rectangle(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_circle_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a); const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b); @@ -858,7 +858,7 @@ static void _collision_circle_rectangle(const Shape2DSW* p_a,const Matrix32& p_t if (!separator.test_axis(axis[1].normalized())) return; - Matrix32 binv = p_transform_b.affine_inverse(); + Transform2D binv = p_transform_b.affine_inverse(); { if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv,sphere ) ) ) @@ -890,7 +890,7 @@ static void _collision_circle_rectangle(const Shape2DSW* p_a,const Matrix32& p_t } template<bool castA, bool castB,bool withMargin> -static void _collision_circle_capsule(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_circle_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a); const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b); @@ -920,7 +920,7 @@ static void _collision_circle_capsule(const Shape2DSW* p_a,const Matrix32& p_tra } template<bool castA, bool castB,bool withMargin> -static void _collision_circle_convex_polygon(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_circle_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a); const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b); @@ -952,7 +952,7 @@ static void _collision_circle_convex_polygon(const Shape2DSW* p_a,const Matrix32 ///////// template<bool castA, bool castB,bool withMargin> -static void _collision_rectangle_rectangle(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_rectangle_rectangle(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW*>(p_a); const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b); @@ -982,22 +982,22 @@ static void _collision_rectangle_rectangle(const Shape2DSW* p_a,const Matrix32& if (withMargin) { - Matrix32 invA=p_transform_a.affine_inverse(); - Matrix32 invB=p_transform_b.affine_inverse(); + Transform2D invA=p_transform_a.affine_inverse(); + Transform2D invB=p_transform_b.affine_inverse(); if (!separator.test_axis( rectangle_A->get_box_axis(p_transform_a,invA,rectangle_B,p_transform_b,invB) ) ) return; if (castA || castB) { - Matrix32 aofs = p_transform_a; + Transform2D aofs = p_transform_a; aofs.elements[2]+=p_motion_a; - Matrix32 bofs = p_transform_b; + Transform2D bofs = p_transform_b; bofs.elements[2]+=p_motion_b; - Matrix32 aofsinv = aofs.affine_inverse(); - Matrix32 bofsinv = bofs.affine_inverse(); + Transform2D aofsinv = aofs.affine_inverse(); + Transform2D bofsinv = bofs.affine_inverse(); if (castA) { @@ -1023,7 +1023,7 @@ static void _collision_rectangle_rectangle(const Shape2DSW* p_a,const Matrix32& } template<bool castA, bool castB,bool withMargin> -static void _collision_rectangle_capsule(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_rectangle_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW*>(p_a); const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b); @@ -1051,7 +1051,7 @@ static void _collision_rectangle_capsule(const Shape2DSW* p_a,const Matrix32& p_ //box endpoints to capsule circles - Matrix32 boxinv = p_transform_a.affine_inverse(); + Transform2D boxinv = p_transform_a.affine_inverse(); for(int i=0;i<2;i++) { @@ -1096,7 +1096,7 @@ static void _collision_rectangle_capsule(const Shape2DSW* p_a,const Matrix32& p_ } template<bool castA, bool castB,bool withMargin> -static void _collision_rectangle_convex_polygon(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_rectangle_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const RectangleShape2DSW *rectangle_A = static_cast<const RectangleShape2DSW*>(p_a); const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b); @@ -1118,7 +1118,7 @@ static void _collision_rectangle_convex_polygon(const Shape2DSW* p_a,const Matri return; //convex faces - Matrix32 boxinv; + Transform2D boxinv; if (withMargin) { boxinv=p_transform_a.affine_inverse(); } @@ -1158,7 +1158,7 @@ static void _collision_rectangle_convex_polygon(const Shape2DSW* p_a,const Matri ///////// template<bool castA, bool castB,bool withMargin> -static void _collision_capsule_capsule(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_capsule_capsule(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const CapsuleShape2DSW *capsule_A = static_cast<const CapsuleShape2DSW*>(p_a); const CapsuleShape2DSW *capsule_B = static_cast<const CapsuleShape2DSW*>(p_b); @@ -1201,7 +1201,7 @@ static void _collision_capsule_capsule(const Shape2DSW* p_a,const Matrix32& p_tr } template<bool castA, bool castB,bool withMargin> -static void _collision_capsule_convex_polygon(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_capsule_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const CapsuleShape2DSW *capsule_A = static_cast<const CapsuleShape2DSW*>(p_a); const ConvexPolygonShape2DSW *convex_B = static_cast<const ConvexPolygonShape2DSW*>(p_b); @@ -1247,7 +1247,7 @@ static void _collision_capsule_convex_polygon(const Shape2DSW* p_a,const Matrix3 template<bool castA, bool castB,bool withMargin> -static void _collision_convex_polygon_convex_polygon(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { +static void _collision_convex_polygon_convex_polygon(const Shape2DSW* p_a,const Transform2D& p_transform_a,const Shape2DSW* p_b,const Transform2D& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) { const ConvexPolygonShape2DSW *convex_A = static_cast<const ConvexPolygonShape2DSW*>(p_a); @@ -1294,7 +1294,7 @@ static void _collision_convex_polygon_convex_polygon(const Shape2DSW* p_a,const //////// -bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Matrix32& p_transform_A, const Vector2& p_motion_A, const Shape2DSW *p_shape_B, const Matrix32& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap,Vector2 *sep_axis,float p_margin_A,float p_margin_B) { +bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D& p_transform_A, const Vector2& p_motion_A, const Shape2DSW *p_shape_B, const Transform2D& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap,Vector2 *sep_axis,float p_margin_A,float p_margin_B) { Physics2DServer::ShapeType type_A=p_shape_A->get_type(); @@ -1551,8 +1551,8 @@ bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Matrix32& p_ const Shape2DSW *A=p_shape_A; const Shape2DSW *B=p_shape_B; - const Matrix32 *transform_A=&p_transform_A; - const Matrix32 *transform_B=&p_transform_B; + const Transform2D *transform_A=&p_transform_A; + const Transform2D *transform_B=&p_transform_B; const Vector2 *motion_A=&p_motion_A; const Vector2 *motion_B=&p_motion_B; real_t margin_A=p_margin_A,margin_B=p_margin_B; diff --git a/servers/physics_2d/collision_solver_2d_sat.h b/servers/physics_2d/collision_solver_2d_sat.h index b885dba91b..01acf319c7 100644 --- a/servers/physics_2d/collision_solver_2d_sat.h +++ b/servers/physics_2d/collision_solver_2d_sat.h @@ -32,6 +32,6 @@ #include "collision_solver_2d_sw.h" -bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Matrix32& p_transform_A, const Vector2& p_motion_A,const Shape2DSW *p_shape_B, const Matrix32& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0); +bool sat_2d_calculate_penetration(const Shape2DSW *p_shape_A, const Transform2D& p_transform_A, const Vector2& p_motion_A,const Shape2DSW *p_shape_B, const Transform2D& p_transform_B,const Vector2& p_motion_B, CollisionSolver2DSW::CallbackResult p_result_callback,void *p_userdata, bool p_swap=false,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0); #endif // COLLISION_SOLVER_2D_SAT_H diff --git a/servers/physics_2d/collision_solver_2d_sw.cpp b/servers/physics_2d/collision_solver_2d_sw.cpp index 079b0499c2..e509bb76cd 100644 --- a/servers/physics_2d/collision_solver_2d_sw.cpp +++ b/servers/physics_2d/collision_solver_2d_sw.cpp @@ -34,7 +34,7 @@ //#define collision_solver gjk_epa_calculate_penetration -bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result) { +bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result) { const LineShape2DSW *line = static_cast<const LineShape2DSW*>(p_shape_A); @@ -77,7 +77,7 @@ bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A,const Mat return found; } -bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis) { +bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis) { @@ -89,7 +89,7 @@ bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A,const Matrix3 Vector2 to = from+p_transform_A[1]*ray->get_length(); Vector2 support_A=to; - Matrix32 invb = p_transform_B.affine_inverse(); + Transform2D invb = p_transform_B.affine_inverse(); from = invb.xform(from); to = invb.xform(to); @@ -145,9 +145,9 @@ bool CollisionSolver2DSW::solve_ray(const Shape2DSW *p_shape_A,const Matrix32& p struct _ConcaveCollisionInfo2D { - const Matrix32 *transform_A; + const Transform2D *transform_A; const Shape2DSW *shape_A; - const Matrix32 *transform_B; + const Transform2D *transform_B; Vector2 motion_A; Vector2 motion_B; real_t margin_A; @@ -181,7 +181,7 @@ void CollisionSolver2DSW::concave_callback(void *p_userdata, Shape2DSW *p_convex } -bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis,float p_margin_A,float p_margin_B) { +bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis,float p_margin_A,float p_margin_B) { const ConcaveShape2DSW *concave_B=static_cast<const ConcaveShape2DSW*>(p_shape_B); @@ -202,7 +202,7 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Matrix3 cinfo.aabb_tests=0; - Matrix32 rel_transform = p_transform_A; + Transform2D rel_transform = p_transform_A; rel_transform.translate(-p_transform_B.get_origin()); //quickly compute a local Rect2 @@ -231,7 +231,7 @@ bool CollisionSolver2DSW::solve_concave(const Shape2DSW *p_shape_A,const Matrix3 } -bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis,float p_margin_A,float p_margin_B) { +bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis,float p_margin_A,float p_margin_B) { diff --git a/servers/physics_2d/collision_solver_2d_sw.h b/servers/physics_2d/collision_solver_2d_sw.h index 8e421dec70..085d3a49fb 100644 --- a/servers/physics_2d/collision_solver_2d_sw.h +++ b/servers/physics_2d/collision_solver_2d_sw.h @@ -35,16 +35,16 @@ class CollisionSolver2DSW { public: typedef void (*CallbackResult)(const Vector2& p_point_A,const Vector2& p_point_B,void *p_userdata); private: - static bool solve_static_line(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result); + static bool solve_static_line(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result); static void concave_callback(void *p_userdata, Shape2DSW *p_convex); - static bool solve_concave(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0); - static bool solve_raycast(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis=NULL); + static bool solve_concave(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0); + static bool solve_raycast(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,CallbackResult p_result_callback,void *p_userdata,bool p_swap_result,Vector2 *sep_axis=NULL); public: - static bool solve(const Shape2DSW *p_shape_A,const Matrix32& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Matrix32& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0); + static bool solve(const Shape2DSW *p_shape_A,const Transform2D& p_transform_A,const Vector2& p_motion_A,const Shape2DSW *p_shape_B,const Transform2D& p_transform_B,const Vector2& p_motion_B,CallbackResult p_result_callback,void *p_userdata,Vector2 *sep_axis=NULL,float p_margin_A=0,float p_margin_B=0); }; diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp index 5318212120..7205e90d27 100644 --- a/servers/physics_2d/joints_2d_sw.cpp +++ b/servers/physics_2d/joints_2d_sw.cpp @@ -215,21 +215,21 @@ bool PinJoint2DSW::setup(float p_step) { real_t B_inv_mass = B?B->get_inv_mass():0.0; - Matrix32 K1; + Transform2D K1; K1[0].x = A->get_inv_mass() + B_inv_mass; K1[1].x = 0.0f; K1[0].y = 0.0f; K1[1].y = A->get_inv_mass() + B_inv_mass; - Matrix32 K2; + Transform2D K2; K2[0].x = A->get_inv_inertia() * rA.y * rA.y; K2[1].x = -A->get_inv_inertia() * rA.x * rA.y; K2[0].y = -A->get_inv_inertia() * rA.x * rA.y; K2[1].y = A->get_inv_inertia() * rA.x * rA.x; - Matrix32 K; + Transform2D K; K[0]= K1[0] + K2[0]; K[1]= K1[1] + K2[1]; if (B) { - Matrix32 K3; + Transform2D K3; K3[0].x = B->get_inv_inertia() * rB.y * rB.y; K3[1].x = -B->get_inv_inertia() * rB.x * rB.y; K3[0].y = -B->get_inv_inertia() * rB.x * rB.y; K3[1].y = B->get_inv_inertia() * rB.x * rB.x; diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h index cbbb6e6db3..91113fa26d 100644 --- a/servers/physics_2d/joints_2d_sw.h +++ b/servers/physics_2d/joints_2d_sw.h @@ -106,7 +106,7 @@ class PinJoint2DSW : public Joint2DSW { Body2DSW *_arr[2]; }; - Matrix32 M; + Transform2D M; Vector2 rA,rB; Vector2 anchor_A; Vector2 anchor_B; diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index abd83c0346..3cc69f470e 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -185,7 +185,7 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2& p_point_A,const Vector2& p } } -bool Physics2DServerSW::shape_collide(RID p_shape_A, const Matrix32& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Matrix32& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count) { +bool Physics2DServerSW::shape_collide(RID p_shape_A, const Transform2D& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Transform2D& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count) { Shape2DSW *shape_A = shape_owner.get(p_shape_A); @@ -348,7 +348,7 @@ Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_overrid } -void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Matrix32& p_transform) { +void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2D& p_transform) { Area2DSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); @@ -372,7 +372,7 @@ void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx,RID p_shape) area->set_shape(p_shape_idx,shape); } -void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Matrix32& p_transform) { +void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D& p_transform) { Area2DSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); @@ -398,10 +398,10 @@ RID Physics2DServerSW::area_get_shape(RID p_area, int p_shape_idx) const { return shape->get_self(); } -Matrix32 Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_idx) const { +Transform2D Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_idx) const { Area2DSW *area = area_owner.get(p_area); - ERR_FAIL_COND_V(!area,Matrix32()); + ERR_FAIL_COND_V(!area,Transform2D()); return area->get_shape_transform(p_shape_idx); } @@ -462,7 +462,7 @@ void Physics2DServerSW::area_set_param(RID p_area,AreaParameter p_param,const Va }; -void Physics2DServerSW::area_set_transform(RID p_area, const Matrix32& p_transform) { +void Physics2DServerSW::area_set_transform(RID p_area, const Transform2D& p_transform) { Area2DSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); @@ -482,10 +482,10 @@ Variant Physics2DServerSW::area_get_param(RID p_area,AreaParameter p_param) cons return area->get_param(p_param); }; -Matrix32 Physics2DServerSW::area_get_transform(RID p_area) const { +Transform2D Physics2DServerSW::area_get_transform(RID p_area) const { Area2DSW *area = area_owner.get(p_area); - ERR_FAIL_COND_V(!area,Matrix32()); + ERR_FAIL_COND_V(!area,Transform2D()); return area->get_transform(); }; @@ -600,7 +600,7 @@ Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const { return body->get_mode(); }; -void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Matrix32& p_transform) { +void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2D& p_transform) { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); @@ -624,7 +624,7 @@ void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx,RID p_shape) body->set_shape(p_shape_idx,shape); } -void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Matrix32& p_transform) { +void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D& p_transform) { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); @@ -666,10 +666,10 @@ RID Physics2DServerSW::body_get_shape(RID p_body, int p_shape_idx) const { return shape->get_self(); } -Matrix32 Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const { +Transform2D Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const { Body2DSW *body = body_owner.get(p_body); - ERR_FAIL_COND_V(!body,Matrix32()); + ERR_FAIL_COND_V(!body,Transform2D()); return body->get_shape_transform(p_shape_idx); } @@ -998,7 +998,7 @@ void Physics2DServerSW::body_set_force_integration_callback(RID p_body,Object *p } -bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count) { +bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count) { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body,false); @@ -1016,7 +1016,7 @@ void Physics2DServerSW::body_set_pickable(RID p_body,bool p_pickable) { } -bool Physics2DServerSW::body_test_motion(RID p_body, const Matrix32 &p_from, const Vector2& p_motion, float p_margin, MotionResult *r_result) { +bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2& p_motion, float p_margin, MotionResult *r_result) { Body2DSW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body,false); diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index f290e9391f..ba45dd9272 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -93,7 +93,7 @@ public: virtual Variant shape_get_data(RID p_shape) const; virtual real_t shape_get_custom_solver_bias(RID p_shape) const; - virtual bool shape_collide(RID p_shape_A, const Matrix32& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Matrix32& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count); + virtual bool shape_collide(RID p_shape_A, const Transform2D& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Transform2D& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count); /* SPACE API */ @@ -123,13 +123,13 @@ public: virtual void area_set_space(RID p_area, RID p_space); virtual RID area_get_space(RID p_area) const; - virtual void area_add_shape(RID p_area, RID p_shape, const Matrix32& p_transform=Matrix32()); + virtual void area_add_shape(RID p_area, RID p_shape, const Transform2D& p_transform=Transform2D()); virtual void area_set_shape(RID p_area, int p_shape_idx,RID p_shape); - virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Matrix32& p_transform); + virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D& p_transform); virtual int area_get_shape_count(RID p_area) const; virtual RID area_get_shape(RID p_area, int p_shape_idx) const; - virtual Matrix32 area_get_shape_transform(RID p_area, int p_shape_idx) const; + virtual Transform2D area_get_shape_transform(RID p_area, int p_shape_idx) const; virtual void area_remove_shape(RID p_area, int p_shape_idx); virtual void area_clear_shapes(RID p_area); @@ -138,10 +138,10 @@ public: virtual ObjectID area_get_object_instance_ID(RID p_area) const; virtual void area_set_param(RID p_area,AreaParameter p_param,const Variant& p_value); - virtual void area_set_transform(RID p_area, const Matrix32& p_transform); + virtual void area_set_transform(RID p_area, const Transform2D& p_transform); virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const; - virtual Matrix32 area_get_transform(RID p_area) const; + virtual Transform2D area_get_transform(RID p_area) const; virtual void area_set_monitorable(RID p_area,bool p_monitorable); virtual void area_set_collision_mask(RID p_area,uint32_t p_mask); virtual void area_set_layer_mask(RID p_area,uint32_t p_mask); @@ -163,15 +163,15 @@ public: virtual void body_set_mode(RID p_body, BodyMode p_mode); virtual BodyMode body_get_mode(RID p_body) const; - virtual void body_add_shape(RID p_body, RID p_shape, const Matrix32& p_transform=Matrix32()); + virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D& p_transform=Transform2D()); virtual void body_set_shape(RID p_body, int p_shape_idx,RID p_shape); - virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Matrix32& p_transform); + virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D& p_transform); virtual void body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant& p_metadata); virtual int body_get_shape_count(RID p_body) const; virtual RID body_get_shape(RID p_body, int p_shape_idx) const; - virtual Matrix32 body_get_shape_transform(RID p_body, int p_shape_idx) const; + virtual Transform2D body_get_shape_transform(RID p_body, int p_shape_idx) const; virtual Variant body_get_shape_metadata(RID p_body, int p_shape_idx) const; @@ -232,11 +232,11 @@ public: virtual void body_set_force_integration_callback(RID p_body,Object *p_receiver,const StringName& p_method,const Variant& p_udata=Variant()); - virtual bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count); + virtual bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count); virtual void body_set_pickable(RID p_body,bool p_pickable); - virtual bool body_test_motion(RID p_body,const Matrix32& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL); + virtual bool body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL); /* JOINT API */ diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index a8e150d8f2..851ba901ec 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -100,7 +100,7 @@ public: //these work well, but should be used from the main thread only - bool shape_collide(RID p_shape_A, const Matrix32& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Matrix32& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count) { + bool shape_collide(RID p_shape_A, const Transform2D& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Transform2D& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count) { ERR_FAIL_COND_V(main_thread!=Thread::get_caller_ID(),false); return physics_2d_server->shape_collide(p_shape_A,p_xform_A,p_motion_A,p_shape_B,p_xform_B,p_motion_B,r_results,p_result_max,r_result_count); @@ -150,13 +150,13 @@ public: FUNC2(area_set_space_override_mode,RID,AreaSpaceOverrideMode); FUNC1RC(AreaSpaceOverrideMode,area_get_space_override_mode,RID); - FUNC3(area_add_shape,RID,RID,const Matrix32&); + FUNC3(area_add_shape,RID,RID,const Transform2D&); FUNC3(area_set_shape,RID,int,RID); - FUNC3(area_set_shape_transform,RID,int,const Matrix32&); + FUNC3(area_set_shape_transform,RID,int,const Transform2D&); FUNC1RC(int,area_get_shape_count,RID); FUNC2RC(RID,area_get_shape,RID,int); - FUNC2RC(Matrix32,area_get_shape_transform,RID,int); + FUNC2RC(Transform2D,area_get_shape_transform,RID,int); FUNC2(area_remove_shape,RID,int); FUNC1(area_clear_shapes,RID); @@ -164,10 +164,10 @@ public: FUNC1RC(ObjectID,area_get_object_instance_ID,RID); FUNC3(area_set_param,RID,AreaParameter,const Variant&); - FUNC2(area_set_transform,RID,const Matrix32&); + FUNC2(area_set_transform,RID,const Transform2D&); FUNC2RC(Variant,area_get_param,RID,AreaParameter); - FUNC1RC(Matrix32,area_get_transform,RID); + FUNC1RC(Transform2D,area_get_transform,RID); FUNC2(area_set_collision_mask,RID,uint32_t); FUNC2(area_set_layer_mask,RID,uint32_t); @@ -191,13 +191,13 @@ public: FUNC1RC(BodyMode,body_get_mode,RID); - FUNC3(body_add_shape,RID,RID,const Matrix32&); + FUNC3(body_add_shape,RID,RID,const Transform2D&); FUNC3(body_set_shape,RID,int,RID); - FUNC3(body_set_shape_transform,RID,int,const Matrix32&); + FUNC3(body_set_shape_transform,RID,int,const Transform2D&); FUNC3(body_set_shape_metadata,RID,int,const Variant&); FUNC1RC(int,body_get_shape_count,RID); - FUNC2RC(Matrix32,body_get_shape_transform,RID,int); + FUNC2RC(Transform2D,body_get_shape_transform,RID,int); FUNC2RC(Variant,body_get_shape_metadata,RID,int); FUNC2RC(RID,body_get_shape,RID,int); @@ -260,13 +260,13 @@ public: FUNC4(body_set_force_integration_callback,RID ,Object *,const StringName& ,const Variant& ); - bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count) { + bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count) { return physics_2d_server->body_collide_shape(p_body,p_body_shape,p_shape,p_shape_xform,p_motion,r_results,p_result_max,r_result_count); } FUNC2(body_set_pickable,RID,bool); - bool body_test_motion(RID p_body,const Matrix32& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL) { + bool body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL) { ERR_FAIL_COND_V(main_thread!=Thread::get_caller_ID(),false); return physics_2d_server->body_test_motion(p_body,p_from,p_motion,p_margin,r_result); diff --git a/servers/physics_2d/shape_2d_sw.cpp b/servers/physics_2d/shape_2d_sw.cpp index e9089e6173..8b19122f17 100644 --- a/servers/physics_2d/shape_2d_sw.cpp +++ b/servers/physics_2d/shape_2d_sw.cpp @@ -684,7 +684,7 @@ real_t ConvexPolygonShape2DSW::get_moment_of_inertia(float p_mass,const Size2& p void ConvexPolygonShape2DSW::set_data(const Variant& p_data) { - ERR_FAIL_COND(p_data.get_type()!=Variant::VECTOR2_ARRAY && p_data.get_type()!=Variant::REAL_ARRAY); + ERR_FAIL_COND(p_data.get_type()!=Variant::POOL_VECTOR2_ARRAY && p_data.get_type()!=Variant::POOL_REAL_ARRAY); if (points) @@ -692,7 +692,7 @@ void ConvexPolygonShape2DSW::set_data(const Variant& p_data) { points=NULL; point_count=0; - if (p_data.get_type()==Variant::VECTOR2_ARRAY) { + if (p_data.get_type()==Variant::POOL_VECTOR2_ARRAY) { PoolVector<Vector2> arr=p_data; ERR_FAIL_COND(arr.size()==0); point_count=arr.size(); @@ -964,11 +964,11 @@ int ConcavePolygonShape2DSW::_generate_bvh(BVH *p_bvh,int p_len,int p_depth) { void ConcavePolygonShape2DSW::set_data(const Variant& p_data) { - ERR_FAIL_COND(p_data.get_type()!=Variant::VECTOR2_ARRAY && p_data.get_type()!=Variant::REAL_ARRAY); + ERR_FAIL_COND(p_data.get_type()!=Variant::POOL_VECTOR2_ARRAY && p_data.get_type()!=Variant::POOL_REAL_ARRAY); Rect2 aabb; - if (p_data.get_type()==Variant::VECTOR2_ARRAY) { + if (p_data.get_type()==Variant::POOL_VECTOR2_ARRAY) { PoolVector<Vector2> p2arr = p_data; int len = p2arr.size(); diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h index a955cb1eee..9160d064ef 100644 --- a/servers/physics_2d/shape_2d_sw.h +++ b/servers/physics_2d/shape_2d_sw.h @@ -80,8 +80,8 @@ public: virtual bool contains_point(const Vector2& p_point) const=0; - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const=0; - virtual void project_range_castv(const Vector2& p_cast, const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const=0; + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const=0; + virtual void project_range_castv(const Vector2& p_cast, const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const=0; virtual Vector2 get_support(const Vector2& p_normal) const; virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const=0; @@ -99,7 +99,7 @@ public: const Map<ShapeOwner2DSW*,int>& get_owners() const; - _FORCE_INLINE_ void get_supports_transformed_cast(const Vector2& p_cast,const Vector2& p_normal,const Matrix32& p_xform,Vector2 *r_supports,int & r_amount) const { + _FORCE_INLINE_ void get_supports_transformed_cast(const Vector2& p_cast,const Vector2& p_normal,const Transform2D& p_xform,Vector2 *r_supports,int & r_amount) const { get_supports(p_xform.basis_xform_inv(p_normal).normalized(),r_supports,r_amount); for(int i=0;i<r_amount;i++) @@ -142,14 +142,14 @@ public: //let the optimizer do the magic #define DEFAULT_PROJECT_RANGE_CAST \ -virtual void project_range_castv(const Vector2& p_cast, const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const {\ +virtual void project_range_castv(const Vector2& p_cast, const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const {\ project_range_cast(p_cast,p_normal,p_transform,r_min,r_max);\ }\ -_FORCE_INLINE_ void project_range_cast(const Vector2& p_cast, const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const {\ +_FORCE_INLINE_ void project_range_cast(const Vector2& p_cast, const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const {\ \ real_t mina,maxa;\ real_t minb,maxb;\ - Matrix32 ofsb=p_transform;\ + Transform2D ofsb=p_transform;\ ofsb.translate(p_cast);\ project_range(p_normal,p_transform,mina,maxa);\ project_range(p_normal,ofsb,minb,maxb); \ @@ -170,7 +170,7 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_LINE; } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; @@ -180,17 +180,17 @@ public: virtual void set_data(const Variant& p_data); virtual Variant get_data() const; - _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { //real large r_min=-1e10; r_max=1e10; } - virtual void project_range_castv(const Vector2& p_cast, const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + virtual void project_range_castv(const Vector2& p_cast, const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range_cast(p_cast,p_normal,p_transform,r_min,r_max); } - _FORCE_INLINE_ void project_range_cast(const Vector2& p_cast, const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range_cast(const Vector2& p_cast, const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { //real large r_min=-1e10; r_max=1e10; @@ -213,7 +213,7 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_RAY; } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; @@ -223,7 +223,7 @@ public: virtual void set_data(const Variant& p_data); virtual Variant get_data() const; - _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { //real large r_max = p_normal.dot(p_transform.get_origin()); r_min = p_normal.dot(p_transform.xform(Vector2(0,length))); @@ -257,11 +257,11 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_SEGMENT; } - _FORCE_INLINE_ Vector2 get_xformed_normal(const Matrix32& p_xform) const { + _FORCE_INLINE_ Vector2 get_xformed_normal(const Transform2D& p_xform) const { return (p_xform.xform(b) - p_xform.xform(a)).normalized().tangent(); } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; @@ -271,7 +271,7 @@ public: virtual void set_data(const Variant& p_data); virtual Variant get_data() const; - _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { //real large r_max = p_normal.dot(p_transform.xform(a)); r_min = p_normal.dot(p_transform.xform(b)); @@ -299,7 +299,7 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CIRCLE; } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; @@ -309,7 +309,7 @@ public: virtual void set_data(const Variant& p_data); virtual Variant get_data() const; - _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { //real large real_t d = p_normal.dot( p_transform.get_origin() ); @@ -339,7 +339,7 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_RECTANGLE; } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; @@ -349,7 +349,7 @@ public: virtual void set_data(const Variant& p_data); virtual Variant get_data() const; - _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { // no matter the angle, the box is mirrored anyway r_max=-1e20; r_min=1e20; @@ -367,7 +367,7 @@ public: - _FORCE_INLINE_ Vector2 get_circle_axis(const Matrix32& p_xform, const Matrix32& p_xform_inv,const Vector2& p_circle) const { + _FORCE_INLINE_ Vector2 get_circle_axis(const Transform2D& p_xform, const Transform2D& p_xform_inv,const Vector2& p_circle) const { Vector2 local_v = p_xform_inv.xform(p_circle); @@ -379,7 +379,7 @@ public: return (p_xform.xform(he)-p_circle).normalized(); } - _FORCE_INLINE_ Vector2 get_box_axis(const Matrix32& p_xform, const Matrix32& p_xform_inv,const RectangleShape2DSW *p_B,const Matrix32& p_B_xform, const Matrix32& p_B_xform_inv) const { + _FORCE_INLINE_ Vector2 get_box_axis(const Transform2D& p_xform, const Transform2D& p_xform_inv,const RectangleShape2DSW *p_B,const Transform2D& p_B_xform, const Transform2D& p_B_xform_inv) const { Vector2 a,b; @@ -427,7 +427,7 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CAPSULE; } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; @@ -437,7 +437,7 @@ public: virtual void set_data(const Variant& p_data); virtual Variant get_data() const; - _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { // no matter the angle, the box is mirrored anyway Vector2 n=p_transform.basis_xform_inv(p_normal).normalized(); float h = (n.y > 0) ? height : -height; @@ -480,7 +480,7 @@ public: _FORCE_INLINE_ int get_point_count() const { return point_count; } _FORCE_INLINE_ const Vector2& get_point(int p_idx) const { return points[p_idx].pos; } _FORCE_INLINE_ const Vector2& get_segment_normal(int p_idx) const { return points[p_idx].normal; } - _FORCE_INLINE_ Vector2 get_xformed_segment_normal(const Matrix32& p_xform, int p_idx) const { + _FORCE_INLINE_ Vector2 get_xformed_segment_normal(const Transform2D& p_xform, int p_idx) const { Vector2 a = points[p_idx].pos; p_idx++; @@ -490,7 +490,7 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CONVEX_POLYGON; } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { project_range(p_normal,p_transform,r_min,r_max); } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; @@ -500,7 +500,7 @@ public: virtual void set_data(const Variant& p_data); virtual Variant get_data() const; - _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { + _FORCE_INLINE_ void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { // no matter the angle, the box is mirrored anyway r_min = r_max = p_normal.dot(p_transform.xform(points[0].pos)); @@ -577,8 +577,8 @@ public: virtual Physics2DServer::ShapeType get_type() const { return Physics2DServer::SHAPE_CONCAVE_POLYGON; } - virtual void project_rangev(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/ } - virtual void project_range(const Vector2& p_normal, const Matrix32& p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/ } + virtual void project_rangev(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/ } + virtual void project_range(const Vector2& p_normal, const Transform2D& p_transform, real_t &r_min, real_t &r_max) const { /*project_range(p_normal,p_transform,r_min,r_max);*/ } virtual void get_supports(const Vector2& p_normal,Vector2 *r_supports,int & r_amount) const; virtual bool contains_point(const Vector2& p_point) const; diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 7985bfef96..2c7b099b36 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -133,7 +133,7 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2& p_from, const Vec const CollisionObject2DSW *col_obj=space->intersection_query_results[i]; int shape_idx=space->intersection_query_subindex_results[i]; - Matrix32 inv_xform = col_obj->get_shape_inv_transform(shape_idx) * col_obj->get_inv_transform(); + Transform2D inv_xform = col_obj->get_shape_inv_transform(shape_idx) * col_obj->get_inv_transform(); Vector2 local_from = inv_xform.xform(begin); Vector2 local_to = inv_xform.xform(end); @@ -153,7 +153,7 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2& p_from, const Vec - Matrix32 xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); + Transform2D xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); shape_point=xform.xform(shape_point); real_t ld = normal.dot(shape_point); @@ -190,7 +190,7 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2& p_from, const Vec } -int Physics2DDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { +int Physics2DDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { if (p_result_max<=0) return 0; @@ -237,7 +237,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Matri -bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { +bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { @@ -280,7 +280,7 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Matrix32 }*/ - Matrix32 col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); + Transform2D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); //test initial overlap, does it collide if going all the way? if (!CollisionSolver2DSW::solve(shape,p_xform,p_motion,col_obj->get_shape(shape_idx),col_obj_xform,Vector2() ,NULL,NULL,NULL,p_margin)) { continue; @@ -362,7 +362,7 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID& p_shape, const Matrix32 } -bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { +bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { if (p_result_max<=0) @@ -471,7 +471,7 @@ static void _rest_cbk_result(const Vector2& p_point_A,const Vector2& p_point_B,v } -bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { +bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape); @@ -592,7 +592,7 @@ int Space2DSW::_cull_aabb_for_body(Body2DSW *p_body,const Rect2& p_aabb) { return amount; } -bool Space2DSW::test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const Vector2&p_motion, float p_margin, Physics2DServer::MotionResult *r_result) { +bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2&p_motion, float p_margin, Physics2DServer::MotionResult *r_result) { //give me back regular physics engine logic //this is madness @@ -618,7 +618,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const body_aabb=body_aabb.grow(p_margin); - Matrix32 body_transform = p_from; + Transform2D body_transform = p_from; { //STEP 1, FREE BODY IF STUCK @@ -649,7 +649,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const if (p_body->is_shape_set_as_trigger(j)) continue; - Matrix32 body_shape_xform = body_transform * p_body->get_shape_transform(j); + Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j); Shape2DSW *body_shape = p_body->get_shape(j); for(int i=0;i<amount;i++) { @@ -739,7 +739,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const if (p_body->is_shape_set_as_trigger(j)) continue; - Matrix32 body_shape_xform = body_transform * p_body->get_shape_transform(j); + Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j); Shape2DSW *body_shape = p_body->get_shape(j); bool stuck=false; @@ -753,7 +753,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const int shape_idx=intersection_query_subindex_results[i]; - Matrix32 col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); + Transform2D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); //test initial overlap, does it collide if going all the way? if (!CollisionSolver2DSW::solve(body_shape,body_shape_xform,p_motion,col_obj->get_shape(shape_idx),col_obj_xform,Vector2() ,NULL,NULL,NULL,0)) { continue; @@ -859,7 +859,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const } else { //it collided, let's get the rest info in unsafe advance - Matrix32 ugt = body_transform; + Transform2D ugt = body_transform; ugt.translate(p_motion*unsafe); _RestCallbackData2D rcd; @@ -867,7 +867,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const rcd.best_object=NULL; rcd.best_shape=0; - Matrix32 body_shape_xform = ugt * p_body->get_shape_transform(best_shape); + Transform2D body_shape_xform = ugt * p_body->get_shape_transform(best_shape); Shape2DSW *body_shape = p_body->get_shape(best_shape); body_aabb.pos+=p_motion*unsafe; diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 692cf08c87..5dee3dea5a 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -49,10 +49,10 @@ public: virtual int intersect_point(const Vector2& p_point,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION, bool p_pick_point=false); virtual bool intersect_ray(const Vector2& p_from, const Vector2& p_to,RayResult &r_result,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); - virtual int intersect_shape(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); - virtual bool cast_motion(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); - virtual bool collide_shape(RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); - virtual bool rest_info(RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); + virtual int intersect_shape(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); + virtual bool cast_motion(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); + virtual bool collide_shape(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); + virtual bool rest_info(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); Physics2DDirectSpaceStateSW(); }; @@ -185,7 +185,7 @@ public: int get_collision_pairs() const { return collision_pairs; } - bool test_body_motion(Body2DSW *p_body, const Matrix32 &p_from, const Vector2&p_motion, float p_margin, Physics2DServer::MotionResult *r_result); + bool test_body_motion(Body2DSW *p_body, const Transform2D &p_from, const Vector2&p_motion, float p_margin, Physics2DServer::MotionResult *r_result); void set_debug_contacts(int p_amount) { contact_debug.resize(p_amount); } diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 22dbfd6e80..666982ebee 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -132,11 +132,11 @@ RID Physics2DShapeQueryParameters::get_shape_rid() const { return shape; } -void Physics2DShapeQueryParameters::set_transform(const Matrix32& p_transform){ +void Physics2DShapeQueryParameters::set_transform(const Transform2D& p_transform){ transform=p_transform; } -Matrix32 Physics2DShapeQueryParameters::get_transform() const{ +Transform2D Physics2DShapeQueryParameters::get_transform() const{ return transform; } @@ -493,7 +493,7 @@ Physics2DTestMotionResult::Physics2DTestMotionResult(){ -bool Physics2DServer::_body_test_motion(RID p_body,const Matrix32& p_from,const Vector2& p_motion,float p_margin,const Ref<Physics2DTestMotionResult>& p_result) { +bool Physics2DServer::_body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,float p_margin,const Ref<Physics2DTestMotionResult>& p_result) { MotionResult *r=NULL; if (p_result.is_valid()) @@ -525,7 +525,7 @@ void Physics2DServer::_bind_methods() { ClassDB::bind_method(_MD("area_set_space_override_mode","area","mode"),&Physics2DServer::area_set_space_override_mode); ClassDB::bind_method(_MD("area_get_space_override_mode","area"),&Physics2DServer::area_get_space_override_mode); - ClassDB::bind_method(_MD("area_add_shape","area","shape","transform"),&Physics2DServer::area_add_shape,DEFVAL(Matrix32())); + ClassDB::bind_method(_MD("area_add_shape","area","shape","transform"),&Physics2DServer::area_add_shape,DEFVAL(Transform2D())); ClassDB::bind_method(_MD("area_set_shape","area","shape_idx","shape"),&Physics2DServer::area_set_shape); ClassDB::bind_method(_MD("area_set_shape_transform","area","shape_idx","transform"),&Physics2DServer::area_set_shape_transform); @@ -558,7 +558,7 @@ void Physics2DServer::_bind_methods() { ClassDB::bind_method(_MD("body_set_mode","body","mode"),&Physics2DServer::body_set_mode); ClassDB::bind_method(_MD("body_get_mode","body"),&Physics2DServer::body_get_mode); - ClassDB::bind_method(_MD("body_add_shape","body","shape","transform"),&Physics2DServer::body_add_shape,DEFVAL(Matrix32())); + ClassDB::bind_method(_MD("body_add_shape","body","shape","transform"),&Physics2DServer::body_add_shape,DEFVAL(Transform2D())); ClassDB::bind_method(_MD("body_set_shape","body","shape_idx","shape"),&Physics2DServer::body_set_shape); ClassDB::bind_method(_MD("body_set_shape_transform","body","shape_idx","transform"),&Physics2DServer::body_set_shape_transform); ClassDB::bind_method(_MD("body_set_shape_metadata","body","shape_idx","metadata"),&Physics2DServer::body_set_shape_metadata); diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index 4b6e6584e6..424d2fa7ce 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -55,8 +55,8 @@ public: virtual void set_angular_velocity(real_t p_velocity)=0; virtual real_t get_angular_velocity() const=0; - virtual void set_transform(const Matrix32& p_transform)=0; - virtual Matrix32 get_transform() const=0; + virtual void set_transform(const Transform2D& p_transform)=0; + virtual Transform2D get_transform() const=0; virtual void set_sleep_state(bool p_enable)=0; virtual bool is_sleeping() const=0; @@ -93,7 +93,7 @@ class Physics2DShapeQueryParameters : public Reference { GDCLASS(Physics2DShapeQueryParameters, Reference); friend class Physics2DDirectSpaceState; RID shape; - Matrix32 transform; + Transform2D transform; Vector2 motion; float margin; Set<RID> exclude; @@ -108,8 +108,8 @@ public: void set_shape_rid(const RID& p_shape); RID get_shape_rid() const; - void set_transform(const Matrix32& p_transform); - Matrix32 get_transform() const; + void set_transform(const Transform2D& p_transform); + Transform2D get_transform() const; void set_motion(const Vector2& p_motion); Vector2 get_motion() const; @@ -184,11 +184,11 @@ public: virtual int intersect_point(const Vector2& p_point,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION,bool p_pick_point=false)=0; - virtual int intersect_shape(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; + virtual int intersect_shape(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; - virtual bool cast_motion(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; + virtual bool cast_motion(const RID& p_shape, const Transform2D& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; - virtual bool collide_shape(RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; + virtual bool collide_shape(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,Vector2 *r_results,int p_result_max,int &r_result_count, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; struct ShapeRestInfo { @@ -202,7 +202,7 @@ public: }; - virtual bool rest_info(RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; + virtual bool rest_info(RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,float p_margin,ShapeRestInfo *r_info, const Set<RID>& p_exclude=Set<RID>(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; Physics2DDirectSpaceState(); @@ -238,7 +238,7 @@ class Physics2DServer : public Object { static Physics2DServer * singleton; - virtual bool _body_test_motion(RID p_body, const Matrix32 &p_from, const Vector2& p_motion, float p_margin=0.08, const Ref<Physics2DTestMotionResult>& p_result=Ref<Physics2DTestMotionResult>()); + virtual bool _body_test_motion(RID p_body, const Transform2D &p_from, const Vector2& p_motion, float p_margin=0.08, const Ref<Physics2DTestMotionResult>& p_result=Ref<Physics2DTestMotionResult>()); protected: static void _bind_methods(); @@ -268,7 +268,7 @@ public: virtual real_t shape_get_custom_solver_bias(RID p_shape) const=0; //these work well, but should be used from the main thread only - virtual bool shape_collide(RID p_shape_A, const Matrix32& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Matrix32& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count)=0; + virtual bool shape_collide(RID p_shape_A, const Transform2D& p_xform_A,const Vector2& p_motion_A,RID p_shape_B, const Transform2D& p_xform_B, const Vector2& p_motion_B,Vector2 *r_results,int p_result_max,int &r_result_count)=0; /* SPACE API */ @@ -333,13 +333,13 @@ public: virtual void area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode)=0; virtual AreaSpaceOverrideMode area_get_space_override_mode(RID p_area) const=0; - virtual void area_add_shape(RID p_area, RID p_shape, const Matrix32& p_transform=Matrix32())=0; + virtual void area_add_shape(RID p_area, RID p_shape, const Transform2D& p_transform=Transform2D())=0; virtual void area_set_shape(RID p_area, int p_shape_idx,RID p_shape)=0; - virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Matrix32& p_transform)=0; + virtual void area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D& p_transform)=0; virtual int area_get_shape_count(RID p_area) const=0; virtual RID area_get_shape(RID p_area, int p_shape_idx) const=0; - virtual Matrix32 area_get_shape_transform(RID p_area, int p_shape_idx) const=0; + virtual Transform2D area_get_shape_transform(RID p_area, int p_shape_idx) const=0; virtual void area_remove_shape(RID p_area, int p_shape_idx)=0; virtual void area_clear_shapes(RID p_area)=0; @@ -348,10 +348,10 @@ public: virtual ObjectID area_get_object_instance_ID(RID p_area) const=0; virtual void area_set_param(RID p_area,AreaParameter p_param,const Variant& p_value)=0; - virtual void area_set_transform(RID p_area, const Matrix32& p_transform)=0; + virtual void area_set_transform(RID p_area, const Transform2D& p_transform)=0; virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const=0; - virtual Matrix32 area_get_transform(RID p_area) const=0; + virtual Transform2D area_get_transform(RID p_area) const=0; virtual void area_set_collision_mask(RID p_area,uint32_t p_mask)=0; virtual void area_set_layer_mask(RID p_area,uint32_t p_mask)=0; @@ -382,14 +382,14 @@ public: virtual void body_set_mode(RID p_body, BodyMode p_mode)=0; virtual BodyMode body_get_mode(RID p_body) const=0; - virtual void body_add_shape(RID p_body, RID p_shape, const Matrix32& p_transform=Matrix32())=0; + virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D& p_transform=Transform2D())=0; virtual void body_set_shape(RID p_body, int p_shape_idx,RID p_shape)=0; - virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Matrix32& p_transform)=0; + virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D& p_transform)=0; virtual void body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant& p_metadata)=0; virtual int body_get_shape_count(RID p_body) const=0; virtual RID body_get_shape(RID p_body, int p_shape_idx) const=0; - virtual Matrix32 body_get_shape_transform(RID p_body, int p_shape_idx) const=0; + virtual Transform2D body_get_shape_transform(RID p_body, int p_shape_idx) const=0; virtual Variant body_get_shape_metadata(RID p_body, int p_shape_idx) const=0; virtual void body_set_shape_as_trigger(RID p_body, int p_shape_idx,bool p_enable)=0; @@ -479,7 +479,7 @@ public: virtual void body_set_force_integration_callback(RID p_body,Object *p_receiver,const StringName& p_method,const Variant& p_udata=Variant())=0; - virtual bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Matrix32& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count)=0; + virtual bool body_collide_shape(RID p_body, int p_body_shape,RID p_shape, const Transform2D& p_shape_xform,const Vector2& p_motion,Vector2 *r_results,int p_result_max,int &r_result_count)=0; virtual void body_set_pickable(RID p_body,bool p_pickable)=0; @@ -497,7 +497,7 @@ public: Variant collider_metadata; }; - virtual bool body_test_motion(RID p_body,const Matrix32& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL)=0; + virtual bool body_test_motion(RID p_body,const Transform2D& p_from,const Vector2& p_motion,float p_margin=0.001,MotionResult *r_result=NULL)=0; /* JOINT API */ diff --git a/servers/physics_server.h b/servers/physics_server.h index 3070f919b0..d57ca93d92 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -46,10 +46,10 @@ public: virtual float get_total_linear_damp() const=0; virtual Vector3 get_center_of_mass() const=0; - virtual Matrix3 get_principal_inertia_axes() const=0; + virtual Basis get_principal_inertia_axes() const=0; virtual float get_inverse_mass() const=0; // get the mass virtual Vector3 get_inverse_inertia() const=0; // get density of this body space - virtual Matrix3 get_inverse_inertia_tensor() const=0; // get density of this body space + virtual Basis get_inverse_inertia_tensor() const=0; // get density of this body space virtual void set_linear_velocity(const Vector3& p_velocity)=0; virtual Vector3 get_linear_velocity() const=0; diff --git a/servers/spatial_sound/spatial_sound_server_sw.cpp b/servers/spatial_sound/spatial_sound_server_sw.cpp index 83b42c5299..ccde73561f 100644 --- a/servers/spatial_sound/spatial_sound_server_sw.cpp +++ b/servers/spatial_sound/spatial_sound_server_sw.cpp @@ -164,9 +164,9 @@ void SpatialSoundServerSW::room_set_space(RID p_room,RID p_space) { Space *space = space_owner.get(p_space); ERR_FAIL_COND(!space); space->rooms.insert(p_room); - room->octree_id=space->octree.create(room,AABB()); + room->octree_id=space->octree.create(room,Rect3()); //set bounds - AABB aabb = room->bounds.is_empty()?AABB():room->bounds.get_aabb(); + Rect3 aabb = room->bounds.is_empty()?Rect3():room->bounds.get_aabb(); space->octree.move(room->octree_id,room->transform.xform(aabb)); room->space=p_space; } @@ -195,7 +195,7 @@ void SpatialSoundServerSW::room_set_bounds(RID p_room, const BSP_Tree& p_bounds) if (!room->space.is_valid()) return; - AABB aabb = room->bounds.is_empty()?AABB():room->bounds.get_aabb(); + Rect3 aabb = room->bounds.is_empty()?Rect3():room->bounds.get_aabb(); Space* space = space_owner.get(room->space); ERR_FAIL_COND(!space); diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp index a930daf729..33e51eb262 100644 --- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp +++ b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.cpp @@ -205,7 +205,7 @@ PoolVector<Point2> SpatialSound2DServerSW::room_get_bounds(RID p_room) const { return room->bounds; } -void SpatialSound2DServerSW::room_set_transform(RID p_room, const Matrix32& p_transform) { +void SpatialSound2DServerSW::room_set_transform(RID p_room, const Transform2D& p_transform) { if (space_owner.owns(p_room)) p_room=space_owner.get(p_room)->default_room; @@ -228,13 +228,13 @@ void SpatialSound2DServerSW::room_set_transform(RID p_room, const Matrix32& p_tr }*/ } -Matrix32 SpatialSound2DServerSW::room_get_transform(RID p_room) const { +Transform2D SpatialSound2DServerSW::room_get_transform(RID p_room) const { if (space_owner.owns(p_room)) p_room=space_owner.get(p_room)->default_room; Room *room = room_owner.get(p_room); - ERR_FAIL_COND_V(!room,Matrix32()); + ERR_FAIL_COND_V(!room,Transform2D()); return room->transform; } @@ -365,17 +365,17 @@ int SpatialSound2DServerSW::source_get_polyphony(RID p_source) const { } -void SpatialSound2DServerSW::source_set_transform(RID p_source, const Matrix32& p_transform) { +void SpatialSound2DServerSW::source_set_transform(RID p_source, const Transform2D& p_transform) { Source *source = source_owner.get(p_source); ERR_FAIL_COND(!source); source->transform=p_transform; source->transform.orthonormalize(); } -Matrix32 SpatialSound2DServerSW::source_get_transform(RID p_source) const { +Transform2D SpatialSound2DServerSW::source_get_transform(RID p_source) const { Source *source = source_owner.get(p_source); - ERR_FAIL_COND_V(!source,Matrix32()); + ERR_FAIL_COND_V(!source,Transform2D()); return source->transform; } @@ -518,17 +518,17 @@ void SpatialSound2DServerSW::listener_set_space(RID p_listener,RID p_space) { } -void SpatialSound2DServerSW::listener_set_transform(RID p_listener, const Matrix32& p_transform) { +void SpatialSound2DServerSW::listener_set_transform(RID p_listener, const Transform2D& p_transform) { Listener *listener = listener_owner.get(p_listener); ERR_FAIL_COND(!listener); listener->transform=p_transform; listener->transform.orthonormalize(); //must be done.. } -Matrix32 SpatialSound2DServerSW::listener_get_transform(RID p_listener) const { +Transform2D SpatialSound2DServerSW::listener_get_transform(RID p_listener) const { Listener *listener = listener_owner.get(p_listener); - ERR_FAIL_COND_V(!listener,Matrix32()); + ERR_FAIL_COND_V(!listener,Transform2D()); return listener->transform; } diff --git a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h index d6c09f50a8..16d2c93e7d 100644 --- a/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h +++ b/servers/spatial_sound_2d/spatial_sound_2d_server_sw.h @@ -80,8 +80,8 @@ class SpatialSound2DServerSW : public SpatialSound2DServer { struct Room : public RID_Data { RID space; - Matrix32 transform; - Matrix32 inverse_transform; + Transform2D transform; + Transform2D inverse_transform; PoolVector<Point2> bounds; RoomReverb reverb; float params[ROOM_PARAM_MAX]; @@ -149,7 +149,7 @@ class SpatialSound2DServerSW : public SpatialSound2DServer { } stream_data; RID space; - Matrix32 transform; + Transform2D transform; float params[SOURCE_PARAM_MAX]; AudioServer::AudioStream *stream; Vector<Voice> voices; @@ -163,7 +163,7 @@ class SpatialSound2DServerSW : public SpatialSound2DServer { struct Listener : public RID_Data { RID space; - Matrix32 transform; + Transform2D transform; float params[LISTENER_PARAM_MAX]; Listener(); @@ -200,8 +200,8 @@ public: virtual void room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds); virtual PoolVector<Point2> room_get_bounds(RID p_room) const; - virtual void room_set_transform(RID p_room, const Matrix32& p_transform); - virtual Matrix32 room_get_transform(RID p_room) const; + virtual void room_set_transform(RID p_room, const Transform2D& p_transform); + virtual Transform2D room_get_transform(RID p_room) const; virtual void room_set_param(RID p_room, RoomParam p_param, float p_value); @@ -224,8 +224,8 @@ public: virtual void source_set_polyphony(RID p_source,int p_voice_count); virtual int source_get_polyphony(RID p_source) const; - virtual void source_set_transform(RID p_source, const Matrix32& p_transform); - virtual Matrix32 source_get_transform(RID p_source) const; + virtual void source_set_transform(RID p_source, const Transform2D& p_transform); + virtual Transform2D source_get_transform(RID p_source) const; virtual void source_set_param(RID p_source, SourceParam p_param, float p_value); virtual float source_get_param(RID p_source, SourceParam p_param) const; @@ -244,8 +244,8 @@ public: virtual RID listener_create(); virtual void listener_set_space(RID p_listener, RID p_space); - virtual void listener_set_transform(RID p_listener, const Matrix32& p_transform); - virtual Matrix32 listener_get_transform(RID p_listener) const; + virtual void listener_set_transform(RID p_listener, const Transform2D& p_transform); + virtual Transform2D listener_get_transform(RID p_listener) const; virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value); virtual float listener_get_param(RID p_listener, ListenerParam p_param) const; diff --git a/servers/spatial_sound_2d_server.h b/servers/spatial_sound_2d_server.h index c19da87c04..331caf8198 100644 --- a/servers/spatial_sound_2d_server.h +++ b/servers/spatial_sound_2d_server.h @@ -59,8 +59,8 @@ public: virtual void room_set_bounds(RID p_room, const PoolVector<Point2>& p_bounds)=0; virtual PoolVector<Point2> room_get_bounds(RID p_room) const=0; - virtual void room_set_transform(RID p_room, const Matrix32& p_transform)=0; - virtual Matrix32 room_get_transform(RID p_room) const=0; + virtual void room_set_transform(RID p_room, const Transform2D& p_transform)=0; + virtual Transform2D room_get_transform(RID p_room) const=0; enum RoomParam { ROOM_PARAM_PITCH_SCALE, @@ -99,8 +99,8 @@ public: virtual RID source_create(RID p_space)=0; - virtual void source_set_transform(RID p_source, const Matrix32& p_transform)=0; - virtual Matrix32 source_get_transform(RID p_source) const=0; + virtual void source_set_transform(RID p_source, const Transform2D& p_transform)=0; + virtual Transform2D source_get_transform(RID p_source) const=0; virtual void source_set_polyphony(RID p_source,int p_voice_count)=0; virtual int source_get_polyphony(RID p_source) const=0; @@ -141,8 +141,8 @@ public: virtual RID listener_create()=0; virtual void listener_set_space(RID p_listener, RID p_space)=0; - virtual void listener_set_transform(RID p_listener, const Matrix32& p_transform)=0; - virtual Matrix32 listener_get_transform(RID p_listener) const=0; + virtual void listener_set_transform(RID p_listener, const Transform2D& p_transform)=0; + virtual Transform2D listener_get_transform(RID p_listener) const=0; virtual void listener_set_param(RID p_listener, ListenerParam p_param, float p_value)=0; virtual float listener_get_param(RID p_listener, ListenerParam p_param) const=0; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index de570b7e4d..887fc5ac5f 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -242,7 +242,7 @@ public: virtual RID mesh_create()=0; - virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const AABB& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<AABB>& p_bone_aabbs=Vector<AABB>())=0; + virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,VS::PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>())=0; virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount)=0; virtual int mesh_get_morph_target_count(RID p_mesh) const=0; @@ -264,17 +264,17 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const=0; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const=0; - virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const=0; + virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const=0; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const=0; - virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const=0; + virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const=0; virtual void mesh_remove_surface(RID p_mesh,int p_index)=0; virtual int mesh_get_surface_count(RID p_mesh) const=0; - virtual void mesh_set_custom_aabb(RID p_mesh,const AABB& p_aabb)=0; - virtual AABB mesh_get_custom_aabb(RID p_mesh) const=0; + virtual void mesh_set_custom_aabb(RID p_mesh,const Rect3& p_aabb)=0; + virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const=0; - virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const=0; + virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const=0; virtual void mesh_clear(RID p_mesh)=0; /* MULTIMESH API */ @@ -287,19 +287,19 @@ public: virtual void multimesh_set_mesh(RID p_multimesh,RID p_mesh)=0; virtual void multimesh_instance_set_transform(RID p_multimesh,int p_index,const Transform& p_transform)=0; - virtual void multimesh_instance_set_transform_2d(RID p_multimesh,int p_index,const Matrix32& p_transform)=0; + virtual void multimesh_instance_set_transform_2d(RID p_multimesh,int p_index,const Transform2D& p_transform)=0; virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color)=0; virtual RID multimesh_get_mesh(RID p_multimesh) const=0; virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const=0; - virtual Matrix32 multimesh_instance_get_transform_2d(RID p_multimesh,int p_index) const=0; + virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh,int p_index) const=0; virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const=0; virtual void multimesh_set_visible_instances(RID p_multimesh,int p_visible)=0; virtual int multimesh_get_visible_instances(RID p_multimesh) const=0; - virtual AABB multimesh_get_aabb(RID p_multimesh) const=0; + virtual Rect3 multimesh_get_aabb(RID p_multimesh) const=0; /* IMMEDIATE API */ @@ -315,7 +315,7 @@ public: virtual void immediate_clear(RID p_immediate)=0; virtual void immediate_set_material(RID p_immediate,RID p_material)=0; virtual RID immediate_get_material(RID p_immediate) const=0; - virtual AABB immediate_get_aabb(RID p_immediate) const=0; + virtual Rect3 immediate_get_aabb(RID p_immediate) const=0; /* SKELETON API */ @@ -325,8 +325,8 @@ public: virtual int skeleton_get_bone_count(RID p_skeleton) const=0; virtual void skeleton_bone_set_transform(RID p_skeleton,int p_bone, const Transform& p_transform)=0; virtual Transform skeleton_bone_get_transform(RID p_skeleton,int p_bone) const =0; - virtual void skeleton_bone_set_transform_2d(RID p_skeleton,int p_bone, const Matrix32& p_transform)=0; - virtual Matrix32 skeleton_bone_get_transform_2d(RID p_skeleton,int p_bone) const=0; + virtual void skeleton_bone_set_transform_2d(RID p_skeleton,int p_bone, const Transform2D& p_transform)=0; + virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton,int p_bone) const=0; /* Light API */ @@ -353,7 +353,7 @@ public: virtual bool light_has_shadow(RID p_light) const=0; virtual VS::LightType light_get_type(RID p_light) const=0; - virtual AABB light_get_aabb(RID p_light) const=0; + virtual Rect3 light_get_aabb(RID p_light) const=0; virtual float light_get_param(RID p_light,VS::LightParam p_param)=0; virtual Color light_get_color(RID p_light)=0; virtual uint64_t light_get_version(RID p_light) const=0; @@ -376,7 +376,7 @@ public: virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable)=0; virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers)=0; - virtual AABB reflection_probe_get_aabb(RID p_probe) const=0; + virtual Rect3 reflection_probe_get_aabb(RID p_probe) const=0; virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const=0; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const=0; virtual Vector3 reflection_probe_get_extents(RID p_probe) const=0; @@ -412,8 +412,8 @@ public: virtual RID gi_probe_create()=0; - virtual void gi_probe_set_bounds(RID p_probe,const AABB& p_bounds)=0; - virtual AABB gi_probe_get_bounds(RID p_probe) const=0; + virtual void gi_probe_set_bounds(RID p_probe,const Rect3& p_bounds)=0; + virtual Rect3 gi_probe_get_bounds(RID p_probe) const=0; virtual void gi_probe_set_cell_size(RID p_probe,float p_range)=0; virtual float gi_probe_get_cell_size(RID p_probe) const=0; @@ -459,7 +459,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles,float p_time)=0; virtual void particles_set_explosiveness_ratio(RID p_particles,float p_ratio)=0; virtual void particles_set_randomness_ratio(RID p_particles,float p_ratio)=0; - virtual void particles_set_custom_aabb(RID p_particles,const AABB& p_aabb)=0; + virtual void particles_set_custom_aabb(RID p_particles,const Rect3& p_aabb)=0; virtual void particles_set_gravity(RID p_particles,const Vector3& p_gravity)=0; virtual void particles_set_use_local_coordinates(RID p_particles,bool p_enable)=0; virtual void particles_set_process_material(RID p_particles,RID p_material)=0; @@ -476,7 +476,7 @@ public: virtual void particles_set_draw_pass_material(RID p_particles,int p_pass, RID p_material)=0; virtual void particles_set_draw_pass_mesh(RID p_particles,int p_pass, RID p_mesh)=0; - virtual AABB particles_get_current_aabb(RID p_particles)=0; + virtual Rect3 particles_get_current_aabb(RID p_particles)=0; @@ -541,7 +541,7 @@ public: bool enabled; Color color; - Matrix32 xform; + Transform2D xform; float height; float energy; float scale; @@ -564,11 +564,11 @@ public: void *texture_cache; // implementation dependent Rect2 rect_cache; - Matrix32 xform_cache; + Transform2D xform_cache; float radius_cache; //used for shadow far plane CameraMatrix shadow_matrix_cache; - Matrix32 light_shader_xform; + Transform2D light_shader_xform; Vector2 light_shader_pos; Light *shadows_next_ptr; @@ -710,7 +710,7 @@ public: struct CommandTransform : public Command { - Matrix32 xform; + Transform2D xform; CommandTransform() { type = TYPE_TRANSFORM; } }; @@ -728,7 +728,7 @@ public: Rect2 rect; }; - Matrix32 xform; + Transform2D xform; bool clip; bool visible; bool behind; @@ -750,7 +750,7 @@ public: Color final_modulate; - Matrix32 final_transform; + Transform2D final_transform; Rect2 final_clip_rect; Item* final_clip_owner; Item* material_owner; @@ -773,7 +773,7 @@ public: return rect; } - Matrix32 xf; + Transform2D xf; bool found_xform=false; bool first=true; @@ -828,7 +828,7 @@ public: case Item::Command::TYPE_MESH: { const Item::CommandMesh* mesh = static_cast< const Item::CommandMesh*>(c); - AABB aabb = RasterizerStorage::base_signleton->mesh_get_aabb(mesh->mesh,mesh->skeleton); + Rect3 aabb = RasterizerStorage::base_signleton->mesh_get_aabb(mesh->mesh,mesh->skeleton); r=Rect2(aabb.pos.x,aabb.pos.y,aabb.size.x,aabb.size.y); @@ -836,7 +836,7 @@ public: case Item::Command::TYPE_MULTIMESH: { const Item::CommandMultiMesh* multimesh = static_cast< const Item::CommandMultiMesh*>(c); - AABB aabb = RasterizerStorage::base_signleton->multimesh_get_aabb(multimesh->multimesh); + Rect3 aabb = RasterizerStorage::base_signleton->multimesh_get_aabb(multimesh->multimesh); r=Rect2(aabb.pos.x,aabb.pos.y,aabb.size.x,aabb.size.y); @@ -898,8 +898,8 @@ public: RID polygon; RID polygon_buffer; Rect2 aabb_cache; - Matrix32 xform; - Matrix32 xform_cache; + Transform2D xform; + Transform2D xform_cache; int light_mask; VS::CanvasOccluderPolygonCullMode cull_cache; @@ -910,7 +910,7 @@ public: - virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Matrix32& p_light_xform, int p_light_mask,float p_near, float p_far, LightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache)=0; + virtual void canvas_light_shadow_buffer_update(RID p_buffer, const Transform2D& p_light_xform, int p_light_mask,float p_near, float p_far, LightOccluderInstance* p_occluders, CameraMatrix *p_xform_cache)=0; virtual void reset_canvas()=0; diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp index 8e6345960f..d68c580442 100644 --- a/servers/visual/visual_server_canvas.cpp +++ b/servers/visual/visual_server_canvas.cpp @@ -2,7 +2,7 @@ #include "visual_server_global.h" #include "visual_server_viewport.h" -void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Matrix32& p_transform, const Rect2& p_clip_rect, const Color& p_modulate, RasterizerCanvas::Light *p_lights) { +void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color& p_modulate, RasterizerCanvas::Light *p_lights) { static const int z_range = VS::CANVAS_ITEM_Z_MAX-VS::CANVAS_ITEM_Z_MIN+1; @@ -25,7 +25,7 @@ void VisualServerCanvas::_render_canvas_item_tree(Item *p_canvas_item, const Mat } -void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect, const Color &p_modulate,int p_z,RasterizerCanvas::Item **z_list,RasterizerCanvas::Item **z_last_list,Item *p_canvas_clip,Item *p_material_owner) { +void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item,const Transform2D& p_transform,const Rect2& p_clip_rect, const Color &p_modulate,int p_z,RasterizerCanvas::Item **z_list,RasterizerCanvas::Item **z_last_list,Item *p_canvas_clip,Item *p_material_owner) { Item *ci = p_canvas_item; @@ -33,7 +33,7 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item,const Matrix32& return; Rect2 rect = ci->get_rect(); - Matrix32 xform = p_transform * ci->xform; + Transform2D xform = p_transform * ci->xform; Rect2 global_rect = xform.xform(rect); global_rect.pos+=p_clip_rect.pos; @@ -150,7 +150,7 @@ void VisualServerCanvas::_light_mask_canvas_items(int p_z,RasterizerCanvas::Item } -void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Matrix32 &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) { +void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights, const Rect2 &p_clip_rect) { VSG::canvas_render->canvas_begin(); @@ -200,17 +200,17 @@ void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Matrix32 &p_trans //mirroring (useful for scrolling backgrounds) if (ci.mirror.x!=0) { - Matrix32 xform2 = p_transform * Matrix32(0,Vector2(ci.mirror.x,0)); + Transform2D xform2 = p_transform * Transform2D(0,Vector2(ci.mirror.x,0)); _render_canvas_item_tree(ci.item,xform2,p_clip_rect,p_canvas->modulate,p_lights); } if (ci.mirror.y!=0) { - Matrix32 xform2 = p_transform * Matrix32(0,Vector2(0,ci.mirror.y)); + Transform2D xform2 = p_transform * Transform2D(0,Vector2(0,ci.mirror.y)); _render_canvas_item_tree(ci.item,xform2,p_clip_rect,p_canvas->modulate,p_lights); } if (ci.mirror.y!=0 && ci.mirror.x!=0) { - Matrix32 xform2 = p_transform * Matrix32(0,ci.mirror); + Transform2D xform2 = p_transform * Transform2D(0,ci.mirror); _render_canvas_item_tree(ci.item,xform2,p_clip_rect,p_canvas->modulate,p_lights); } @@ -323,7 +323,7 @@ void VisualServerCanvas::canvas_item_set_light_mask(RID p_item,int p_mask){ } -void VisualServerCanvas::canvas_item_set_transform(RID p_item, const Matrix32& p_transform){ +void VisualServerCanvas::canvas_item_set_transform(RID p_item, const Transform2D& p_transform){ Item *canvas_item = canvas_item_owner.getornull( p_item ); ERR_FAIL_COND(!canvas_item); @@ -618,7 +618,7 @@ void VisualServerCanvas::canvas_item_add_triangle_array(RID p_item, const Vector } -void VisualServerCanvas::canvas_item_add_set_transform(RID p_item,const Matrix32& p_transform) { +void VisualServerCanvas::canvas_item_add_set_transform(RID p_item,const Transform2D& p_transform) { Item *canvas_item = canvas_item_owner.getornull( p_item ); @@ -809,7 +809,7 @@ void VisualServerCanvas::canvas_light_set_scale(RID p_light, float p_scale){ clight->scale=p_scale; } -void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Matrix32& p_transform){ +void VisualServerCanvas::canvas_light_set_transform(RID p_light, const Transform2D& p_transform){ RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light); @@ -1036,7 +1036,7 @@ void VisualServerCanvas::canvas_light_occluder_set_polygon(RID p_occluder,RID p_ } } -void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder,const Matrix32& p_xform) { +void VisualServerCanvas::canvas_light_occluder_set_transform(RID p_occluder,const Transform2D& p_xform) { RasterizerCanvas::LightOccluderInstance *occluder = canvas_light_occluder_owner.get(p_occluder); ERR_FAIL_COND(!occluder); diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 4a5091e754..035c48d9ef 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -114,12 +114,12 @@ public: private: - void _render_canvas_item_tree(Item *p_canvas_item, const Matrix32& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights); - void _render_canvas_item(Item *p_canvas_item, const Matrix32& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner); + void _render_canvas_item_tree(Item *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, RasterizerCanvas::Light *p_lights); + void _render_canvas_item(Item *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, int p_z, RasterizerCanvas::Item **z_list, RasterizerCanvas::Item **z_last_list, Item *p_canvas_clip, Item *p_material_owner); void _light_mask_canvas_items(int p_z,RasterizerCanvas::Item *p_canvas_item,RasterizerCanvas::Light *p_masked_lights); public: - void render_canvas(Canvas *p_canvas, const Matrix32 &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights,const Rect2& p_clip_rect); + void render_canvas(Canvas *p_canvas, const Transform2D &p_transform, RasterizerCanvas::Light *p_lights, RasterizerCanvas::Light *p_masked_lights,const Rect2& p_clip_rect); RID canvas_create(); void canvas_set_item_mirroring(RID p_canvas,RID p_item,const Point2& p_mirroring); @@ -132,7 +132,7 @@ public: void canvas_item_set_visible(RID p_item,bool p_visible); void canvas_item_set_light_mask(RID p_item,int p_mask); - void canvas_item_set_transform(RID p_item, const Matrix32& p_transform); + void canvas_item_set_transform(RID p_item, const Transform2D& p_transform); void canvas_item_set_clip(RID p_item, bool p_clip); void canvas_item_set_distance_field_mode(RID p_item, bool p_enable); void canvas_item_set_custom_rect(RID p_item, bool p_custom_rect,const Rect2& p_rect=Rect2()); @@ -153,7 +153,7 @@ public: void canvas_item_add_triangle_array(RID p_item, const Vector<int>& p_indices, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), RID p_texture=RID(), int p_count=-1); void canvas_item_add_mesh(RID p_item, const RID& p_mesh,RID p_skeleton=RID()); void canvas_item_add_multimesh(RID p_item, RID p_mesh,RID p_skeleton=RID()); - void canvas_item_add_set_transform(RID p_item,const Matrix32& p_transform); + void canvas_item_add_set_transform(RID p_item,const Transform2D& p_transform); void canvas_item_add_clip_ignore(RID p_item, bool p_ignore); void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable); void canvas_item_set_z(RID p_item, int p_z); @@ -171,7 +171,7 @@ public: void canvas_light_attach_to_canvas(RID p_light,RID p_canvas); void canvas_light_set_enabled(RID p_light, bool p_enabled); void canvas_light_set_scale(RID p_light, float p_scale); - void canvas_light_set_transform(RID p_light, const Matrix32& p_transform); + void canvas_light_set_transform(RID p_light, const Transform2D& p_transform); void canvas_light_set_texture(RID p_light, RID p_texture); void canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset); void canvas_light_set_color(RID p_light, const Color& p_color); @@ -197,7 +197,7 @@ public: void canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas); void canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled); void canvas_light_occluder_set_polygon(RID p_occluder,RID p_polygon); - void canvas_light_occluder_set_transform(RID p_occluder,const Matrix32& p_xform); + void canvas_light_occluder_set_transform(RID p_occluder,const Transform2D& p_xform); void canvas_light_occluder_set_light_mask(RID p_occluder,int p_mask); RID canvas_occluder_polygon_create(); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 5fb71aa0f5..d9b650d569 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -104,7 +104,7 @@ class VisualServerRaster : public VisualServer { Rasterizer::BakedLightData data; PoolVector<int> sampler; - AABB octree_aabb; + Rect3 octree_aabb; Size2i octree_tex_size; Size2i light_tex_size; @@ -177,8 +177,8 @@ class VisualServerRaster : public VisualServer { RID base_rid; - AABB aabb; - AABB transformed_aabb; + Rect3 aabb; + Rect3 transformed_aabb; uint32_t object_ID; bool visible; bool visible_in_all_rooms; @@ -428,11 +428,11 @@ class VisualServerRaster : public VisualServer { struct CanvasData { Canvas *canvas; - Matrix32 transform; + Transform2D transform; int layer; }; - Matrix32 global_transform; + Transform2D global_transform; Map<RID,CanvasData> canvas_map; @@ -451,7 +451,7 @@ class VisualServerRaster : public VisualServer { float min,max; float z_near,z_far; - void add_aabb(const AABB& p_aabb) { + void add_aabb(const Rect3& p_aabb) { } @@ -554,9 +554,9 @@ class VisualServerRaster : public VisualServer { void _render_no_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario); void _render_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario); static void _render_canvas_item_viewport(VisualServer* p_self,void *p_vp,const Rect2& p_rect); - void _render_canvas_item_tree(CanvasItem *p_canvas_item, const Matrix32& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, Rasterizer::CanvasLight *p_lights); - void _render_canvas_item(CanvasItem *p_canvas_item, const Matrix32& p_transform, const Rect2& p_clip_rect, float p_opacity, int p_z, Rasterizer::CanvasItem **z_list, Rasterizer::CanvasItem **z_last_list, CanvasItem *p_canvas_clip, CanvasItem *p_material_owner); - void _render_canvas(Canvas *p_canvas, const Matrix32 &p_transform, Rasterizer::CanvasLight *p_lights, Rasterizer::CanvasLight *p_masked_lights); + void _render_canvas_item_tree(CanvasItem *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, Rasterizer::CanvasLight *p_lights); + void _render_canvas_item(CanvasItem *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, float p_opacity, int p_z, Rasterizer::CanvasItem **z_list, Rasterizer::CanvasItem **z_last_list, CanvasItem *p_canvas_clip, CanvasItem *p_material_owner); + void _render_canvas(Canvas *p_canvas, const Transform2D &p_transform, Rasterizer::CanvasLight *p_lights, Rasterizer::CanvasLight *p_masked_lights); void _light_mask_canvas_items(int p_z,Rasterizer::CanvasItem *p_canvas_item,Rasterizer::CanvasLight *p_masked_lights); Vector<Vector3> _camera_generate_endpoints(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max); @@ -671,7 +671,7 @@ public: BIND0R(RID,mesh_create) - BIND10(mesh_add_surface,RID,uint32_t,PrimitiveType,const PoolVector<uint8_t>&,int ,const PoolVector<uint8_t>& ,int ,const AABB&,const Vector<PoolVector<uint8_t> >&,const Vector<AABB>& ) + BIND10(mesh_add_surface,RID,uint32_t,PrimitiveType,const PoolVector<uint8_t>&,int ,const PoolVector<uint8_t>& ,int ,const Rect3&,const Vector<PoolVector<uint8_t> >&,const Vector<Rect3>& ) BIND2(mesh_set_morph_target_count,RID,int) BIND1RC(int,mesh_get_morph_target_count,RID) @@ -692,15 +692,15 @@ public: BIND2RC(uint32_t,mesh_surface_get_format,RID,int) BIND2RC(PrimitiveType,mesh_surface_get_primitive_type,RID,int) - BIND2RC(AABB,mesh_surface_get_aabb,RID,int) + BIND2RC(Rect3,mesh_surface_get_aabb,RID,int) BIND2RC(Vector<PoolVector<uint8_t> >,mesh_surface_get_blend_shapes,RID,int) - BIND2RC(Vector<AABB>,mesh_surface_get_skeleton_aabb,RID,int) + BIND2RC(Vector<Rect3>,mesh_surface_get_skeleton_aabb,RID,int) BIND2(mesh_remove_surface,RID,int) BIND1RC(int,mesh_get_surface_count,RID) - BIND2(mesh_set_custom_aabb,RID,const AABB&) - BIND1RC(AABB,mesh_get_custom_aabb,RID) + BIND2(mesh_set_custom_aabb,RID,const Rect3&) + BIND1RC(Rect3,mesh_get_custom_aabb,RID) BIND1(mesh_clear,RID) @@ -714,14 +714,14 @@ public: BIND2(multimesh_set_mesh,RID,RID) BIND3(multimesh_instance_set_transform,RID,int,const Transform&) - BIND3(multimesh_instance_set_transform_2d,RID,int,const Matrix32& ) + BIND3(multimesh_instance_set_transform_2d,RID,int,const Transform2D& ) BIND3(multimesh_instance_set_color,RID,int,const Color&) BIND1RC(RID,multimesh_get_mesh,RID) - BIND1RC(AABB,multimesh_get_aabb,RID) + BIND1RC(Rect3,multimesh_get_aabb,RID) BIND2RC(Transform,multimesh_instance_get_transform,RID,int ) - BIND2RC(Matrix32,multimesh_instance_get_transform_2d,RID,int) + BIND2RC(Transform2D,multimesh_instance_get_transform_2d,RID,int) BIND2RC(Color,multimesh_instance_get_color,RID,int) BIND2(multimesh_set_visible_instances,RID,int) @@ -750,8 +750,8 @@ public: BIND1RC(int,skeleton_get_bone_count,RID) BIND3(skeleton_bone_set_transform,RID,int,const Transform&) BIND2RC(Transform,skeleton_bone_get_transform,RID,int) - BIND3(skeleton_bone_set_transform_2d,RID,int, const Matrix32& ) - BIND2RC(Matrix32,skeleton_bone_get_transform_2d,RID,int) + BIND3(skeleton_bone_set_transform_2d,RID,int, const Transform2D& ) + BIND2RC(Transform2D,skeleton_bone_get_transform_2d,RID,int) /* Light API */ @@ -809,8 +809,8 @@ public: BIND0R(RID, gi_probe_create) - BIND2(gi_probe_set_bounds,RID,const AABB&) - BIND1RC(AABB,gi_probe_get_bounds,RID) + BIND2(gi_probe_set_bounds,RID,const Rect3&) + BIND1RC(Rect3,gi_probe_get_bounds,RID) BIND2(gi_probe_set_cell_size,RID,float) BIND1RC(float,gi_probe_get_cell_size,RID) @@ -843,7 +843,7 @@ public: BIND2(particles_set_pre_process_time,RID,float ) BIND2(particles_set_explosiveness_ratio,RID,float ) BIND2(particles_set_randomness_ratio,RID,float ) - BIND2(particles_set_custom_aabb,RID,const AABB& ) + BIND2(particles_set_custom_aabb,RID,const Rect3& ) BIND2(particles_set_gravity,RID,const Vector3& ) BIND2(particles_set_use_local_coordinates,RID,bool ) BIND2(particles_set_process_material,RID,RID ) @@ -860,7 +860,7 @@ public: BIND3(particles_set_draw_pass_material,RID,int , RID ) BIND3(particles_set_draw_pass_mesh,RID,int , RID ) - BIND1R(AABB,particles_get_current_aabb,RID); + BIND1R(Rect3,particles_get_current_aabb,RID); #undef BINDBASE @@ -912,10 +912,10 @@ public: BIND2(viewport_attach_canvas,RID,RID ) BIND2(viewport_remove_canvas,RID,RID ) - BIND3(viewport_set_canvas_transform,RID ,RID ,const Matrix32& ) + BIND3(viewport_set_canvas_transform,RID ,RID ,const Transform2D& ) BIND2(viewport_set_transparent_background,RID ,bool ) - BIND2(viewport_set_global_canvas_transform,RID,const Matrix32& ) + BIND2(viewport_set_global_canvas_transform,RID,const Transform2D& ) BIND3(viewport_set_canvas_layer,RID ,RID ,int ) BIND2(viewport_set_shadow_atlas_size,RID ,int ) BIND3(viewport_set_shadow_atlas_quadrant_subdivision,RID ,int, int ) @@ -988,7 +988,7 @@ public: BIND2(instance_set_extra_visibility_margin, RID, real_t ) // don't use these in a game! - BIND2RC(Vector<ObjectID>,instances_cull_aabb,const AABB& , RID) + BIND2RC(Vector<ObjectID>,instances_cull_aabb,const Rect3& , RID) BIND3RC(Vector<ObjectID>,instances_cull_ray,const Vector3& , const Vector3& , RID ) BIND2RC(Vector<ObjectID>,instances_cull_convex,const Vector<Plane>& , RID) @@ -1018,7 +1018,7 @@ public: BIND2(canvas_item_set_visible,RID,bool ) BIND2(canvas_item_set_light_mask,RID,int ) - BIND2(canvas_item_set_transform,RID, const Matrix32& ) + BIND2(canvas_item_set_transform,RID, const Transform2D& ) BIND2(canvas_item_set_clip,RID, bool ) BIND2(canvas_item_set_distance_field_mode,RID, bool ) BIND3(canvas_item_set_custom_rect,RID, bool ,const Rect2& ) @@ -1039,7 +1039,7 @@ public: BIND7(canvas_item_add_triangle_array,RID, const Vector<int>& , const Vector<Point2>& , const Vector<Color>& ,const Vector<Point2>& , RID , int) BIND3(canvas_item_add_mesh,RID, const RID& ,RID ) BIND3(canvas_item_add_multimesh,RID, RID ,RID ) - BIND2(canvas_item_add_set_transform,RID,const Matrix32& ) + BIND2(canvas_item_add_set_transform,RID,const Transform2D& ) BIND2(canvas_item_add_clip_ignore,RID, bool ) BIND2(canvas_item_set_sort_children_by_y,RID, bool ) BIND2(canvas_item_set_z,RID, int ) @@ -1058,7 +1058,7 @@ public: BIND2(canvas_light_attach_to_canvas,RID,RID ) BIND2(canvas_light_set_enabled,RID, bool ) BIND2(canvas_light_set_scale,RID, float ) - BIND2(canvas_light_set_transform,RID, const Matrix32& ) + BIND2(canvas_light_set_transform,RID, const Transform2D& ) BIND2(canvas_light_set_texture,RID, RID ) BIND2(canvas_light_set_texture_offset,RID, const Vector2& ) BIND2(canvas_light_set_color,RID, const Color& ) @@ -1083,7 +1083,7 @@ public: BIND2(canvas_light_occluder_attach_to_canvas,RID,RID ) BIND2(canvas_light_occluder_set_enabled,RID,bool ) BIND2(canvas_light_occluder_set_polygon,RID,RID ) - BIND2(canvas_light_occluder_set_transform,RID,const Matrix32& ) + BIND2(canvas_light_occluder_set_transform,RID,const Transform2D& ) BIND2(canvas_light_occluder_set_light_mask,RID,int ) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 0f789d9695..4635b0fcfe 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -933,7 +933,7 @@ void VisualServerScene::instance_set_extra_visibility_margin( RID p_instance, re } -Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB& p_aabb, RID p_scenario) const { +Vector<ObjectID> VisualServerScene::instances_cull_aabb(const Rect3& p_aabb, RID p_scenario) const { Vector<ObjectID> instances; @@ -1143,7 +1143,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) { p_instance->mirror = p_instance->transform.basis.determinant() < 0.0; - AABB new_aabb; + Rect3 new_aabb; #if 0 if (p_instance->base_type==INSTANCE_PORTAL) { @@ -1266,7 +1266,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) { void VisualServerScene::_update_instance_aabb(Instance *p_instance) { - AABB new_aabb; + Rect3 new_aabb; ERR_FAIL_COND(p_instance->base_type!=VS::INSTANCE_NONE && !p_instance->base.is_valid()); @@ -2485,7 +2485,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { probe->dynamic.enabled=true; Transform cell_to_xform = VSG::storage->gi_probe_get_to_cell_xform(p_instance->base); - AABB bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); + Rect3 bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); float cell_size = VSG::storage->gi_probe_get_cell_size(p_instance->base); probe->dynamic.light_to_cell_xform=cell_to_xform * p_instance->transform.affine_inverse(); diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index ac272467b4..fc3ea29b00 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -210,8 +210,8 @@ public: SelfList<Instance> update_item; - AABB aabb; - AABB transformed_aabb; + Rect3 aabb; + Rect3 transformed_aabb; float extra_margin; uint32_t object_ID; @@ -504,7 +504,7 @@ public: // don't use these in a game! - virtual Vector<ObjectID> instances_cull_aabb(const AABB& p_aabb, RID p_scenario=RID()) const; + virtual Vector<ObjectID> instances_cull_aabb(const Rect3& p_aabb, RID p_scenario=RID()) const; virtual Vector<ObjectID> instances_cull_ray(const Vector3& p_from, const Vector3& p_to, RID p_scenario=RID()) const; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane>& p_convex, RID p_scenario=RID()) const; diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index 7ecf041d2a..780335a7f4 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -82,7 +82,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { for (Map<RID,Viewport::CanvasData>::Element *E=p_viewport->canvas_map.front();E;E=E->next()) { - Matrix32 xf = p_viewport->global_transform * E->get().transform; + Transform2D xf = p_viewport->global_transform * E->get().transform; VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas*>(E->get().canvas); @@ -108,7 +108,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { cl->filter_next_ptr=lights; lights=cl; cl->texture_cache=NULL; - Matrix32 scale; + Transform2D scale; scale.scale(cl->rect_cache.size); scale.elements[2]=cl->rect_cache.pos; cl->light_shader_xform = (cl->xform_cache * scale).affine_inverse(); @@ -152,7 +152,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { for (Map<RID,Viewport::CanvasData>::Element *E=p_viewport->canvas_map.front();E;E=E->next()) { VisualServerCanvas::Canvas *canvas = static_cast<VisualServerCanvas::Canvas*>(E->get().canvas); - Matrix32 xf = p_viewport->global_transform * E->get().transform; + Transform2D xf = p_viewport->global_transform * E->get().transform; for(Set<RasterizerCanvas::LightOccluderInstance*>::Element *F=canvas->occluders.front();F;F=F->next()) { @@ -198,7 +198,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport) { // print_line("canvas "+itos(i)+" size: "+itos(I->get()->canvas->child_items.size())); //print_line("GT "+p_viewport->global_transform+". CT: "+E->get()->transform); - Matrix32 xform = p_viewport->global_transform * E->get()->transform; + Transform2D xform = p_viewport->global_transform * E->get()->transform; RasterizerCanvas::Light *canvas_lights=NULL; @@ -461,7 +461,7 @@ void VisualServerViewport::viewport_remove_canvas(RID p_viewport,RID p_canvas){ canvas->viewports.erase(p_viewport); } -void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Matrix32& p_offset){ +void VisualServerViewport::viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Transform2D& p_offset){ Viewport * viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); @@ -479,7 +479,7 @@ void VisualServerViewport::viewport_set_transparent_background(RID p_viewport,bo } -void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport,const Matrix32& p_transform){ +void VisualServerViewport::viewport_set_global_canvas_transform(RID p_viewport,const Transform2D& p_transform){ Viewport * viewport = viewport_owner.getornull(p_viewport); ERR_FAIL_COND(!viewport); diff --git a/servers/visual/visual_server_viewport.h b/servers/visual/visual_server_viewport.h index 3b14ee2b1c..ff4bc2601d 100644 --- a/servers/visual/visual_server_viewport.h +++ b/servers/visual/visual_server_viewport.h @@ -56,11 +56,11 @@ public: struct CanvasData { CanvasBase *canvas; - Matrix32 transform; + Transform2D transform; int layer; }; - Matrix32 global_transform; + Transform2D global_transform; Map<RID,CanvasData> canvas_map; @@ -128,10 +128,10 @@ public: void viewport_set_scenario(RID p_viewport,RID p_scenario); void viewport_attach_canvas(RID p_viewport,RID p_canvas); void viewport_remove_canvas(RID p_viewport,RID p_canvas); - void viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Matrix32& p_offset); + void viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Transform2D& p_offset); void viewport_set_transparent_background(RID p_viewport,bool p_enabled); - void viewport_set_global_canvas_transform(RID p_viewport,const Matrix32& p_transform); + void viewport_set_global_canvas_transform(RID p_viewport,const Transform2D& p_transform); void viewport_set_canvas_layer(RID p_viewport,RID p_canvas,int p_layer); void viewport_set_shadow_atlas_size(RID p_viewport,int p_size); diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 9de17dc431..71f9c88f2a 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -345,7 +345,7 @@ RID VisualServer::get_white_texture() { } -Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,PoolVector<uint8_t> &r_vertex_array,int p_vertex_array_len,PoolVector<uint8_t> &r_index_array,int p_index_array_len,AABB &r_aabb,Vector<AABB> r_bone_aabb) { +Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,PoolVector<uint8_t> &r_vertex_array,int p_vertex_array_len,PoolVector<uint8_t> &r_index_array,int p_index_array_len,Rect3 &r_aabb,Vector<Rect3> r_bone_aabb) { PoolVector<uint8_t>::Write vw = r_vertex_array.write(); @@ -420,7 +420,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } } - r_aabb=AABB(Vector3(aabb.pos.x,aabb.pos.y,0),Vector3(aabb.size.x,aabb.size.y,0)); + r_aabb=Rect3(Vector3(aabb.pos.x,aabb.pos.y,0),Vector3(aabb.size.x,aabb.size.y,0)); } else { @@ -432,7 +432,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t const Vector3* src=read.ptr(); // setting vertices means regenerating the AABB - AABB aabb; + Rect3 aabb; if (p_format&ARRAY_COMPRESS_VERTEX) { @@ -446,7 +446,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t if (i==0) { - aabb=AABB(src[i],Vector3()); + aabb=Rect3(src[i],Vector3()); } else { aabb.expand_to( src[i] ); @@ -464,7 +464,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t if (i==0) { - aabb=AABB(src[i],Vector3()); + aabb=Rect3(src[i],Vector3()); } else { aabb.expand_to( src[i] ); @@ -480,7 +480,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } break; case VS::ARRAY_NORMAL: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<Vector3> array = p_arrays[ai]; ERR_FAIL_COND_V( array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER ); @@ -520,7 +520,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t case VS::ARRAY_TANGENT: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<real_t> array = p_arrays[ai]; @@ -564,7 +564,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } break; case VS::ARRAY_COLOR: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::COLOR_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_COLOR_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<Color> array = p_arrays[ai]; @@ -604,7 +604,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } break; case VS::ARRAY_TEX_UV: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::VECTOR2_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::POOL_VECTOR2_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<Vector2> array = p_arrays[ai]; @@ -640,7 +640,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t case VS::ARRAY_TEX_UV2: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::VECTOR2_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_VECTOR3_ARRAY && p_arrays[ai].get_type() != Variant::POOL_VECTOR2_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<Vector2> array = p_arrays[ai]; @@ -672,7 +672,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } break; case VS::ARRAY_WEIGHTS: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::REAL_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_REAL_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<real_t> array = p_arrays[ai]; @@ -712,7 +712,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t } break; case VS::ARRAY_BONES: { - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<int> array = p_arrays[ai]; @@ -762,7 +762,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t ERR_FAIL_COND_V( p_index_array_len<=0, ERR_INVALID_DATA ); - ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::INT_ARRAY, ERR_INVALID_PARAMETER ); + ERR_FAIL_COND_V( p_arrays[ai].get_type() != Variant::POOL_INT_ARRAY, ERR_INVALID_PARAMETER ); PoolVector<int> indices = p_arrays[ai]; ERR_FAIL_COND_V( indices.size() == 0, ERR_INVALID_PARAMETER ); @@ -821,7 +821,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t PoolVector<int>::Read rb=bones.read(); PoolVector<float>::Read rw=weights.read(); - AABB *bptr = r_bone_aabb.ptr(); + Rect3 *bptr = r_bone_aabb.ptr(); for(int i=0;i<vs;i++) { @@ -836,7 +836,7 @@ Error VisualServer::_surface_set_data(Array p_arrays,uint32_t p_format,uint32_t if (bptr->size.x<0) { //first - bptr[idx]=AABB(); + bptr[idx]=Rect3(); bptr[idx].pos=v; any_valid=true; } else { @@ -877,11 +877,11 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi Variant var = p_arrays[i]; switch(var.get_type()) { - case Variant::VECTOR2_ARRAY: { + case Variant::POOL_VECTOR2_ARRAY: { PoolVector<Vector2> v2 = var; array_len=v2.size(); } break; - case Variant::VECTOR3_ARRAY: { + case Variant::POOL_VECTOR3_ARRAY: { PoolVector<Vector3> v3 = var; array_len=v3.size(); } break; @@ -891,11 +891,11 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi } break; } - array_len=Vector3Array(p_arrays[i]).size(); + array_len=PoolVector3Array(p_arrays[i]).size(); ERR_FAIL_COND(array_len==0); } else if (i==VS::ARRAY_INDEX) { - index_array_len=IntArray(p_arrays[i]).size(); + index_array_len=PoolIntArray(p_arrays[i]).size(); } } @@ -939,10 +939,10 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi case VS::ARRAY_VERTEX: { Variant arr = p_arrays[0]; - if (arr.get_type()==Variant::VECTOR2_ARRAY) { + if (arr.get_type()==Variant::POOL_VECTOR2_ARRAY) { elem_size=2; p_compress_format|=ARRAY_FLAG_USE_2D_VERTICES; - } else if (arr.get_type()==Variant::VECTOR3_ARRAY) { + } else if (arr.get_type()==Variant::POOL_VECTOR3_ARRAY) { p_compress_format&=~ARRAY_FLAG_USE_2D_VERTICES; elem_size=3; } else { @@ -1078,8 +1078,8 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi PoolVector<uint8_t> index_array; index_array.resize(index_array_size); - AABB aabb; - Vector<AABB> bone_aabb; + Rect3 aabb; + Vector<Rect3> bone_aabb; Error err = _surface_set_data(p_arrays,format,offsets,total_elem_size,vertex_array,array_len,index_array,index_array_len,aabb,bone_aabb); @@ -1096,7 +1096,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primi vertex_array_shape.resize(array_size); PoolVector<uint8_t> noindex; - AABB laabb; + Rect3 laabb; Error err = _surface_set_data(p_blend_shapes[i],format&~ARRAY_FORMAT_INDEX,offsets,total_elem_size,vertex_array_shape,array_len,noindex,0,laabb,bone_aabb); aabb.merge_with(laabb); if (err) { diff --git a/servers/visual_server.h b/servers/visual_server.h index d1a20dd6ba..3e7240af6f 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -62,7 +62,7 @@ protected: RID material_2d[16]; - Error _surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,PoolVector<uint8_t> &r_vertex_array,int p_vertex_array_len,PoolVector<uint8_t> &r_index_array,int p_index_array_len,AABB &r_aabb,Vector<AABB> r_bone_aabb); + Error _surface_set_data(Array p_arrays,uint32_t p_format,uint32_t *p_offsets,uint32_t p_stride,PoolVector<uint8_t> &r_vertex_array,int p_vertex_array_len,PoolVector<uint8_t> &r_index_array,int p_index_array_len,Rect3 &r_aabb,Vector<Rect3> r_bone_aabb); static VisualServer* (*create_func)(); static void _bind_methods(); @@ -244,7 +244,7 @@ public: virtual void mesh_add_surface_from_arrays(RID p_mesh,PrimitiveType p_primitive,const Array& p_arrays,const Array& p_blend_shapes=Array(),uint32_t p_compress_format=ARRAY_COMPRESS_DEFAULT); - virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const AABB& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<AABB>& p_bone_aabbs=Vector<AABB>())=0; + virtual void mesh_add_surface(RID p_mesh,uint32_t p_format,PrimitiveType p_primitive,const PoolVector<uint8_t>& p_array,int p_vertex_count,const PoolVector<uint8_t>& p_index_array,int p_index_count,const Rect3& p_aabb,const Vector<PoolVector<uint8_t> >& p_blend_shapes=Vector<PoolVector<uint8_t> >(),const Vector<Rect3>& p_bone_aabbs=Vector<Rect3>())=0; virtual void mesh_set_morph_target_count(RID p_mesh,int p_amount)=0; virtual int mesh_get_morph_target_count(RID p_mesh) const=0; @@ -271,15 +271,15 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const=0; virtual PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const=0; - virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const=0; + virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const=0; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const=0; - virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const=0; + virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const=0; virtual void mesh_remove_surface(RID p_mesh,int p_index)=0; virtual int mesh_get_surface_count(RID p_mesh) const=0; - virtual void mesh_set_custom_aabb(RID p_mesh,const AABB& p_aabb)=0; - virtual AABB mesh_get_custom_aabb(RID p_mesh) const=0; + virtual void mesh_set_custom_aabb(RID p_mesh,const Rect3& p_aabb)=0; + virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const=0; virtual void mesh_clear(RID p_mesh)=0; @@ -304,14 +304,14 @@ public: virtual void multimesh_set_mesh(RID p_multimesh,RID p_mesh)=0; virtual void multimesh_instance_set_transform(RID p_multimesh,int p_index,const Transform& p_transform)=0; - virtual void multimesh_instance_set_transform_2d(RID p_multimesh,int p_index,const Matrix32& p_transform)=0; + virtual void multimesh_instance_set_transform_2d(RID p_multimesh,int p_index,const Transform2D& p_transform)=0; virtual void multimesh_instance_set_color(RID p_multimesh,int p_index,const Color& p_color)=0; virtual RID multimesh_get_mesh(RID p_multimesh) const=0; - virtual AABB multimesh_get_aabb(RID p_multimesh) const=0; + virtual Rect3 multimesh_get_aabb(RID p_multimesh) const=0; virtual Transform multimesh_instance_get_transform(RID p_multimesh,int p_index) const=0; - virtual Matrix32 multimesh_instance_get_transform_2d(RID p_multimesh,int p_index) const=0; + virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh,int p_index) const=0; virtual Color multimesh_instance_get_color(RID p_multimesh,int p_index) const=0; virtual void multimesh_set_visible_instances(RID p_multimesh,int p_visible)=0; @@ -341,8 +341,8 @@ public: virtual int skeleton_get_bone_count(RID p_skeleton) const=0; virtual void skeleton_bone_set_transform(RID p_skeleton,int p_bone, const Transform& p_transform)=0; virtual Transform skeleton_bone_get_transform(RID p_skeleton,int p_bone) const=0; - virtual void skeleton_bone_set_transform_2d(RID p_skeleton,int p_bone, const Matrix32& p_transform)=0; - virtual Matrix32 skeleton_bone_get_transform_2d(RID p_skeleton,int p_bone)const =0; + virtual void skeleton_bone_set_transform_2d(RID p_skeleton,int p_bone, const Transform2D& p_transform)=0; + virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton,int p_bone)const =0; /* Light API */ @@ -451,8 +451,8 @@ public: virtual RID gi_probe_create()=0; - virtual void gi_probe_set_bounds(RID p_probe,const AABB& p_bounds)=0; - virtual AABB gi_probe_get_bounds(RID p_probe) const=0; + virtual void gi_probe_set_bounds(RID p_probe,const Rect3& p_bounds)=0; + virtual Rect3 gi_probe_get_bounds(RID p_probe) const=0; virtual void gi_probe_set_cell_size(RID p_probe,float p_range)=0; virtual float gi_probe_get_cell_size(RID p_probe) const=0; @@ -485,7 +485,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles,float p_time)=0; virtual void particles_set_explosiveness_ratio(RID p_particles,float p_ratio)=0; virtual void particles_set_randomness_ratio(RID p_particles,float p_ratio)=0; - virtual void particles_set_custom_aabb(RID p_particles,const AABB& p_aabb)=0; + virtual void particles_set_custom_aabb(RID p_particles,const Rect3& p_aabb)=0; virtual void particles_set_gravity(RID p_particles,const Vector3& p_gravity)=0; virtual void particles_set_use_local_coordinates(RID p_particles,bool p_enable)=0; virtual void particles_set_process_material(RID p_particles,RID p_material)=0; @@ -521,7 +521,7 @@ public: virtual void particles_set_draw_pass_material(RID p_particles,int p_pass, RID p_material)=0; virtual void particles_set_draw_pass_mesh(RID p_particles,int p_pass, RID p_mesh)=0; - virtual AABB particles_get_current_aabb(RID p_particles)=0; + virtual Rect3 particles_get_current_aabb(RID p_particles)=0; /* CAMERA API */ @@ -584,10 +584,10 @@ public: virtual void viewport_set_scenario(RID p_viewport,RID p_scenario)=0; virtual void viewport_attach_canvas(RID p_viewport,RID p_canvas)=0; virtual void viewport_remove_canvas(RID p_viewport,RID p_canvas)=0; - virtual void viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Matrix32& p_offset)=0; + virtual void viewport_set_canvas_transform(RID p_viewport,RID p_canvas,const Transform2D& p_offset)=0; virtual void viewport_set_transparent_background(RID p_viewport,bool p_enabled)=0; - virtual void viewport_set_global_canvas_transform(RID p_viewport,const Matrix32& p_transform)=0; + virtual void viewport_set_global_canvas_transform(RID p_viewport,const Transform2D& p_transform)=0; virtual void viewport_set_canvas_layer(RID p_viewport,RID p_canvas,int p_layer)=0; virtual void viewport_set_shadow_atlas_size(RID p_viewport,int p_size)=0; @@ -725,7 +725,7 @@ public: virtual void instance_set_extra_visibility_margin( RID p_instance, real_t p_margin )=0; // don't use these in a game! - virtual Vector<ObjectID> instances_cull_aabb(const AABB& p_aabb, RID p_scenario=RID()) const=0; + virtual Vector<ObjectID> instances_cull_aabb(const Rect3& p_aabb, RID p_scenario=RID()) const=0; virtual Vector<ObjectID> instances_cull_ray(const Vector3& p_from, const Vector3& p_to, RID p_scenario=RID()) const=0; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane>& p_convex, RID p_scenario=RID()) const=0; @@ -767,7 +767,7 @@ public: virtual void canvas_item_set_visible(RID p_item,bool p_visible)=0; virtual void canvas_item_set_light_mask(RID p_item,int p_mask)=0; - virtual void canvas_item_set_transform(RID p_item, const Matrix32& p_transform)=0; + virtual void canvas_item_set_transform(RID p_item, const Transform2D& p_transform)=0; virtual void canvas_item_set_clip(RID p_item, bool p_clip)=0; virtual void canvas_item_set_distance_field_mode(RID p_item, bool p_enable)=0; virtual void canvas_item_set_custom_rect(RID p_item, bool p_custom_rect,const Rect2& p_rect=Rect2())=0; @@ -793,7 +793,7 @@ public: virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int>& p_indices, const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs=Vector<Point2>(), RID p_texture=RID(), int p_count=-1)=0; virtual void canvas_item_add_mesh(RID p_item, const RID& p_mesh,RID p_skeleton=RID())=0; virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh,RID p_skeleton=RID())=0; - virtual void canvas_item_add_set_transform(RID p_item,const Matrix32& p_transform)=0; + virtual void canvas_item_add_set_transform(RID p_item,const Transform2D& p_transform)=0; virtual void canvas_item_add_clip_ignore(RID p_item, bool p_ignore)=0; virtual void canvas_item_set_sort_children_by_y(RID p_item, bool p_enable)=0; virtual void canvas_item_set_z(RID p_item, int p_z)=0; @@ -811,7 +811,7 @@ public: virtual void canvas_light_attach_to_canvas(RID p_light,RID p_canvas)=0; virtual void canvas_light_set_enabled(RID p_light, bool p_enabled)=0; virtual void canvas_light_set_scale(RID p_light, float p_scale)=0; - virtual void canvas_light_set_transform(RID p_light, const Matrix32& p_transform)=0; + virtual void canvas_light_set_transform(RID p_light, const Transform2D& p_transform)=0; virtual void canvas_light_set_texture(RID p_light, RID p_texture)=0; virtual void canvas_light_set_texture_offset(RID p_light, const Vector2& p_offset)=0; virtual void canvas_light_set_color(RID p_light, const Color& p_color)=0; @@ -852,7 +852,7 @@ public: virtual void canvas_light_occluder_attach_to_canvas(RID p_occluder,RID p_canvas)=0; virtual void canvas_light_occluder_set_enabled(RID p_occluder,bool p_enabled)=0; virtual void canvas_light_occluder_set_polygon(RID p_occluder,RID p_polygon)=0; - virtual void canvas_light_occluder_set_transform(RID p_occluder,const Matrix32& p_xform)=0; + virtual void canvas_light_occluder_set_transform(RID p_occluder,const Transform2D& p_xform)=0; virtual void canvas_light_occluder_set_light_mask(RID p_occluder,int p_mask)=0; virtual RID canvas_occluder_polygon_create()=0; |