diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h index 70f4a8ec4c8..0c6ec326691 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics/body_sw.h @@ -393,10 +393,16 @@ public: virtual Vector3 get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space virtual Basis get_inverse_inertia_tensor() const { return body->get_inv_inertia_tensor(); } // get density of this body space - virtual void set_linear_velocity(const Vector3 &p_velocity) { body->set_linear_velocity(p_velocity); } + virtual void set_linear_velocity(const Vector3 &p_velocity) { + body->wakeup(); + body->set_linear_velocity(p_velocity); + } virtual Vector3 get_linear_velocity() const { return body->get_linear_velocity(); } - virtual void set_angular_velocity(const Vector3 &p_velocity) { body->set_angular_velocity(p_velocity); } + virtual void set_angular_velocity(const Vector3 &p_velocity) { + body->wakeup(); + body->set_angular_velocity(p_velocity); + } virtual Vector3 get_angular_velocity() const { return body->get_angular_velocity(); } virtual void set_transform(const Transform &p_transform) { body->set_state(PhysicsServer::BODY_STATE_TRANSFORM, p_transform); } @@ -404,12 +410,30 @@ public: virtual Vector3 get_velocity_at_local_position(const Vector3 &p_position) const { return body->get_velocity_in_local_point(p_position); } - virtual void add_central_force(const Vector3 &p_force) { body->add_central_force(p_force); } - virtual void add_force(const Vector3 &p_force, const Vector3 &p_pos) { body->add_force(p_force, p_pos); } - virtual void add_torque(const Vector3 &p_torque) { body->add_torque(p_torque); } - virtual void apply_central_impulse(const Vector3 &p_j) { body->apply_central_impulse(p_j); } - virtual void apply_impulse(const Vector3 &p_pos, const Vector3 &p_j) { body->apply_impulse(p_pos, p_j); } - virtual void apply_torque_impulse(const Vector3 &p_j) { body->apply_torque_impulse(p_j); } + virtual void add_central_force(const Vector3 &p_force) { + body->wakeup(); + body->add_central_force(p_force); + } + virtual void add_force(const Vector3 &p_force, const Vector3 &p_pos) { + body->wakeup(); + body->add_force(p_force, p_pos); + } + virtual void add_torque(const Vector3 &p_torque) { + body->wakeup(); + body->add_torque(p_torque); + } + virtual void apply_central_impulse(const Vector3 &p_j) { + body->wakeup(); + body->apply_central_impulse(p_j); + } + virtual void apply_impulse(const Vector3 &p_pos, const Vector3 &p_j) { + body->wakeup(); + body->apply_impulse(p_pos, p_j); + } + virtual void apply_torque_impulse(const Vector3 &p_j) { + body->wakeup(); + body->apply_torque_impulse(p_j); + } virtual void set_sleep_state(bool p_enable) { body->set_active(!p_enable); } virtual bool is_sleeping() const { return !body->is_active(); } diff --git a/servers/physics_2d/body_2d_sw.h b/servers/physics_2d/body_2d_sw.h index b9e78326888..3520bf2f2ba 100644 --- a/servers/physics_2d/body_2d_sw.h +++ b/servers/physics_2d/body_2d_sw.h @@ -354,10 +354,16 @@ public: virtual real_t get_inverse_mass() const { return body->get_inv_mass(); } // get the mass virtual real_t get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space - virtual void set_linear_velocity(const Vector2 &p_velocity) { body->set_linear_velocity(p_velocity); } + virtual void set_linear_velocity(const Vector2 &p_velocity) { + body->wakeup(); + body->set_linear_velocity(p_velocity); + } virtual Vector2 get_linear_velocity() const { return body->get_linear_velocity(); } - virtual void set_angular_velocity(real_t p_velocity) { body->set_angular_velocity(p_velocity); } + virtual void set_angular_velocity(real_t p_velocity) { + body->wakeup(); + body->set_angular_velocity(p_velocity); + } virtual real_t get_angular_velocity() const { return body->get_angular_velocity(); } virtual void set_transform(const Transform2D &p_transform) { body->set_state(Physics2DServer::BODY_STATE_TRANSFORM, p_transform); } @@ -365,12 +371,30 @@ public: virtual Vector2 get_velocity_at_local_position(const Vector2 &p_position) const { return body->get_velocity_in_local_point(p_position); } - virtual void add_central_force(const Vector2 &p_force) { body->add_central_force(p_force); } - virtual void add_force(const Vector2 &p_offset, const Vector2 &p_force) { body->add_force(p_offset, p_force); } - virtual void add_torque(real_t p_torque) { body->add_torque(p_torque); } - virtual void apply_central_impulse(const Vector2 &p_impulse) { body->apply_central_impulse(p_impulse); } - virtual void apply_impulse(const Vector2 &p_offset, const Vector2 &p_force) { body->apply_impulse(p_offset, p_force); } - virtual void apply_torque_impulse(real_t p_torque) { body->apply_torque_impulse(p_torque); } + virtual void add_central_force(const Vector2 &p_force) { + body->wakeup(); + body->add_central_force(p_force); + } + virtual void add_force(const Vector2 &p_offset, const Vector2 &p_force) { + body->wakeup(); + body->add_force(p_offset, p_force); + } + virtual void add_torque(real_t p_torque) { + body->wakeup(); + body->add_torque(p_torque); + } + virtual void apply_central_impulse(const Vector2 &p_impulse) { + body->wakeup(); + body->apply_central_impulse(p_impulse); + } + virtual void apply_impulse(const Vector2 &p_offset, const Vector2 &p_force) { + body->wakeup(); + body->apply_impulse(p_offset, p_force); + } + virtual void apply_torque_impulse(real_t p_torque) { + body->wakeup(); + body->apply_torque_impulse(p_torque); + } virtual void set_sleep_state(bool p_enable) { body->set_active(!p_enable); } virtual bool is_sleeping() const { return !body->is_active(); }