Merge pull request #47484 from rafallus/fix/rigidbody-crash3.x
Fix crash on RigidBody _direct_state_changed (3.x)
This commit is contained in:
commit
e572be0c5f
3 changed files with 6 additions and 19 deletions
|
@ -440,12 +440,8 @@ bool RigidBody2D::_test_motion(const Vector2 &p_motion, bool p_infinite_inertia,
|
|||
}
|
||||
|
||||
void RigidBody2D::_direct_state_changed(Object *p_state) {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
state = Object::cast_to<Physics2DDirectBodyState>(p_state);
|
||||
#else
|
||||
state = (Physics2DDirectBodyState *)p_state; //trust it
|
||||
#endif
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid Physics2DDirectBodyState object as argument");
|
||||
|
||||
set_block_transform_notify(true); // don't want notify (would feedback loop)
|
||||
if (mode != MODE_KINEMATIC)
|
||||
|
@ -1437,11 +1433,11 @@ bool KinematicBody2D::is_sync_to_physics_enabled() const {
|
|||
}
|
||||
|
||||
void KinematicBody2D::_direct_state_changed(Object *p_state) {
|
||||
|
||||
if (!sync_to_physics)
|
||||
return;
|
||||
|
||||
Physics2DDirectBodyState *state = Object::cast_to<Physics2DDirectBodyState>(p_state);
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid Physics2DDirectBodyState object as argument");
|
||||
|
||||
last_valid_transform = state->get_transform();
|
||||
set_notify_local_transform(false);
|
||||
|
|
|
@ -442,12 +442,8 @@ struct _RigidBodyInOut {
|
|||
};
|
||||
|
||||
void RigidBody::_direct_state_changed(Object *p_state) {
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
#else
|
||||
state = (PhysicsDirectBodyState *)p_state; //trust it
|
||||
#endif
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState object as argument");
|
||||
|
||||
set_ignore_transform_notification(true);
|
||||
set_global_transform(state->get_transform());
|
||||
|
@ -2220,13 +2216,8 @@ void PhysicalBone::_direct_state_changed(Object *p_state) {
|
|||
|
||||
/// Update bone transform
|
||||
|
||||
PhysicsDirectBodyState *state;
|
||||
|
||||
#ifdef DEBUG_ENABLED
|
||||
state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
#else
|
||||
state = (PhysicsDirectBodyState *)p_state; //trust it
|
||||
#endif
|
||||
PhysicsDirectBodyState *state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState object as argument");
|
||||
|
||||
Transform global_transform(state->get_transform());
|
||||
|
||||
|
|
|
@ -857,10 +857,10 @@ void VehicleBody::_update_friction(PhysicsDirectBodyState *s) {
|
|||
}
|
||||
|
||||
void VehicleBody::_direct_state_changed(Object *p_state) {
|
||||
|
||||
RigidBody::_direct_state_changed(p_state);
|
||||
|
||||
state = Object::cast_to<PhysicsDirectBodyState>(p_state);
|
||||
ERR_FAIL_COND_MSG(!state, "Method '_direct_state_changed' must receive a valid PhysicsDirectBodyState object as argument");
|
||||
|
||||
float step = state->get_step();
|
||||
|
||||
|
|
Loading…
Reference in a new issue