summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2015-12-29 14:47:13 -0300
committerreduz <reduzio@gmail.com>2015-12-29 14:47:13 -0300
commit5063cd7757191d62355f4d1a7bb16abc288f9212 (patch)
tree0f2e18f3cdde53d8f3c1976d782fc7bf8a6a5324 /scene
parent77b5b4f4dfcd9d3bc050d3dda84847f1ee088234 (diff)
-Make tilemap able to change light mask, fixes #2557
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/tile_map.cpp11
-rw-r--r--scene/2d/tile_map.h2
3 files changed, 14 insertions, 1 deletions
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<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+ for (List<RID>::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();