diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-05-10 15:58:08 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-05-10 15:58:08 -0300 |
commit | 421b4fec3e6d50b764227a7f0b76c93c0be0ff46 (patch) | |
tree | 65bc426290f94fe8d1e182cf41d6e7f8805f0076 /scene | |
parent | 18251997dd3a0032ce332de8456e0047b60a4eb5 (diff) |
-compatibility option for physicsbody layers, fixes #1842
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 14 | ||||
-rw-r--r-- | scene/2d/physics_body_2d.h | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 9fd4a25e7f..3d2917d843 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -68,18 +68,32 @@ float PhysicsBody2D::get_one_way_collision_max_depth() const{ } +void PhysicsBody2D::_set_layers(uint32_t p_mask) { + + set_layer_mask(p_mask); + set_collision_mask(p_mask); +} + +uint32_t PhysicsBody2D::_get_layers() const{ + + return get_layer_mask(); +} + void PhysicsBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask); ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask); ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask); ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask); + ObjectTypeDB::bind_method(_MD("_set_layers","mask"),&PhysicsBody2D::_set_layers); + ObjectTypeDB::bind_method(_MD("_get_layers"),&PhysicsBody2D::_get_layers); ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction); ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction); ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth); ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth); ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with); ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with); + ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS,"",0),_SCS("_set_layers"),_SCS("_get_layers")); //for backwards compat ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask")); ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask")); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction")); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index b6be07500f..03f95959b6 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -42,6 +42,11 @@ class PhysicsBody2D : public CollisionObject2D { uint32_t collision_mask; Vector2 one_way_collision_direction; float one_way_collision_max_depth; + + + void _set_layers(uint32_t p_mask); + uint32_t _get_layers() const; + protected: void _notification(int p_what); |