浏览代码

dynamic_cast check for regeneration for paranoias sake + an alias method.

Azaezel 9 年之前
父节点
当前提交
f06db00255
共有 1 个文件被更改,包括 23 次插入1 次删除
  1. 23 1
      Engine/source/navigation/navMesh.cpp

+ 23 - 1
Engine/source/navigation/navMesh.cpp

@@ -112,7 +112,7 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals
    SimSet *set = NavMesh::getServerSet();
    SimSet *set = NavMesh::getServerSet();
    for(U32 i = 0; i < set->size(); i++)
    for(U32 i = 0; i < set->size(); i++)
    {
    {
-      NavMesh *m = static_cast<NavMesh*>(set->at(i));
+      NavMesh *m = dynamic_cast<NavMesh*>(set->at(i));
       if (m)
       if (m)
       {
       {
          m->cancelBuild();
          m->cancelBuild();
@@ -123,6 +123,28 @@ DefineConsoleFunction(NavMeshUpdateAll, void, (S32 objid, bool remove), (0, fals
       obj->enableCollision();
       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),
 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.")
    "@brief Update all tiles in a given NavMesh that intersect the given object's world box.")
 {
 {