navmesh construction fix
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
austin 2025-04-16 17:06:29 -04:00
parent f64d360d14
commit 6c06391245
3 changed files with 90 additions and 69 deletions

View File

@ -1515,6 +1515,7 @@ Obliterate old navmesh/pathfinding code
Integrate recast4j as pathfinding source
GriddedDataCellManager pathfinding solution
ServerTerrainManager nullcheck fix
Fix nav mesh construction params

View File

@ -357,7 +357,9 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
TerrainChunkData terrainMeshData = cell.getTerrainChunkData();
ServerDataCell serverDataCell = this.groundDataCells.get(key);
GriddedDataCellTrackingData trackingData = this.cellTrackingMap.get(serverDataCell);
if(terrainMeshData.getVertices().length > 0){
trackingData.setNavMeshData(NavMeshConstructor.constructNavmesh(terrainMeshData));
}
loadedCellsLock.lock();
posPhysicsMap.put(key, cell);
@ -778,7 +780,9 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
}
//create pathfinding mesh
if(terrainMeshData.getVertices().length > 0){
trackingData.setNavMeshData(NavMeshConstructor.constructNavmesh(terrainMeshData));
}
//set ready
dataCell.setReady(true);

View File

@ -76,8 +76,11 @@ public class NavMeshConstructor {
* @return the MeshData
*/
public static MeshData constructNavmesh(TerrainChunkData terrainChunkData){
MeshData rVal = null;
try {
RecastConfig recastConfig = new RecastConfig(
PartitionType.MONOTONE,
PartitionType.WATERSHED,
RECAST_CELL_SIZE,
RECAST_CELL_HEIGHT,
RECAST_AGENT_HEIGHT,
@ -101,7 +104,13 @@ public class NavMeshConstructor {
for(int i = 0; i < polyMesh.npolys; i++){
polyMesh.flags[i] = 1;
}
PolyMeshDetail polyMeshDetail = recastBuilderResult.getMeshDetail();
if(polyMeshDetail == null){
throw new Error("Poly mesh detail is null");
}
//set params
NavMeshDataCreateParams params = new NavMeshDataCreateParams();
params.verts = polyMesh.verts;
params.vertCount = polyMesh.nverts;
@ -142,9 +151,16 @@ public class NavMeshConstructor {
// params.offMeshConUserID = new int[1];
// params.offMeshConUserID[0] = 0x4567;
// params.offMeshConCount = 1;
MeshData meshData = NavMeshBuilder.createNavMeshData(params);
return meshData;
//actually build
rVal = NavMeshBuilder.createNavMeshData(params);
} catch (Exception e){
e.printStackTrace();
}
return rVal;
}
}