diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-04-26 16:20:00 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-04-26 16:20:00 -0300 |
commit | 3bcb930e8ac1c8048de990f41c29cd2dfcc3c2a2 (patch) | |
tree | edf0979625a5dfee10b6110083f036c727a7e89d /servers/physics | |
parent | 65c96a71bd5593a7a6b0aaaf80ae68fceca849b9 (diff) |
properly wake up bodies when a parameter changes, fixes #1740
Diffstat (limited to 'servers/physics')
-rw-r--r-- | servers/physics/body_sw.cpp | 3 | ||||
-rw-r--r-- | servers/physics/body_sw.h | 6 | ||||
-rw-r--r-- | servers/physics/physics_server_sw.cpp | 9 |
3 files changed, 18 insertions, 0 deletions
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index 05b3fa727e..43c20d211f 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -261,6 +261,7 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant& p_varian _set_inv_transform(get_transform().inverse()); } + wakeup(); } break; case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: { @@ -268,11 +269,13 @@ void BodySW::set_state(PhysicsServer::BodyState p_state, const Variant& p_varian //if (mode==PhysicsServer::BODY_MODE_STATIC) // break; linear_velocity=p_variant; + wakeup(); } break; case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: { //if (mode!=PhysicsServer::BODY_MODE_RIGID) // break; angular_velocity=p_variant; + wakeup(); } break; case PhysicsServer::BODY_STATE_SLEEPING: { diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h index 63dd3e6762..f15fd9b831 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics/body_sw.h @@ -200,6 +200,12 @@ public: void set_active(bool p_active); _FORCE_INLINE_ bool is_active() const { return active; } + _FORCE_INLINE_ void wakeup() { + if ((get_space() && active) || mode==PhysicsServer::BODY_MODE_STATIC || mode==PhysicsServer::BODY_MODE_KINEMATIC) + return; + set_active(true); + } + void set_param(PhysicsServer::BodyParameter p_param, float); float get_param(PhysicsServer::BodyParameter p_param) const; diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 53335f2e19..2b4a137e11 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -604,6 +604,7 @@ void PhysicsServerSW::body_set_layer_mask(RID p_body, uint32_t p_mask) { ERR_FAIL_COND(!body); body->set_layer_mask(p_mask); + body->wakeup(); } @@ -674,6 +675,7 @@ void PhysicsServerSW::body_set_state(RID p_body, BodyState p_state, const Varian ERR_FAIL_COND(!body); body->set_state(p_state,p_variant); + }; Variant PhysicsServerSW::body_get_state(RID p_body, BodyState p_state) const { @@ -691,6 +693,7 @@ void PhysicsServerSW::body_set_applied_force(RID p_body, const Vector3& p_force) ERR_FAIL_COND(!body); body->set_applied_force(p_force); + body->wakeup(); }; Vector3 PhysicsServerSW::body_get_applied_force(RID p_body) const { @@ -706,6 +709,7 @@ void PhysicsServerSW::body_set_applied_torque(RID p_body, const Vector3& p_torqu ERR_FAIL_COND(!body); body->set_applied_torque(p_torque); + body->wakeup(); }; Vector3 PhysicsServerSW::body_get_applied_torque(RID p_body) const { @@ -722,6 +726,7 @@ void PhysicsServerSW::body_apply_impulse(RID p_body, const Vector3& p_pos, const ERR_FAIL_COND(!body); body->apply_impulse(p_pos,p_impulse); + body->wakeup(); }; void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3& p_axis_velocity) { @@ -734,6 +739,7 @@ void PhysicsServerSW::body_set_axis_velocity(RID p_body, const Vector3& p_axis_v v-=axis*axis.dot(v); v+=p_axis_velocity; body->set_linear_velocity(v); + body->wakeup(); }; @@ -743,6 +749,7 @@ void PhysicsServerSW::body_set_axis_lock(RID p_body,BodyAxisLock p_lock) { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND(!body); body->set_axis_lock(p_lock); + body->wakeup(); } @@ -762,6 +769,7 @@ void PhysicsServerSW::body_add_collision_exception(RID p_body, RID p_body_b) { ERR_FAIL_COND(!body); body->add_exception(p_body_b); + body->wakeup(); }; @@ -771,6 +779,7 @@ void PhysicsServerSW::body_remove_collision_exception(RID p_body, RID p_body_b) ERR_FAIL_COND(!body); body->remove_exception(p_body_b); + body->wakeup(); }; |