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

Method buildTileData

Engine/source/navigation/navMesh.cpp:857–1095  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected