|
@@ -669,68 +669,68 @@ void GodotPhysicsServer2D::body_attach_object_instance_id(RID p_body, ObjectID p
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
body->set_instance_id(p_id);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
ObjectID GodotPhysicsServer2D::body_get_object_instance_id(RID p_body) const {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND_V(!body, ObjectID());
|
|
|
|
|
|
return body->get_instance_id();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
void GodotPhysicsServer2D::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
body->set_canvas_instance_id(p_id);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
ObjectID GodotPhysicsServer2D::body_get_canvas_instance_id(RID p_body) const {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND_V(!body, ObjectID());
|
|
|
|
|
|
return body->get_canvas_instance_id();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
void GodotPhysicsServer2D::body_set_collision_layer(RID p_body, uint32_t p_layer) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
body->set_collision_layer(p_layer);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
uint32_t GodotPhysicsServer2D::body_get_collision_layer(RID p_body) const {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND_V(!body, 0);
|
|
|
|
|
|
return body->get_collision_layer();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
void GodotPhysicsServer2D::body_set_collision_mask(RID p_body, uint32_t p_mask) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
body->set_collision_mask(p_mask);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
uint32_t GodotPhysicsServer2D::body_get_collision_mask(RID p_body) const {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND_V(!body, 0);
|
|
|
|
|
|
return body->get_collision_mask();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
void GodotPhysicsServer2D::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
body->set_param(p_param, p_value);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
Variant GodotPhysicsServer2D::body_get_param(RID p_body, BodyParameter p_param) const {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND_V(!body, 0);
|
|
|
|
|
|
return body->get_param(p_param);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
void GodotPhysicsServer2D::body_reset_mass_properties(RID p_body) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
@@ -744,95 +744,123 @@ void GodotPhysicsServer2D::body_set_state(RID p_body, BodyState p_state, const V
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
body->set_state(p_state, p_variant);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
Variant GodotPhysicsServer2D::body_get_state(RID p_body, BodyState p_state) const {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND_V(!body, Variant());
|
|
|
|
|
|
return body->get_state(p_state);
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_set_applied_force(RID p_body, const Vector2 &p_force) {
|
|
|
+void GodotPhysicsServer2D::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- body->set_applied_force(p_force);
|
|
|
+ body->apply_central_impulse(p_impulse);
|
|
|
body->wakeup();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
-Vector2 GodotPhysicsServer2D::body_get_applied_force(RID p_body) const {
|
|
|
+void GodotPhysicsServer2D::body_apply_torque_impulse(RID p_body, real_t p_torque) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
- ERR_FAIL_COND_V(!body, Vector2());
|
|
|
- return body->get_applied_force();
|
|
|
-};
|
|
|
+ ERR_FAIL_COND(!body);
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_set_applied_torque(RID p_body, real_t p_torque) {
|
|
|
+ _update_shapes();
|
|
|
+
|
|
|
+ body->apply_torque_impulse(p_torque);
|
|
|
+ body->wakeup();
|
|
|
+}
|
|
|
+
|
|
|
+void GodotPhysicsServer2D::body_apply_impulse(RID p_body, const Vector2 &p_impulse, const Vector2 &p_position) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- body->set_applied_torque(p_torque);
|
|
|
+ _update_shapes();
|
|
|
+
|
|
|
+ body->apply_impulse(p_impulse, p_position);
|
|
|
body->wakeup();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
-real_t GodotPhysicsServer2D::body_get_applied_torque(RID p_body) const {
|
|
|
+void GodotPhysicsServer2D::body_apply_central_force(RID p_body, const Vector2 &p_force) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
- ERR_FAIL_COND_V(!body, 0);
|
|
|
+ ERR_FAIL_COND(!body);
|
|
|
|
|
|
- return body->get_applied_torque();
|
|
|
-};
|
|
|
+ body->apply_central_force(p_force);
|
|
|
+ body->wakeup();
|
|
|
+}
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
|
|
|
+void GodotPhysicsServer2D::body_apply_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- body->apply_central_impulse(p_impulse);
|
|
|
+ body->apply_force(p_force, p_position);
|
|
|
body->wakeup();
|
|
|
}
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_apply_torque_impulse(RID p_body, real_t p_torque) {
|
|
|
+void GodotPhysicsServer2D::body_apply_torque(RID p_body, real_t p_torque) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- _update_shapes();
|
|
|
-
|
|
|
- body->apply_torque_impulse(p_torque);
|
|
|
+ body->apply_torque(p_torque);
|
|
|
body->wakeup();
|
|
|
}
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_apply_impulse(RID p_body, const Vector2 &p_impulse, const Vector2 &p_position) {
|
|
|
+void GodotPhysicsServer2D::body_add_constant_central_force(RID p_body, const Vector2 &p_force) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- _update_shapes();
|
|
|
-
|
|
|
- body->apply_impulse(p_impulse, p_position);
|
|
|
+ body->add_constant_central_force(p_force);
|
|
|
body->wakeup();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_add_central_force(RID p_body, const Vector2 &p_force) {
|
|
|
+void GodotPhysicsServer2D::body_add_constant_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- body->add_central_force(p_force);
|
|
|
+ body->add_constant_force(p_force, p_position);
|
|
|
body->wakeup();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_add_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) {
|
|
|
+void GodotPhysicsServer2D::body_add_constant_torque(RID p_body, real_t p_torque) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- body->add_force(p_force, p_position);
|
|
|
+ body->add_constant_torque(p_torque);
|
|
|
body->wakeup();
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
-void GodotPhysicsServer2D::body_add_torque(RID p_body, real_t p_torque) {
|
|
|
+void GodotPhysicsServer2D::body_set_constant_force(RID p_body, const Vector2 &p_force) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
ERR_FAIL_COND(!body);
|
|
|
|
|
|
- body->add_torque(p_torque);
|
|
|
- body->wakeup();
|
|
|
-};
|
|
|
+ body->set_constant_force(p_force);
|
|
|
+ if (!p_force.is_equal_approx(Vector2())) {
|
|
|
+ body->wakeup();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+Vector2 GodotPhysicsServer2D::body_get_constant_force(RID p_body) const {
|
|
|
+ GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
+ ERR_FAIL_COND_V(!body, Vector2());
|
|
|
+ return body->get_constant_force();
|
|
|
+}
|
|
|
+
|
|
|
+void GodotPhysicsServer2D::body_set_constant_torque(RID p_body, real_t p_torque) {
|
|
|
+ GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
+ ERR_FAIL_COND(!body);
|
|
|
+
|
|
|
+ body->set_constant_torque(p_torque);
|
|
|
+ if (!Math::is_zero_approx(p_torque)) {
|
|
|
+ body->wakeup();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+real_t GodotPhysicsServer2D::body_get_constant_torque(RID p_body) const {
|
|
|
+ GodotBody2D *body = body_owner.get_or_null(p_body);
|
|
|
+ ERR_FAIL_COND_V(!body, 0);
|
|
|
+
|
|
|
+ return body->get_constant_torque();
|
|
|
+}
|
|
|
|
|
|
void GodotPhysicsServer2D::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
|
|
|
GodotBody2D *body = body_owner.get_or_null(p_body);
|