diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 768712a2..dc04fd6c 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -1914,6 +1914,7 @@ Delete unused class Calculate road-interection nodes for town layout Place roads using line segments instead of splines Town layout tries to connect intersection nodes with roads +Macro area objects don't store start/end bounds separate from aabb anymore diff --git a/src/main/java/electrosphere/server/ai/nodes/solvers/SolveBuildMaterialNode.java b/src/main/java/electrosphere/server/ai/nodes/solvers/SolveBuildMaterialNode.java index 23955165..64d976a9 100644 --- a/src/main/java/electrosphere/server/ai/nodes/solvers/SolveBuildMaterialNode.java +++ b/src/main/java/electrosphere/server/ai/nodes/solvers/SolveBuildMaterialNode.java @@ -1,5 +1,6 @@ package electrosphere.server.ai.nodes.solvers; +import org.joml.AABBd; import org.joml.Vector3d; import org.joml.Vector3i; @@ -41,7 +42,8 @@ public class SolveBuildMaterialNode implements AITreeNode { String itemId = Item.getBlockTypeId(blockType); //store the position of the block we want to place - Vector3d realPos = new Vector3d(struct.getStartPos()).add( + AABBd structAABB = struct.getAABB(); + Vector3d realPos = new Vector3d(structAABB.minX,structAABB.minY,structAABB.minZ).add( repairPos.x * BlockChunkData.BLOCK_SIZE_MULTIPLIER, repairPos.y * BlockChunkData.BLOCK_SIZE_MULTIPLIER, repairPos.z * BlockChunkData.BLOCK_SIZE_MULTIPLIER diff --git a/src/main/java/electrosphere/server/macro/civilization/road/Road.java b/src/main/java/electrosphere/server/macro/civilization/road/Road.java index 4a7596a4..9f19c684 100644 --- a/src/main/java/electrosphere/server/macro/civilization/road/Road.java +++ b/src/main/java/electrosphere/server/macro/civilization/road/Road.java @@ -159,16 +159,6 @@ public class Road implements MacroAreaObject { throw new UnsupportedOperationException("Unimplemented method 'setPos'"); } - @Override - public Vector3d getStartPos() { - return new Vector3d(aabb.minX, aabb.minY, aabb.minZ); - } - - @Override - public Vector3d getEndPos() { - return new Vector3d(aabb.maxX, aabb.maxY, aabb.maxZ); - } - @Override public AABBd getAABB() { return aabb; diff --git a/src/main/java/electrosphere/server/macro/spatial/MacroAreaObject.java b/src/main/java/electrosphere/server/macro/spatial/MacroAreaObject.java index 565221a5..fbb44622 100644 --- a/src/main/java/electrosphere/server/macro/spatial/MacroAreaObject.java +++ b/src/main/java/electrosphere/server/macro/spatial/MacroAreaObject.java @@ -1,24 +1,11 @@ package electrosphere.server.macro.spatial; import org.joml.AABBd; -import org.joml.Vector3d; /** * A macro object that takes up an area of space instead of just a point */ public interface MacroAreaObject extends MacroObject { - - /** - * Gets the start position of the AABB for the object - * @return The start position - */ - public Vector3d getStartPos(); - - /** - * Gets the end position of the AABB for the object - * @return The end position - */ - public Vector3d getEndPos(); /** * Gets the AABB for the object diff --git a/src/main/java/electrosphere/server/macro/structure/VirtualStructure.java b/src/main/java/electrosphere/server/macro/structure/VirtualStructure.java index 6d428d3f..3c753f99 100644 --- a/src/main/java/electrosphere/server/macro/structure/VirtualStructure.java +++ b/src/main/java/electrosphere/server/macro/structure/VirtualStructure.java @@ -85,16 +85,6 @@ public class VirtualStructure implements MacroAreaObject { this.position = pos; } - @Override - public Vector3d getStartPos() { - return new Vector3d(aabb.minX,aabb.minY,aabb.minZ); - } - - @Override - public Vector3d getEndPos() { - return new Vector3d(aabb.maxX,aabb.maxY,aabb.maxZ); - } - @Override public AABBd getAABB() { return this.aabb; diff --git a/src/main/java/electrosphere/server/macro/town/Town.java b/src/main/java/electrosphere/server/macro/town/Town.java index f5d42268..0d4d03cc 100644 --- a/src/main/java/electrosphere/server/macro/town/Town.java +++ b/src/main/java/electrosphere/server/macro/town/Town.java @@ -164,19 +164,9 @@ public class Town implements MacroAreaObject { this.position = pos; } - @Override - public Vector3d getStartPos() { - return new Vector3d(this.position).sub(this.radius,this.radius,this.radius); - } - - @Override - public Vector3d getEndPos() { - return new Vector3d(this.position).add(this.radius,this.radius,this.radius); - } - @Override public AABBd getAABB() { - return new AABBd(this.getStartPos(), this.getEndPos()); + return new AABBd(new Vector3d(this.position).sub(this.radius,this.radius,this.radius), new Vector3d(this.position).add(this.radius,this.radius,this.radius)); } /** diff --git a/src/main/java/electrosphere/server/macro/utils/StructureRepairUtils.java b/src/main/java/electrosphere/server/macro/utils/StructureRepairUtils.java index f8aef5d9..26f73df3 100644 --- a/src/main/java/electrosphere/server/macro/utils/StructureRepairUtils.java +++ b/src/main/java/electrosphere/server/macro/utils/StructureRepairUtils.java @@ -31,7 +31,7 @@ public class StructureRepairUtils { } BlockFab fab = struct.getFab(); - Vector3d structStartPos = struct.getStartPos(); + Vector3d structStartPos = new Vector3d(struct.getAABB().minX,struct.getAABB().minY,struct.getAABB().minZ); GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)realm.getDataCellManager(); for(int x = 0; x < fab.getDimensions().x; x++){ for(int y = 0; y < fab.getDimensions().y; y++){ @@ -92,7 +92,7 @@ public class StructureRepairUtils { struct.setRepairable(false); BlockFab fab = struct.getFab(); - Vector3d structStartPos = struct.getStartPos(); + Vector3d structStartPos = new Vector3d(struct.getAABB().minX,struct.getAABB().minY,struct.getAABB().minZ); GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)realm.getDataCellManager(); for(int x = 0; x < fab.getDimensions().x; x++){ for(int y = 0; y < fab.getDimensions().y; y++){ @@ -123,7 +123,7 @@ public class StructureRepairUtils { } BlockFab fab = struct.getFab(); - Vector3d structStartPos = struct.getStartPos(); + Vector3d structStartPos = new Vector3d(struct.getAABB().minX,struct.getAABB().minY,struct.getAABB().minZ); GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)realm.getDataCellManager(); for(int x = 0; x < fab.getDimensions().x; x++){ for(int y = 0; y < fab.getDimensions().y; y++){ diff --git a/src/main/java/electrosphere/server/physics/block/manager/ServerBlockChunkGenerationThread.java b/src/main/java/electrosphere/server/physics/block/manager/ServerBlockChunkGenerationThread.java index 748f2e1e..3e41ea4e 100644 --- a/src/main/java/electrosphere/server/physics/block/manager/ServerBlockChunkGenerationThread.java +++ b/src/main/java/electrosphere/server/physics/block/manager/ServerBlockChunkGenerationThread.java @@ -181,10 +181,11 @@ public class ServerBlockChunkGenerationThread implements Runnable { Vector3d currRealPoint = ServerWorldData.convertLocalBlockToRealSpace(chunkPos, blockPos); for(VirtualStructure struct : filtered){ if(struct.getAABB().testPoint(currRealPoint.x, currRealPoint.y, currRealPoint.z)){ + AABBd aabb = struct.getAABB(); localBlockPos.set( - (int)((chunkRealPos.x + (x * BlockChunkData.BLOCK_SIZE_MULTIPLIER) - struct.getStartPos().x) / BlockChunkData.BLOCK_SIZE_MULTIPLIER), - (int)((chunkRealPos.y + (y * BlockChunkData.BLOCK_SIZE_MULTIPLIER) - struct.getStartPos().y) / BlockChunkData.BLOCK_SIZE_MULTIPLIER), - (int)((chunkRealPos.z + (z * BlockChunkData.BLOCK_SIZE_MULTIPLIER) - struct.getStartPos().z) / BlockChunkData.BLOCK_SIZE_MULTIPLIER) + (int)((chunkRealPos.x + (x * BlockChunkData.BLOCK_SIZE_MULTIPLIER) - aabb.minX) / BlockChunkData.BLOCK_SIZE_MULTIPLIER), + (int)((chunkRealPos.y + (y * BlockChunkData.BLOCK_SIZE_MULTIPLIER) - aabb.minY) / BlockChunkData.BLOCK_SIZE_MULTIPLIER), + (int)((chunkRealPos.z + (z * BlockChunkData.BLOCK_SIZE_MULTIPLIER) - aabb.minZ) / BlockChunkData.BLOCK_SIZE_MULTIPLIER) ); //structure file might have dimensions larger than fab, so need to make sure we're inbounds on fab file to draw data from fab file if(localBlockPos.x < struct.getFab().getDimensions().x && localBlockPos.y < struct.getFab().getDimensions().y && localBlockPos.z < struct.getFab().getDimensions().z){