Merge pull request #93970 from MarblesFr/feature/collision-occlusion-options-layer-map
Add occlusion enabled option to TileMapLayer
This commit is contained in:
commit
6cb21a56fd
3 changed files with 29 additions and 2 deletions
|
@ -284,6 +284,9 @@
|
|||
<member name="navigation_visibility_mode" type="int" setter="set_navigation_visibility_mode" getter="get_navigation_visibility_mode" enum="TileMapLayer.DebugVisibilityMode" default="0">
|
||||
Show or hide the [TileMapLayer]'s navigation meshes. If set to [constant DEBUG_VISIBILITY_MODE_DEFAULT], this depends on the show navigation debug settings.
|
||||
</member>
|
||||
<member name="occlusion_enabled" type="bool" setter="set_occlusion_enabled" getter="is_occlusion_enabled" default="true">
|
||||
Enable or disable light occlusion.
|
||||
</member>
|
||||
<member name="rendering_quadrant_size" type="int" setter="set_rendering_quadrant_size" getter="get_rendering_quadrant_size" default="16">
|
||||
The [TileMapLayer]'s quadrant size. A quadrant is a group of tiles to be drawn together on a single canvas item, for optimization purposes. [member rendering_quadrant_size] defines the length of a square's side, in the map's coordinate system, that forms the quadrant. Thus, the default quadrant size groups together [code]16 * 16 = 256[/code] tiles.
|
||||
The quadrant size does not apply on a Y-sorted [TileMapLayer], as tiles are grouped by Y position instead in that case.
|
||||
|
|
|
@ -411,7 +411,7 @@ void TileMapLayer::_rendering_update(bool p_force_cleanup) {
|
|||
}
|
||||
|
||||
// ----------- Occluders processing -----------
|
||||
if (forced_cleanup) {
|
||||
if (forced_cleanup || !occlusion_enabled) {
|
||||
// Clean everything.
|
||||
for (KeyValue<Vector2i, CellData> &kv : tile_map_layer_data) {
|
||||
_rendering_occluders_clear_cell(kv.value);
|
||||
|
@ -433,7 +433,7 @@ void TileMapLayer::_rendering_update(bool p_force_cleanup) {
|
|||
|
||||
// -----------
|
||||
// Mark the rendering state as up to date.
|
||||
_rendering_was_cleaned_up = forced_cleanup;
|
||||
_rendering_was_cleaned_up = forced_cleanup || !occlusion_enabled;
|
||||
}
|
||||
|
||||
void TileMapLayer::_rendering_notification(int p_what) {
|
||||
|
@ -1828,6 +1828,9 @@ void TileMapLayer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "visibility_mode"), &TileMapLayer::set_collision_visibility_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &TileMapLayer::get_collision_visibility_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_occlusion_enabled", "enabled"), &TileMapLayer::set_occlusion_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_occlusion_enabled"), &TileMapLayer::is_occlusion_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_enabled", "enabled"), &TileMapLayer::set_navigation_enabled);
|
||||
ClassDB::bind_method(D_METHOD("is_navigation_enabled"), &TileMapLayer::is_navigation_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_navigation_map", "map"), &TileMapLayer::set_navigation_map);
|
||||
|
@ -1843,6 +1846,7 @@ void TileMapLayer::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "tile_set", PROPERTY_HINT_RESOURCE_TYPE, "TileSet"), "set_tile_set", "get_tile_set");
|
||||
ADD_GROUP("Rendering", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "occlusion_enabled"), "set_occlusion_enabled", "is_occlusion_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "y_sort_origin"), "set_y_sort_origin", "get_y_sort_origin");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "x_draw_order_reversed"), "set_x_draw_order_reversed", "is_x_draw_order_reversed");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "rendering_quadrant_size"), "set_rendering_quadrant_size", "get_rendering_quadrant_size");
|
||||
|
@ -2960,6 +2964,20 @@ TileMapLayer::DebugVisibilityMode TileMapLayer::get_collision_visibility_mode()
|
|||
return collision_visibility_mode;
|
||||
}
|
||||
|
||||
void TileMapLayer::set_occlusion_enabled(bool p_enabled) {
|
||||
if (occlusion_enabled == p_enabled) {
|
||||
return;
|
||||
}
|
||||
occlusion_enabled = p_enabled;
|
||||
dirty.flags[DIRTY_FLAGS_LAYER_OCCLUSION_ENABLED] = true;
|
||||
_queue_internal_update();
|
||||
emit_signal(CoreStringName(changed));
|
||||
}
|
||||
|
||||
bool TileMapLayer::is_occlusion_enabled() const {
|
||||
return occlusion_enabled;
|
||||
}
|
||||
|
||||
void TileMapLayer::set_navigation_enabled(bool p_enabled) {
|
||||
if (navigation_enabled == p_enabled) {
|
||||
return;
|
||||
|
|
|
@ -254,6 +254,7 @@ public:
|
|||
DIRTY_FLAGS_LAYER_COLLISION_ENABLED,
|
||||
DIRTY_FLAGS_LAYER_USE_KINEMATIC_BODIES,
|
||||
DIRTY_FLAGS_LAYER_COLLISION_VISIBILITY_MODE,
|
||||
DIRTY_FLAGS_LAYER_OCCLUSION_ENABLED,
|
||||
DIRTY_FLAGS_LAYER_NAVIGATION_ENABLED,
|
||||
DIRTY_FLAGS_LAYER_NAVIGATION_MAP,
|
||||
DIRTY_FLAGS_LAYER_NAVIGATION_VISIBILITY_MODE,
|
||||
|
@ -288,6 +289,8 @@ private:
|
|||
bool use_kinematic_bodies = false;
|
||||
DebugVisibilityMode collision_visibility_mode = DEBUG_VISIBILITY_MODE_DEFAULT;
|
||||
|
||||
bool occlusion_enabled = true;
|
||||
|
||||
bool navigation_enabled = true;
|
||||
RID navigation_map_override;
|
||||
DebugVisibilityMode navigation_visibility_mode = DEBUG_VISIBILITY_MODE_DEFAULT;
|
||||
|
@ -497,6 +500,9 @@ public:
|
|||
void set_collision_visibility_mode(DebugVisibilityMode p_show_collision);
|
||||
DebugVisibilityMode get_collision_visibility_mode() const;
|
||||
|
||||
void set_occlusion_enabled(bool p_enabled);
|
||||
bool is_occlusion_enabled() const;
|
||||
|
||||
void set_navigation_enabled(bool p_enabled);
|
||||
bool is_navigation_enabled() const;
|
||||
void set_navigation_map(RID p_map);
|
||||
|
|
Loading…
Reference in a new issue