--mikko
Sent from my iPhone
TileRefs are just handlers which are kind of like pointers which can
be stored to disk.
Your could not completely follow your example case. I recommend you to
try to mimic the example code.
TileCache tiles know their world position. When you update tile cache,
it will compute any changes that happen and directly add/remove
navmesh pieces in the attached navmesh.
--mikko
Why many tile caches? There should be one tile cache per navmesh.
--mikko
You should not do that. But you can store the cache tiles per your
terrain tile if you want to do so. Tile cache does not care where the
data comes from.
What is really important is to make sure the tile coordinates are
correct. They describe at which location the tile will be put in the
world. The tile coordinates are set when you build the cached tile.
--mikko
If you have large world, you should only add the tiles to the cache
that can fit into memory at any given time (or based on some other
constraint). The data to dtTileCache.addTile() can be stored in any
where you like, it is just a blob of data.
When you add a tile to tile cache, the intended procedure is to first
add all the layers (addTile()), and the build navmesh piece for that
location (buildNavMeshTilesAt()). I probably could add few things
there it simplify this process.
--mikko
Your thoughts about rebuild are correct. Also note that recast stores the navmesh in world coordinates.
--mikko
Sent from my iPhone
--mikko
If you want the seams of the tiles to get patched up at run time, you need to pass in the neighboring geometry to the tile generation process. This allows recast to 1: make sure vertices along neighbor edges have the same quantized position in all tiles and 2: actually know those points on the edge should generate portals to polygons in the neighbor instead of being eroded.
It sounded like you were going to go the route of just adding tiles instead of using the tile cache. With this approach you'll still only need one dtNavMesh; you just add multiple tiles. If you want to generate paths across your tiles they'll need to be in the same dtNavMes or you'll need to implement your own solution for traversing the tiles.
--mikko
The tiles A, B, C, D... are your game world tiles. Now when you build
Recast tile 1 for your game world tile E, you will need to pass the
level geometry from your tiles A, B, D, and E. That is, all the
geometry that touches the expanded bounding box (dotted line around
the Recast tile).
This expanded bounding box is calculate here:
http://code.google.com/p/recastnavigation/source/browse/trunk/RecastDemo/Source/Sample_TileMesh.cpp#927
This whole process ensures that the Recast navmesh tiles will match
when they are build for your different game world tiles, and that the
obstacles which are close to the border will be computed correctly.
--mikko
--mikko
--
- Piotr Zaremba