diff --git a/panda/src/physics/linearIntegrator.cxx b/panda/src/physics/linearIntegrator.cxx index 58912e85d7..6eb842504e 100644 --- a/panda/src/physics/linearIntegrator.cxx +++ b/panda/src/physics/linearIntegrator.cxx @@ -1,4 +1,4 @@ -// Filename: LinearIntegrator.cxx +// Filename: LinearIntegrator.C // Created by: charles (02Aug00) // //////////////////////////////////////////////////////////////////// @@ -37,9 +37,27 @@ LinearIntegrator:: void LinearIntegrator:: integrate(Physical *physical, vector< PT(LinearForce) > &forces, float dt) { +/*// darren, 2000.10.06 // cap dt so physics don't go flying off on lags if (dt > _max_linear_dt) dt = _max_linear_dt; +*/ + + vector< PT(PhysicsObject) >::const_iterator current_object_iter; + current_object_iter = physical->get_object_vector().begin(); + for (; current_object_iter != physical->get_object_vector().end(); + current_object_iter++) { + PhysicsObject *current_object = *current_object_iter; + + // bail out if this object doesn't exist or doesn't want to be + // processed. + if (current_object == (PhysicsObject *) NULL) + continue; + + // set the object's last position to its current position before we move it + current_object->set_last_position(current_object->get_position()); + + } child_integrate(physical, forces, dt); } diff --git a/panda/src/physics/physicsObject.I b/panda/src/physics/physicsObject.I index 99580612a1..a449eff245 100644 --- a/panda/src/physics/physicsObject.I +++ b/panda/src/physics/physicsObject.I @@ -33,6 +33,29 @@ set_position(float x, float y, float z) { _position.set(x, y, z); } +//////////////////////////////////////////////////////////////////// +// Function : set_position_HandOfGod +// Access : Public +// Description : use this to place an object in a completely new +// position, that has nothing to do with its last +// position (moved by the Hand Of God, or "HOG") +//////////////////////////////////////////////////////////////////// +INLINE void PhysicsObject:: +set_position_HandOfGod(const LPoint3f &pos) { + _position = pos; + _last_position = pos; +} + +//////////////////////////////////////////////////////////////////// +// Function : set_last_position +// Access : Public +// Description : Last position assignment +//////////////////////////////////////////////////////////////////// +INLINE void PhysicsObject:: +set_last_position(const LPoint3f& pos) { + _last_position = pos; +} + //////////////////////////////////////////////////////////////////// // Function : set_velocity // Access : Public @@ -93,6 +116,16 @@ get_position(void) const { return _position; } +//////////////////////////////////////////////////////////////////// +// Function : get_last_position +// Access : Public +// Description : Last position Query +//////////////////////////////////////////////////////////////////// +INLINE LPoint3f PhysicsObject:: +get_last_position(void) const { + return _last_position; +} + //////////////////////////////////////////////////////////////////// // Function : get_velocity // Access : Public diff --git a/panda/src/physics/physicsObject.cxx b/panda/src/physics/physicsObject.cxx index d2c74003de..b2f3efb130 100644 --- a/panda/src/physics/physicsObject.cxx +++ b/panda/src/physics/physicsObject.cxx @@ -1,4 +1,4 @@ -// Filename: physics_object.cxx +// Filename: physics_object.C // Created by: charles (13Jun00) // //////////////////////////////////////////////////////////////////// @@ -17,6 +17,7 @@ PhysicsObject(void) : _process_me(false), _mass(1.0f), _oriented(true), _terminal_velocity(_default_terminal_velocity) { _position.set(0, 0, 0); + _last_position = _position; _velocity.set(0, 0, 0); _orientation.set(1, 0, 0, 0); _rotation.set(0, 0, 0); @@ -51,6 +52,7 @@ operator =(const PhysicsObject &other) { _process_me = other._process_me; _mass = other._mass; _position = other._position; + _last_position = other._last_position; _velocity = other._velocity; _orientation = other._orientation; _rotation = other._rotation; diff --git a/panda/src/physics/physicsObject.h b/panda/src/physics/physicsObject.h index 457f83a272..3e22845d88 100644 --- a/panda/src/physics/physicsObject.h +++ b/panda/src/physics/physicsObject.h @@ -6,7 +6,7 @@ #ifndef PHYSICS_OBJECT_H #define PHYSICS_OBJECT_H -#include +#include #include #include @@ -20,6 +20,7 @@ class EXPCL_PANDAPHYSICS PhysicsObject : public TypedReferenceCount { private: // physical LPoint3f _position; + LPoint3f _last_position; LVector3f _velocity; // angular @@ -47,6 +48,11 @@ public: INLINE void set_position(float x, float y, float z); INLINE LPoint3f get_position(void) const; + INLINE void set_position_HandOfGod(const LPoint3f &pos); + + INLINE void set_last_position(const LPoint3f &pos); + INLINE LPoint3f get_last_position(void) const; + INLINE void set_velocity(const LVector3f &vel); INLINE void set_velocity(float x, float y, float z); INLINE LVector3f get_velocity(void) const;