Godot Version
4.7
Question
I’ve got an array of terrain patches with custom AABB’s but I want to slide the patches along in the x direction by 1 tile and when that happens I would like the AABB data to copy over from the adjacent tiles …
grid[i][j].mesh.custom_aabb = grid[i+1][j].mesh.custom_aabb
but if there is a large array then I lose some performance … e.g
for i in range( 32 ):
for j in range( 32 ):
# do something with grid[ i ][ j ]
if i == 31:
grid[ i ][ j ].mesh.custom_aabb = grid[ 0 ][ j ].mesh.custom_aabb
basically thats like a loop of 1024 assignments. This might work in time but it could also cause some pretty low 1% low FPS scores, and so I would like to thread perhaps …
for i in range(32):
WorkerThreadPool.add_task(func(): set_aabb(grid[i], 32))
and the function
func set_aabb(grid:Array, count):
for i in range(count):
if i == count-1:
grid[ i ].mesh.custom_aabb = grid[ 0 ].mesh.custom_aabb
else:
grid[ i ].mesh.custom_aabb = grid[ i+1 ].mesh.custom_aabb
Does that even work ?
Is there a way of accessing the AABB data of the grid in a compute shader and setting it that way ?
What about clipping in a compute shader, making my own clip function and removing meshes from the render using an instance buffer?
Can I access the occlusion buffer in a compute shader ?