mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
replacing is_in_outer_space with has_contact
This commit is contained in:
parent
1f92189aa4
commit
1e11242da3
@ -70,18 +70,6 @@ is_on_ground() const {
|
|||||||
return get_airborne_height() == 0.0f && _current_velocity == 0.0f;
|
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
|
// Function: CollisionHandlerGravity::get_impact_velocity
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -38,7 +38,6 @@ CollisionHandlerGravity() {
|
|||||||
_gravity = 32.174f;
|
_gravity = 32.174f;
|
||||||
_current_velocity = 0.0f;
|
_current_velocity = 0.0f;
|
||||||
_max_velocity = 400.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;
|
float max_height = 0.0f;
|
||||||
CollisionEntry *highest = NULL;
|
CollisionEntry *highest = NULL;
|
||||||
|
|
||||||
_outer_space = entries.empty();
|
|
||||||
Entries::const_iterator ei;
|
Entries::const_iterator ei;
|
||||||
for (ei = entries.begin(); ei != entries.end(); ++ei) {
|
for (ei = entries.begin(); ei != entries.end(); ++ei) {
|
||||||
CollisionEntry *entry = (*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
|
#if 0
|
||||||
cout<<"\ncolliding with:\n";
|
cout<<"\ncolliding with:\n";
|
||||||
|
@ -42,7 +42,6 @@ PUBLISHED:
|
|||||||
|
|
||||||
INLINE float get_airborne_height() const;
|
INLINE float get_airborne_height() const;
|
||||||
INLINE bool is_on_ground() const;
|
INLINE bool is_on_ground() const;
|
||||||
INLINE bool is_in_outer_space() const;
|
|
||||||
INLINE float get_impact_velocity() const;
|
INLINE float get_impact_velocity() const;
|
||||||
|
|
||||||
INLINE void add_velocity(float velocity);
|
INLINE void add_velocity(float velocity);
|
||||||
@ -67,7 +66,6 @@ private:
|
|||||||
float _gravity;
|
float _gravity;
|
||||||
float _current_velocity;
|
float _current_velocity;
|
||||||
float _max_velocity;
|
float _max_velocity;
|
||||||
bool _outer_space;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -63,6 +63,20 @@ has_center() const {
|
|||||||
return !_center.is_empty();
|
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
|
// Function: CollisionHandlerPhysical::ColliderDef::set_target
|
||||||
// Access: Public
|
// Access: Public
|
||||||
|
@ -31,6 +31,7 @@ TypeHandle CollisionHandlerPhysical::_type_handle;
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
CollisionHandlerPhysical::
|
CollisionHandlerPhysical::
|
||||||
CollisionHandlerPhysical() {
|
CollisionHandlerPhysical() {
|
||||||
|
_has_contact = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -54,6 +55,7 @@ void CollisionHandlerPhysical::
|
|||||||
begin_group() {
|
begin_group() {
|
||||||
CollisionHandlerEvent::begin_group();
|
CollisionHandlerEvent::begin_group();
|
||||||
_from_entries.clear();
|
_from_entries.clear();
|
||||||
|
_has_contact = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -85,6 +87,7 @@ add_entry(CollisionEntry *entry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_from_entries[entry->get_from_node_path()].push_back(entry);
|
_from_entries[entry->get_from_node_path()].push_back(entry);
|
||||||
|
_has_contact = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,11 @@ PUBLISHED:
|
|||||||
INLINE void clear_center();
|
INLINE void clear_center();
|
||||||
INLINE const NodePath &get_center() const;
|
INLINE const NodePath &get_center() const;
|
||||||
INLINE bool has_center() const;
|
INLINE bool has_center() const;
|
||||||
|
INLINE bool has_contact() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool _has_contact; // Are we in contact with anything?
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class ColliderDef {
|
class ColliderDef {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user