|
@@ -205,11 +205,12 @@ void TileMapLayer::_rendering_update(bool p_force_cleanup) {
|
|
|
|
|
|
// Check if anything changed that might change the quadrant shape.
|
|
|
// If so, recreate everything.
|
|
|
- bool quandrant_shape_changed = dirty.flags[DIRTY_FLAGS_LAYER_RENDERING_QUADRANT_SIZE] ||
|
|
|
- (is_y_sort_enabled() && (dirty.flags[DIRTY_FLAGS_LAYER_Y_SORT_ENABLED] || dirty.flags[DIRTY_FLAGS_LAYER_Y_SORT_ORIGIN] || dirty.flags[DIRTY_FLAGS_LAYER_LOCAL_TRANSFORM] || dirty.flags[DIRTY_FLAGS_TILE_SET]));
|
|
|
+ bool quadrant_shape_changed = dirty.flags[DIRTY_FLAGS_LAYER_Y_SORT_ENABLED] || dirty.flags[DIRTY_FLAGS_TILE_SET] ||
|
|
|
+ (is_y_sort_enabled() && (dirty.flags[DIRTY_FLAGS_LAYER_Y_SORT_ORIGIN] || dirty.flags[DIRTY_FLAGS_LAYER_X_DRAW_ORDER_REVERSED] || dirty.flags[DIRTY_FLAGS_LAYER_LOCAL_TRANSFORM])) ||
|
|
|
+ (!is_y_sort_enabled() && dirty.flags[DIRTY_FLAGS_LAYER_RENDERING_QUADRANT_SIZE]);
|
|
|
|
|
|
// Free all quadrants.
|
|
|
- if (forced_cleanup || quandrant_shape_changed) {
|
|
|
+ if (forced_cleanup || quadrant_shape_changed) {
|
|
|
for (const KeyValue<Vector2i, Ref<RenderingQuadrant>> &kv : rendering_quadrant_map) {
|
|
|
for (const RID &ci : kv.value->canvas_items) {
|
|
|
if (ci.is_valid()) {
|
|
@@ -264,9 +265,8 @@ void TileMapLayer::_rendering_update(bool p_force_cleanup) {
|
|
|
rendering_quadrant->canvas_items.clear();
|
|
|
|
|
|
// Sort the quadrant cells.
|
|
|
- if (is_y_sort_enabled()) {
|
|
|
- // For compatibility reasons, we use another comparator for Y-sorted layers.
|
|
|
- rendering_quadrant->cells.sort_custom<CellDataYSortedComparator>();
|
|
|
+ if (is_y_sort_enabled() && x_draw_order_reversed) {
|
|
|
+ rendering_quadrant->cells.sort_custom<CellDataYSortedXReversedComparator>();
|
|
|
} else {
|
|
|
rendering_quadrant->cells.sort();
|
|
|
}
|
|
@@ -1770,6 +1770,8 @@ void TileMapLayer::_bind_methods() {
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_y_sort_origin", "y_sort_origin"), &TileMapLayer::set_y_sort_origin);
|
|
|
ClassDB::bind_method(D_METHOD("get_y_sort_origin"), &TileMapLayer::get_y_sort_origin);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_x_draw_order_reversed", "x_draw_order_reversed"), &TileMapLayer::set_x_draw_order_reversed);
|
|
|
+ ClassDB::bind_method(D_METHOD("is_x_draw_order_reversed"), &TileMapLayer::is_x_draw_order_reversed);
|
|
|
ClassDB::bind_method(D_METHOD("set_rendering_quadrant_size", "size"), &TileMapLayer::set_rendering_quadrant_size);
|
|
|
ClassDB::bind_method(D_METHOD("get_rendering_quadrant_size"), &TileMapLayer::get_rendering_quadrant_size);
|
|
|
|
|
@@ -1796,6 +1798,7 @@ void TileMapLayer::_bind_methods() {
|
|
|
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::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");
|
|
|
ADD_GROUP("Physics", "");
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_enabled"), "set_collision_enabled", "is_collision_enabled");
|
|
@@ -1814,6 +1817,18 @@ void TileMapLayer::_bind_methods() {
|
|
|
BIND_ENUM_CONSTANT(DEBUG_VISIBILITY_MODE_FORCE_SHOW);
|
|
|
}
|
|
|
|
|
|
+void TileMapLayer::_validate_property(PropertyInfo &p_property) const {
|
|
|
+ if (is_y_sort_enabled()) {
|
|
|
+ if (p_property.name == "rendering_quadrant_size") {
|
|
|
+ p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (p_property.name == "x_draw_order_reversed") {
|
|
|
+ p_property.usage |= PROPERTY_USAGE_READ_ONLY;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void TileMapLayer::_update_self_texture_filter(RS::CanvasItemTextureFilter p_texture_filter) {
|
|
|
// Set a default texture filter for the whole tilemap.
|
|
|
CanvasItem::_update_self_texture_filter(p_texture_filter);
|
|
@@ -2772,6 +2787,7 @@ void TileMapLayer::set_y_sort_enabled(bool p_y_sort_enabled) {
|
|
|
_queue_internal_update();
|
|
|
emit_signal(CoreStringName(changed));
|
|
|
|
|
|
+ notify_property_list_changed();
|
|
|
_update_notify_local_transform();
|
|
|
}
|
|
|
|
|
@@ -2789,6 +2805,20 @@ int TileMapLayer::get_y_sort_origin() const {
|
|
|
return y_sort_origin;
|
|
|
}
|
|
|
|
|
|
+void TileMapLayer::set_x_draw_order_reversed(bool p_x_draw_order_reversed) {
|
|
|
+ if (x_draw_order_reversed == p_x_draw_order_reversed) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ x_draw_order_reversed = p_x_draw_order_reversed;
|
|
|
+ dirty.flags[DIRTY_FLAGS_LAYER_X_DRAW_ORDER_REVERSED] = true;
|
|
|
+ _queue_internal_update();
|
|
|
+ emit_signal(CoreStringName(changed));
|
|
|
+}
|
|
|
+
|
|
|
+bool TileMapLayer::is_x_draw_order_reversed() const {
|
|
|
+ return x_draw_order_reversed;
|
|
|
+}
|
|
|
+
|
|
|
void TileMapLayer::set_z_index(int p_z_index) {
|
|
|
if (get_z_index() == p_z_index) {
|
|
|
return;
|
|
@@ -2813,10 +2843,9 @@ void TileMapLayer::set_rendering_quadrant_size(int p_size) {
|
|
|
if (rendering_quadrant_size == p_size) {
|
|
|
return;
|
|
|
}
|
|
|
- dirty.flags[DIRTY_FLAGS_LAYER_RENDERING_QUADRANT_SIZE] = true;
|
|
|
ERR_FAIL_COND_MSG(p_size < 1, "TileMapQuadrant size cannot be smaller than 1.");
|
|
|
-
|
|
|
rendering_quadrant_size = p_size;
|
|
|
+ dirty.flags[DIRTY_FLAGS_LAYER_RENDERING_QUADRANT_SIZE] = true;
|
|
|
_queue_internal_update();
|
|
|
emit_signal(CoreStringName(changed));
|
|
|
}
|
|
@@ -2840,6 +2869,9 @@ bool TileMapLayer::is_collision_enabled() const {
|
|
|
}
|
|
|
|
|
|
void TileMapLayer::set_use_kinematic_bodies(bool p_use_kinematic_bodies) {
|
|
|
+ if (use_kinematic_bodies == p_use_kinematic_bodies) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
use_kinematic_bodies = p_use_kinematic_bodies;
|
|
|
dirty.flags[DIRTY_FLAGS_LAYER_USE_KINEMATIC_BODIES] = p_use_kinematic_bodies;
|
|
|
_queue_internal_update();
|