I built my Minecraft-like block-world using 3d-Arrays of Objects (Block[x,y,z]).
Then i read everywhere that Jagged Arrays are much better performance wise. So I changed the whole code from 3d-Arrays zu Jagged Arrays with 3 Level depth (Block[y][z]).
It still works, but my benchmarking shows that EVERYTHING (from level build to block manipulation/Chunk rebuild) takes up to 2 times longer…
So now I’m reverting to the earlier version with 3D-Arrays.
Can somebody explain why Jagged Arrays actually seem to be slower than Multidimensional ones? Or is the problem that I changed all my foreach-loops to layered for-loops? That would be strange as well because for loops are supposed to be faster than foreach…
I’m confused…
Either way, doing a minecraft clone instantiating geometry will be very inefficient.
– Default117Why? I'm saving the vertice and uv positions in each block, then combine this information to the mesh for each chunk (normally 64x64x1 Blocks). And it Runs extremely fast, when I edit a block, it updates 3-6 Chunks and takes max. 0.004 seconds. What would you suggest to optimize (I know it sure isnt perfect but I dont see a better way than saving Block data in an Array of Objects, maybe just Arrays of Data)
– maikkel