From 5063cd7757191d62355f4d1a7bb16abc288f9212 Mon Sep 17 00:00:00 2001 From: reduz Date: Tue, 29 Dec 2015 14:47:13 -0300 Subject: -Make tilemap able to change light mask, fixes #2557 --- scene/2d/canvas_item.h | 2 +- scene/2d/tile_map.cpp | 11 +++++++++++ scene/2d/tile_map.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'scene') diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 4c0386b953..b96267f967 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -197,7 +197,7 @@ public: void set_blend_mode(BlendMode p_blend_mode); BlendMode get_blend_mode() const; - void set_light_mask(int p_light_mask); + virtual void set_light_mask(int p_light_mask); int get_light_mask() const; void set_opacity(float p_opacity); diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 679ff719c5..1cba29f351 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -333,6 +333,8 @@ void TileMap::_update_dirty_quadrants() { Matrix32 xform; xform.set_origin( q.pos ); vs->canvas_item_set_transform( canvas_item, xform ); + vs->canvas_item_set_light_mask(canvas_item,get_light_mask()); + q.canvas_items.push_back(canvas_item); if (debug_shapes) { @@ -1105,7 +1107,16 @@ int TileMap::get_occluder_light_mask() const{ return occluder_light_mask; } +void TileMap::set_light_mask(int p_light_mask) { + + CanvasItem::set_light_mask(p_light_mask); + for (Map::Element *E=quadrant_map.front();E;E=E->next()) { + for (List::Element *F=E->get().canvas_items.front();F;F=F->next()) { + VisualServer::get_singleton()->canvas_item_set_light_mask(F->get(),get_light_mask()); + } + } +} void TileMap::_bind_methods() { diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 4676d1ef7a..fdf760483d 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -253,6 +253,8 @@ public: void set_occluder_light_mask(int p_mask); int get_occluder_light_mask() const; + virtual void set_light_mask(int p_light_mask); + void clear(); TileMap(); -- cgit v1.2.3