i'm trying to utilise roblox's actors to make my chunk generation faster. my idea is that since i will be generating 25 chunks every frame if the player moves around, i will make 25 actors and give the 25 actors each a chunk coordinate to:
- loop through each block (3k blocks in a chunk) to calculate if they should be rendered
- render each block
its simple. but, in reality, this is my pseudo code:
main thread:
local Actors = {...}
for i = 1, Chunk in pairs(Chunks) do
Actor[i].Event:Fire(Chunk)
end
actor (parallel) thread:
Event:ConnectParallel(function (Chunk)
--... calculate
task.synchronise()
for Block in Blocks do
--render block
end
end)
the main problem is task.synchronise, since all 25 actors may vary in calculation speed, task.synchronise will basically (i think) force them to be in sync with the main thread which caused immense lag, more than having the chunk loading on a single thread which is a problem. the reason im doing task.synchronise is because i can only render blocks in a sync thread not parallel