diff --git a/panda/src/collide/collisionHandlerPusher.I b/panda/src/collide/collisionHandlerPusher.I index 31d240689e..fb0ab1cfc2 100644 --- a/panda/src/collide/collisionHandlerPusher.I +++ b/panda/src/collide/collisionHandlerPusher.I @@ -13,3 +13,22 @@ //////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////// +// Function: CollisionHandlerPusher::set_horizontal +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE void CollisionHandlerPusher:: +set_horizontal(bool flag) { + _horizontal = flag; +} + +//////////////////////////////////////////////////////////////////// +// Function: CollisionHandlerPusher::get_horizontal +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE bool CollisionHandlerPusher:: +get_horizontal() const { + return _horizontal; +} diff --git a/panda/src/collide/collisionHandlerPusher.cxx b/panda/src/collide/collisionHandlerPusher.cxx index f35bbacef5..1e5489673f 100644 --- a/panda/src/collide/collisionHandlerPusher.cxx +++ b/panda/src/collide/collisionHandlerPusher.cxx @@ -43,6 +43,7 @@ public: //////////////////////////////////////////////////////////////////// CollisionHandlerPusher:: CollisionHandlerPusher() { + _horizontal = true; } //////////////////////////////////////////////////////////////////// @@ -119,9 +120,12 @@ handle_entries() { } else { // Shove it just enough to clear the volume. if (!surface_point.almost_equal(interior_point)) { + if (_horizontal) { + normal[2] = 0.0f; + } // Just to be on the safe size, we normalize the normal // vector, even though it really ought to be unit-length - // already. + // already (unless we just forced it horizontal, above). normal.normalize(); ShoveData sd; diff --git a/panda/src/collide/collisionHandlerPusher.h b/panda/src/collide/collisionHandlerPusher.h index a2c45fb17a..990793008f 100644 --- a/panda/src/collide/collisionHandlerPusher.h +++ b/panda/src/collide/collisionHandlerPusher.h @@ -31,6 +31,9 @@ PUBLISHED: CollisionHandlerPusher(); virtual ~CollisionHandlerPusher(); + INLINE void set_horizontal(bool flag); + INLINE bool get_horizontal() const; + protected: virtual bool handle_entries(); virtual void apply_net_shove( @@ -38,6 +41,8 @@ protected: const LVector3f &force_normal); virtual void apply_linear_force(ColliderDef &def, const LVector3f &force); + bool _horizontal; + public: static TypeHandle get_class_type() {