From aacd41f2e5e5a3407e22ae76323b02faebb93062 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Wed, 6 Dec 2023 15:11:04 +0200 Subject: [PATCH] More z-index layer ordering fixes --- src/Autoload/DrawingAlgos.gd | 7 ++++++- src/Classes/Project.gd | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Autoload/DrawingAlgos.gd b/src/Autoload/DrawingAlgos.gd index 41bbdb66e..73276fb12 100644 --- a/src/Autoload/DrawingAlgos.gd +++ b/src/Autoload/DrawingAlgos.gd @@ -20,12 +20,15 @@ func blend_layers( # Nx3 texture, where N is the number of layers and the first row are the blend modes, # the second are the opacities and the third are the origins var metadata_image := Image.create(project.layers.size(), 3, false, Image.FORMAT_R8) + var frame_index := project.frames.find(frame) + var previous_ordered_layers: Array[int] = Array(project.ordered_layers) + project.order_layers(frame_index) for i in project.layers.size(): var ordered_index := project.ordered_layers[i] var layer := project.layers[ordered_index] var include := true if layer.is_visible_in_hierarchy() else false if only_selected and include: - var test_array := [project.frames.find(frame), i] + var test_array := [frame_index, i] if not test_array in project.selected_cels: include = false var cel := frame.cels[ordered_index] @@ -49,6 +52,8 @@ func blend_layers( var gen := ShaderImageEffect.new() gen.generate_image(blended, blend_layers_shader, params, project.size) image.blend_rect(blended, Rect2i(Vector2i.ZERO, project.size), origin) + # Re-order the layers again to ensure correct canvas drawing + project.ordered_layers = Array(previous_ordered_layers) ## Algorithm based on http://members.chello.at/easyfilter/bresenham.html diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index a5a870e04..2e9c116ac 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -522,6 +522,7 @@ func change_cel(new_frame: int, new_layer := -1) -> void: if new_layer != current_layer: # If the layer has changed current_layer = new_layer + order_layers() Global.transparent_checker.update_rect() Global.cel_changed.emit() if get_current_cel() is Cel3D: @@ -868,4 +869,3 @@ func _update_layer_ui() -> void: for f in frames.size(): cel_hbox.get_child(f).layer = l cel_hbox.get_child(f).button_setup() - order_layers()