diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-10-16 00:06:34 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-10-16 00:06:34 -0300 |
commit | 371eac9beffdfe416b8555ee006baf0ffae2bef3 (patch) | |
tree | bfb0f6dc2a0a4812d69a8aa9902ad0c42021a522 /scene | |
parent | 6e87c80e41857fe4f151cdeb8b9a7206c226bd8f (diff) |
-added custom metadata to physics shapes (2D only for now)
-gizmos are not displayed in camera preview
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 10 | ||||
-rw-r--r-- | scene/2d/physics_body_2d.h | 2 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 3 | ||||
-rw-r--r-- | scene/3d/camera.cpp | 3 | ||||
-rw-r--r-- | scene/3d/physics_body.h | 1 |
5 files changed, 18 insertions, 1 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 22dbd157b7..308aa8402f 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -926,6 +926,7 @@ Vector2 KinematicBody2D::move(const Vector2& p_motion) { collider=rest_info.collider_id; collider_vel=rest_info.linear_velocity; collider_shape=rest_info.shape; + collider_metadata=rest_info.metadata; } } @@ -1020,6 +1021,14 @@ int KinematicBody2D::get_collider_shape() const { ERR_FAIL_COND_V(!colliding,0); return collider_shape; } + +Variant KinematicBody2D::get_collider_metadata() const { + + ERR_FAIL_COND_V(!colliding,0); + return collider_metadata; + +} + void KinematicBody2D::set_collide_with_static_bodies(bool p_enable) { collide_static=p_enable; @@ -1084,6 +1093,7 @@ void KinematicBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_collider_velocity"),&KinematicBody2D::get_collider_velocity); ObjectTypeDB::bind_method(_MD("get_collider:Object"),&KinematicBody2D::_get_collider); ObjectTypeDB::bind_method(_MD("get_collider_shape"),&KinematicBody2D::get_collider_shape); + ObjectTypeDB::bind_method(_MD("get_collider_metadata"),&KinematicBody2D::get_collider_metadata); ObjectTypeDB::bind_method(_MD("set_collide_with_static_bodies","enable"),&KinematicBody2D::set_collide_with_static_bodies); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 2771aa6aa4..e429ca1432 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -255,6 +255,7 @@ class KinematicBody2D : public PhysicsBody2D { Vector2 collider_vel; ObjectID collider; int collider_shape; + Variant collider_metadata; Variant _get_collider() const; @@ -274,6 +275,7 @@ public: Vector2 get_collider_velocity() const; ObjectID get_collider() const; int get_collider_shape() const; + Variant get_collider_metadata() const; void set_collide_with_static_bodies(bool p_enable); bool can_collide_with_static_bodies() const; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 72ef653d14..eb04ca924f 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -179,6 +179,7 @@ void TileMap::_update_dirty_quadrants() { vs->canvas_item_clear(q.canvas_item); ps->body_clear_shapes(q.static_body); + int shape_idx=0; for(int i=0;i<q.cells.size();i++) { @@ -259,6 +260,8 @@ void TileMap::_update_dirty_quadrants() { ps->body_add_shape(q.static_body,shape->get_rid(),xform); + ps->body_set_shape_metadata(q.static_body,shape_idx++,Vector2(E->key().x,E->key().y)); + } } } diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 075bb94ea1..93a27f7ac1 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -756,7 +756,8 @@ Camera::Camera() { mode=PROJECTION_PERSPECTIVE; set_perspective(60.0,0.1,100.0); keep_aspect=KEEP_HEIGHT; - layers=0xFFFFFFFF; + layers=0xfffff; + VisualServer::get_singleton()->camera_set_visible_layers(camera,layers); //active=false; } diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 1615fdd1d4..a19ad48c87 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -269,6 +269,7 @@ class KinematicBody : public PhysicsBody { int collider_shape; + Variant _get_collider() const; _FORCE_INLINE_ bool _ignores_mode(PhysicsServer::BodyMode) const; |