summaryrefslogtreecommitdiff
path: root/scene/3d/physics_body.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d/physics_body.cpp')
-rw-r--r--scene/3d/physics_body.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 0fb0869979..970e8cf1ee 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -32,7 +32,10 @@
#include "core/core_string_names.h"
#include "core/engine.h"
+#include "core/list.h"
#include "core/method_bind_ext.gen.inc"
+#include "core/object.h"
+#include "core/rid.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@@ -108,6 +111,20 @@ bool PhysicsBody::get_collision_layer_bit(int p_bit) const {
return get_collision_layer() & (1 << p_bit);
}
+Array PhysicsBody::get_collision_exceptions() {
+ List<RID> exceptions;
+ PhysicsServer::get_singleton()->body_get_collision_exceptions(get_rid(), &exceptions);
+ Array ret;
+ for (List<RID>::Element *E = exceptions.front(); E; E = E->next()) {
+ RID body = E->get();
+ ObjectID instance_id = PhysicsServer::get_singleton()->body_get_object_instance_id(body);
+ Object *obj = ObjectDB::get_instance(instance_id);
+ PhysicsBody *physics_body = Object::cast_to<PhysicsBody>(obj);
+ ret.append(physics_body);
+ }
+ return ret;
+}
+
void PhysicsBody::add_collision_exception_with(Node *p_node) {
ERR_FAIL_NULL(p_node);
@@ -289,6 +306,7 @@ void StaticBody::_bind_methods() {
ClassDB::bind_method(D_METHOD("_reload_physics_characteristics"), &StaticBody::_reload_physics_characteristics);
+ ClassDB::bind_method(D_METHOD("get_collision_exceptions"), &PhysicsBody::get_collision_exceptions);
ClassDB::bind_method(D_METHOD("add_collision_exception_with", "body"), &PhysicsBody::add_collision_exception_with);
ClassDB::bind_method(D_METHOD("remove_collision_exception_with", "body"), &PhysicsBody::remove_collision_exception_with);
@@ -2326,7 +2344,8 @@ void PhysicalBone::set_joint_type(JointType p_joint_type) {
if (p_joint_type == get_joint_type())
return;
- memdelete(joint_data);
+ if (joint_data)
+ memdelete(joint_data);
joint_data = NULL;
switch (p_joint_type) {
case JOINT_TYPE_PIN:
@@ -2526,7 +2545,8 @@ PhysicalBone::PhysicalBone() :
}
PhysicalBone::~PhysicalBone() {
- memdelete(joint_data);
+ if (joint_data)
+ memdelete(joint_data);
}
void PhysicalBone::update_bone_id() {