From 294cc53817261accab14e8ac7b7fa9fafc313d6a Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Thu, 9 Mar 2006 22:52:16 +0000 Subject: [PATCH] add torque --- panda/src/physics/physicsObject.I | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/panda/src/physics/physicsObject.I b/panda/src/physics/physicsObject.I index 9087b122f2..c76fe17829 100644 --- a/panda/src/physics/physicsObject.I +++ b/panda/src/physics/physicsObject.I @@ -29,7 +29,8 @@ set_mass(float m) { //////////////////////////////////////////////////////////////////// // Function : set_position // Access : Public -// Description : Vector position assignment +// Description : Vector position assignment. This is also used as +// the center of mass. //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: set_position(const LPoint3f &pos) { @@ -108,6 +109,20 @@ set_velocity(float x, float y, float z) { _velocity.set(x, y, z); } +//////////////////////////////////////////////////////////////////// +// Function : add_torque +// Access : Public +// Description : Adds an torque force (i.e. an instantanious change +// in velocity). This is a quicker way to get the +// angular velocity, add a vector to it and set that +// value to be the new angular velocity. +//////////////////////////////////////////////////////////////////// +INLINE void PhysicsObject:: +add_torque(const LRotationf &torque) { + nassertv(!torque.is_nan()); + _rotation+=torque; +} + //////////////////////////////////////////////////////////////////// // Function : add_impulse // Access : Public @@ -118,6 +133,7 @@ set_velocity(float x, float y, float z) { //////////////////////////////////////////////////////////////////// INLINE void PhysicsObject:: add_impulse(const LVector3f &impulse) { + nassertv(!impulse.is_nan()); _velocity+=impulse; }