summaryrefslogtreecommitdiff
path: root/servers/physics_2d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2019-06-10 12:38:51 -0300
committerJuan Linietsky <reduzio@gmail.com>2020-02-11 11:53:26 +0100
commit4f163972bbd9c7379b01a1f9aa5310646ca7865e (patch)
tree3bbf4693663d8fc071912c114af782736ea17168 /servers/physics_2d
parent1522d8c3ee6ddf43267f124940f4e43612058407 (diff)
Refactored RID/RID_Owner to always use O(1) allocation.
* Implements a growing chunked allocator * Removed redudant methods get and getptr, only getornull is supported now.
Diffstat (limited to 'servers/physics_2d')
-rw-r--r--servers/physics_2d/body_2d_sw.cpp2
-rw-r--r--servers/physics_2d/constraint_2d_sw.h2
-rw-r--r--servers/physics_2d/physics_2d_server_sw.cpp262
-rw-r--r--servers/physics_2d/physics_2d_server_sw.h11
-rw-r--r--servers/physics_2d/shape_2d_sw.h4
-rw-r--r--servers/physics_2d/space_2d_sw.cpp8
-rw-r--r--servers/physics_2d/space_2d_sw.h2
7 files changed, 146 insertions, 145 deletions
diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp
index 225aab3a92..b973fa75a9 100644
--- a/servers/physics_2d/body_2d_sw.cpp
+++ b/servers/physics_2d/body_2d_sw.cpp
@@ -721,7 +721,7 @@ Variant Physics2DDirectBodyStateSW::get_contact_collider_shape_metadata(int p_co
return Variant();
}
- Body2DSW *other = Physics2DServerSW::singletonsw->body_owner.get(body->contacts[p_contact_idx].collider);
+ Body2DSW *other = Physics2DServerSW::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()) {
diff --git a/servers/physics_2d/constraint_2d_sw.h b/servers/physics_2d/constraint_2d_sw.h
index f3314f0ffc..6f99b3fb5d 100644
--- a/servers/physics_2d/constraint_2d_sw.h
+++ b/servers/physics_2d/constraint_2d_sw.h
@@ -33,7 +33,7 @@
#include "body_2d_sw.h"
-class Constraint2DSW : public RID_Data {
+class Constraint2DSW {
Body2DSW **_body_ptr;
int _body_count;
diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp
index 809c5c40e0..65873d9612 100644
--- a/servers/physics_2d/physics_2d_server_sw.cpp
+++ b/servers/physics_2d/physics_2d_server_sw.cpp
@@ -126,28 +126,28 @@ RID Physics2DServerSW::concave_polygon_shape_create() {
void Physics2DServerSW::shape_set_data(RID p_shape, const Variant &p_data) {
- Shape2DSW *shape = shape_owner.get(p_shape);
+ Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_data(p_data);
};
void Physics2DServerSW::shape_set_custom_solver_bias(RID p_shape, real_t p_bias) {
- Shape2DSW *shape = shape_owner.get(p_shape);
+ Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
shape->set_custom_bias(p_bias);
}
Physics2DServer::ShapeType Physics2DServerSW::shape_get_type(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.get(p_shape);
+ const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, SHAPE_CUSTOM);
return shape->get_type();
};
Variant Physics2DServerSW::shape_get_data(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.get(p_shape);
+ const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, Variant());
ERR_FAIL_COND_V(!shape->is_configured(), Variant());
return shape->get_data();
@@ -155,7 +155,7 @@ Variant Physics2DServerSW::shape_get_data(RID p_shape) const {
real_t Physics2DServerSW::shape_get_custom_solver_bias(RID p_shape) const {
- const Shape2DSW *shape = shape_owner.get(p_shape);
+ const Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
return shape->get_custom_bias();
}
@@ -219,9 +219,9 @@ void Physics2DServerSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
bool Physics2DServerSW::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.get(p_shape_A);
+ Shape2DSW *shape_A = shape_owner.getornull(p_shape_A);
ERR_FAIL_COND_V(!shape_A, false);
- Shape2DSW *shape_B = shape_owner.get(p_shape_B);
+ Shape2DSW *shape_B = shape_owner.getornull(p_shape_B);
ERR_FAIL_COND_V(!shape_B, false);
if (p_result_max == 0) {
@@ -246,7 +246,7 @@ RID Physics2DServerSW::space_create() {
RID id = space_owner.make_rid(space);
space->set_self(id);
RID area_id = area_create();
- Area2DSW *area = area_owner.get(area_id);
+ Area2DSW *area = area_owner.getornull(area_id);
ERR_FAIL_COND_V(!area, RID());
space->set_default_area(area);
area->set_space(space);
@@ -257,7 +257,7 @@ RID Physics2DServerSW::space_create() {
void Physics2DServerSW::space_set_active(RID p_space, bool p_active) {
- Space2DSW *space = space_owner.get(p_space);
+ Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
if (p_active)
active_spaces.insert(space);
@@ -267,7 +267,7 @@ void Physics2DServerSW::space_set_active(RID p_space, bool p_active) {
bool Physics2DServerSW::space_is_active(RID p_space) const {
- const Space2DSW *space = space_owner.get(p_space);
+ const Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, false);
return active_spaces.has(space);
@@ -275,7 +275,7 @@ bool Physics2DServerSW::space_is_active(RID p_space) const {
void Physics2DServerSW::space_set_param(RID p_space, SpaceParameter p_param, real_t p_value) {
- Space2DSW *space = space_owner.get(p_space);
+ Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_param(p_param, p_value);
@@ -283,35 +283,35 @@ void Physics2DServerSW::space_set_param(RID p_space, SpaceParameter p_param, rea
real_t Physics2DServerSW::space_get_param(RID p_space, SpaceParameter p_param) const {
- const Space2DSW *space = space_owner.get(p_space);
+ const Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_param(p_param);
}
void Physics2DServerSW::space_set_debug_contacts(RID p_space, int p_max_contacts) {
- Space2DSW *space = space_owner.get(p_space);
+ Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
space->set_debug_contacts(p_max_contacts);
}
Vector<Vector2> Physics2DServerSW::space_get_contacts(RID p_space) const {
- Space2DSW *space = space_owner.get(p_space);
+ Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, Vector<Vector2>());
return space->get_debug_contacts();
}
int Physics2DServerSW::space_get_contact_count(RID p_space) const {
- Space2DSW *space = space_owner.get(p_space);
+ Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, 0);
return space->get_debug_contact_count();
}
Physics2DDirectSpaceState *Physics2DServerSW::space_get_direct_state(RID p_space) {
- Space2DSW *space = space_owner.get(p_space);
+ Space2DSW *space = space_owner.getornull(p_space);
ERR_FAIL_COND_V(!space, NULL);
ERR_FAIL_COND_V_MSG((using_threads && !doing_sync) || space->is_locked(), NULL, "Space state is inaccessible right now, wait for iteration or physics process notification.");
@@ -328,12 +328,12 @@ RID Physics2DServerSW::area_create() {
void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
Space2DSW *space = NULL;
if (p_space.is_valid()) {
- space = space_owner.get(p_space);
+ space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
}
@@ -346,7 +346,7 @@ void Physics2DServerSW::area_set_space(RID p_area, RID p_space) {
RID Physics2DServerSW::area_get_space(RID p_area) const {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
Space2DSW *space = area->get_space();
@@ -357,7 +357,7 @@ RID Physics2DServerSW::area_get_space(RID p_area) const {
void Physics2DServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_space_override_mode(p_mode);
@@ -365,7 +365,7 @@ void Physics2DServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverri
Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_override_mode(RID p_area) const {
- const Area2DSW *area = area_owner.get(p_area);
+ const Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, AREA_SPACE_OVERRIDE_DISABLED);
return area->get_space_override_mode();
@@ -373,10 +373,10 @@ Physics2DServer::AreaSpaceOverrideMode Physics2DServerSW::area_get_space_overrid
void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- Shape2DSW *shape = shape_owner.get(p_shape);
+ Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
area->add_shape(shape, p_transform, p_disabled);
@@ -384,10 +384,10 @@ void Physics2DServerSW::area_add_shape(RID p_area, RID p_shape, const Transform2
void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- Shape2DSW *shape = shape_owner.get(p_shape);
+ Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -395,7 +395,7 @@ void Physics2DServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape)
}
void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, const Transform2D &p_transform) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_shape_transform(p_shape_idx, p_transform);
@@ -403,7 +403,7 @@ void Physics2DServerSW::area_set_shape_transform(RID p_area, int p_shape_idx, co
void Physics2DServerSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_disabled) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
ERR_FAIL_INDEX(p_shape, area->get_shape_count());
FLUSH_QUERY_CHECK(area);
@@ -413,14 +413,14 @@ void Physics2DServerSW::area_set_shape_disabled(RID p_area, int p_shape, bool p_
int Physics2DServerSW::area_get_shape_count(RID p_area) const {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, -1);
return area->get_shape_count();
}
RID Physics2DServerSW::area_get_shape(RID p_area, int p_shape_idx) const {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, RID());
Shape2DSW *shape = area->get_shape(p_shape_idx);
@@ -430,7 +430,7 @@ RID Physics2DServerSW::area_get_shape(RID p_area, int p_shape_idx) const {
}
Transform2D Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_idx) const {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
return area->get_shape_transform(p_shape_idx);
@@ -438,7 +438,7 @@ Transform2D Physics2DServerSW::area_get_shape_transform(RID p_area, int p_shape_
void Physics2DServerSW::area_remove_shape(RID p_area, int p_shape_idx) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->remove_shape(p_shape_idx);
@@ -446,7 +446,7 @@ void Physics2DServerSW::area_remove_shape(RID p_area, int p_shape_idx) {
void Physics2DServerSW::area_clear_shapes(RID p_area) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
while (area->get_shape_count())
@@ -456,20 +456,20 @@ void Physics2DServerSW::area_clear_shapes(RID p_area) {
void Physics2DServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.get(p_area);
+ Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_instance_id(p_id);
}
ObjectID Physics2DServerSW::area_get_object_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.get(p_area);
+ Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, 0);
return area->get_instance_id();
}
@@ -477,20 +477,20 @@ ObjectID Physics2DServerSW::area_get_object_instance_id(RID p_area) const {
void Physics2DServerSW::area_attach_canvas_instance_id(RID p_area, ObjectID p_id) {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.get(p_area);
+ Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_canvas_instance_id(p_id);
}
ObjectID Physics2DServerSW::area_get_canvas_instance_id(RID p_area) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.get(p_area);
+ Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, 0);
return area->get_canvas_instance_id();
}
@@ -498,17 +498,17 @@ ObjectID Physics2DServerSW::area_get_canvas_instance_id(RID p_area) const {
void Physics2DServerSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.get(p_area);
+ Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_param(p_param, p_value);
};
void Physics2DServerSW::area_set_transform(RID p_area, const Transform2D &p_transform) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_transform(p_transform);
};
@@ -516,10 +516,10 @@ void Physics2DServerSW::area_set_transform(RID p_area, const Transform2D &p_tran
Variant Physics2DServerSW::area_get_param(RID p_area, AreaParameter p_param) const {
if (space_owner.owns(p_area)) {
- Space2DSW *space = space_owner.get(p_area);
+ Space2DSW *space = space_owner.getornull(p_area);
p_area = space->get_default_area()->get_self();
}
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Variant());
return area->get_param(p_param);
@@ -527,7 +527,7 @@ Variant Physics2DServerSW::area_get_param(RID p_area, AreaParameter p_param) con
Transform2D Physics2DServerSW::area_get_transform(RID p_area) const {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND_V(!area, Transform2D());
return area->get_transform();
@@ -535,14 +535,14 @@ Transform2D Physics2DServerSW::area_get_transform(RID p_area) const {
void Physics2DServerSW::area_set_pickable(RID p_area, bool p_pickable) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_pickable(p_pickable);
}
void Physics2DServerSW::area_set_monitorable(RID p_area, bool p_monitorable) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
FLUSH_QUERY_CHECK(area);
@@ -551,7 +551,7 @@ void Physics2DServerSW::area_set_monitorable(RID p_area, bool p_monitorable) {
void Physics2DServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_mask(p_mask);
@@ -559,7 +559,7 @@ void Physics2DServerSW::area_set_collision_mask(RID p_area, uint32_t p_mask) {
void Physics2DServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_collision_layer(p_layer);
@@ -567,7 +567,7 @@ void Physics2DServerSW::area_set_collision_layer(RID p_area, uint32_t p_layer) {
void Physics2DServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method);
@@ -575,7 +575,7 @@ void Physics2DServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver
void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) {
- Area2DSW *area = area_owner.get(p_area);
+ Area2DSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method);
@@ -593,11 +593,11 @@ RID Physics2DServerSW::body_create() {
void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
Space2DSW *space = NULL;
if (p_space.is_valid()) {
- space = space_owner.get(p_space);
+ space = space_owner.getornull(p_space);
ERR_FAIL_COND(!space);
}
@@ -610,7 +610,7 @@ void Physics2DServerSW::body_set_space(RID p_body, RID p_space) {
RID Physics2DServerSW::body_get_space(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
Space2DSW *space = body->get_space();
@@ -621,7 +621,7 @@ RID Physics2DServerSW::body_get_space(RID p_body) const {
void Physics2DServerSW::body_set_mode(RID p_body, BodyMode p_mode) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
FLUSH_QUERY_CHECK(body);
@@ -630,7 +630,7 @@ void Physics2DServerSW::body_set_mode(RID p_body, BodyMode p_mode) {
Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, BODY_MODE_STATIC);
return body->get_mode();
@@ -638,10 +638,10 @@ Physics2DServer::BodyMode Physics2DServerSW::body_get_mode(RID p_body) const {
void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2D &p_transform, bool p_disabled) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- Shape2DSW *shape = shape_owner.get(p_shape);
+ Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
body->add_shape(shape, p_transform, p_disabled);
@@ -649,10 +649,10 @@ void Physics2DServerSW::body_add_shape(RID p_body, RID p_shape, const Transform2
void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
- Shape2DSW *shape = shape_owner.get(p_shape);
+ Shape2DSW *shape = shape_owner.getornull(p_shape);
ERR_FAIL_COND(!shape);
ERR_FAIL_COND(!shape->is_configured());
@@ -660,7 +660,7 @@ void Physics2DServerSW::body_set_shape(RID p_body, int p_shape_idx, RID p_shape)
}
void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, const Transform2D &p_transform) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_transform(p_shape_idx, p_transform);
@@ -668,28 +668,28 @@ void Physics2DServerSW::body_set_shape_transform(RID p_body, int p_shape_idx, co
void Physics2DServerSW::body_set_shape_metadata(RID p_body, int p_shape_idx, const Variant &p_metadata) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_shape_metadata(p_shape_idx, p_metadata);
}
Variant Physics2DServerSW::body_get_shape_metadata(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_shape_metadata(p_shape_idx);
}
int Physics2DServerSW::body_get_shape_count(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_shape_count();
}
RID Physics2DServerSW::body_get_shape(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, RID());
Shape2DSW *shape = body->get_shape(p_shape_idx);
@@ -699,7 +699,7 @@ RID Physics2DServerSW::body_get_shape(RID p_body, int p_shape_idx) const {
}
Transform2D Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_idx) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Transform2D());
return body->get_shape_transform(p_shape_idx);
@@ -707,7 +707,7 @@ Transform2D Physics2DServerSW::body_get_shape_transform(RID p_body, int p_shape_
void Physics2DServerSW::body_remove_shape(RID p_body, int p_shape_idx) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_shape(p_shape_idx);
@@ -715,7 +715,7 @@ void Physics2DServerSW::body_remove_shape(RID p_body, int p_shape_idx) {
void Physics2DServerSW::body_clear_shapes(RID p_body) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
while (body->get_shape_count())
@@ -724,7 +724,7 @@ void Physics2DServerSW::body_clear_shapes(RID p_body) {
void Physics2DServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, bool p_disabled) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -733,7 +733,7 @@ void Physics2DServerSW::body_set_shape_disabled(RID p_body, int p_shape_idx, boo
}
void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_shape_idx, bool p_enable, float p_margin) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
ERR_FAIL_INDEX(p_shape_idx, body->get_shape_count());
FLUSH_QUERY_CHECK(body);
@@ -743,14 +743,14 @@ void Physics2DServerSW::body_set_shape_as_one_way_collision(RID p_body, int p_sh
void Physics2DServerSW::body_set_continuous_collision_detection_mode(RID p_body, CCDMode p_mode) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_continuous_collision_detection_mode(p_mode);
}
Physics2DServerSW::CCDMode Physics2DServerSW::body_get_continuous_collision_detection_mode(RID p_body) const {
- const Body2DSW *body = body_owner.get(p_body);
+ const Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, CCD_MODE_DISABLED);
return body->get_continuous_collision_detection_mode();
@@ -758,7 +758,7 @@ Physics2DServerSW::CCDMode Physics2DServerSW::body_get_continuous_collision_dete
void Physics2DServerSW::body_attach_object_instance_id(RID p_body, uint32_t p_id) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_instance_id(p_id);
@@ -766,7 +766,7 @@ void Physics2DServerSW::body_attach_object_instance_id(RID p_body, uint32_t p_id
uint32_t Physics2DServerSW::body_get_object_instance_id(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_instance_id();
@@ -774,7 +774,7 @@ uint32_t Physics2DServerSW::body_get_object_instance_id(RID p_body) const {
void Physics2DServerSW::body_attach_canvas_instance_id(RID p_body, uint32_t p_id) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_canvas_instance_id(p_id);
@@ -782,7 +782,7 @@ void Physics2DServerSW::body_attach_canvas_instance_id(RID p_body, uint32_t p_id
uint32_t Physics2DServerSW::body_get_canvas_instance_id(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_canvas_instance_id();
@@ -790,14 +790,14 @@ uint32_t Physics2DServerSW::body_get_canvas_instance_id(RID p_body) const {
void Physics2DServerSW::body_set_collision_layer(RID p_body, uint32_t p_layer) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_layer(p_layer);
};
uint32_t Physics2DServerSW::body_get_collision_layer(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_layer();
@@ -805,14 +805,14 @@ uint32_t Physics2DServerSW::body_get_collision_layer(RID p_body) const {
void Physics2DServerSW::body_set_collision_mask(RID p_body, uint32_t p_mask) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_collision_mask(p_mask);
};
uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_collision_mask();
@@ -820,7 +820,7 @@ uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body) const {
void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t p_value) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_param(p_param, p_value);
@@ -828,7 +828,7 @@ void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, real_t
real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_param(p_param);
@@ -836,7 +836,7 @@ real_t Physics2DServerSW::body_get_param(RID p_body, BodyParameter p_param) cons
void Physics2DServerSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_state(p_state, p_variant);
@@ -844,7 +844,7 @@ void Physics2DServerSW::body_set_state(RID p_body, BodyState p_state, const Vari
Variant Physics2DServerSW::body_get_state(RID p_body, BodyState p_state) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Variant());
return body->get_state(p_state);
@@ -852,7 +852,7 @@ Variant Physics2DServerSW::body_get_state(RID p_body, BodyState p_state) const {
void Physics2DServerSW::body_set_applied_force(RID p_body, const Vector2 &p_force) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_force(p_force);
@@ -861,14 +861,14 @@ void Physics2DServerSW::body_set_applied_force(RID p_body, const Vector2 &p_forc
Vector2 Physics2DServerSW::body_get_applied_force(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, Vector2());
return body->get_applied_force();
};
void Physics2DServerSW::body_set_applied_torque(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_applied_torque(p_torque);
@@ -877,14 +877,14 @@ void Physics2DServerSW::body_set_applied_torque(RID p_body, real_t p_torque) {
real_t Physics2DServerSW::body_get_applied_torque(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return body->get_applied_torque();
};
void Physics2DServerSW::body_apply_central_impulse(RID p_body, const Vector2 &p_impulse) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->apply_central_impulse(p_impulse);
@@ -892,7 +892,7 @@ void Physics2DServerSW::body_apply_central_impulse(RID p_body, const Vector2 &p_
}
void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -902,7 +902,7 @@ void Physics2DServerSW::body_apply_torque_impulse(RID p_body, real_t p_torque) {
void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, const Vector2 &p_impulse) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -912,7 +912,7 @@ void Physics2DServerSW::body_apply_impulse(RID p_body, const Vector2 &p_pos, con
};
void Physics2DServerSW::body_add_central_force(RID p_body, const Vector2 &p_force) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->add_central_force(p_force);
@@ -921,7 +921,7 @@ void Physics2DServerSW::body_add_central_force(RID p_body, const Vector2 &p_forc
void Physics2DServerSW::body_add_force(RID p_body, const Vector2 &p_offset, const Vector2 &p_force) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->add_force(p_offset, p_force);
@@ -929,7 +929,7 @@ void Physics2DServerSW::body_add_force(RID p_body, const Vector2 &p_offset, cons
};
void Physics2DServerSW::body_add_torque(RID p_body, real_t p_torque) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->add_torque(p_torque);
@@ -938,7 +938,7 @@ void Physics2DServerSW::body_add_torque(RID p_body, real_t p_torque) {
void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis_velocity) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
_update_shapes();
@@ -953,7 +953,7 @@ void Physics2DServerSW::body_set_axis_velocity(RID p_body, const Vector2 &p_axis
void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->add_exception(p_body_b);
@@ -962,7 +962,7 @@ void Physics2DServerSW::body_add_collision_exception(RID p_body, RID p_body_b) {
void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->remove_exception(p_body_b);
@@ -971,7 +971,7 @@ void Physics2DServerSW::body_remove_collision_exception(RID p_body, RID p_body_b
void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_exceptions) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
for (int i = 0; i < body->get_exceptions().size(); i++) {
@@ -981,20 +981,20 @@ void Physics2DServerSW::body_get_collision_exceptions(RID p_body, List<RID> *p_e
void Physics2DServerSW::body_set_contacts_reported_depth_threshold(RID p_body, real_t p_threshold) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
};
real_t Physics2DServerSW::body_get_contacts_reported_depth_threshold(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, 0);
return 0;
};
void Physics2DServerSW::body_set_omit_force_integration(RID p_body, bool p_omit) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_omit_force_integration(p_omit);
@@ -1002,35 +1002,35 @@ void Physics2DServerSW::body_set_omit_force_integration(RID p_body, bool p_omit)
bool Physics2DServerSW::body_is_omitting_force_integration(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
return body->get_omit_force_integration();
};
void Physics2DServerSW::body_set_max_contacts_reported(RID p_body, int p_contacts) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_max_contacts_reported(p_contacts);
}
int Physics2DServerSW::body_get_max_contacts_reported(RID p_body) const {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, -1);
return body->get_max_contacts_reported();
}
void Physics2DServerSW::body_set_force_integration_callback(RID p_body, Object *p_receiver, const StringName &p_method, const Variant &p_udata) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(0), p_method, p_udata);
}
bool Physics2DServerSW::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.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, false);
ERR_FAIL_INDEX_V(p_body_shape, body->get_shape_count(), false);
@@ -1039,14 +1039,14 @@ bool Physics2DServerSW::body_collide_shape(RID p_body, int p_body_shape, RID p_s
void Physics2DServerSW::body_set_pickable(RID p_body, bool p_pickable) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
body->set_pickable(p_pickable);
}
bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from, const Vector2 &p_motion, bool p_infinite_inertia, real_t p_margin, MotionResult *r_result, bool p_exclude_raycast_shapes) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(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);
@@ -1058,7 +1058,7 @@ bool Physics2DServerSW::body_test_motion(RID p_body, const Transform2D &p_from,
int Physics2DServerSW::body_test_ray_separation(RID p_body, const Transform2D &p_transform, bool p_infinite_inertia, Vector2 &r_recover_motion, SeparationResult *r_results, int p_result_max, float p_margin) {
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(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);
@@ -1073,7 +1073,7 @@ Physics2DDirectBodyState *Physics2DServerSW::body_get_direct_state(RID p_body) {
if (!body_owner.owns(p_body))
return NULL;
- Body2DSW *body = body_owner.get(p_body);
+ Body2DSW *body = body_owner.getornull(p_body);
ERR_FAIL_COND_V(!body, NULL);
ERR_FAIL_COND_V(!body->get_space(), NULL);
ERR_FAIL_COND_V_MSG(body->get_space()->is_locked(), NULL, "Body state is inaccessible right now, wait for iteration or physics process notification.");
@@ -1086,7 +1086,7 @@ Physics2DDirectBodyState *Physics2DServerSW::body_get_direct_state(RID p_body) {
void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t p_value) {
- Joint2DSW *joint = joint_owner.get(p_joint);
+ Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
switch (p_param) {
@@ -1098,7 +1098,7 @@ void Physics2DServerSW::joint_set_param(RID p_joint, JointParam p_param, real_t
real_t Physics2DServerSW::joint_get_param(RID p_joint, JointParam p_param) const {
- const Joint2DSW *joint = joint_owner.get(p_joint);
+ const Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, -1);
switch (p_param) {
@@ -1111,7 +1111,7 @@ real_t Physics2DServerSW::joint_get_param(RID p_joint, JointParam p_param) const
}
void Physics2DServerSW::joint_disable_collisions_between_bodies(RID p_joint, const bool p_disable) {
- Joint2DSW *joint = joint_owner.get(p_joint);
+ Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!joint);
joint->disable_collisions_between_bodies(p_disable);
@@ -1131,7 +1131,7 @@ void Physics2DServerSW::joint_disable_collisions_between_bodies(RID p_joint, con
}
bool Physics2DServerSW::joint_is_disabled_collisions_between_bodies(RID p_joint) const {
- const Joint2DSW *joint = joint_owner.get(p_joint);
+ const Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, true);
return joint->is_disabled_collisions_between_bodies();
@@ -1139,11 +1139,11 @@ bool Physics2DServerSW::joint_is_disabled_collisions_between_bodies(RID p_joint)
RID Physics2DServerSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID p_body_b) {
- Body2DSW *A = body_owner.get(p_body_a);
+ Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
Body2DSW *B = NULL;
if (body_owner.owns(p_body_b)) {
- B = body_owner.get(p_body_b);
+ B = body_owner.getornull(p_body_b);
ERR_FAIL_COND_V(!B, RID());
}
@@ -1156,10 +1156,10 @@ RID Physics2DServerSW::pin_joint_create(const Vector2 &p_pos, RID p_body_a, RID
RID Physics2DServerSW::groove_joint_create(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.get(p_body_a);
+ Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
- Body2DSW *B = body_owner.get(p_body_b);
+ Body2DSW *B = body_owner.getornull(p_body_b);
ERR_FAIL_COND_V(!B, RID());
Joint2DSW *joint = memnew(GrooveJoint2DSW(p_a_groove1, p_a_groove2, p_b_anchor, A, B));
@@ -1170,10 +1170,10 @@ RID Physics2DServerSW::groove_joint_create(const Vector2 &p_a_groove1, const Vec
RID Physics2DServerSW::damped_spring_joint_create(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, RID p_body_a, RID p_body_b) {
- Body2DSW *A = body_owner.get(p_body_a);
+ Body2DSW *A = body_owner.getornull(p_body_a);
ERR_FAIL_COND_V(!A, RID());
- Body2DSW *B = body_owner.get(p_body_b);
+ Body2DSW *B = body_owner.getornull(p_body_b);
ERR_FAIL_COND_V(!B, RID());
Joint2DSW *joint = memnew(DampedSpringJoint2DSW(p_anchor_a, p_anchor_b, A, B));
@@ -1184,7 +1184,7 @@ RID Physics2DServerSW::damped_spring_joint_create(const Vector2 &p_anchor_a, con
void Physics2DServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param, real_t p_value) {
- Joint2DSW *j = joint_owner.get(p_joint);
+ Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_PIN);
@@ -1193,7 +1193,7 @@ void Physics2DServerSW::pin_joint_set_param(RID p_joint, PinJointParam p_param,
}
real_t Physics2DServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param) const {
- Joint2DSW *j = joint_owner.get(p_joint);
+ Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_PIN, 0);
@@ -1203,7 +1203,7 @@ real_t Physics2DServerSW::pin_joint_get_param(RID p_joint, PinJointParam p_param
void Physics2DServerSW::damped_string_joint_set_param(RID p_joint, DampedStringParam p_param, real_t p_value) {
- Joint2DSW *j = joint_owner.get(p_joint);
+ Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND(!j);
ERR_FAIL_COND(j->get_type() != JOINT_DAMPED_SPRING);
@@ -1213,7 +1213,7 @@ void Physics2DServerSW::damped_string_joint_set_param(RID p_joint, DampedStringP
real_t Physics2DServerSW::damped_string_joint_get_param(RID p_joint, DampedStringParam p_param) const {
- Joint2DSW *j = joint_owner.get(p_joint);
+ Joint2DSW *j = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!j, 0);
ERR_FAIL_COND_V(j->get_type() != JOINT_DAMPED_SPRING, 0);
@@ -1223,7 +1223,7 @@ real_t Physics2DServerSW::damped_string_joint_get_param(RID p_joint, DampedStrin
Physics2DServer::JointType Physics2DServerSW::joint_get_type(RID p_joint) const {
- Joint2DSW *joint = joint_owner.get(p_joint);
+ Joint2DSW *joint = joint_owner.getornull(p_joint);
ERR_FAIL_COND_V(!joint, JOINT_PIN);
return joint->get_type();
@@ -1235,7 +1235,7 @@ void Physics2DServerSW::free(RID p_rid) {
if (shape_owner.owns(p_rid)) {
- Shape2DSW *shape = shape_owner.get(p_rid);
+ Shape2DSW *shape = shape_owner.getornull(p_rid);
while (shape->get_owners().size()) {
ShapeOwner2DSW *so = shape->get_owners().front()->key();
@@ -1246,7 +1246,7 @@ void Physics2DServerSW::free(RID p_rid) {
memdelete(shape);
} else if (body_owner.owns(p_rid)) {
- Body2DSW *body = body_owner.get(p_rid);
+ Body2DSW *body = body_owner.getornull(p_rid);
/*
if (body->get_state_query())
@@ -1268,7 +1268,7 @@ void Physics2DServerSW::free(RID p_rid) {
} else if (area_owner.owns(p_rid)) {
- Area2DSW *area = area_owner.get(p_rid);
+ Area2DSW *area = area_owner.getornull(p_rid);
/*
if (area->get_monitor_query())
@@ -1286,7 +1286,7 @@ void Physics2DServerSW::free(RID p_rid) {
memdelete(area);
} else if (space_owner.owns(p_rid)) {
- Space2DSW *space = space_owner.get(p_rid);
+ Space2DSW *space = space_owner.getornull(p_rid);
while (space->get_objects().size()) {
CollisionObject2DSW *co = (CollisionObject2DSW *)space->get_objects().front()->get();
@@ -1299,7 +1299,7 @@ void Physics2DServerSW::free(RID p_rid) {
memdelete(space);
} else if (joint_owner.owns(p_rid)) {
- Joint2DSW *joint = joint_owner.get(p_rid);
+ Joint2DSW *joint = joint_owner.getornull(p_rid);
joint_owner.free(p_rid);
memdelete(joint);
diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h
index c8f443e3b6..6a636bb72a 100644
--- a/servers/physics_2d/physics_2d_server_sw.h
+++ b/servers/physics_2d/physics_2d_server_sw.h
@@ -31,6 +31,7 @@
#ifndef PHYSICS_2D_SERVER_SW
#define PHYSICS_2D_SERVER_SW
+#include "core/rid_owner.h"
#include "joints_2d_sw.h"
#include "servers/physics_2d_server.h"
#include "shape_2d_sw.h"
@@ -61,11 +62,11 @@ class Physics2DServerSW : public Physics2DServer {
Physics2DDirectBodyStateSW *direct_state;
- mutable RID_Owner<Shape2DSW> shape_owner;
- mutable RID_Owner<Space2DSW> space_owner;
- mutable RID_Owner<Area2DSW> area_owner;
- mutable RID_Owner<Body2DSW> body_owner;
- mutable RID_Owner<Joint2DSW> joint_owner;
+ mutable RID_PtrOwner<Shape2DSW> shape_owner;
+ mutable RID_PtrOwner<Space2DSW> space_owner;
+ mutable RID_PtrOwner<Area2DSW> area_owner;
+ mutable RID_PtrOwner<Body2DSW> body_owner;
+ mutable RID_PtrOwner<Joint2DSW> joint_owner;
static Physics2DServerSW *singletonsw;
diff --git a/servers/physics_2d/shape_2d_sw.h b/servers/physics_2d/shape_2d_sw.h
index a336dcecf5..0a9d55ec4e 100644
--- a/servers/physics_2d/shape_2d_sw.h
+++ b/servers/physics_2d/shape_2d_sw.h
@@ -48,7 +48,7 @@ SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_creat
class Shape2DSW;
-class ShapeOwner2DSW : public RID_Data {
+class ShapeOwner2DSW {
public:
virtual void _shape_changed() = 0;
virtual void remove_shape(Shape2DSW *p_shape) = 0;
@@ -56,7 +56,7 @@ public:
virtual ~ShapeOwner2DSW() {}
};
-class Shape2DSW : public RID_Data {
+class Shape2DSW {
RID self;
Rect2 aabb;
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index 08a261da2a..150fda4322 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -198,7 +198,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans
if (p_result_max <= 0)
return 0;
- Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+ Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -240,7 +240,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans
bool Physics2DDirectSpaceStateSW::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 = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+ Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, false);
Rect2 aabb = p_xform.xform(shape->get_aabb());
@@ -313,7 +313,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
if (p_result_max <= 0)
return 0;
- Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+ Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
@@ -404,7 +404,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
bool Physics2DDirectSpaceStateSW::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 = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
+ Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.getornull(p_shape);
ERR_FAIL_COND_V(!shape, 0);
Rect2 aabb = p_shape_xform.xform(shape->get_aabb());
diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h
index 94f8cf9d71..e4b3714d15 100644
--- a/servers/physics_2d/space_2d_sw.h
+++ b/servers/physics_2d/space_2d_sw.h
@@ -61,7 +61,7 @@ public:
Physics2DDirectSpaceStateSW();
};
-class Space2DSW : public RID_Data {
+class Space2DSW {
public:
enum ElapsedTime {