| 792 | } |
| 793 | |
| 794 | void 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 | |
| 850 | static void buildCallback(SceneObject* object,void *key) |
| 851 | { |
nothing calls this directly
no test coverage detected