diff --git a/panda/src/physx/physxActor.cxx b/panda/src/physx/physxActor.cxx index 816f3a80fc..4c7ad866e2 100644 --- a/panda/src/physx/physxActor.cxx +++ b/panda/src/physx/physxActor.cxx @@ -257,7 +257,7 @@ set_global_pos(const LPoint3f &pos) { // and would like to have it correctly interact with // dynamic bodies and joints, you should create a // dynamic body with the BF_kinematic flag, and then -// use the move_lobal_*() commands to move it along +// use the move_global_*() commands to move it along // a path! // // When briefly moving dynamic actors, one should not: @@ -297,6 +297,80 @@ set_global_hpr(float h, float p, float r) { _ptr->setGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q)); } +//////////////////////////////////////////////////////////////////// +// Function: PhysxActor::move_global_pos +// Access: Published +// Description: The move_global_* calls serve to move kinematically +// controlled dynamic actors through the game world. +// +// See move_global_mat() for more information. +// +// This call wakes the actor if it is sleeping. +//////////////////////////////////////////////////////////////////// +void PhysxActor:: +move_global_pos(const LPoint3f &pos) { + + nassertv(_error_type == ET_ok); + nassertv_always(!pos.is_nan()); + + _ptr->moveGlobalPosition(PhysxManager::point3_to_nxVec3(pos)); +} + +//////////////////////////////////////////////////////////////////// +// Function: PhysxActor::move_global_mat +// Access: Published +// Description: The move_global_* calls serve to move +// kinematically controlled dynamic actors through +// the game world. +// +// You set a dynamic actor to be kinematic using the +// BF_KINEMATIC body flag, used either in the +// PhysBodyDesc or with set_body_flag(). +// +// The move command will result in a velocity that, +// when successfully carried out (i.e. the motion is +// not blocked due to joints or collisions) inside +// run*(), will move the body into the desired pose. +// After the move is carried out during a single time +// step, the velocity is returned to zero. Thus, you +// must continuously call this in every time step for +// kinematic actors so that they move along a path. +// +// These functions simply store the move destination +// until run*() is called, so consecutive calls will +// simply overwrite the stored target variable. +// +// This call wakes the actor if it is sleeping. +//////////////////////////////////////////////////////////////////// +void PhysxActor:: +move_global_mat(const LMatrix4f &mat) { + + nassertv(_error_type == ET_ok); + nassertv_always(!mat.is_nan()); + + _ptr->moveGlobalPose(PhysxManager::mat4_to_nxMat34(mat)); +} + +//////////////////////////////////////////////////////////////////// +// Function: PhysxActor::move_global_hpr +// Access: Published +// Description: The move_global_* calls serve to move kinematically +// controlled dynamic actors through the game world. +// +// See move_global_mat() for more information. +// +// This call wakes the actor if it is sleeping. +//////////////////////////////////////////////////////////////////// +void PhysxActor:: +move_global_hpr(float h, float p, float r) { + + nassertv(_error_type == ET_ok); + + LQuaternionf q; + q.set_hpr(LVector3f(h, p, r)); + _ptr->moveGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q)); +} + //////////////////////////////////////////////////////////////////// // Function: PhysxActor::attach_node_path // Access: Published diff --git a/panda/src/physx/physxActor.h b/panda/src/physx/physxActor.h index db1058fa48..e40048bd37 100644 --- a/panda/src/physx/physxActor.h +++ b/panda/src/physx/physxActor.h @@ -144,7 +144,7 @@ PUBLISHED: float get_linear_damping() const; float get_angular_damping() const; - // Vecocity + // Velocity void set_linear_velocity(const LVector3f &linVel); void set_angular_velocity(const LVector3f &angVel); void set_max_angular_velocity(float maxAngVel); @@ -174,6 +174,11 @@ PUBLISHED: void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL); void put_to_sleep(); + // Kinematic + void move_global_pos(const LPoint3f &pos); + void move_global_mat(const LMatrix4f &mat); + void move_global_hpr(float h, float p, float r); + INLINE void ls() const; INLINE void ls(ostream &out, int indent_level=0) const;