summaryrefslogtreecommitdiff
path: root/servers/physics_2d/godot_body_direct_state_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics_2d/godot_body_direct_state_2d.cpp')
-rw-r--r--servers/physics_2d/godot_body_direct_state_2d.cpp61
1 files changed, 49 insertions, 12 deletions
diff --git a/servers/physics_2d/godot_body_direct_state_2d.cpp b/servers/physics_2d/godot_body_direct_state_2d.cpp
index 9c9bd56268..2843466e01 100644
--- a/servers/physics_2d/godot_body_direct_state_2d.cpp
+++ b/servers/physics_2d/godot_body_direct_state_2d.cpp
@@ -92,34 +92,71 @@ Vector2 GodotPhysicsDirectBodyState2D::get_velocity_at_local_position(const Vect
return body->get_velocity_in_local_point(p_position);
}
-void GodotPhysicsDirectBodyState2D::add_central_force(const Vector2 &p_force) {
+void GodotPhysicsDirectBodyState2D::apply_central_impulse(const Vector2 &p_impulse) {
body->wakeup();
- body->add_central_force(p_force);
+ body->apply_central_impulse(p_impulse);
}
-void GodotPhysicsDirectBodyState2D::add_force(const Vector2 &p_force, const Vector2 &p_position) {
+void GodotPhysicsDirectBodyState2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position) {
body->wakeup();
- body->add_force(p_force, p_position);
+ body->apply_impulse(p_impulse, p_position);
}
-void GodotPhysicsDirectBodyState2D::add_torque(real_t p_torque) {
+void GodotPhysicsDirectBodyState2D::apply_torque_impulse(real_t p_torque) {
body->wakeup();
- body->add_torque(p_torque);
+ body->apply_torque_impulse(p_torque);
}
-void GodotPhysicsDirectBodyState2D::apply_central_impulse(const Vector2 &p_impulse) {
+void GodotPhysicsDirectBodyState2D::apply_central_force(const Vector2 &p_force) {
body->wakeup();
- body->apply_central_impulse(p_impulse);
+ body->apply_central_force(p_force);
}
-void GodotPhysicsDirectBodyState2D::apply_impulse(const Vector2 &p_impulse, const Vector2 &p_position) {
+void GodotPhysicsDirectBodyState2D::apply_force(const Vector2 &p_force, const Vector2 &p_position) {
body->wakeup();
- body->apply_impulse(p_impulse, p_position);
+ body->apply_force(p_force, p_position);
}
-void GodotPhysicsDirectBodyState2D::apply_torque_impulse(real_t p_torque) {
+void GodotPhysicsDirectBodyState2D::apply_torque(real_t p_torque) {
body->wakeup();
- body->apply_torque_impulse(p_torque);
+ body->apply_torque(p_torque);
+}
+
+void GodotPhysicsDirectBodyState2D::add_constant_central_force(const Vector2 &p_force) {
+ body->wakeup();
+ body->add_constant_central_force(p_force);
+}
+
+void GodotPhysicsDirectBodyState2D::add_constant_force(const Vector2 &p_force, const Vector2 &p_position) {
+ body->wakeup();
+ body->add_constant_force(p_force, p_position);
+}
+
+void GodotPhysicsDirectBodyState2D::add_constant_torque(real_t p_torque) {
+ body->wakeup();
+ body->add_constant_torque(p_torque);
+}
+
+void GodotPhysicsDirectBodyState2D::set_constant_force(const Vector2 &p_force) {
+ if (!p_force.is_equal_approx(Vector2())) {
+ body->wakeup();
+ }
+ body->set_constant_force(p_force);
+}
+
+Vector2 GodotPhysicsDirectBodyState2D::get_constant_force() const {
+ return body->get_constant_force();
+}
+
+void GodotPhysicsDirectBodyState2D::set_constant_torque(real_t p_torque) {
+ if (!Math::is_zero_approx(p_torque)) {
+ body->wakeup();
+ }
+ body->set_constant_torque(p_torque);
+}
+
+real_t GodotPhysicsDirectBodyState2D::get_constant_torque() const {
+ return body->get_constant_torque();
}
void GodotPhysicsDirectBodyState2D::set_sleep_state(bool p_enable) {