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 | |
parent | 04c749a1f034c0b2256fdca0ca2675f696b490e8 (diff) |
Rename collision layer as suggested in #5696
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 29 | ||||
-rw-r--r-- | scene/2d/physics_body_2d.h | 8 | ||||
-rw-r--r-- | scene/3d/physics_body.cpp | 37 | ||||
-rw-r--r-- | scene/3d/physics_body.h | 8 |
4 files changed, 42 insertions, 40 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 1498ad13a6..46a345f1cb 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -70,19 +70,19 @@ float PhysicsBody2D::get_one_way_collision_max_depth() const{ void PhysicsBody2D::_set_layers(uint32_t p_mask) { - set_layer_mask(p_mask); + set_collision_layer(p_mask); set_collision_mask(p_mask); } uint32_t PhysicsBody2D::_get_layers() const{ - return get_layer_mask(); + return get_collision_layer(); } void PhysicsBody2D::_bind_methods() { - ClassDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask); - ClassDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask); + ClassDB::bind_method(_MD("set_collision_layer","mask"),&PhysicsBody2D::set_collision_layer); + ClassDB::bind_method(_MD("get_collision_layer"),&PhysicsBody2D::get_collision_layer); ClassDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask); ClassDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask); @@ -90,8 +90,8 @@ void PhysicsBody2D::_bind_methods() { ClassDB::bind_method(_MD("set_collision_mask_bit","bit","value"),&PhysicsBody2D::set_collision_mask_bit); ClassDB::bind_method(_MD("get_collision_mask_bit","bit"),&PhysicsBody2D::get_collision_mask_bit); - ClassDB::bind_method(_MD("set_layer_mask_bit","bit","value"),&PhysicsBody2D::set_layer_mask_bit); - ClassDB::bind_method(_MD("get_layer_mask_bit","bit"),&PhysicsBody2D::get_layer_mask_bit); + ClassDB::bind_method(_MD("set_collision_layer_bit","bit","value"),&PhysicsBody2D::set_collision_layer_bit); + ClassDB::bind_method(_MD("get_collision_layer_bit","bit"),&PhysicsBody2D::get_collision_layer_bit); ClassDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers); ClassDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers); @@ -102,21 +102,22 @@ void PhysicsBody2D::_bind_methods() { ClassDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with); ClassDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with); ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_LAYERS_2D_PHYSICS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat + ADD_GROUP("Collision","collision_"); - ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layers",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); + ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_layer",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_layer"),_SCS("get_collision_layer")); ADD_PROPERTY(PropertyInfo(Variant::INT,"collision_mask",PROPERTY_HINT_LAYERS_2D_PHYSICS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); ADD_GROUP("",""); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction")); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth")); } -void PhysicsBody2D::set_layer_mask(uint32_t p_mask) { +void PhysicsBody2D::set_collision_layer(uint32_t p_mask) { mask=p_mask; Physics2DServer::get_singleton()->body_set_layer_mask(get_rid(),p_mask); } -uint32_t PhysicsBody2D::get_layer_mask() const { +uint32_t PhysicsBody2D::get_collision_layer() const { return mask; } @@ -148,20 +149,20 @@ bool PhysicsBody2D::get_collision_mask_bit(int p_bit) const{ } -void PhysicsBody2D::set_layer_mask_bit(int p_bit, bool p_value) { +void PhysicsBody2D::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 PhysicsBody2D::get_layer_mask_bit(int p_bit) const{ +bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const{ - return get_layer_mask()&(1<<p_bit); + return get_collision_layer()&(1<<p_bit); } PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) { diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 2637238c04..5b7db35fe8 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -55,8 +55,8 @@ protected: static void _bind_methods(); public: - void set_layer_mask(uint32_t p_mask); - uint32_t get_layer_mask() const; + void set_collision_layer(uint32_t p_mask); + uint32_t get_collision_layer() const; void set_collision_mask(uint32_t p_mask); uint32_t get_collision_mask() const; @@ -65,8 +65,8 @@ public: void set_collision_mask_bit(int p_bit, bool p_value); bool get_collision_mask_bit(int p_bit) const; - void set_layer_mask_bit(int p_bit, bool p_value); - bool get_layer_mask_bit(int p_bit) const; + void set_collision_layer_bit(int p_bit, bool p_value); + bool get_collision_layer_bit(int p_bit) const; void add_collision_exception_with(Node* p_node); //must be physicsbody void remove_collision_exception_with(Node* p_node); 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; } diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 9f317745b3..86be98f81e 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -55,14 +55,14 @@ public: virtual Vector3 get_angular_velocity() const; virtual float get_inverse_mass() const; - void set_layer_mask(uint32_t p_mask); - uint32_t get_layer_mask() const; + void set_collision_layer(uint32_t p_mask); + uint32_t get_collision_layer() const; void set_collision_mask(uint32_t p_mask); uint32_t get_collision_mask() const; - void set_layer_mask_bit(int p_bit, bool p_value); - bool get_layer_mask_bit(int p_bit) const; + void set_collision_layer_bit(int p_bit, bool p_value); + bool get_collision_layer_bit(int p_bit) const; void set_collision_mask_bit(int p_bit, bool p_value); bool get_collision_mask_bit(int p_bit) const; |