|
@@ -112,13 +112,39 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals
|
|
|
SimSet *set = NavMesh::getServerSet();
|
|
|
for(U32 i = 0; i < set->size(); i++)
|
|
|
{
|
|
|
- NavMesh *m = static_cast<NavMesh*>(set->at(i));
|
|
|
- m->buildTiles(obj->getWorldBox());
|
|
|
+ NavMesh *m = dynamic_cast<NavMesh*>(set->at(i));
|
|
|
+ if (m)
|
|
|
+ {
|
|
|
+ m->cancelBuild();
|
|
|
+ m->buildTiles(obj->getWorldBox());
|
|
|
+ }
|
|
|
}
|
|
|
if(remove)
|
|
|
obj->enableCollision();
|
|
|
}
|
|
|
|
|
|
+DefineConsoleFunction(NavMeshUpdateAroundObject, void, (S32 objid, bool remove), (0, false),
|
|
|
+ "@brief Update all NavMesh tiles that intersect the given object's world box.")
|
|
|
+{
|
|
|
+ SceneObject *obj;
|
|
|
+ if (!Sim::findObject(objid, obj))
|
|
|
+ return;
|
|
|
+ if (remove)
|
|
|
+ obj->disableCollision();
|
|
|
+ SimSet *set = NavMesh::getServerSet();
|
|
|
+ for (U32 i = 0; i < set->size(); i++)
|
|
|
+ {
|
|
|
+ NavMesh *m = dynamic_cast<NavMesh*>(set->at(i));
|
|
|
+ if (m)
|
|
|
+ {
|
|
|
+ m->cancelBuild();
|
|
|
+ m->buildTiles(obj->getWorldBox());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (remove)
|
|
|
+ obj->enableCollision();
|
|
|
+}
|
|
|
+
|
|
|
DefineConsoleFunction(NavMeshUpdateOne, void, (S32 meshid, S32 objid, bool remove), (0, 0, false),
|
|
|
"@brief Update all tiles in a given NavMesh that intersect the given object's world box.")
|
|
|
{
|
|
@@ -147,7 +173,7 @@ NavMesh::NavMesh()
|
|
|
mFileName = StringTable->insert("");
|
|
|
mNetFlags.clear(Ghostable);
|
|
|
|
|
|
- mSaveIntermediates = true;
|
|
|
+ mSaveIntermediates = false;
|
|
|
nm = NULL;
|
|
|
ctx = NULL;
|
|
|
|
|
@@ -765,13 +791,15 @@ void NavMesh::buildNextTile()
|
|
|
// Intermediate data for tile build.
|
|
|
TileData tempdata;
|
|
|
TileData &tdata = mSaveIntermediates ? mTileData[i] : tempdata;
|
|
|
+
|
|
|
+ // Remove any previous data.
|
|
|
+ nm->removeTile(nm->getTileRefAt(tile.x, tile.y, 0), 0, 0);
|
|
|
+
|
|
|
// Generate navmesh for this tile.
|
|
|
U32 dataSize = 0;
|
|
|
unsigned char* data = buildTileData(tile, tdata, dataSize);
|
|
|
if(data)
|
|
|
{
|
|
|
- // Remove any previous data.
|
|
|
- nm->removeTile(nm->getTileRefAt(tile.x, tile.y, 0), 0, 0);
|
|
|
// Add new data (navmesh owns and deletes the data).
|
|
|
dtStatus status = nm->addTile(data, dataSize, DT_TILE_FREE_DATA, 0, 0);
|
|
|
int success = 1;
|
|
@@ -830,6 +858,7 @@ unsigned char *NavMesh::buildTileData(const Tile &tile, TileData &data, U32 &dat
|
|
|
SceneContainer::CallbackInfo info;
|
|
|
info.context = PLC_Navigation;
|
|
|
info.boundingBox = box;
|
|
|
+ data.geom.clear();
|
|
|
info.polyList = &data.geom;
|
|
|
info.key = this;
|
|
|
getContainer()->findObjects(box, StaticShapeObjectType | TerrainObjectType, buildCallback, &info);
|
|
@@ -843,8 +872,11 @@ unsigned char *NavMesh::buildTileData(const Tile &tile, TileData &data, U32 &dat
|
|
|
}
|
|
|
|
|
|
// Check for no geometry.
|
|
|
- if(!data.geom.getVertCount())
|
|
|
+ if (!data.geom.getVertCount())
|
|
|
+ {
|
|
|
+ data.geom.clear();
|
|
|
return NULL;
|
|
|
+ }
|
|
|
|
|
|
// Figure out voxel dimensions of this tile.
|
|
|
U32 width = 0, height = 0;
|