diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-13 11:01:19 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-01-13 11:01:19 -0300 |
commit | 0ad9939603a3d659f3f9cfba095a2e0c082483e8 (patch) | |
tree | 5d9bfac1fd97ee38ac4acafadfa7fd53d27c3d11 /scene/3d/physics_body.cpp | |
parent | 04c749a1f034c0b2256fdca0ca2675f696b490e8 (diff) |
Rename collision layer as suggested in #5696
Diffstat (limited to 'scene/3d/physics_body.cpp')
-rw-r--r-- | scene/3d/physics_body.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index f923ba1aaf..9235eae643 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -58,13 +58,13 @@ float PhysicsBody::get_inverse_mass() const { } -void PhysicsBody::set_layer_mask(uint32_t p_mask) { +void PhysicsBody::set_collision_layer(uint32_t p_mask) { layer_mask=p_mask; PhysicsServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask); } -uint32_t PhysicsBody::get_layer_mask() const { +uint32_t PhysicsBody::get_collision_layer() const { return layer_mask; } @@ -97,20 +97,20 @@ bool PhysicsBody::get_collision_mask_bit(int p_bit) const{ } -void PhysicsBody::set_layer_mask_bit(int p_bit, bool p_value) { +void PhysicsBody::set_collision_layer_bit(int p_bit, bool p_value) { - uint32_t mask = get_layer_mask(); + uint32_t mask = get_collision_layer(); if (p_value) mask|=1<<p_bit; else mask&=~(1<<p_bit); - set_layer_mask(mask); + set_collision_layer(mask); } -bool PhysicsBody::get_layer_mask_bit(int p_bit) const{ +bool PhysicsBody::get_collision_layer_bit(int p_bit) const{ - return get_layer_mask()&(1<<p_bit); + return get_collision_layer()&(1<<p_bit); } void PhysicsBody::add_collision_exception_with(Node* p_node) { @@ -137,18 +137,18 @@ void PhysicsBody::remove_collision_exception_with(Node* p_node) { } void PhysicsBody::_set_layers(uint32_t p_mask) { - set_layer_mask(p_mask); + set_collision_layer(p_mask); set_collision_mask(p_mask); } uint32_t PhysicsBody::_get_layers() const{ - return get_layer_mask(); + return get_collision_layer(); } void PhysicsBody::_bind_methods() { - ClassDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody::set_layer_mask); - ClassDB::bind_method(_MD("get_layer_mask"),&PhysicsBody::get_layer_mask); + ClassDB::bind_method(_MD("set_collision_layer","layer"),&PhysicsBody::set_collision_layer); + ClassDB::bind_method(_MD("get_collision_layer"),&PhysicsBody::get_collision_layer); ClassDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody::set_collision_mask); ClassDB::bind_method(_MD("get_collision_mask"),&PhysicsBody::get_collision_mask); @@ -156,13 +156,14 @@ void PhysicsBody::_bind_methods() { ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody::set_collision_mask_bit); ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody::get_collision_mask_bit); - ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody::set_layer_mask_bit); - ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody::get_layer_mask_bit); + ClassDB::bind_method(_MD("set_collision_layer_bit","bit","value"),&PhysicsBody::set_collision_layer_bit); + ClassDB::bind_method(_MD("get_collision_layer_bit","bit"),&PhysicsBody::get_collision_layer_bit); ClassDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody::_set_layers); ClassDB::bind_method(_MD("_get_layers"),&PhysicsBody::_get_layers); - ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_GROUP("Collision","collision_"); + ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layer",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_3D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); } @@ -1014,7 +1015,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) { if (is_shape_set_as_trigger(i)) continue; - if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),m,sr,max_shapes,res_shapes,exclude,get_layer_mask(),mask)) { + if (dss->collide_shape(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i),m,sr,max_shapes,res_shapes,exclude,get_collision_layer(),mask)) { collided=true; } @@ -1096,7 +1097,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) { float lsafe,lunsafe; PhysicsDirectSpaceState::ShapeRestInfo lrest; - bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion,0, lsafe,lunsafe,exclude,get_layer_mask(),mask,&lrest); + bool valid = dss->cast_motion(get_shape(i)->get_rid(), get_global_transform() * get_shape_transform(i), p_motion,0, lsafe,lunsafe,exclude,get_collision_layer(),mask,&lrest); //print_line("shape: "+itos(i)+" travel:"+rtos(ltravel)); if (!valid) { safe=0; @@ -1137,7 +1138,7 @@ Vector3 KinematicBody::move(const Vector3& p_motion) { ugt.origin+=p_motion*unsafe; PhysicsDirectSpaceState::ShapeRestInfo rest_info; - bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), m,&rest,exclude,get_layer_mask(),mask); + bool c2 = dss->rest_info(get_shape(best_shape)->get_rid(), ugt*get_shape_transform(best_shape), m,&rest,exclude,get_collision_layer(),mask); if (!c2) { //should not happen, but floating point precision is so weird.. colliding=false; @@ -1200,7 +1201,7 @@ bool KinematicBody::can_teleport_to(const Vector3& p_position) { if (is_shape_set_as_trigger(i)) continue; - bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i),0,NULL,1,exclude,get_layer_mask(),mask); + bool col = dss->intersect_shape(get_shape(i)->get_rid(), xform * get_shape_transform(i),0,NULL,1,exclude,get_collision_layer(),mask); if (col) return false; } |