summaryrefslogtreecommitdiff
path: root/servers/physics
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics')
-rw-r--r--servers/physics/area_sw.cpp10
-rw-r--r--servers/physics/area_sw.h4
-rw-r--r--servers/physics/body_sw.cpp4
-rw-r--r--servers/physics/body_sw.h2
-rw-r--r--servers/physics/collision_object_sw.cpp2
-rw-r--r--servers/physics/physics_server_sw.cpp14
-rw-r--r--servers/physics/physics_server_sw.h4
-rw-r--r--servers/physics/space_sw.cpp8
8 files changed, 23 insertions, 25 deletions
diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp
index 398849edb8..1016afcaba 100644
--- a/servers/physics/area_sw.cpp
+++ b/servers/physics/area_sw.cpp
@@ -175,7 +175,7 @@ void AreaSW::set_monitorable(bool p_monitorable) {
void AreaSW::call_queries() {
- if (monitor_callback_id && !monitored_bodies.empty()) {
+ if (monitor_callback_id.is_valid() && !monitored_bodies.empty()) {
Variant res[5];
Variant *resptr[5];
@@ -185,7 +185,7 @@ void AreaSW::call_queries() {
Object *obj = ObjectDB::get_instance(monitor_callback_id);
if (!obj) {
monitored_bodies.clear();
- monitor_callback_id = 0;
+ monitor_callback_id = ObjectID();
return;
}
@@ -207,7 +207,7 @@ void AreaSW::call_queries() {
monitored_bodies.clear();
- if (area_monitor_callback_id && !monitored_areas.empty()) {
+ if (area_monitor_callback_id.is_valid() && !monitored_areas.empty()) {
Variant res[5];
Variant *resptr[5];
@@ -217,7 +217,7 @@ void AreaSW::call_queries() {
Object *obj = ObjectDB::get_instance(area_monitor_callback_id);
if (!obj) {
monitored_areas.clear();
- area_monitor_callback_id = 0;
+ area_monitor_callback_id = ObjectID();
return;
}
@@ -257,8 +257,6 @@ AreaSW::AreaSW() :
linear_damp = 0.1;
priority = 0;
set_ray_pickable(false);
- monitor_callback_id = 0;
- area_monitor_callback_id = 0;
monitorable = false;
}
diff --git a/servers/physics/area_sw.h b/servers/physics/area_sw.h
index 846243a133..4da2b00d20 100644
--- a/servers/physics/area_sw.h
+++ b/servers/physics/area_sw.h
@@ -111,10 +111,10 @@ public:
//_FORCE_INLINE_ SpaceSW* get_owner() { return owner; }
void set_monitor_callback(ObjectID p_id, const StringName &p_method);
- _FORCE_INLINE_ bool has_monitor_callback() const { return monitor_callback_id; }
+ _FORCE_INLINE_ bool has_monitor_callback() const { return monitor_callback_id.is_valid(); }
void set_area_monitor_callback(ObjectID p_id, const StringName &p_method);
- _FORCE_INLINE_ bool has_area_monitor_callback() const { return area_monitor_callback_id; }
+ _FORCE_INLINE_ bool has_area_monitor_callback() const { return area_monitor_callback_id.is_valid(); }
_FORCE_INLINE_ void add_body_to_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
_FORCE_INLINE_ void remove_body_from_query(BodySW *p_body, uint32_t p_body_shape, uint32_t p_area_shape);
diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp
index 64e07e1155..b71c9772df 100644
--- a/servers/physics/body_sw.cpp
+++ b/servers/physics/body_sw.cpp
@@ -709,7 +709,7 @@ void BodySW::call_queries() {
Object *obj = ObjectDB::get_instance(fi_callback->id);
if (!obj) {
- set_force_integration_callback(0, StringName());
+ set_force_integration_callback(ObjectID(), StringName());
} else {
const Variant *vp[2] = { &v, &fi_callback->udata };
@@ -749,7 +749,7 @@ void BodySW::set_force_integration_callback(ObjectID p_id, const StringName &p_m
fi_callback = NULL;
}
- if (p_id != 0) {
+ if (p_id.is_valid()) {
fi_callback = memnew(ForceIntegrationCallback);
fi_callback->id = p_id;
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index ee4dd0b310..d712b09878 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -451,7 +451,7 @@ public:
return body->contacts[p_contact_idx].collider_pos;
}
virtual ObjectID get_contact_collider_id(int p_contact_idx) const {
- ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, 0);
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, ObjectID());
return body->contacts[p_contact_idx].collider_instance_id;
}
virtual int get_contact_collider_shape(int p_contact_idx) const {
diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp
index cdae26078c..3cabf75ab6 100644
--- a/servers/physics/collision_object_sw.cpp
+++ b/servers/physics/collision_object_sw.cpp
@@ -232,7 +232,7 @@ CollisionObjectSW::CollisionObjectSW(Type p_type) :
_static = true;
type = p_type;
space = NULL;
- instance_id = 0;
+
collision_layer = 1;
collision_mask = 1;
ray_pickable = true;
diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp
index cd6fc6c0a5..6024e9ab7f 100644
--- a/servers/physics/physics_server_sw.cpp
+++ b/servers/physics/physics_server_sw.cpp
@@ -374,7 +374,7 @@ ObjectID PhysicsServerSW::area_get_object_instance_id(RID p_area) const {
p_area = space->get_default_area()->get_self();
}
AreaSW *area = area_owner.getornull(p_area);
- ERR_FAIL_COND_V(!area, 0);
+ ERR_FAIL_COND_V(!area, ObjectID());
return area->get_instance_id();
}
@@ -446,7 +446,7 @@ void PhysicsServerSW::area_set_monitor_callback(RID p_area, Object *p_receiver,
AreaSW *area = area_owner.getornull(p_area);
ERR_FAIL_COND(!area);
- area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method);
+ area->set_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
void PhysicsServerSW::area_set_ray_pickable(RID p_area, bool p_enable) {
@@ -470,7 +470,7 @@ void PhysicsServerSW::area_set_area_monitor_callback(RID p_area, Object *p_recei
AreaSW *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);
+ area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method);
}
/* BODY API */
@@ -665,7 +665,7 @@ uint32_t PhysicsServerSW::body_get_collision_mask(RID p_body) const {
return body->get_collision_mask();
}
-void PhysicsServerSW::body_attach_object_instance_id(RID p_body, uint32_t p_id) {
+void PhysicsServerSW::body_attach_object_instance_id(RID p_body, ObjectID p_id) {
BodySW *body = body_owner.getornull(p_body);
ERR_FAIL_COND(!body);
@@ -673,10 +673,10 @@ void PhysicsServerSW::body_attach_object_instance_id(RID p_body, uint32_t p_id)
body->set_instance_id(p_id);
};
-uint32_t PhysicsServerSW::body_get_object_instance_id(RID p_body) const {
+ObjectID PhysicsServerSW::body_get_object_instance_id(RID p_body) const {
BodySW *body = body_owner.getornull(p_body);
- ERR_FAIL_COND_V(!body, 0);
+ ERR_FAIL_COND_V(!body, ObjectID());
return body->get_instance_id();
};
@@ -934,7 +934,7 @@ void PhysicsServerSW::body_set_force_integration_callback(RID p_body, Object *p_
BodySW *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);
+ body->set_force_integration_callback(p_receiver ? p_receiver->get_instance_id() : ObjectID(), p_method, p_udata);
}
void PhysicsServerSW::body_set_ray_pickable(RID p_body, bool p_enable) {
diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h
index 37ebfb09c0..459c7688f0 100644
--- a/servers/physics/physics_server_sw.h
+++ b/servers/physics/physics_server_sw.h
@@ -177,8 +177,8 @@ public:
virtual void body_remove_shape(RID p_body, int p_shape_idx);
virtual void body_clear_shapes(RID p_body);
- virtual void body_attach_object_instance_id(RID p_body, uint32_t p_id);
- virtual uint32_t body_get_object_instance_id(RID p_body) const;
+ virtual void body_attach_object_instance_id(RID p_body, ObjectID p_id);
+ virtual ObjectID body_get_object_instance_id(RID p_body) const;
virtual void body_set_enable_continuous_collision_detection(RID p_body, bool p_enable);
virtual bool body_is_continuous_collision_detection_enabled(RID p_body) const;
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 49e1a57879..03dca8b9ec 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -80,7 +80,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu
continue;
r_results[cc].collider_id = col_obj->get_instance_id();
- if (r_results[cc].collider_id != 0)
+ if (r_results[cc].collider_id.is_valid())
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
else
r_results[cc].collider = NULL;
@@ -159,7 +159,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto
return false;
r_result.collider_id = res_obj->get_instance_id();
- if (r_result.collider_id != 0)
+ if (r_result.collider_id.is_valid())
r_result.collider = ObjectDB::get_instance(r_result.collider_id);
else
r_result.collider = NULL;
@@ -208,7 +208,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
if (r_results) {
r_results[cc].collider_id = col_obj->get_instance_id();
- if (r_results[cc].collider_id != 0)
+ if (r_results[cc].collider_id.is_valid())
r_results[cc].collider = ObjectDB::get_instance(r_results[cc].collider_id);
else
r_results[cc].collider = NULL;
@@ -705,7 +705,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
//but is it right? who knows at this point..
if (r_result) {
- r_result->collider_id = 0;
+ r_result->collider_id = ObjectID();
r_result->collider_shape = 0;
}
AABB body_aabb;