MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / buildTileData

Method buildTileData

Engine/source/navigation/navMesh.cpp:855–1093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

853}
854
855unsigned char *NavMesh::buildTileData(const Tile &tile, TileData &data, U32 &dataSize)
856{
857 // Push out tile boundaries a bit.
858 F32 tileBmin[3], tileBmax[3];
859 rcVcopy(tileBmin, tile.bmin);
860 rcVcopy(tileBmax, tile.bmax);
861 tileBmin[0] -= cfg.borderSize * cfg.cs;
862 tileBmin[2] -= cfg.borderSize * cfg.cs;
863 tileBmax[0] += cfg.borderSize * cfg.cs;
864 tileBmax[2] += cfg.borderSize * cfg.cs;
865
866 // Parse objects from level into RC-compatible format.
867 Box3F box = RCtoDTS(tileBmin, tileBmax);
868 SceneContainer::CallbackInfo info;
869 info.context = PLC_Navigation;
870 info.boundingBox = box;
871 data.geom.clear();
872 info.polyList = &data.geom;
873 info.key = this;
874 getContainer()->findObjects(box, StaticObjectType | DynamicShapeObjectType, buildCallback, &info);
875
876 // Parse water objects into the same list, but remember how much geometry was /not/ water.
877 U32 nonWaterVertCount = data.geom.getVertCount();
878 U32 nonWaterTriCount = data.geom.getTriCount();
879 if(mWaterMethod != Ignore)
880 {
881 getContainer()->findObjects(box, WaterObjectType, buildCallback, &info);
882 }
883
884 // Check for no geometry.
885 if (!data.geom.getVertCount())
886 {
887 data.geom.clear();
888 return NULL;
889 }
890
891 // Figure out voxel dimensions of this tile.
892 U32 width = 0, height = 0;
893 width = cfg.tileSize + cfg.borderSize * 2;
894 height = cfg.tileSize + cfg.borderSize * 2;
895
896 // Create a heightfield to voxelise our input geometry.
897 data.hf = rcAllocHeightfield();
898 if(!data.hf)
899 {
900 Con::errorf("Out of memory (rcHeightField) for NavMesh %s", getIdString());
901 return NULL;
902 }
903 if(!rcCreateHeightfield(ctx, *data.hf, width, height, tileBmin, tileBmax, cfg.cs, cfg.ch))
904 {
905 Con::errorf("Could not generate rcHeightField for NavMesh %s", getIdString());
906 return NULL;
907 }
908
909 unsigned char *areas = new unsigned char[data.geom.getTriCount()];
910
911 dMemset(areas, 0, data.geom.getTriCount() * sizeof(unsigned char));
912

Callers

nothing calls this directly

Calls 15

rcVcopyFunction · 0.85
RCtoDTSFunction · 0.85
rcAllocHeightfieldFunction · 0.85
rcCreateHeightfieldFunction · 0.85
rcMarkWalkableTrianglesFunction · 0.85
rcRasterizeTrianglesFunction · 0.85
rcFilterLedgeSpansFunction · 0.85
rcErodeWalkableAreaFunction · 0.85

Tested by

no test coverage detected