mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-12 08:43:08 +00:00
Greatly optimize selection content deletion
New speeds with this commit (approximately) 64x64: 0-1ms 1024x1024: 27ms 2048x2048: 73ms 4096x4096: 261ms Old speeds before this commit (approximately) 64x64: 42ms 1024x1024: 5204ms 2048x2048: 20988ms 4096x4096: 83973ms
This commit is contained in:
parent
8a6e393d69
commit
a9e624e319
|
@ -782,12 +782,16 @@ func delete(selected_cels := true) -> void:
|
||||||
else:
|
else:
|
||||||
images = [project.frames[project.current_frame].cels[project.current_layer].image]
|
images = [project.frames[project.current_frame].cels[project.current_layer].image]
|
||||||
|
|
||||||
for x in big_bounding_rectangle.size.x:
|
var blank := Image.new()
|
||||||
for y in big_bounding_rectangle.size.y:
|
blank.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||||
var pos := Vector2(x, y) + big_bounding_rectangle.position
|
var selection_map_copy := SelectionMap.new()
|
||||||
if project.can_pixel_get_drawn(pos):
|
selection_map_copy.copy_from(project.selection_map)
|
||||||
|
# In case the selection map is bigger than the canvas
|
||||||
|
selection_map_copy.crop(project.size.x, project.size.y)
|
||||||
for image in images:
|
for image in images:
|
||||||
image.set_pixelv(pos, Color(0))
|
image.blit_rect_mask(
|
||||||
|
blank, selection_map_copy, big_bounding_rectangle, big_bounding_rectangle.position
|
||||||
|
)
|
||||||
commit_undo("Draw", undo_data_tmp)
|
commit_undo("Draw", undo_data_tmp)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue