mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +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:
|
||||
images = [project.frames[project.current_frame].cels[project.current_layer].image]
|
||||
|
||||
for x in big_bounding_rectangle.size.x:
|
||||
for y in big_bounding_rectangle.size.y:
|
||||
var pos := Vector2(x, y) + big_bounding_rectangle.position
|
||||
if project.can_pixel_get_drawn(pos):
|
||||
for image in images:
|
||||
image.set_pixelv(pos, Color(0))
|
||||
var blank := Image.new()
|
||||
blank.create(project.size.x, project.size.y, false, Image.FORMAT_RGBA8)
|
||||
var selection_map_copy := SelectionMap.new()
|
||||
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:
|
||||
image.blit_rect_mask(
|
||||
blank, selection_map_copy, big_bounding_rectangle, big_bounding_rectangle.position
|
||||
)
|
||||
commit_undo("Draw", undo_data_tmp)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue