navmesh construction fix
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
f64d360d14
commit
6c06391245
@ -1515,6 +1515,7 @@ Obliterate old navmesh/pathfinding code
|
|||||||
Integrate recast4j as pathfinding source
|
Integrate recast4j as pathfinding source
|
||||||
GriddedDataCellManager pathfinding solution
|
GriddedDataCellManager pathfinding solution
|
||||||
ServerTerrainManager nullcheck fix
|
ServerTerrainManager nullcheck fix
|
||||||
|
Fix nav mesh construction params
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -357,7 +357,9 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
|||||||
TerrainChunkData terrainMeshData = cell.getTerrainChunkData();
|
TerrainChunkData terrainMeshData = cell.getTerrainChunkData();
|
||||||
ServerDataCell serverDataCell = this.groundDataCells.get(key);
|
ServerDataCell serverDataCell = this.groundDataCells.get(key);
|
||||||
GriddedDataCellTrackingData trackingData = this.cellTrackingMap.get(serverDataCell);
|
GriddedDataCellTrackingData trackingData = this.cellTrackingMap.get(serverDataCell);
|
||||||
|
if(terrainMeshData.getVertices().length > 0){
|
||||||
trackingData.setNavMeshData(NavMeshConstructor.constructNavmesh(terrainMeshData));
|
trackingData.setNavMeshData(NavMeshConstructor.constructNavmesh(terrainMeshData));
|
||||||
|
}
|
||||||
|
|
||||||
loadedCellsLock.lock();
|
loadedCellsLock.lock();
|
||||||
posPhysicsMap.put(key, cell);
|
posPhysicsMap.put(key, cell);
|
||||||
@ -778,7 +780,9 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
//create pathfinding mesh
|
//create pathfinding mesh
|
||||||
|
if(terrainMeshData.getVertices().length > 0){
|
||||||
trackingData.setNavMeshData(NavMeshConstructor.constructNavmesh(terrainMeshData));
|
trackingData.setNavMeshData(NavMeshConstructor.constructNavmesh(terrainMeshData));
|
||||||
|
}
|
||||||
|
|
||||||
//set ready
|
//set ready
|
||||||
dataCell.setReady(true);
|
dataCell.setReady(true);
|
||||||
|
|||||||
@ -76,8 +76,11 @@ public class NavMeshConstructor {
|
|||||||
* @return the MeshData
|
* @return the MeshData
|
||||||
*/
|
*/
|
||||||
public static MeshData constructNavmesh(TerrainChunkData terrainChunkData){
|
public static MeshData constructNavmesh(TerrainChunkData terrainChunkData){
|
||||||
|
MeshData rVal = null;
|
||||||
|
|
||||||
|
try {
|
||||||
RecastConfig recastConfig = new RecastConfig(
|
RecastConfig recastConfig = new RecastConfig(
|
||||||
PartitionType.MONOTONE,
|
PartitionType.WATERSHED,
|
||||||
RECAST_CELL_SIZE,
|
RECAST_CELL_SIZE,
|
||||||
RECAST_CELL_HEIGHT,
|
RECAST_CELL_HEIGHT,
|
||||||
RECAST_AGENT_HEIGHT,
|
RECAST_AGENT_HEIGHT,
|
||||||
@ -101,7 +104,13 @@ public class NavMeshConstructor {
|
|||||||
for(int i = 0; i < polyMesh.npolys; i++){
|
for(int i = 0; i < polyMesh.npolys; i++){
|
||||||
polyMesh.flags[i] = 1;
|
polyMesh.flags[i] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PolyMeshDetail polyMeshDetail = recastBuilderResult.getMeshDetail();
|
PolyMeshDetail polyMeshDetail = recastBuilderResult.getMeshDetail();
|
||||||
|
if(polyMeshDetail == null){
|
||||||
|
throw new Error("Poly mesh detail is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
//set params
|
||||||
NavMeshDataCreateParams params = new NavMeshDataCreateParams();
|
NavMeshDataCreateParams params = new NavMeshDataCreateParams();
|
||||||
params.verts = polyMesh.verts;
|
params.verts = polyMesh.verts;
|
||||||
params.vertCount = polyMesh.nverts;
|
params.vertCount = polyMesh.nverts;
|
||||||
@ -142,9 +151,16 @@ public class NavMeshConstructor {
|
|||||||
// params.offMeshConUserID = new int[1];
|
// params.offMeshConUserID = new int[1];
|
||||||
// params.offMeshConUserID[0] = 0x4567;
|
// params.offMeshConUserID[0] = 0x4567;
|
||||||
// params.offMeshConCount = 1;
|
// params.offMeshConCount = 1;
|
||||||
MeshData meshData = NavMeshBuilder.createNavMeshData(params);
|
|
||||||
|
|
||||||
return meshData;
|
//actually build
|
||||||
|
rVal = NavMeshBuilder.createNavMeshData(params);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user