From 5d2aeba4e93c73891ac5ecb677c0f62b4bdc3b79 Mon Sep 17 00:00:00 2001 From: austin Date: Wed, 28 May 2025 15:54:04 -0400 Subject: [PATCH] improve TownLayout placement --- docs/src/progress/renderertodo.md | 1 + .../server/macro/town/TownLayout.java | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 09a68d93..694ef7c0 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2023,6 +2023,7 @@ Body synchronization includes enabled state Fix upright tree continuously re-enabling bodies Fix server collision resolution never triggering for second body Fix macro structure rotation generation +Improvement to building placement math in TownLayout diff --git a/src/main/java/electrosphere/server/macro/town/TownLayout.java b/src/main/java/electrosphere/server/macro/town/TownLayout.java index dc427b86..a3a6b9a4 100644 --- a/src/main/java/electrosphere/server/macro/town/TownLayout.java +++ b/src/main/java/electrosphere/server/macro/town/TownLayout.java @@ -226,7 +226,7 @@ public class TownLayout { MacroData macroData = realm.getMacroData(); //get values to scan along - Vector3d dir = new Vector3d(endPoint).sub(startPoint).normalize(); + // Vector3d dir = new Vector3d(endPoint).sub(startPoint).normalize(); int len = (int)startPoint.distance(endPoint); //determine if it's primarily north-south or east-west @@ -254,8 +254,8 @@ public class TownLayout { rotQuat2 = CursorState.getBlockRotation(rotation2); } else { roadOffset = new Vector3d(0,0,roadRadiusOffsetRaw); - rotation1 = VirtualStructure.ROT_FACE_WEST; - rotation2 = VirtualStructure.ROT_FACE_EAST; + rotation1 = VirtualStructure.ROT_FACE_EAST; + rotation2 = VirtualStructure.ROT_FACE_WEST; rotQuat1 = CursorState.getBlockRotation(rotation1); rotQuat2 = CursorState.getBlockRotation(rotation2); } @@ -268,7 +268,7 @@ public class TownLayout { StructureData structureData = allowedStructures.get(0); //scan along the length of the road - for(int i = roadRadiusOffsetRaw; i < len; i++){ + for(int i = roadRadiusOffsetRaw; i < len - roadRadiusOffsetRaw; i++){ //update rotation spatial offset based on current struct rotOffset.set(structureData.getDimensions()); rotQuat1.transform(rotOffset); @@ -298,7 +298,7 @@ public class TownLayout { } //scan along the length of the road - for(int i = 0; i < len; i++){ + for(int i = roadRadiusOffsetRaw; i < len - roadRadiusOffsetRaw; i++){ //update rotation spatial offset based on current struct rotOffset.set(structureData.getDimensions()); rotQuat2.transform(rotOffset); @@ -308,12 +308,12 @@ public class TownLayout { rotOffset.mul(-1); //solve terrain position to place - currPos.set(dir).mul(i).add(startPoint).sub(roadOffset).sub(structureData.getDimensions()); + currPos.set(startPoint).lerp(endPoint,i/(double)len).sub(roadOffset);//.sub(structureData.getDimensions()); currPos.y = realm.getServerWorldData().getServerTerrainManager().getElevation(currPos); //apply structure placement offset currPos.add(structureData.getPlacementOffset()); //add offset to re-align after rotation - // currPos.add(5,0,5); + currPos.add(rotOffset.x,0,rotOffset.z); //update aabb VirtualStructure.setAABB(aabb, currPos, structureData.getDimensions(), rotation2);