MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / buildNextTile

Method buildNextTile

Engine/source/navigation/navMesh.cpp:794–848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792}
793
794void NavMesh::buildNextTile()
795{
796 if(!mDirtyTiles.empty())
797 {
798 // Pop a single dirty tile and process it.
799 U32 i = mDirtyTiles.front();
800 mDirtyTiles.pop_front();
801 const Tile &tile = mTiles[i];
802 // Intermediate data for tile build.
803 TileData tempdata;
804 TileData &tdata = mSaveIntermediates ? mTileData[i] : tempdata;
805
806 // Remove any previous data.
807 nm->removeTile(nm->getTileRefAt(tile.x, tile.y, 0), 0, 0);
808
809 // Generate navmesh for this tile.
810 U32 dataSize = 0;
811 unsigned char* data = buildTileData(tile, tdata, dataSize);
812 if(data)
813 {
814 // Add new data (navmesh owns and deletes the data).
815 dtStatus status = nm->addTile(data, dataSize, DT_TILE_FREE_DATA, 0, 0);
816 int success = 1;
817 if(dtStatusFailed(status))
818 {
819 success = 0;
820 dtFree(data);
821 }
822 if(getEventManager())
823 {
824 String str = String::ToString("%d %d %d (%d, %d) %d %.3f %s",
825 getId(),
826 i, mTiles.size(),
827 tile.x, tile.y,
828 success,
829 ctx->getAccumulatedTime(RC_TIMER_TOTAL) / 1000.0f,
830 castConsoleTypeToString(tile.box));
831 getEventManager()->postEvent("NavMeshTileUpdate", str.c_str());
832 setMaskBits(LoadFlag);
833 }
834 }
835 // Did we just build the last tile?
836 if(mDirtyTiles.empty())
837 {
838 ctx->stopTimer(RC_TIMER_TOTAL);
839 if(getEventManager())
840 {
841 String str = String::ToString("%d", getId());
842 getEventManager()->postEvent("NavMeshUpdate", str.c_str());
843 setMaskBits(LoadFlag);
844 }
845 mBuilding = false;
846 }
847 }
848}
849
850static void buildCallback(SceneObject* object,void *key)
851{

Callers

nothing calls this directly

Calls 13

dtStatusFailedFunction · 0.85
dtFreeFunction · 0.85
getTileRefAtMethod · 0.80
getAccumulatedTimeMethod · 0.80
postEventMethod · 0.80
emptyMethod · 0.45
frontMethod · 0.45
pop_frontMethod · 0.45
removeTileMethod · 0.45
addTileMethod · 0.45
sizeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected