Thursday, December 1, 2016

opengl - How can I insert and remove blocks quickly in a Minecraft-style world?


I currently have volume data for the world stored as an array of booleans. I then check each empty block and if it has non-empty neighbors the faces get drawn. This prevents me from sending a bunch of faces to the graphics card using OpenGL.


I'm now working on inserting and removing blocks but I'm not sure how to do this quickly. It is simple enough to change the volume data but I don't want to recompute all the vertices from the volume data each time someone inserts or removes a block. It occurred to me just to add the block to the vertex buffer at the end of the existing vertex data but then I don't have a good way of destroying it as I have no way to correlate between the volume and vertex buffer data.


Any thoughts on how I can fix the mess I'm in?



Answer




Notch says:



Terrain is generated, saved and loaded, and (kind of) rendered in chunks of 16*16*128 blocks



Divide your world into small subsections of space. Within each of these sections, generate a VBO for the faces of the cubes (or place the faces into a big shared VBO). Each time you edit in a section, regenerate the VBO from scratch. This is unlikely to be a performance bottleneck.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...