replacing is_in_outer_space with has_contact

This commit is contained in:
Dave Schuyler 2004-02-11 03:48:26 +00:00
parent 1f92189aa4
commit 1e11242da3
6 changed files with 23 additions and 16 deletions

View File

@ -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

View File

@ -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";

View File

@ -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:

View File

@ -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

View File

@ -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;
}
}

View File

@ -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 {