From 1e11242da3ba025aa33c1dd454d295957ed545ad Mon Sep 17 00:00:00 2001 From: Dave Schuyler Date: Wed, 11 Feb 2004 03:48:26 +0000 Subject: [PATCH] replacing is_in_outer_space with has_contact --- panda/src/collide/collisionHandlerGravity.I | 12 ------------ panda/src/collide/collisionHandlerGravity.cxx | 3 +-- panda/src/collide/collisionHandlerGravity.h | 2 -- panda/src/collide/collisionHandlerPhysical.I | 14 ++++++++++++++ panda/src/collide/collisionHandlerPhysical.cxx | 3 +++ panda/src/collide/collisionHandlerPhysical.h | 5 +++++ 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/panda/src/collide/collisionHandlerGravity.I b/panda/src/collide/collisionHandlerGravity.I index 1279e98116..d77f3c30ce 100755 --- a/panda/src/collide/collisionHandlerGravity.I +++ b/panda/src/collide/collisionHandlerGravity.I @@ -70,18 +70,6 @@ is_on_ground() const { return get_airborne_height() == 0.0f && _current_velocity == 0.0f; } -//////////////////////////////////////////////////////////////////// -// Function: CollisionHandlerGravity::is_in_outer_space -// Access: Public -// Description: The object is in outer space if there is no -// ground/floor anywhere below it (I guess you could -// also say the height is infinite). -//////////////////////////////////////////////////////////////////// -INLINE bool CollisionHandlerGravity:: -is_in_outer_space() const { - return _outer_space; -} - //////////////////////////////////////////////////////////////////// // Function: CollisionHandlerGravity::get_impact_velocity // Access: Public diff --git a/panda/src/collide/collisionHandlerGravity.cxx b/panda/src/collide/collisionHandlerGravity.cxx index a99c5fa9fd..e3c3d6ef1d 100755 --- a/panda/src/collide/collisionHandlerGravity.cxx +++ b/panda/src/collide/collisionHandlerGravity.cxx @@ -38,7 +38,6 @@ CollisionHandlerGravity() { _gravity = 32.174f; _current_velocity = 0.0f; _max_velocity = 400.0f; - _outer_space = false; } //////////////////////////////////////////////////////////////////// @@ -68,7 +67,6 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod float max_height = 0.0f; CollisionEntry *highest = NULL; - _outer_space = entries.empty(); Entries::const_iterator ei; for (ei = entries.begin(); ei != entries.end(); ++ei) { CollisionEntry *entry = (*ei); @@ -90,6 +88,7 @@ set_highest_collision(const NodePath &target_node_path, const NodePath &from_nod } } } + //#*#_has_contact = got_max; #if 0 cout<<"\ncolliding with:\n"; diff --git a/panda/src/collide/collisionHandlerGravity.h b/panda/src/collide/collisionHandlerGravity.h index 9450abd779..aaff44a848 100755 --- a/panda/src/collide/collisionHandlerGravity.h +++ b/panda/src/collide/collisionHandlerGravity.h @@ -42,7 +42,6 @@ PUBLISHED: INLINE float get_airborne_height() const; INLINE bool is_on_ground() const; - INLINE bool is_in_outer_space() const; INLINE float get_impact_velocity() const; INLINE void add_velocity(float velocity); @@ -67,7 +66,6 @@ private: float _gravity; float _current_velocity; float _max_velocity; - bool _outer_space; public: diff --git a/panda/src/collide/collisionHandlerPhysical.I b/panda/src/collide/collisionHandlerPhysical.I index 46983803cc..89e6d2ce1d 100644 --- a/panda/src/collide/collisionHandlerPhysical.I +++ b/panda/src/collide/collisionHandlerPhysical.I @@ -63,6 +63,20 @@ has_center() const { return !_center.is_empty(); } +//////////////////////////////////////////////////////////////////// +// Function: CollisionHandlerPhysical::has_contact +// Access: Public +// Description: Did the handler make any contacts with anything +// on the last collision pass? Depending on how your +// world is setup, this can be used to tell if the +// handler is out of the world (i.e. out of bounds). +// That is the original use of this call. +//////////////////////////////////////////////////////////////////// +INLINE bool CollisionHandlerPhysical:: +has_contact() const { + return _has_contact; +} + //////////////////////////////////////////////////////////////////// // Function: CollisionHandlerPhysical::ColliderDef::set_target // Access: Public diff --git a/panda/src/collide/collisionHandlerPhysical.cxx b/panda/src/collide/collisionHandlerPhysical.cxx index 5aa148937c..361ff21ef1 100644 --- a/panda/src/collide/collisionHandlerPhysical.cxx +++ b/panda/src/collide/collisionHandlerPhysical.cxx @@ -31,6 +31,7 @@ TypeHandle CollisionHandlerPhysical::_type_handle; //////////////////////////////////////////////////////////////////// CollisionHandlerPhysical:: CollisionHandlerPhysical() { + _has_contact = false; } //////////////////////////////////////////////////////////////////// @@ -54,6 +55,7 @@ void CollisionHandlerPhysical:: begin_group() { CollisionHandlerEvent::begin_group(); _from_entries.clear(); + _has_contact = false; } //////////////////////////////////////////////////////////////////// @@ -85,6 +87,7 @@ add_entry(CollisionEntry *entry) { } _from_entries[entry->get_from_node_path()].push_back(entry); + _has_contact = true; } } diff --git a/panda/src/collide/collisionHandlerPhysical.h b/panda/src/collide/collisionHandlerPhysical.h index 0513497af7..7da6466b10 100644 --- a/panda/src/collide/collisionHandlerPhysical.h +++ b/panda/src/collide/collisionHandlerPhysical.h @@ -56,6 +56,11 @@ PUBLISHED: INLINE void clear_center(); INLINE const NodePath &get_center() const; INLINE bool has_center() const; + INLINE bool has_contact() const; + +protected: + bool _has_contact; // Are we in contact with anything? + protected: class ColliderDef {