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