summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-09-22 01:03:56 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-09-22 01:03:56 -0300
commitcf04e1a827cadb597d8cbed534a4cc04a0ada4fc (patch)
tree3e5197e938d04382ffcf886a12043a898160323e
parent048fdc8aeabbd80ba9cc8914ec7f7baa00ad0c3d (diff)
-added collision exception to 3D Physics API too
-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();