mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 10:21:23 +00:00
ability to set occluder mask in tilemap, fixes #3025
This commit is contained in:
parent
e19f176765
commit
ec8f0d7eb9
@ -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;
|
||||
|
@ -150,6 +150,8 @@ private:
|
||||
|
||||
TileOrigin tile_origin;
|
||||
|
||||
int occluder_light_mask;
|
||||
|
||||
void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc);
|
||||
|
||||
Map<PosKey,Quadrant>::Element *_create_quadrant(const PosKey& p_qk);
|
||||
@ -187,6 +189,7 @@ public:
|
||||
INVALID_CELL=-1
|
||||
};
|
||||
|
||||
|
||||
void set_tileset(const Ref<TileSet>& p_tileset);
|
||||
Ref<TileSet> get_tileset() const;
|
||||
|
||||
@ -247,6 +250,9 @@ public:
|
||||
void set_y_sort_mode(bool p_enable);
|
||||
bool is_y_sort_mode_enabled() const;
|
||||
|
||||
void set_occluder_light_mask(int p_mask);
|
||||
int get_occluder_light_mask() const;
|
||||
|
||||
void clear();
|
||||
|
||||
TileMap();
|
||||
|
Loading…
Reference in New Issue
Block a user