mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
is in outer space
This commit is contained in:
parent
5a713cbba9
commit
5da93cd1d8
@ -49,6 +49,8 @@ get_offset() const {
|
|||||||
// The object might not necessarily be at rest. Use
|
// The object might not necessarily be at rest. Use
|
||||||
// is_on_ground() if you want to know whether the
|
// is_on_ground() if you want to know whether the
|
||||||
// object is on the ground and at rest.
|
// object is on the ground and at rest.
|
||||||
|
//
|
||||||
|
// See Also: is_in_outer_space()
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE float CollisionHandlerGravity::
|
INLINE float CollisionHandlerGravity::
|
||||||
get_airborne_height() const {
|
get_airborne_height() const {
|
||||||
@ -68,6 +70,18 @@ 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,6 +38,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -63,6 +64,7 @@ CollisionHandlerGravity::
|
|||||||
bool CollisionHandlerGravity::
|
bool CollisionHandlerGravity::
|
||||||
handle_entries() {
|
handle_entries() {
|
||||||
bool okflag = true;
|
bool okflag = true;
|
||||||
|
_outer_space = true;
|
||||||
|
|
||||||
FromEntries::const_iterator fi;
|
FromEntries::const_iterator fi;
|
||||||
for (fi = _from_entries.begin(); fi != _from_entries.end(); ++fi) {
|
for (fi = _from_entries.begin(); fi != _from_entries.end(); ++fi) {
|
||||||
@ -87,6 +89,9 @@ handle_entries() {
|
|||||||
float max_height = 0.0f;
|
float max_height = 0.0f;
|
||||||
|
|
||||||
Entries::const_iterator ei;
|
Entries::const_iterator ei;
|
||||||
|
if (ei != entries.end()) {
|
||||||
|
_outer_space = false;
|
||||||
|
}
|
||||||
for (ei = entries.begin(); ei != entries.end(); ++ei) {
|
for (ei = entries.begin(); ei != entries.end(); ++ei) {
|
||||||
CollisionEntry *entry = (*ei);
|
CollisionEntry *entry = (*ei);
|
||||||
nassertr(entry != (CollisionEntry *)NULL, false);
|
nassertr(entry != (CollisionEntry *)NULL, false);
|
||||||
|
@ -42,6 +42,7 @@ 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);
|
||||||
@ -65,6 +66,7 @@ private:
|
|||||||
float _gravity;
|
float _gravity;
|
||||||
float _current_velocity;
|
float _current_velocity;
|
||||||
float _max_velocity;
|
float _max_velocity;
|
||||||
|
bool _outer_space;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user