summaryrefslogtreecommitdiffstats
path: root/scene/3d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-12-08 17:47:12 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-12-08 17:47:12 -0300
commit09ff4571859b012b64876883e186bb7dfaca0c8c (patch)
tree4f804c8036eb89e0c1cf17e9fbce0b6daf968ba7 /scene/3d
parentecad3a285feabecf44aeb52c94a0d3552933bba1 (diff)
downloadredot-engine-09ff4571859b012b64876883e186bb7dfaca0c8c.tar.gz
made the exclusion of nodes from joints optional, fixes #3015
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/physics_joint.cpp31
-rw-r--r--scene/3d/physics_joint.h4
2 files changed, 33 insertions, 2 deletions
diff --git a/scene/3d/physics_joint.cpp b/scene/3d/physics_joint.cpp
index 0cc72b28e5..f4facb7c3f 100644
--- a/scene/3d/physics_joint.cpp
+++ b/scene/3d/physics_joint.cpp
@@ -34,8 +34,15 @@ void Joint::_update_joint(bool p_only_free) {
if (joint.is_valid()) {
- if (ba.is_valid() && bb.is_valid())
- PhysicsServer::get_singleton()->body_remove_collision_exception(ba,bb);
+ if (ba.is_valid() && bb.is_valid()) {
+
+ if (exclude_from_collision)
+ PhysicsServer::get_singleton()->body_add_collision_exception(ba,bb);
+ else
+ PhysicsServer::get_singleton()->body_remove_collision_exception(ba,bb);
+
+ }
+
PhysicsServer::get_singleton()->free(joint);
joint=RID();
ba=RID();
@@ -144,6 +151,19 @@ void Joint::_notification(int p_what) {
}
+void Joint::set_exclude_nodes_from_collision(bool p_enable) {
+
+ if (exclude_from_collision==p_enable)
+ return;
+ exclude_from_collision=p_enable;
+ _update_joint();
+}
+
+bool Joint::get_exclude_nodes_from_collision() const{
+
+ return exclude_from_collision;
+}
+
void Joint::_bind_methods() {
@@ -156,10 +176,16 @@ void Joint::_bind_methods() {
ObjectTypeDB::bind_method( _MD("set_solver_priority","priority"), &Joint::set_solver_priority );
ObjectTypeDB::bind_method( _MD("get_solver_priority"), &Joint::get_solver_priority );
+ ObjectTypeDB::bind_method( _MD("set_exclude_nodes_from_collision","enable"), &Joint::set_exclude_nodes_from_collision );
+ ObjectTypeDB::bind_method( _MD("get_exclude_nodes_from_collision"), &Joint::get_exclude_nodes_from_collision );
+
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_a"), _SCS("set_node_a"),_SCS("get_node_a") );
ADD_PROPERTY( PropertyInfo( Variant::NODE_PATH, "nodes/node_b"), _SCS("set_node_b"),_SCS("get_node_b") );
ADD_PROPERTY( PropertyInfo( Variant::INT, "solver/priority",PROPERTY_HINT_RANGE,"1,8,1"), _SCS("set_solver_priority"),_SCS("get_solver_priority") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "collision/exclude_nodes"), _SCS("set_exclude_nodes_from_collision"),_SCS("get_exclude_nodes_from_collision") );
+
+
}
@@ -167,6 +193,7 @@ void Joint::_bind_methods() {
Joint::Joint() {
+ exclude_from_collision=true;
solver_priority=1;
}
diff --git a/scene/3d/physics_joint.h b/scene/3d/physics_joint.h
index a5f4ea4bdb..3f5a0e91a6 100644
--- a/scene/3d/physics_joint.h
+++ b/scene/3d/physics_joint.h
@@ -45,6 +45,7 @@ class Joint : public Spatial {
NodePath b;
int solver_priority;
+ bool exclude_from_collision;
protected:
@@ -67,6 +68,9 @@ public:
void set_solver_priority(int p_priority);
int get_solver_priority() const;
+ void set_exclude_nodes_from_collision(bool p_enable);
+ bool get_exclude_nodes_from_collision() const;
+
RID get_joint() const { return joint; }
Joint();