pathing construction for farm plots
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-05-30 14:39:43 -04:00
parent 518c249b9e
commit d4858f7d90
2 changed files with 34 additions and 3 deletions

View File

@ -2077,6 +2077,7 @@ Start work on macro pathfinding storage
Town constructs nav graph of road nodes Town constructs nav graph of road nodes
Render pathing nodes (still needs some work) Render pathing nodes (still needs some work)
Pathing construction between town buildings and road nodes Pathing construction between town buildings and road nodes
Pathing construction for farm plots

View File

@ -374,8 +374,20 @@ public class TownLayout {
plotPoint2.y = plotPoint1.y; plotPoint2.y = plotPoint1.y;
plotPoint3.y = plotPoint1.y; plotPoint3.y = plotPoint1.y;
plotPoint4.y = plotPoint1.y; plotPoint4.y = plotPoint1.y;
//define a farm plot with these points MacroPathNode roadPoint1 = positionNodeMap.get(openHash);
TownLayout.generateFarmPlot(realm,macroData,town,plotPoint1,plotPoint2,plotPoint3,plotPoint4); MacroPathNode roadPoint2 = positionNodeMap.get(HashUtils.hashIVec(HASH_OFFSET + x + 1, 0, HASH_OFFSET + z + 0));
MacroPathNode roadPoint3 = positionNodeMap.get(HashUtils.hashIVec(HASH_OFFSET + x + 0, 0, HASH_OFFSET + z + 1));
MacroPathNode roadPoint4 = positionNodeMap.get(HashUtils.hashIVec(HASH_OFFSET + x + 1, 0, HASH_OFFSET + z + 1));
if(roadPoint1 == null || roadPoint2 == null || roadPoint3 == null || roadPoint4 == null){
// throw new Error("Failed to resolve road points! " + roadPoint1 + " " + roadPoint2 + " " + roadPoint1 + " " + roadPoint2);
} else {
//define a farm plot with these points
TownLayout.generateFarmPlot(
realm,macroData,town,
roadPoint1,roadPoint2,roadPoint3,roadPoint4,
plotPoint1,plotPoint2,plotPoint3,plotPoint4
);
}
} }
closedSet.add(openHash); closedSet.add(openHash);
@ -516,7 +528,11 @@ public class TownLayout {
* @param point3 The third point * @param point3 The third point
* @param point4 The fourth point * @param point4 The fourth point
*/ */
private static void generateFarmPlot(Realm realm, MacroData macroData, Town town, Vector3d point1, Vector3d point2, Vector3d point3, Vector3d point4){ private static void generateFarmPlot(
Realm realm, MacroData macroData, Town town,
MacroPathNode roadPoint1, MacroPathNode roadPoint2, MacroPathNode roadPoint3, MacroPathNode roadPoint4,
Vector3d point1, Vector3d point2, Vector3d point3, Vector3d point4
){
RegionPrism region = RegionPrism.create(new Vector3d[]{ RegionPrism region = RegionPrism.create(new Vector3d[]{
new Vector3d(point1).sub(0,FARM_PLOT_DEFAULT_HEIGHT/2.0f,0), new Vector3d(point1).sub(0,FARM_PLOT_DEFAULT_HEIGHT/2.0f,0),
new Vector3d(point2).sub(0,FARM_PLOT_DEFAULT_HEIGHT/2.0f,0), new Vector3d(point2).sub(0,FARM_PLOT_DEFAULT_HEIGHT/2.0f,0),
@ -525,6 +541,20 @@ public class TownLayout {
}, FARM_PLOT_DEFAULT_HEIGHT); }, FARM_PLOT_DEFAULT_HEIGHT);
MacroRegion macroRegion = MacroRegion.create(macroData, region); MacroRegion macroRegion = MacroRegion.create(macroData, region);
town.addFarmPlot(macroRegion); town.addFarmPlot(macroRegion);
//find center point of region
Vector3d centerPoint = new Vector3d();
centerPoint.add(point1);
centerPoint.add(point2);
centerPoint.add(point3);
centerPoint.add(point4);
centerPoint.mul(0.25);
centerPoint.y = realm.getServerWorldData().getServerTerrainManager().getElevation(centerPoint);
//create pathing node for region and link it to nearest town centers
MacroPathNode structNode = MacroPathNode.create(macroData.getPathCache(), macroRegion, centerPoint);
structNode.addNeighbor(roadPoint1);
structNode.addNeighbor(roadPoint2);
structNode.addNeighbor(roadPoint3);
structNode.addNeighbor(roadPoint4);
} }
/** /**