voxel placement improvements
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-30 12:34:58 -04:00
parent 2452cf194b
commit 24fd4791da
5 changed files with 21 additions and 7 deletions

View File

@ -1,7 +1,7 @@
{
"items" : [
{
"id" : "woodfloor",
"id" : "fab:woodfloor",
"tokens" : [
"GRAVITY",
"TARGETABLE"

View File

@ -1607,6 +1607,8 @@ Items keep charge state
UI renders charge state
Item stacking
(04/20/2025)
Voxel placement improvements

View File

@ -173,6 +173,7 @@ public class CursorState {
}
cursorPos.set(this.clampPositionToNearestBlock(cursorPos));
EntityUtils.getPosition(Globals.playerBlockCursor).set(cursorPos);
cursorPos.sub(BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0,BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0,BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0);
EntityUtils.getPosition(CursorState.playerFabCursor).set(cursorPos);
}
}

View File

@ -62,10 +62,12 @@ public class ServerChargeState implements BehaviorTree {
Entity inventoryItem = serverToolbarState.getInInventoryItem();
if(inventoryItem != null){
ServerChargeState serverChargeState = ServerChargeState.getServerChargeState(inventoryItem);
if(serverChargeState.getCharges() - charges > 0){
serverChargeState.setCharges(serverChargeState.getCharges() - charges);
} else {
throw new Error("Undefined! " + charges + serverChargeState.getCharges());
if(serverChargeState != null){
if(serverChargeState.getCharges() - charges > 0){
serverChargeState.setCharges(serverChargeState.getCharges() - charges);
} else {
throw new Error("Undefined! " + charges + serverChargeState.getCharges());
}
}
}
}

View File

@ -93,14 +93,23 @@ public class ServerBlockEditing {
Quaterniond rotationQuatd = CursorState.getBlockRotation(rotation);
Quaternionf rotationQuatf = new Quaternionf((float)rotationQuatd.x,(float)rotationQuatd.y,(float)rotationQuatd.z,(float)rotationQuatd.w);
Matrix4f rotMat = new Matrix4f().rotate(rotationQuatf);
Vector4f rotationHolder = new Vector4f();
Vector4f rotationHolder = new Vector4f(1,1,1,1);
rotMat.transform(rotationHolder);
//if the cursor is not the default rotation, we want to actually place blocks one position LOWER than the cursor depending on the rotation
//this is because we want the final vertex to end on the block (ie we must place at final vertex-1)
Vector3i offsetFromRot = new Vector3i(
Math.round(Math.min(0,rotationHolder.x)),
Math.round(Math.min(0,rotationHolder.y)),
Math.round(Math.min(0,rotationHolder.z))
);
for(int x = 0; x < dims.x; x++){
for(int y = 0; y < dims.y; y++){
for(int z = 0; z < dims.z; z++){
rotationHolder.set(x,y,z,1);
rotMat.transform(rotationHolder);
currVoxelPos.set(voxelPos).add(Math.round(rotationHolder.x),Math.round(rotationHolder.y),Math.round(rotationHolder.z));
currVoxelPos.set(voxelPos).add(Math.round(rotationHolder.x),Math.round(rotationHolder.y),Math.round(rotationHolder.z)).add(offsetFromRot);
currChunkPos.set(chunkPos).add(