I am trying to procedurally generate terrain using the jobs system. I seem to be having an issue with my bounds, but I don’t understand what is going on. I am visualizing my bounds and they are appearing as they should, but when I face them from the positive x direction and move close to them they disappear. I think it may have something to do with world vs local space, but I am not sure. I am setting the gameobject to appear in worldspace, and then setting the meshdata locally since I tried doing it globally before and messed things up, doing it locally seems to be what I need. I then set the bounds. When doing mesh.Recalcualatebounds it sets all of the bounds to the same spot, I have set the bounds and they appear correct, but as I said, there are issues.
The position of the gameobject is set as…
var overallPos = new int2((chunkPos.x * (mapWidth)),(chunkPos.y * (mapWidth)));
terrain.transform.position = new Vector3(overallPos.x,0,overallPos.y);
chunkPos is values such as (0,0),(1,0),(0,1) etc and then I use the mapWidth to set it properly in the world. I will leave out the code to keep it short, but I set the vertices, normals, etc locally, they all appear correct when I generate the meshes…
The bounds are set here…
var bounds = new Bounds(new Vector3((overallPos.x + ((mapWidth+1)/2 )),0,(overallPos.y + ((mapWidth + 1) / 2))), Vector3.one * (mapWidth+1));
This puts the bounds around each terrain chunk and it appears correct. See the following images
