mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
Improve behaviour of get_deactivation_enabled/is_deactivation_enabled
This commit is contained in:
parent
d7552f0d8a
commit
76e135b835
@ -155,6 +155,8 @@ output(ostream &out) const {
|
|||||||
|
|
||||||
out << " (" << get_num_shapes() << " shapes)";
|
out << " (" << get_num_shapes() << " shapes)";
|
||||||
|
|
||||||
|
out << (is_active() ? " active" : " inactive");
|
||||||
|
|
||||||
if (is_static()) out << " static";
|
if (is_static()) out << " static";
|
||||||
if (is_kinematic()) out << " kinematic";
|
if (is_kinematic()) out << " kinematic";
|
||||||
}
|
}
|
||||||
@ -448,19 +450,22 @@ set_active(bool active, bool force) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: BulletBodyNode::set_deactivation_enabled
|
// Function: BulletBodyNode::set_deactivation_enabled
|
||||||
// Access: Published
|
// Access: Published
|
||||||
// Description:
|
// Description: If true, this object will be deactivated after a
|
||||||
|
// certain amount of time has passed without movement.
|
||||||
|
// If false, the object will always remain active.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void BulletBodyNode::
|
void BulletBodyNode::
|
||||||
set_deactivation_enabled(const bool enabled, const bool force) {
|
set_deactivation_enabled(bool enabled) {
|
||||||
|
|
||||||
int state = (enabled) ? WANTS_DEACTIVATION : DISABLE_DEACTIVATION;
|
// Don't change the state if it's currently active and we enable
|
||||||
|
// deactivation.
|
||||||
|
if (enabled != is_deactivation_enabled()) {
|
||||||
|
|
||||||
if (force) {
|
// It's OK to set to ACTIVE_TAG even if we don't mean to activate it; it
|
||||||
|
// will be disabled right away if the deactivation timer has run out.
|
||||||
|
int state = (enabled) ? ACTIVE_TAG : DISABLE_DEACTIVATION;
|
||||||
get_object()->forceActivationState(state);
|
get_object()->forceActivationState(state);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
get_object()->setActivationState(state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -471,7 +476,7 @@ set_deactivation_enabled(const bool enabled, const bool force) {
|
|||||||
bool BulletBodyNode::
|
bool BulletBodyNode::
|
||||||
is_deactivation_enabled() const {
|
is_deactivation_enabled() const {
|
||||||
|
|
||||||
return (get_object()->getActivationState() & DISABLE_DEACTIVATION) == 0;
|
return (get_object()->getActivationState() != DISABLE_DEACTIVATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -82,7 +82,7 @@ PUBLISHED:
|
|||||||
void set_deactivation_time(PN_stdfloat dt);
|
void set_deactivation_time(PN_stdfloat dt);
|
||||||
PN_stdfloat get_deactivation_time() const;
|
PN_stdfloat get_deactivation_time() const;
|
||||||
|
|
||||||
void set_deactivation_enabled(const bool enabled, const bool force=false);
|
void set_deactivation_enabled(bool enabled);
|
||||||
bool is_deactivation_enabled() const;
|
bool is_deactivation_enabled() const;
|
||||||
|
|
||||||
// Debug Visualistion
|
// Debug Visualistion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user