scaffolding for farm plots
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-28 18:33:19 -04:00
parent 258d73be9a
commit 9ee7c9e208
2 changed files with 87 additions and 1 deletions

View File

@ -2034,6 +2034,8 @@ More job data scaffolding
Config class cleanup
Fix jobs data, simplify block chunk gen algo
Convex y-aligned prism intersection checking
Fix block LOD chunk rendering (scaling not applying)
Scaffolding for laying out farm plots around towns

View File

@ -37,6 +37,11 @@ public class TownLayout {
*/
public static final double TOWN_MAX_RADIUS = 256;
/**
* Radius within which to place densly-packed buildings
*/
public static final double TOWN_CENTER_RADIUS = 128;
/**
* Relaxation factor for regularizing placement of town center nodes
*/
@ -206,13 +211,79 @@ public class TownLayout {
//build road and structures between curr and next node
if(closedSet.contains(newHash)){
TownLayout.generateStructuresAlongRoad(realm, town, nearPoint, currPoint, Road.DEFAULT_RADIUS, allowedStructures);
if(nearPoint.distance(townCenter) < TOWN_CENTER_RADIUS && currPoint.distance(townCenter) < TOWN_CENTER_RADIUS){
TownLayout.generateStructuresAlongRoad(realm, town, nearPoint, currPoint, Road.DEFAULT_RADIUS, allowedStructures);
}
}
}
}
closedSet.add(openHash);
}
//
//Place field plots
//
//points for defining farm plots
Vector3d plotPoint1 = new Vector3d();
Vector3d plotPoint2 = new Vector3d();
Vector3d plotPoint3 = new Vector3d();
Vector3d plotPoint4 = new Vector3d();
//
//sets for breadth search
openSet = new LinkedList<Long>();
closedSet = new LinkedList<Long>();
closedSet.add(HashUtils.hashIVec(HASH_OFFSET, 0, HASH_OFFSET));
openSet.add(HashUtils.hashIVec(HASH_OFFSET - 1, 0, HASH_OFFSET));
openSet.add(HashUtils.hashIVec(HASH_OFFSET + 1, 0, HASH_OFFSET));
openSet.add(HashUtils.hashIVec(HASH_OFFSET, 0, HASH_OFFSET - 1));
openSet.add(HashUtils.hashIVec(HASH_OFFSET, 0, HASH_OFFSET + 1));
while(openSet.size() > 0){
long openHash = openSet.poll();
int x = HashUtils.unhashIVec(openHash, HashUtils.UNHASH_COMPONENT_X) - HASH_OFFSET;
int z = HashUtils.unhashIVec(openHash, HashUtils.UNHASH_COMPONENT_Z) - HASH_OFFSET;
scanPoint.set(townCenter).add(TOWN_LAYOUT_SCALER * x,0,TOWN_LAYOUT_SCALER * z);
currPoint = TownLayout.getTownCenter(realm, scanPoint);
//check below
for(int i = 0; i < 4; i++){
int oX = x + offsetX[i];
int oZ = z + offsetZ[i];
scanPoint.set(townCenter).add(TOWN_LAYOUT_SCALER * oX,0,TOWN_LAYOUT_SCALER * oZ);
nearPoint = TownLayout.getTownCenter(realm, scanPoint);
long newHash = HashUtils.hashIVec(HASH_OFFSET + oX, 0, HASH_OFFSET + oZ);
if(nearPoint.distance(townCenter) < TOWN_MAX_RADIUS){
if(!openSet.contains(newHash) && !closedSet.contains(newHash)){
openSet.add(newHash);
}
}
}
//this is +0,+0
plotPoint1.set(currPoint);
scanPoint.set(townCenter).add(TOWN_LAYOUT_SCALER * (x + 1),0,TOWN_LAYOUT_SCALER * (z + 0));
plotPoint2.set(scanPoint);
scanPoint.set(townCenter).add(TOWN_LAYOUT_SCALER * (x + 1),0,TOWN_LAYOUT_SCALER * (z + 1));
plotPoint3.set(scanPoint);
scanPoint.set(townCenter).add(TOWN_LAYOUT_SCALER * (x + 0),0,TOWN_LAYOUT_SCALER * (z + 1));
plotPoint4.set(scanPoint);
if(
plotPoint1.distance(townCenter) > TOWN_CENTER_RADIUS &&
plotPoint2.distance(townCenter) > TOWN_CENTER_RADIUS &&
plotPoint3.distance(townCenter) > TOWN_CENTER_RADIUS &&
plotPoint4.distance(townCenter) > TOWN_CENTER_RADIUS
){
plotPoint1.y = realm.getServerWorldData().getServerTerrainManager().getElevation(plotPoint1);
//define a farm plot with these points
TownLayout.generateFarmPlot(realm,town,plotPoint1,plotPoint2,plotPoint3,plotPoint4);
}
closedSet.add(openHash);
}
}
/**
@ -325,6 +396,19 @@ public class TownLayout {
}
}
/**
* Creates a farm plot in the town at a given set of points
* @param realm The realm the town is in
* @param town The town
* @param point1 The first point
* @param point2 The second point
* @param point3 The third point
* @param point4 The fourth point
*/
private static void generateFarmPlot(Realm realm, Town town, Vector3d point1, Vector3d point2, Vector3d point3, Vector3d point4){
}
/**
* Clamps the scan point to the closest town center point
* @param realm The realm