Skip to content

Commit

Permalink
column graphics updates freeze the editor less
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed May 30, 2024
1 parent fe23420 commit f92a530
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Scenes/GenerateBorderWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func _on_ButtonNewMapOK_pressed():

oCurrentMap._on_ButtonNewMap_pressed()

yield(oOverheadGraphics, "graphics_thread_completed")
yield(oOverheadGraphics, "column_graphics_completed")

if Slabset.dat.empty() == true:
oMessage.quick("Failed loading slabset, game executable might not be correct. Set in File -> Preferences")
Expand Down
1 change: 1 addition & 0 deletions Scenes/MapBrowser.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func activate(path):
else: # Edit
path = path.get_basename()
oOpenMap.open_map(path)
yield(oOverheadGraphics, "column_graphics_completed")
toggle_map_preview(false)

func _on_DynamicMapTree_item_selected():
Expand Down
14 changes: 9 additions & 5 deletions Scenes/OverheadGraphics.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ onready var oUndoStates = Nodelist.list["oUndoStates"]
onready var oQuickMapPreviewDisplay = Nodelist.list["oQuickMapPreviewDisplay"]
onready var oMessage = Nodelist.list["oMessage"]

signal column_graphics_completed

var overheadImgData = Image.new()
var overheadTexData = ImageTexture.new()

Expand All @@ -34,8 +36,9 @@ func update_full_overhead_map():
for xSlab in range(0, M.xSize):
shapePositionArray.append(Vector2(xSlab,ySlab))

overhead2d_update_rect_single_threaded(shapePositionArray)

for i in 2: # Helps prevent the column updating from freezing the editor so much.
yield(get_tree(),'idle_frame')
call_deferred("overhead2d_update_rect_single_threaded", shapePositionArray)
print('Overhead graphics done in '+str(OS.get_ticks_msec()-CODETIME_START)+'ms')


Expand All @@ -45,12 +48,13 @@ func overhead2d_update_rect_single_threaded(shapePositionArray):
pixel_data = generate_pixel_data(pixel_data, shapePositionArray)
overheadImgData.create_from_data(M.xSize * 3, M.ySize * 3, false, Image.FORMAT_RGB8, pixel_data)
overheadTexData.create_from_image(overheadImgData, 0)
emit_signal("column_graphics_completed")


func generate_pixel_data(pixData, shapePositionArray):
print("generate_pixel_data START")
var CODETIME_START = OS.get_ticks_msec()
var width = M.xSize * 3
var height = M.ySize * 3

pixData.resize(width * height * 3) # Assuming RGB8 format

for pos in shapePositionArray:
Expand All @@ -67,7 +71,7 @@ func generate_pixel_data(pixData, shapePositionArray):
pixData[pixelIndex] = cubeFace >> 16 & 255
pixData[pixelIndex + 1] = cubeFace >> 8 & 255
pixData[pixelIndex + 2] = cubeFace & 255
print("generate_pixel_data END")
print('pixData Codetime: ' + str(OS.get_ticks_msec() - CODETIME_START) + 'ms')
return pixData


Expand Down
2 changes: 0 additions & 2 deletions Scenes/WriteData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func write_tng():


func write_tngfx():
print("write_tngfx START")
var buffer = StreamPeerBuffer.new()
var groupNames = {
Things.TYPE.OBJECT: "Object",
Expand Down Expand Up @@ -210,7 +209,6 @@ func write_tngfx():
lines.set(1, "ThingsCount = " + str(entryNumber))
buffer.put_data("\n".join(lines).to_ascii())

print("write_tngfx END")
return buffer


Expand Down

0 comments on commit f92a530

Please sign in to comment.