diff options
Diffstat (limited to 'servers/physics_2d')
-rw-r--r-- | servers/physics_2d/body_2d_sw.cpp | 4 | ||||
-rw-r--r-- | servers/physics_2d/body_direct_state_2d_sw.cpp | 16 | ||||
-rw-r--r-- | servers/physics_2d/body_direct_state_2d_sw.h | 1 | ||||
-rw-r--r-- | servers/physics_2d/collision_object_2d_sw.cpp | 5 | ||||
-rw-r--r-- | servers/physics_2d/collision_object_2d_sw.h | 6 | ||||
-rw-r--r-- | servers/physics_2d/physics_server_2d_sw.cpp | 280 | ||||
-rw-r--r-- | servers/physics_2d/physics_server_2d_sw.h | 2 | ||||
-rw-r--r-- | servers/physics_2d/physics_server_2d_wrap_mt.h | 2 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 13 |
9 files changed, 140 insertions, 189 deletions
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index edd769aa9a..38b98b7bca 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -113,7 +113,7 @@ void Body2DSW::update_mass_properties() { _inv_inertia = 0; _inv_mass = 0; } break; - case PhysicsServer2D::BODY_MODE_DYNAMIC_LOCKED: { + case PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR: { _inv_inertia = 0; _inv_mass = 1.0 / mass; @@ -257,7 +257,7 @@ void Body2DSW::set_mode(PhysicsServer2D::BodyMode p_mode) { set_active(true); } break; - case PhysicsServer2D::BODY_MODE_DYNAMIC_LOCKED: { + case PhysicsServer2D::BODY_MODE_DYNAMIC_LINEAR: { _inv_mass = mass > 0 ? (1.0 / mass) : 0; _inv_inertia = 0; angular_velocity = 0; diff --git a/servers/physics_2d/body_direct_state_2d_sw.cpp b/servers/physics_2d/body_direct_state_2d_sw.cpp index 1e924a831e..1c6adfe27c 100644 --- a/servers/physics_2d/body_direct_state_2d_sw.cpp +++ b/servers/physics_2d/body_direct_state_2d_sw.cpp @@ -169,22 +169,6 @@ Vector2 PhysicsDirectBodyState2DSW::get_contact_collider_velocity_at_position(in return body->contacts[p_contact_idx].collider_velocity_at_pos; } -Variant PhysicsDirectBodyState2DSW::get_contact_collider_shape_metadata(int p_contact_idx) const { - ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Variant()); - - if (!PhysicsServer2DSW::singletonsw->body_owner.owns(body->contacts[p_contact_idx].collider)) { - return Variant(); - } - Body2DSW *other = PhysicsServer2DSW::singletonsw->body_owner.getornull(body->contacts[p_contact_idx].collider); - - int sidx = body->contacts[p_contact_idx].collider_shape; - if (sidx < 0 || sidx >= other->get_shape_count()) { - return Variant(); - } - - return other->get_shape_metadata(sidx); -} - PhysicsDirectSpaceState2D *PhysicsDirectBodyState2DSW::get_space_state() { return body->get_space()->get_direct_state(); } diff --git a/servers/physics_2d/body_direct_state_2d_sw.h b/servers/physics_2d/body_direct_state_2d_sw.h index 34faa174d8..4266b24842 100644 --- a/servers/physics_2d/body_direct_state_2d_sw.h +++ b/servers/physics_2d/body_direct_state_2d_sw.h @@ -80,7 +80,6 @@ public: virtual Vector2 get_contact_collider_position(int p_contact_idx) const override; virtual ObjectID get_contact_collider_id(int p_contact_idx) const override; virtual int get_contact_collider_shape(int p_contact_idx) const override; - virtual Variant get_contact_collider_shape_metadata(int p_contact_idx) const override; virtual Vector2 get_contact_collider_velocity_at_position(int p_contact_idx) const override; diff --git a/servers/physics_2d/collision_object_2d_sw.cpp b/servers/physics_2d/collision_object_2d_sw.cpp index c92f01d120..bc7d277152 100644 --- a/servers/physics_2d/collision_object_2d_sw.cpp +++ b/servers/physics_2d/collision_object_2d_sw.cpp @@ -61,11 +61,6 @@ void CollisionObject2DSW::set_shape(int p_index, Shape2DSW *p_shape) { } } -void CollisionObject2DSW::set_shape_metadata(int p_index, const Variant &p_metadata) { - ERR_FAIL_INDEX(p_index, shapes.size()); - shapes.write[p_index].metadata = p_metadata; -} - void CollisionObject2DSW::set_shape_transform(int p_index, const Transform2D &p_transform) { ERR_FAIL_INDEX(p_index, shapes.size()); diff --git a/servers/physics_2d/collision_object_2d_sw.h b/servers/physics_2d/collision_object_2d_sw.h index 69487631a6..ca258a906a 100644 --- a/servers/physics_2d/collision_object_2d_sw.h +++ b/servers/physics_2d/collision_object_2d_sw.h @@ -58,7 +58,6 @@ private: BroadPhase2DSW::ID bpid = 0; Rect2 aabb_cache; //for rayqueries Shape2DSW *shape = nullptr; - Variant metadata; bool disabled = false; bool one_way_collision = false; real_t one_way_collision_margin = 0.0; @@ -110,7 +109,6 @@ public: void add_shape(Shape2DSW *p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false); void set_shape(int p_index, Shape2DSW *p_shape); void set_shape_transform(int p_index, const Transform2D &p_transform); - void set_shape_metadata(int p_index, const Variant &p_metadata); _FORCE_INLINE_ int get_shape_count() const { return shapes.size(); } _FORCE_INLINE_ Shape2DSW *get_shape(int p_index) const { @@ -129,10 +127,6 @@ public: CRASH_BAD_INDEX(p_index, shapes.size()); return shapes[p_index].aabb_cache; } - _FORCE_INLINE_ const Variant &get_shape_metadata(int p_index) const { - CRASH_BAD_INDEX(p_index, shapes.size()); - return shapes[p_index].metadata; - } _FORCE_INLINE_ const Transform2D &get_transform() const { return transform; } _FORCE_INLINE_ const Transform2D &get_inv_transform() const { return inv_transform; } diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp index e052258a92..4315b55df4 100644 --- a/servers/physics_2d/physics_server_2d_sw.cpp +++ b/servers/physics_2d/physics_server_2d_sw.cpp @@ -112,32 +112,32 @@ RID PhysicsServer2DSW::concave_polygon_shape_create() { } void PhysicsServer2DSW::shape_set_data(RID p_shape, const Variant &p_data) { - Shape2DSW *shape = shape_owner.getornull(p_shape); + Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND(!shape); shape->set_data(p_data); }; void PhysicsServer2DSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) { - Shape2DSW *shape = shape_owner.getornull(p_shape); + Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND(!shape); shape->set_custom_bias(p_bias); } PhysicsServer2D::ShapeType PhysicsServer2DSW::shape_get_type(RID p_shape) const { - const Shape2DSW *shape = shape_owner.getornull(p_shape); + const Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM); return shape->get_type(); }; Variant PhysicsServer2DSW::shape_get_data(RID p_shape) const { - const Shape2DSW *shape = shape_owner.getornull(p_shape); + const Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND_V(!shape, Variant()); ERR_FAIL_COND_V(!shape->is_configured(), Variant()); return shape->get_data(); }; real_t PhysicsServer2DSW::shape_get_custom_solver_bias(RID p_shape) const { - const Shape2DSW *shape = shape_owner.getornull(p_shape); + const Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND_V(!shape, 0); return shape->get_custom_bias(); } @@ -193,9 +193,9 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 & } bool PhysicsServer2DSW::shape_collide(RID p_shape_A, const Transform2D &p_xform_A, const Vector2 &p_motion_A, RID p_shape_B, const Transform2D &p_xform_B, const Vector2 &p_motion_B, Vector2 *r_results, int p_result_max, int &r_result_count) { - Shape2DSW *shape_A = shape_owner.getornull(p_shape_A); + Shape2DSW *shape_A = shape_owner.get_or_null(p_shape_A); ERR_FAIL_COND_V(!shape_A, false); - Shape2DSW *shape_B = shape_owner.getornull(p_shape_B); + Shape2DSW *shape_B = shape_owner.get_or_null(p_shape_B); ERR_FAIL_COND_V(!shape_B, false); if (p_result_max == 0) { @@ -218,7 +218,7 @@ RID PhysicsServer2DSW::space_create() { RID id = space_owner.make_rid(space); space->set_self(id); RID area_id = area_create(); - Area2DSW *area = area_owner.getornull(area_id); + Area2DSW *area = area_owner.get_or_null(area_id); ERR_FAIL_COND_V(!area, RID()); space->set_default_area(area); area->set_space(space); @@ -228,7 +228,7 @@ RID PhysicsServer2DSW::space_create() { }; void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) { - Space2DSW *space = space_owner.getornull(p_space); + Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND(!space); if (p_active) { active_spaces.insert(space); @@ -238,45 +238,45 @@ void PhysicsServer2DSW::space_set_active(RID p_space, bool p_active) { } bool PhysicsServer2DSW::space_is_active(RID p_space) const { - const Space2DSW *space = space_owner.getornull(p_space); + const Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND_V(!space, false); return active_spaces.has(space); } void PhysicsServer2DSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) { - Space2DSW *space = space_owner.getornull(p_space); + Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND(!space); space->set_param(p_param, p_value); } real_t PhysicsServer2DSW::space_get_param(RID p_space, SpaceParameter p_param) const { - const Space2DSW *space = space_owner.getornull(p_space); + const Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_param(p_param); } void PhysicsServer2DSW::space_set_debug_contacts(RID p_space, int p_max_contacts) { - Space2DSW *space = space_owner.getornull(p_space); + Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND(!space); space->set_debug_contacts(p_max_contacts); } Vector<Vector2> PhysicsServer2DSW::space_get_contacts(RID p_space) const { - Space2DSW *space = space_owner.getornull(p_space); + Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND_V(!space, Vector<Vector2>()); return space->get_debug_contacts(); } int PhysicsServer2DSW::space_get_contact_count(RID p_space) const { - Space2DSW *space = space_owner.getornull(p_space); + Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND_V(!space, 0); return space->get_debug_contact_count(); } PhysicsDirectSpaceState2D *PhysicsServer2DSW::space_get_direct_state(RID p_space) { - Space2DSW *space = space_owner.getornull(p_space); + Space2DSW *space = space_owner.get_or_null(p_space); ERR_FAIL_COND_V(!space, nullptr); ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification."); @@ -291,12 +291,12 @@ RID PhysicsServer2DSW::area_create() { }; void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); Space2DSW *space = nullptr; if (p_space.is_valid()) { - space = space_owner.getornull(p_space); + space = space_owner.get_or_null(p_space); ERR_FAIL_COND(!space); } @@ -309,7 +309,7 @@ void PhysicsServer2DSW::area_set_space(RID p_area, RID p_space) { }; RID PhysicsServer2DSW::area_get_space(RID p_area) const { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, RID()); Space2DSW *space = area->get_space(); @@ -320,34 +320,34 @@ RID PhysicsServer2DSW::area_get_space(RID p_area) const { }; void PhysicsServer2DSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_space_override_mode(p_mode); } PhysicsServer2D::AreaSpaceOverrideMode PhysicsServer2DSW::area_get_space_override_mode(RID p_area) const { - const Area2DSW *area = area_owner.getornull(p_area); + const Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED); return area->get_space_override_mode(); } void PhysicsServer2DSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); - Shape2DSW *shape = shape_owner.getornull(p_shape); + Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND(!shape); area->add_shape(shape, p_transform, p_disabled); } void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); - Shape2DSW *shape = shape_owner.getornull(p_shape); + Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND(!shape); ERR_FAIL_COND(!shape->is_configured()); @@ -355,14 +355,14 @@ void PhysicsServer2DSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) } void PhysicsServer2DSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_shape_transform(p_shape_idx, p_transform); } void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); ERR_FAIL_INDEX(p_shape, area->get_shape_count()); FLUSH_QUERY_CHECK(area); @@ -371,14 +371,14 @@ void PhysicsServer2DSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_ } int PhysicsServer2DSW::area_get_shape_count(RID p_area) const { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, -1); return area->get_shape_count(); } RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, RID()); Shape2DSW *shape = area->get_shape(p_shape_idx); @@ -388,21 +388,21 @@ RID PhysicsServer2DSW::area_get_shape(RID p_area, int p_shape_idx) const { } Transform2D PhysicsServer2DSW::area_get_shape_transform(RID p_area, int p_shape_idx) const { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, Transform2D()); return area->get_shape_transform(p_shape_idx); } void PhysicsServer2DSW::area_remove_shape(RID p_area, int p_shape_idx) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->remove_shape(p_shape_idx); } void PhysicsServer2DSW::area_clear_shapes(RID p_area) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); while (area->get_shape_count()) { @@ -412,86 +412,86 @@ void PhysicsServer2DSW::area_clear_shapes(RID p_area) { void PhysicsServer2DSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) { if (space_owner.owns(p_area)) { - Space2DSW *space = space_owner.getornull(p_area); + Space2DSW *space = space_owner.get_or_null(p_area); p_area = space->get_default_area()->get_self(); } - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_instance_id(p_id); } ObjectID PhysicsServer2DSW::area_get_object_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { - Space2DSW *space = space_owner.getornull(p_area); + Space2DSW *space = space_owner.get_or_null(p_area); p_area = space->get_default_area()->get_self(); } - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, ObjectID()); return area->get_instance_id(); } void PhysicsServer2DSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) { if (space_owner.owns(p_area)) { - Space2DSW *space = space_owner.getornull(p_area); + Space2DSW *space = space_owner.get_or_null(p_area); p_area = space->get_default_area()->get_self(); } - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_canvas_instance_id(p_id); } ObjectID PhysicsServer2DSW::area_get_canvas_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { - Space2DSW *space = space_owner.getornull(p_area); + Space2DSW *space = space_owner.get_or_null(p_area); p_area = space->get_default_area()->get_self(); } - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, ObjectID()); return area->get_canvas_instance_id(); } void PhysicsServer2DSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { if (space_owner.owns(p_area)) { - Space2DSW *space = space_owner.getornull(p_area); + Space2DSW *space = space_owner.get_or_null(p_area); p_area = space->get_default_area()->get_self(); } - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_param(p_param, p_value); }; void PhysicsServer2DSW::area_set_transform(RID p_area, const Transform2D &p_transform) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_transform(p_transform); }; Variant PhysicsServer2DSW::area_get_param(RID p_area, AreaParameter p_param) const { if (space_owner.owns(p_area)) { - Space2DSW *space = space_owner.getornull(p_area); + Space2DSW *space = space_owner.get_or_null(p_area); p_area = space->get_default_area()->get_self(); } - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, Variant()); return area->get_param(p_param); }; Transform2D PhysicsServer2DSW::area_get_transform(RID p_area) const { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND_V(!area, Transform2D()); return area->get_transform(); }; void PhysicsServer2DSW::area_set_pickable(RID p_area, bool p_pickable) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_pickable(p_pickable); } void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); FLUSH_QUERY_CHECK(area); @@ -499,28 +499,28 @@ void PhysicsServer2DSW::area_set_monitorable(RID p_area, bool p_monitorable) { } void PhysicsServer2DSW::area_set_collision_mask(RID p_area, uint32_t p_mask) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_collision_mask(p_mask); } void PhysicsServer2DSW::area_set_collision_layer(RID p_area, uint32_t p_layer) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_collision_layer(p_layer); } void PhysicsServer2DSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); } void PhysicsServer2DSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { - Area2DSW *area = area_owner.getornull(p_area); + Area2DSW *area = area_owner.get_or_null(p_area); ERR_FAIL_COND(!area); area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method); @@ -536,11 +536,11 @@ RID PhysicsServer2DSW::body_create() { } void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); Space2DSW *space = nullptr; if (p_space.is_valid()) { - space = space_owner.getornull(p_space); + space = space_owner.get_or_null(p_space); ERR_FAIL_COND(!space); } @@ -553,7 +553,7 @@ void PhysicsServer2DSW::body_set_space(RID p_body, RID p_space) { }; RID PhysicsServer2DSW::body_get_space(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, RID()); Space2DSW *space = body->get_space(); @@ -564,7 +564,7 @@ RID PhysicsServer2DSW::body_get_space(RID p_body) const { }; void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); FLUSH_QUERY_CHECK(body); @@ -572,27 +572,27 @@ void PhysicsServer2DSW::body_set_mode(RID p_body, BodyMode p_mode) { }; PhysicsServer2D::BodyMode PhysicsServer2DSW::body_get_mode(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, BODY_MODE_STATIC); return body->get_mode(); }; void PhysicsServer2DSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); - Shape2DSW *shape = shape_owner.getornull(p_shape); + Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND(!shape); body->add_shape(shape, p_transform, p_disabled); } void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); - Shape2DSW *shape = shape_owner.getornull(p_shape); + Shape2DSW *shape = shape_owner.get_or_null(p_shape); ERR_FAIL_COND(!shape); ERR_FAIL_COND(!shape->is_configured()); @@ -600,33 +600,21 @@ void PhysicsServer2DSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) } void PhysicsServer2DSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_shape_transform(p_shape_idx, p_transform); } -void PhysicsServer2DSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) { - Body2DSW *body = body_owner.getornull(p_body); - ERR_FAIL_COND(!body); - body->set_shape_metadata(p_shape_idx, p_metadata); -} - -Variant PhysicsServer2DSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const { - Body2DSW *body = body_owner.getornull(p_body); - ERR_FAIL_COND_V(!body, Variant()); - return body->get_shape_metadata(p_shape_idx); -} - int PhysicsServer2DSW::body_get_shape_count(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, -1); return body->get_shape_count(); } RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, RID()); Shape2DSW *shape = body->get_shape(p_shape_idx); @@ -636,21 +624,21 @@ RID PhysicsServer2DSW::body_get_shape(RID p_body, int p_shape_idx) const { } Transform2D PhysicsServer2DSW::body_get_shape_transform(RID p_body, int p_shape_idx) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, Transform2D()); return body->get_shape_transform(p_shape_idx); } void PhysicsServer2DSW::body_remove_shape(RID p_body, int p_shape_idx) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->remove_shape(p_shape_idx); } void PhysicsServer2DSW::body_clear_shapes(RID p_body) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); while (body->get_shape_count()) { @@ -659,7 +647,7 @@ void PhysicsServer2DSW::body_clear_shapes(RID p_body) { } void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count()); FLUSH_QUERY_CHECK(body); @@ -668,7 +656,7 @@ void PhysicsServer2DSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo } void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, real_t p_margin) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count()); FLUSH_QUERY_CHECK(body); @@ -677,109 +665,109 @@ void PhysicsServer2DSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh } void PhysicsServer2DSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_continuous_collision_detection_mode(p_mode); } PhysicsServer2DSW::CCDMode PhysicsServer2DSW::body_get_continuous_collision_detection_mode(RID p_body) const { - const Body2DSW *body = body_owner.getornull(p_body); + const Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED); return body->get_continuous_collision_detection_mode(); } void PhysicsServer2DSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_instance_id(p_id); }; ObjectID PhysicsServer2DSW::body_get_object_instance_id(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, ObjectID()); return body->get_instance_id(); }; void PhysicsServer2DSW::body_attach_canvas_instance_id(RID p_body, ObjectID p_id) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_canvas_instance_id(p_id); }; ObjectID PhysicsServer2DSW::body_get_canvas_instance_id(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, ObjectID()); return body->get_canvas_instance_id(); }; void PhysicsServer2DSW::body_set_collision_layer(RID p_body, uint32_t p_layer) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_collision_layer(p_layer); }; uint32_t PhysicsServer2DSW::body_get_collision_layer(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_layer(); }; void PhysicsServer2DSW::body_set_collision_mask(RID p_body, uint32_t p_mask) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_collision_mask(p_mask); }; uint32_t PhysicsServer2DSW::body_get_collision_mask(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_collision_mask(); }; void PhysicsServer2DSW::body_set_param(RID p_body, BodyParameter p_param, const Variant &p_value) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_param(p_param, p_value); }; Variant PhysicsServer2DSW::body_get_param(RID p_body, BodyParameter p_param) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_param(p_param); }; void PhysicsServer2DSW::body_reset_mass_properties(RID p_body) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); return body->reset_mass_properties(); } void PhysicsServer2DSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_state(p_state, p_variant); }; Variant PhysicsServer2DSW::body_get_state(RID p_body, BodyState p_state) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, Variant()); return body->get_state(p_state); }; void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_force) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_applied_force(p_force); @@ -787,13 +775,13 @@ void PhysicsServer2DSW::body_set_applied_force(RID p_body, const Vector2 &p_forc }; Vector2 PhysicsServer2DSW::body_get_applied_force(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, Vector2()); return body->get_applied_force(); }; void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_applied_torque(p_torque); @@ -801,14 +789,14 @@ void PhysicsServer2DSW::body_set_applied_torque(RID p_body, real_t p_torque) { }; real_t PhysicsServer2DSW::body_get_applied_torque(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, 0); return body->get_applied_torque(); }; void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->apply_central_impulse(p_impulse); @@ -816,7 +804,7 @@ void PhysicsServer2DSW::body_apply_central_impulse(RID p_body, const Vector2 &p_ } void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); _update_shapes(); @@ -826,7 +814,7 @@ void PhysicsServer2DSW::body_apply_torque_impulse(RID p_body, real_t p_torque) { } void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_impulse, const Vector2 &p_position) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); _update_shapes(); @@ -836,7 +824,7 @@ void PhysicsServer2DSW::body_apply_impulse(RID p_body, const Vector2 &p_impulse, }; void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_force) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->add_central_force(p_force); @@ -844,7 +832,7 @@ void PhysicsServer2DSW::body_add_central_force(RID p_body, const Vector2 &p_forc }; void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_force, const Vector2 &p_position) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->add_force(p_force, p_position); @@ -852,7 +840,7 @@ void PhysicsServer2DSW::body_add_force(RID p_body, const Vector2 &p_force, const }; void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->add_torque(p_torque); @@ -860,7 +848,7 @@ void PhysicsServer2DSW::body_add_torque(RID p_body, real_t p_torque) { }; void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); _update_shapes(); @@ -874,7 +862,7 @@ void PhysicsServer2DSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis }; void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->add_exception(p_body_b); @@ -882,7 +870,7 @@ void PhysicsServer2DSW::body_add_collision_exception(RID p_body, RID p_body_b) { }; void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->remove_exception(p_body_b); @@ -890,7 +878,7 @@ void PhysicsServer2DSW::body_remove_collision_exception(RID p_body, RID p_body_b }; void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); for (int i = 0; i < body->get_exceptions().size(); i++) { @@ -899,55 +887,55 @@ void PhysicsServer2DSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e }; void PhysicsServer2DSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); }; real_t PhysicsServer2DSW::body_get_contacts_reported_depth_threshold(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, 0); return 0; }; void PhysicsServer2DSW::body_set_omit_force_integration(RID p_body, bool p_omit) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_omit_force_integration(p_omit); }; bool PhysicsServer2DSW::body_is_omitting_force_integration(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, false); return body->get_omit_force_integration(); }; void PhysicsServer2DSW::body_set_max_contacts_reported(RID p_body, int p_contacts) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_max_contacts_reported(p_contacts); } int PhysicsServer2DSW::body_get_max_contacts_reported(RID p_body) const { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, -1); return body->get_max_contacts_reported(); } void PhysicsServer2DSW::body_set_state_sync_callback(RID p_body, void *p_instance, BodyStateCallback p_callback) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_state_sync_callback(p_instance, p_callback); } void PhysicsServer2DSW::body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_force_integration_callback(p_callable, p_udata); } bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, false); ERR_FAIL_INDEX_V(p_body_shape, body->get_shape_count(), false); @@ -955,13 +943,13 @@ bool PhysicsServer2DSW::body_collide_shape(RID p_body, int p_body_shape, RID p_s } void PhysicsServer2DSW::body_set_pickable(RID p_body, bool p_pickable) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND(!body); body->set_pickable(p_pickable); } bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, real_t p_margin, MotionResult *r_result, bool p_collide_separation_ray, const Set<RID> &p_exclude) { - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, false); ERR_FAIL_COND_V(!body->get_space(), false); ERR_FAIL_COND_V(body->get_space()->is_locked(), false); @@ -974,7 +962,7 @@ bool PhysicsServer2DSW::body_test_motion(RID p_body, const Transform2D &p_from, PhysicsDirectBodyState2D *PhysicsServer2DSW::body_get_direct_state(RID p_body) { ERR_FAIL_COND_V_MSG((using_threads && !doing_sync), nullptr, "Body state is inaccessible right now, wait for iteration or physics process notification."); - Body2DSW *body = body_owner.getornull(p_body); + Body2DSW *body = body_owner.get_or_null(p_body); ERR_FAIL_COND_V(!body, nullptr); ERR_FAIL_COND_V(!body->get_space(), nullptr); @@ -993,7 +981,7 @@ RID PhysicsServer2DSW::joint_create() { } void PhysicsServer2DSW::joint_clear(RID p_joint) { - Joint2DSW *joint = joint_owner.getornull(p_joint); + Joint2DSW *joint = joint_owner.get_or_null(p_joint); if (joint->get_type() != JOINT_TYPE_MAX) { Joint2DSW *empty_joint = memnew(Joint2DSW); empty_joint->copy_settings_from(joint); @@ -1004,7 +992,7 @@ void PhysicsServer2DSW::joint_clear(RID p_joint) { } void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) { - Joint2DSW *joint = joint_owner.getornull(p_joint); + Joint2DSW *joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND(!joint); switch (p_param) { @@ -1021,7 +1009,7 @@ void PhysicsServer2DSW::joint_set_param(RID p_joint, JointParam p_param, real_t } real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const { - const Joint2DSW *joint = joint_owner.getornull(p_joint); + const Joint2DSW *joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND_V(!joint, -1); switch (p_param) { @@ -1040,7 +1028,7 @@ real_t PhysicsServer2DSW::joint_get_param(RID p_joint, JointParam p_param) const } void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) { - Joint2DSW *joint = joint_owner.getornull(p_joint); + Joint2DSW *joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND(!joint); joint->disable_collisions_between_bodies(p_disable); @@ -1060,22 +1048,22 @@ void PhysicsServer2DSW::joint_disable_collisions_between_bodies(RID p_joint, con } bool PhysicsServer2DSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const { - const Joint2DSW *joint = joint_owner.getornull(p_joint); + const Joint2DSW *joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND_V(!joint, true); return joint->is_disabled_collisions_between_bodies(); } void PhysicsServer2DSW::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID p_body_a, RID p_body_b) { - Body2DSW *A = body_owner.getornull(p_body_a); + Body2DSW *A = body_owner.get_or_null(p_body_a); ERR_FAIL_COND(!A); Body2DSW *B = nullptr; if (body_owner.owns(p_body_b)) { - B = body_owner.getornull(p_body_b); + B = body_owner.get_or_null(p_body_b); ERR_FAIL_COND(!B); } - Joint2DSW *prev_joint = joint_owner.getornull(p_joint); + Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND(prev_joint == nullptr); Joint2DSW *joint = memnew(PinJoint2DSW(p_pos, A, B)); @@ -1086,13 +1074,13 @@ void PhysicsServer2DSW::joint_make_pin(RID p_joint, const Vector2 &p_pos, RID p_ } void PhysicsServer2DSW::joint_make_groove(RID p_joint, const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, RID p_body_a, RID p_body_b) { - Body2DSW *A = body_owner.getornull(p_body_a); + Body2DSW *A = body_owner.get_or_null(p_body_a); ERR_FAIL_COND(!A); - Body2DSW *B = body_owner.getornull(p_body_b); + Body2DSW *B = body_owner.get_or_null(p_body_b); ERR_FAIL_COND(!B); - Joint2DSW *prev_joint = joint_owner.getornull(p_joint); + Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND(prev_joint == nullptr); Joint2DSW *joint = memnew(GrooveJoint2DSW(p_a_groove1, p_a_groove2, p_b_anchor, A, B)); @@ -1103,13 +1091,13 @@ void PhysicsServer2DSW::joint_make_groove(RID p_joint, const Vector2 &p_a_groove } void PhysicsServer2DSW::joint_make_damped_spring(RID p_joint, const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) { - Body2DSW *A = body_owner.getornull(p_body_a); + Body2DSW *A = body_owner.get_or_null(p_body_a); ERR_FAIL_COND(!A); - Body2DSW *B = body_owner.getornull(p_body_b); + Body2DSW *B = body_owner.get_or_null(p_body_b); ERR_FAIL_COND(!B); - Joint2DSW *prev_joint = joint_owner.getornull(p_joint); + Joint2DSW *prev_joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND(prev_joint == nullptr); Joint2DSW *joint = memnew(DampedSpringJoint2DSW(p_anchor_a, p_anchor_b, A, B)); @@ -1120,7 +1108,7 @@ void PhysicsServer2DSW::joint_make_damped_spring(RID p_joint, const Vector2 &p_a } void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) { - Joint2DSW *j = joint_owner.getornull(p_joint); + Joint2DSW *j = joint_owner.get_or_null(p_joint); ERR_FAIL_COND(!j); ERR_FAIL_COND(j->get_type() != JOINT_TYPE_PIN); @@ -1129,7 +1117,7 @@ void PhysicsServer2DSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, } real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const { - Joint2DSW *j = joint_owner.getornull(p_joint); + Joint2DSW *j = joint_owner.get_or_null(p_joint); ERR_FAIL_COND_V(!j, 0); ERR_FAIL_COND_V(j->get_type() != JOINT_TYPE_PIN, 0); @@ -1138,7 +1126,7 @@ real_t PhysicsServer2DSW::pin_joint_get_param(RID p_joint, PinJointParam p_param } void PhysicsServer2DSW::damped_spring_joint_set_param(RID p_joint, DampedSpringParam p_param, real_t p_value) { - Joint2DSW *j = joint_owner.getornull(p_joint); + Joint2DSW *j = joint_owner.get_or_null(p_joint); ERR_FAIL_COND(!j); ERR_FAIL_COND(j->get_type() != JOINT_TYPE_DAMPED_SPRING); @@ -1147,7 +1135,7 @@ void PhysicsServer2DSW::damped_spring_joint_set_param(RID p_joint, DampedSpringP } real_t PhysicsServer2DSW::damped_spring_joint_get_param(RID p_joint, DampedSpringParam p_param) const { - Joint2DSW *j = joint_owner.getornull(p_joint); + Joint2DSW *j = joint_owner.get_or_null(p_joint); ERR_FAIL_COND_V(!j, 0); ERR_FAIL_COND_V(j->get_type() != JOINT_TYPE_DAMPED_SPRING, 0); @@ -1156,7 +1144,7 @@ real_t PhysicsServer2DSW::damped_spring_joint_get_param(RID p_joint, DampedSprin } PhysicsServer2D::JointType PhysicsServer2DSW::joint_get_type(RID p_joint) const { - Joint2DSW *joint = joint_owner.getornull(p_joint); + Joint2DSW *joint = joint_owner.get_or_null(p_joint); ERR_FAIL_COND_V(!joint, JOINT_TYPE_PIN); return joint->get_type(); @@ -1166,7 +1154,7 @@ void PhysicsServer2DSW::free(RID p_rid) { _update_shapes(); // just in case if (shape_owner.owns(p_rid)) { - Shape2DSW *shape = shape_owner.getornull(p_rid); + Shape2DSW *shape = shape_owner.get_or_null(p_rid); while (shape->get_owners().size()) { ShapeOwner2DSW *so = shape->get_owners().front()->key(); @@ -1176,7 +1164,7 @@ void PhysicsServer2DSW::free(RID p_rid) { shape_owner.free(p_rid); memdelete(shape); } else if (body_owner.owns(p_rid)) { - Body2DSW *body = body_owner.getornull(p_rid); + Body2DSW *body = body_owner.get_or_null(p_rid); /* if (body->get_state_query()) @@ -1196,7 +1184,7 @@ void PhysicsServer2DSW::free(RID p_rid) { memdelete(body); } else if (area_owner.owns(p_rid)) { - Area2DSW *area = area_owner.getornull(p_rid); + Area2DSW *area = area_owner.get_or_null(p_rid); /* if (area->get_monitor_query()) @@ -1212,7 +1200,7 @@ void PhysicsServer2DSW::free(RID p_rid) { area_owner.free(p_rid); memdelete(area); } else if (space_owner.owns(p_rid)) { - Space2DSW *space = space_owner.getornull(p_rid); + Space2DSW *space = space_owner.get_or_null(p_rid); while (space->get_objects().size()) { CollisionObject2DSW *co = (CollisionObject2DSW *)space->get_objects().front()->get(); @@ -1224,7 +1212,7 @@ void PhysicsServer2DSW::free(RID p_rid) { space_owner.free(p_rid); memdelete(space); } else if (joint_owner.owns(p_rid)) { - Joint2DSW *joint = joint_owner.getornull(p_rid); + Joint2DSW *joint = joint_owner.get_or_null(p_rid); joint_owner.free(p_rid); memdelete(joint); diff --git a/servers/physics_2d/physics_server_2d_sw.h b/servers/physics_2d/physics_server_2d_sw.h index 1db4dd8343..1f35e83995 100644 --- a/servers/physics_2d/physics_server_2d_sw.h +++ b/servers/physics_2d/physics_server_2d_sw.h @@ -177,12 +177,10 @@ public: virtual void body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform = Transform2D(), bool p_disabled = false) override; virtual void body_set_shape(RID p_body, int p_shape_idx, RID p_shape) override; virtual void body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) override; - virtual void body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) override; virtual int body_get_shape_count(RID p_body) const override; virtual RID body_get_shape(RID p_body, int p_shape_idx) const override; virtual Transform2D body_get_shape_transform(RID p_body, int p_shape_idx) const override; - virtual Variant body_get_shape_metadata(RID p_body, int p_shape_idx) const override; virtual void body_remove_shape(RID p_body, int p_shape_idx) override; virtual void body_clear_shapes(RID p_body) override; diff --git a/servers/physics_2d/physics_server_2d_wrap_mt.h b/servers/physics_2d/physics_server_2d_wrap_mt.h index f8733863aa..7925344d76 100644 --- a/servers/physics_2d/physics_server_2d_wrap_mt.h +++ b/servers/physics_2d/physics_server_2d_wrap_mt.h @@ -184,11 +184,9 @@ public: FUNC4(body_add_shape, RID, RID, const Transform2D &, bool); FUNC3(body_set_shape, RID, int, RID); FUNC3(body_set_shape_transform, RID, int, const Transform2D &); - FUNC3(body_set_shape_metadata, RID, int, const Variant &); FUNC1RC(int, body_get_shape_count, RID); FUNC2RC(Transform2D, body_get_shape_transform, RID, int); - FUNC2RC(Variant, body_get_shape_metadata, RID, int); FUNC2RC(RID, body_get_shape, RID, int); FUNC3(body_set_shape_disabled, RID, int, bool); diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 1058f75407..5cd9bf3223 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -105,7 +105,6 @@ int PhysicsDirectSpaceState2DSW::_intersect_point_impl(const Vector2 &p_point, S } r_results[cc].rid = col_obj->get_self(); r_results[cc].shape = shape_idx; - r_results[cc].metadata = col_obj->get_shape_metadata(shape_idx); cc++; } @@ -193,7 +192,6 @@ bool PhysicsDirectSpaceState2DSW::intersect_ray(const Vector2 &p_from, const Vec r_result.collider = ObjectDB::get_instance(r_result.collider_id); } r_result.normal = res_normal; - r_result.metadata = res_obj->get_shape_metadata(res_shape); r_result.position = res_point; r_result.rid = res_obj->get_self(); r_result.shape = res_shape; @@ -206,7 +204,7 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans return 0; } - Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape); ERR_FAIL_COND_V(!shape, 0); Rect2 aabb = p_xform.xform(shape->get_aabb()); @@ -242,7 +240,6 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans } r_results[cc].rid = col_obj->get_self(); r_results[cc].shape = shape_idx; - r_results[cc].metadata = col_obj->get_shape_metadata(shape_idx); cc++; } @@ -251,7 +248,7 @@ int PhysicsDirectSpaceState2DSW::intersect_shape(const RID &p_shape, const Trans } bool PhysicsDirectSpaceState2DSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape); ERR_FAIL_COND_V(!shape, false); Rect2 aabb = p_xform.xform(shape->get_aabb()); @@ -338,7 +335,7 @@ bool PhysicsDirectSpaceState2DSW::collide_shape(RID p_shape, const Transform2D & return false; } - Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape); ERR_FAIL_COND_V(!shape, 0); Rect2 aabb = p_shape_xform.xform(shape->get_aabb()); @@ -435,7 +432,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B, } bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) { - Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.getornull(p_shape); + Shape2DSW *shape = PhysicsServer2DSW::singletonsw->shape_owner.get_or_null(p_shape); ERR_FAIL_COND_V(!shape, 0); real_t min_contact_depth = p_margin * TEST_MOTION_MIN_CONTACT_DEPTH_FACTOR; @@ -484,7 +481,6 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh r_info->normal = rcd.best_normal; r_info->point = rcd.best_contact; r_info->rid = rcd.best_object->get_self(); - r_info->metadata = rcd.best_object->get_shape_metadata(rcd.best_shape); if (rcd.best_object->get_type() == CollisionObject2DSW::TYPE_BODY) { const Body2DSW *body = static_cast<const Body2DSW *>(rcd.best_object); Vector2 rel_vec = r_info->point - (body->get_transform().get_origin() + body->get_center_of_mass()); @@ -961,7 +957,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co r_result->collision_depth = rcd.best_len; r_result->collision_safe_fraction = safe; r_result->collision_unsafe_fraction = unsafe; - r_result->collider_metadata = rcd.best_object->get_shape_metadata(rcd.best_shape); const Body2DSW *body = static_cast<const Body2DSW *>(rcd.best_object); Vector2 rel_vec = r_result->collision_point - (body->get_transform().get_origin() + body->get_center_of_mass()); |