Prechádzať zdrojové kódy

restored horizontal collision mode, still being used

Darren Ranalli 16 rokov pred
rodič
commit
509e414ef4

+ 19 - 0
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;
+}

+ 5 - 1
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;

+ 5 - 0
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() {