is in outer space

This commit is contained in:
Dave Schuyler 2003-12-11 00:55:46 +00:00
parent 5a713cbba9
commit 5da93cd1d8
3 changed files with 21 additions and 0 deletions

View File

@ -49,6 +49,8 @@ get_offset() const {
// The object might not necessarily be at rest. Use
// is_on_ground() if you want to know whether the
// object is on the ground and at rest.
//
// See Also: is_in_outer_space()
////////////////////////////////////////////////////////////////////
INLINE float CollisionHandlerGravity::
get_airborne_height() const {
@ -68,6 +70,18 @@ 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,6 +38,7 @@ CollisionHandlerGravity() {
_gravity = 32.174f;
_current_velocity = 0.0f;
_max_velocity = 400.0f;
_outer_space = false;
}
////////////////////////////////////////////////////////////////////
@ -63,6 +64,7 @@ CollisionHandlerGravity::
bool CollisionHandlerGravity::
handle_entries() {
bool okflag = true;
_outer_space = true;
FromEntries::const_iterator fi;
for (fi = _from_entries.begin(); fi != _from_entries.end(); ++fi) {
@ -87,6 +89,9 @@ handle_entries() {
float max_height = 0.0f;
Entries::const_iterator ei;
if (ei != entries.end()) {
_outer_space = false;
}
for (ei = entries.begin(); ei != entries.end(); ++ei) {
CollisionEntry *entry = (*ei);
nassertr(entry != (CollisionEntry *)NULL, false);

View File

@ -42,6 +42,7 @@ 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);
@ -65,6 +66,7 @@ private:
float _gravity;
float _current_velocity;
float _max_velocity;
bool _outer_space;
public: