Browse Source

added legacy mode for Toontown, only throws events for floor that Toon is standing on

Darren Ranalli 16 years ago
parent
commit
9531a23ef1

+ 24 - 0
panda/src/collide/collisionHandlerGravity.I

@@ -200,3 +200,27 @@ INLINE float CollisionHandlerGravity::
 get_max_velocity() const {
   return _max_velocity;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: CollisionHandlerGravity::set_legacy_mode
+//       Access: Public
+//  Description: Enables old behavior required by Toontown
+//               (Sellbot Factory lava room is good test case,
+//               lava and conveyor belt specifically). Behavior
+//               is to throw enter/exit events only for floor
+//               that the toon is in contact with
+////////////////////////////////////////////////////////////////////
+INLINE void CollisionHandlerGravity::
+set_legacy_mode(bool legacy_mode) {
+  _legacy_mode = legacy_mode;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: CollisionHandlerGravity::get_legacy_mode
+//       Access: Public
+//  Description: returns true if legacy mode is enabled
+////////////////////////////////////////////////////////////////////
+INLINE bool CollisionHandlerGravity::
+get_legacy_mode() const {
+  return _legacy_mode;
+}

+ 14 - 12
panda/src/collide/collisionHandlerGravity.cxx

@@ -100,11 +100,13 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod
     cout<<endl;
   #endif
 
-  // We only collide with things we are impacting with.
-  // Remove the collisions:
-  //_current_colliding.clear();
-  // Add only the one that we're impacting with:
-  // add_entry(highest);
+  if (_legacy_mode) {
+    // We only collide with things we are impacting with.
+    // Remove the collisions:
+    _current_colliding.clear();
+    // Add only the one that we're impacting with:
+    add_entry(highest);
+  }
   
   return max_height;
 }
@@ -177,8 +179,12 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod
   // We only collide with things we are impacting with.
   // Remove the collisions:
   _current_colliding.clear();
-  // Add only the one that we're impacting with:
-  _current_colliding.insert(valid_entries.begin(), valid_entries.end());
+  if (_legacy_mode) {
+    // Add only the one that we're impacting with:
+    add_entry(highest);
+  } else {
+    _current_colliding.insert(valid_entries.begin(), valid_entries.end());
+  }
 
   
   // Set the contact normal so that other code can make use of the
@@ -275,14 +281,10 @@ handle_entries() {
           _impact_velocity = _current_velocity;
           // These values are used by is_on_ground().
           _current_velocity = _airborne_height = 0.0f;
-        }
-/*      //ZAC - Commented out, until someone can give me a good reason why we
-        //need such wierd behaviour
-        } else {
+        } else if (_legacy_mode) {
           // ...we're airborne.
           _current_colliding.clear();
         }
-*/
 
         CPT(TransformState) trans = def._target.get_transform();
         LVecBase3f pos = trans->get_pos();

+ 4 - 0
panda/src/collide/collisionHandlerGravity.h

@@ -54,6 +54,9 @@ PUBLISHED:
   INLINE void set_max_velocity(float max_vel);
   INLINE float get_max_velocity() const;
 
+  INLINE void set_legacy_mode(bool legacy_mode);
+  INLINE bool get_legacy_mode() const;
+
 protected:
   float set_highest_collision(const NodePath &target_node_path, const NodePath &from_node_path, const Entries &entries);
   virtual bool handle_entries();
@@ -68,6 +71,7 @@ private:
   float _current_velocity;
   float _max_velocity;
   LVector3f _contact_normal;
+  bool _legacy_mode;
 
 
 public: