aboutsummaryrefslogtreecommitdiff
path: root/scene/2d/tile_map.cpp
diff options
context:
space:
mode:
authorJuan Linietsky2015-12-12 10:45:31 -0300
committerJuan Linietsky2015-12-12 10:45:31 -0300
commitec8f0d7eb9a5d5842e54618a4f4f31952a1d1ede (patch)
tree8762a3fb928f286bfd0fefd5c12d03c0eb3b3eb0 /scene/2d/tile_map.cpp
parente19f176765d8daafa2af9cdf1c8e87441c783e63 (diff)
downloadgodot-ec8f0d7eb9a5d5842e54618a4f4f31952a1d1ede.tar.gz
godot-ec8f0d7eb9a5d5842e54618a4f4f31952a1d1ede.tar.zst
godot-ec8f0d7eb9a5d5842e54618a4f4f31952a1d1ede.zip
ability to set occluder mask in tilemap, fixes #3025
Diffstat (limited to 'scene/2d/tile_map.cpp')
-rw-r--r--scene/2d/tile_map.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index e23b00bf0..1d48a9c8a 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -32,6 +32,8 @@
#include "method_bind_ext.inc"
#include "os/os.h"
+
+
int TileMap::_get_quadrant_size() const {
if (y_sort_mode)
@@ -463,6 +465,7 @@ void TileMap::_update_dirty_quadrants() {
VS::get_singleton()->canvas_light_occluder_set_transform(orid,get_global_transform() * xform);
VS::get_singleton()->canvas_light_occluder_set_polygon(orid,occluder->get_rid());
VS::get_singleton()->canvas_light_occluder_attach_to_canvas(orid,get_canvas());
+ VS::get_singleton()->canvas_light_occluder_set_light_mask(orid,occluder_light_mask);
Quadrant::Occluder oc;
oc.xform=xform;
oc.id=orid;
@@ -1086,6 +1089,24 @@ Array TileMap::get_used_cells() const {
return a;
}
+void TileMap::set_occluder_light_mask(int p_mask) {
+
+ occluder_light_mask=p_mask;
+ for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
+
+ for (Map<PosKey,Quadrant::Occluder>::Element *F=E->get().occluder_instances.front();F;F=F->next()) {
+ VisualServer::get_singleton()->canvas_light_occluder_set_light_mask(F->get().id,occluder_light_mask);
+ }
+ }
+}
+
+int TileMap::get_occluder_light_mask() const{
+
+ return occluder_light_mask;
+}
+
+
+
void TileMap::_bind_methods() {
@@ -1137,6 +1158,9 @@ void TileMap::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_collision_bounce","value"),&TileMap::set_collision_bounce);
ObjectTypeDB::bind_method(_MD("get_collision_bounce"),&TileMap::get_collision_bounce);
+ ObjectTypeDB::bind_method(_MD("set_occluder_light_mask","mask"),&TileMap::set_occluder_light_mask);
+ ObjectTypeDB::bind_method(_MD("get_occluder_light_mask"),&TileMap::get_occluder_light_mask);
+
ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell);
@@ -1171,6 +1195,7 @@ void TileMap::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"occluder/light_mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_occluder_light_mask"),_SCS("get_occluder_light_mask"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data"));
@@ -1208,6 +1233,7 @@ TileMap::TileMap() {
use_kinematic=false;
navigation=NULL;
y_sort_mode=false;
+ occluder_light_mask=1;
fp_adjust=0.00001;
tile_origin=TILE_ORIGIN_TOP_LEFT;