I'm using pseudo-random noise to create a cube world a la Minecraft. So I've got my noise generators up and running, working great. Right now I'm just directly scaling the noise output to a height and assuming everything below that is solid, I intend to go back later and add some caves, pits, etc. My problem right now is taking these three dimensional integer arrays, and turning them into blocks. I'm hitting a big wall there.
After the numerical list, it's taking almost 30 seconds for a chunk(16x128x16) to generate. That's not counting rendering, that's fast enough iff I don't draw every block in the chunk at one time.
My first approach wast to draw all 20,000+ blocks every frame. I figured out that was bad really fast because I was getting maybe 2 fps.
Then I decided it was better to check if the block was exposed before rendering it. That is when I started to get a huge slowdown. If my list indicated a block existed, then I would check the value of the array in all six directions surrounding the cube with my integer list to see if they also held a cube. This works great, but as I said, my generation time for just one chunk is ~30 sec.
My Exposure check code:
public bool determineExposed(int x, int y, int z)
{
try
{
if (_list[x + 1, y, z] == 1 && _list[x - 1, y, z] == 1 && _list[x, y + 1, z] == 1 && _list[x, y - 1, z] == 1 &&
_list[x, y, z + 1] == 1 && _list[x, y, z - 1] == 1) return false;
else return true;
}
catch
{
return false;
}
}
How Can I speed this up?