summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene/3d/physics_body.cpp26
-rw-r--r--scene/3d/physics_body.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp
index 0597117c4c..a99964cc54 100644
--- a/scene/3d/physics_body.cpp
+++ b/scene/3d/physics_body.cpp
@@ -69,6 +69,29 @@ uint32_t PhysicsBody::get_layer_mask() const {
return layer_mask;
}
+void PhysicsBody::add_collision_exception_with(Node* p_node) {
+
+ ERR_FAIL_NULL(p_node);
+ PhysicsBody *physics_body = p_node->cast_to<PhysicsBody>();
+ if (!physics_body) {
+ ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
+ }
+ ERR_FAIL_COND(!physics_body);
+ PhysicsServer::get_singleton()->body_add_collision_exception(get_rid(),physics_body->get_rid());
+
+}
+
+void PhysicsBody::remove_collision_exception_with(Node* p_node) {
+
+ ERR_FAIL_NULL(p_node);
+ PhysicsBody *physics_body = p_node->cast_to<PhysicsBody>();
+ if (!physics_body) {
+ ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
+ }
+ ERR_FAIL_COND(!physics_body);
+ PhysicsServer::get_singleton()->body_remove_collision_exception(get_rid(),physics_body->get_rid());
+}
+
void PhysicsBody::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody::set_layer_mask);
ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody::get_layer_mask);
@@ -146,6 +169,9 @@ void StaticBody::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_bounce","bounce"),&StaticBody::set_bounce);
ObjectTypeDB::bind_method(_MD("get_bounce"),&StaticBody::get_bounce);
+ ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody"),&PhysicsBody::add_collision_exception_with);
+ ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody"),&PhysicsBody::remove_collision_exception_with);
+
ADD_PROPERTY( PropertyInfo(Variant::REAL,"friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_friction"),_SCS("get_friction"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_bounce"),_SCS("get_bounce"));
diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h
index 30a64c802f..442921302e 100644
--- a/scene/3d/physics_body.h
+++ b/scene/3d/physics_body.h
@@ -53,6 +53,8 @@ public:
void set_layer_mask(uint32_t p_mask);
uint32_t get_layer_mask() const;
+ void add_collision_exception_with(Node* p_node); //must be physicsbody
+ void remove_collision_exception_with(Node* p_node);
PhysicsBody();