work on rotating structures
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
2f05fc06dd
commit
84b4c11199
@ -5,9 +5,9 @@
|
||||
"displayName" : "Default House",
|
||||
"fabPath" : "Data/fab/defaultHouse.fab",
|
||||
"dimensions" : {
|
||||
"x" : 5,
|
||||
"x" : 4.75,
|
||||
"y" : 5,
|
||||
"z" : 5
|
||||
"z" : 4.75
|
||||
},
|
||||
"placementOffset" : {
|
||||
"x" : 0,
|
||||
|
||||
@ -1950,6 +1950,11 @@ Town layout work
|
||||
Macro broadphase filters prior to per-voxel macro data intersection checks
|
||||
Block chunks properly stride
|
||||
|
||||
(05/24/2025)
|
||||
Work on rotating structures
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ import org.joml.Vector3d;
|
||||
import electrosphere.controls.cursor.CursorState;
|
||||
import electrosphere.data.block.fab.BlockFab;
|
||||
import electrosphere.data.struct.StructureData;
|
||||
import electrosphere.server.datacell.ServerWorldData;
|
||||
import electrosphere.server.macro.MacroData;
|
||||
import electrosphere.server.macro.spatial.MacroAreaObject;
|
||||
import electrosphere.util.annotation.Exclude;
|
||||
@ -90,7 +91,7 @@ public class VirtualStructure implements MacroAreaObject {
|
||||
rVal.fabPath = data.getFabPath();
|
||||
rVal.fab = data.getFab();
|
||||
rVal.type = data.getId();
|
||||
rVal.position = position;
|
||||
rVal.position = ServerWorldData.clampRealToBlock(position);
|
||||
rVal.rotation = rotation;
|
||||
rVal.aabb = new AABBd();
|
||||
VirtualStructure.setAABB(rVal.aabb, rVal.position, data.getDimensions(), rotation);
|
||||
|
||||
@ -244,9 +244,9 @@ public class ServerBlockChunkGenerationThread implements Runnable {
|
||||
if(struct.getAABB().testPoint(currRealPos.x, currRealPos.y, currRealPos.z)){
|
||||
AABBd aabb = struct.getAABB();
|
||||
localBlockPos.set(
|
||||
(int)Math.round((currRealPos.x - aabb.minX) / BlockChunkData.BLOCK_SIZE_MULTIPLIER),
|
||||
(int)Math.round((currRealPos.y - aabb.minY) / BlockChunkData.BLOCK_SIZE_MULTIPLIER),
|
||||
(int)Math.round((currRealPos.z - aabb.minZ) / BlockChunkData.BLOCK_SIZE_MULTIPLIER)
|
||||
Math.round((currRealPos.x - aabb.minX) / BlockChunkData.BLOCK_SIZE_MULTIPLIER),
|
||||
Math.round((currRealPos.y - aabb.minY) / BlockChunkData.BLOCK_SIZE_MULTIPLIER),
|
||||
Math.round((currRealPos.z - aabb.minZ) / BlockChunkData.BLOCK_SIZE_MULTIPLIER)
|
||||
);
|
||||
|
||||
Quaterniond rotationQuat = CursorState.getBlockRotation(struct.getRotation());
|
||||
@ -255,27 +255,27 @@ public class ServerBlockChunkGenerationThread implements Runnable {
|
||||
rotationQuat.transform(dimVec);
|
||||
dimVec.absolute();
|
||||
if(localBlockPos.x < 0){
|
||||
localBlockPos.x = (int)(dimVec.x + localBlockPos.x);
|
||||
localBlockPos.x = dimVec.x + localBlockPos.x;
|
||||
}
|
||||
if(localBlockPos.y < 0){
|
||||
localBlockPos.y = (int)(dimVec.y + localBlockPos.y);
|
||||
localBlockPos.y = dimVec.y + localBlockPos.y;
|
||||
}
|
||||
if(localBlockPos.z < 0){
|
||||
localBlockPos.z = (int)(dimVec.z + localBlockPos.z);
|
||||
localBlockPos.z = dimVec.z + localBlockPos.z;
|
||||
}
|
||||
localBlockPos.x = Math.round(localBlockPos.x);
|
||||
localBlockPos.y = Math.round(localBlockPos.y);
|
||||
localBlockPos.z = Math.round(localBlockPos.z);
|
||||
int finalX = Math.round((float)localBlockPos.x);
|
||||
int finalY = Math.round((float)localBlockPos.y);
|
||||
int finalZ = Math.round((float)localBlockPos.z);
|
||||
//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(
|
||||
(int)localBlockPos.x >= 0 &&
|
||||
(int)localBlockPos.y >= 0 &&
|
||||
(int)localBlockPos.z >= 0 &&
|
||||
(int)localBlockPos.x < struct.getFab().getDimensions().x &&
|
||||
(int)localBlockPos.y < struct.getFab().getDimensions().y &&
|
||||
(int)localBlockPos.z < struct.getFab().getDimensions().z
|
||||
finalX >= 0 &&
|
||||
finalY >= 0 &&
|
||||
finalZ >= 0 &&
|
||||
finalX < struct.getFab().getDimensions().x &&
|
||||
finalY < struct.getFab().getDimensions().y &&
|
||||
finalZ < struct.getFab().getDimensions().z
|
||||
){
|
||||
short blocktype = struct.getFab().getType((int)localBlockPos.x,(int)localBlockPos.y,(int)localBlockPos.z);
|
||||
short blocktype = struct.getFab().getType(finalX,finalY,finalZ);
|
||||
chunk.setType(x, y, z, blocktype);
|
||||
placedBlock = true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user