area selection improvements
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
eb1724a82d
commit
df9401aba0
@ -1611,6 +1611,7 @@ Item stacking
|
||||
Voxel placement improvements
|
||||
Smaller wall section
|
||||
First proper house~!
|
||||
Rect area selection expands each axis independently
|
||||
|
||||
|
||||
|
||||
|
||||
@ -74,26 +74,72 @@ public class AreaSelection {
|
||||
public static AreaSelection selectRectangularBlockCavity(Vector3i chunkPos, Vector3i blockPos, int maxRadius){
|
||||
AreaSelection rVal = null;
|
||||
|
||||
int radStart = 0;
|
||||
int radEnd = 1;
|
||||
Vector3i startOffset = new Vector3i(0,0,0);
|
||||
Vector3i endOffset = new Vector3i(1,1,1);
|
||||
int increment = 0;
|
||||
boolean expandPositive = true;
|
||||
boolean expandNegative = true;
|
||||
boolean expandPositiveX = true;
|
||||
boolean expandPositiveY = true;
|
||||
boolean expandPositiveZ = true;
|
||||
boolean expandNegativeX = true;
|
||||
boolean expandNegativeY = true;
|
||||
boolean expandNegativeZ = true;
|
||||
Vector3i currVoxelPos = new Vector3i();
|
||||
Vector3i currChunkPos = new Vector3i();
|
||||
while(radStart > -maxRadius && radEnd < maxRadius && (expandPositive || expandNegative)){
|
||||
if(increment % 2 == 0){
|
||||
if(!expandPositive){
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if(!expandNegative){
|
||||
continue;
|
||||
}
|
||||
while(
|
||||
startOffset.x > -maxRadius && startOffset.y > -maxRadius && startOffset.z > -maxRadius &&
|
||||
endOffset.x < maxRadius && endOffset.y < maxRadius && endOffset.z < maxRadius &&
|
||||
(
|
||||
expandPositiveX || expandPositiveY || expandPositiveZ ||
|
||||
expandNegativeX || expandNegativeY || expandNegativeZ
|
||||
)){
|
||||
increment++;
|
||||
switch(increment % 6){
|
||||
case 0: {
|
||||
if(expandPositiveX){
|
||||
endOffset.x = endOffset.x + 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if(expandPositiveY){
|
||||
endOffset.y = endOffset.y + 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if(expandPositiveZ){
|
||||
endOffset.z = endOffset.z + 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
if(expandNegativeX){
|
||||
startOffset.x = startOffset.x - 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} break;
|
||||
case 4: {
|
||||
if(expandNegativeY){
|
||||
startOffset.y = startOffset.y - 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} break;
|
||||
case 5: {
|
||||
if(expandNegativeZ){
|
||||
startOffset.z = startOffset.z - 1;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
for(int x = radStart; x < radEnd; x++){
|
||||
for(int y = radStart; y < radEnd; y++){
|
||||
for(int z = radStart; z < radEnd; z++){
|
||||
for(int x = startOffset.x; x < endOffset.x; x++){
|
||||
for(int y = startOffset.y; y < endOffset.y; y++){
|
||||
for(int z = startOffset.z; z < endOffset.z; z++){
|
||||
currVoxelPos.set(blockPos).add(x,y,z);
|
||||
currChunkPos.set(chunkPos).add(
|
||||
currVoxelPos.x / BlockChunkData.CHUNK_DATA_WIDTH,
|
||||
@ -106,19 +152,109 @@ public class AreaSelection {
|
||||
currVoxelPos.z % BlockChunkData.CHUNK_DATA_WIDTH
|
||||
);
|
||||
if(!Globals.clientWorldData.chunkInBounds(currChunkPos)){
|
||||
if(increment % 2 == 0){
|
||||
expandPositive = false;
|
||||
} else {
|
||||
expandNegative = false;
|
||||
switch(increment % 6){
|
||||
case 0: {
|
||||
if(expandPositiveX){
|
||||
expandPositiveX = false;
|
||||
if(endOffset.x > 1){
|
||||
endOffset.x--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if(expandPositiveY){
|
||||
expandPositiveY = false;
|
||||
if(endOffset.y > 1){
|
||||
endOffset.y--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if(expandPositiveZ){
|
||||
expandPositiveZ = false;
|
||||
if(endOffset.z > 1){
|
||||
endOffset.z--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
if(expandNegativeX){
|
||||
expandNegativeX = false;
|
||||
if(startOffset.x < 0){
|
||||
startOffset.x++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 4: {
|
||||
if(expandNegativeY){
|
||||
expandNegativeY = false;
|
||||
if(startOffset.y < 0){
|
||||
startOffset.y++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 5: {
|
||||
if(expandNegativeZ){
|
||||
expandNegativeZ = false;
|
||||
if(startOffset.z < 0){
|
||||
startOffset.z++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
BlockChunkData chunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(currChunkPos, BlockChunkData.LOD_FULL_RES);
|
||||
if(chunkData == null){
|
||||
if(increment % 2 == 0){
|
||||
expandPositive = false;
|
||||
} else {
|
||||
expandNegative = false;
|
||||
switch(increment % 6){
|
||||
case 0: {
|
||||
if(expandPositiveX){
|
||||
expandPositiveX = false;
|
||||
if(endOffset.x > 1){
|
||||
endOffset.x--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if(expandPositiveY){
|
||||
expandPositiveY = false;
|
||||
if(endOffset.y > 1){
|
||||
endOffset.y--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if(expandPositiveZ){
|
||||
expandPositiveZ = false;
|
||||
if(endOffset.z > 1){
|
||||
endOffset.z--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
if(expandNegativeX){
|
||||
expandNegativeX = false;
|
||||
if(startOffset.x < 0){
|
||||
startOffset.x++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 4: {
|
||||
if(expandNegativeY){
|
||||
expandNegativeY = false;
|
||||
if(startOffset.y < 0){
|
||||
startOffset.y++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 5: {
|
||||
if(expandNegativeZ){
|
||||
expandNegativeZ = false;
|
||||
if(startOffset.z < 0){
|
||||
startOffset.z++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -132,47 +268,94 @@ public class AreaSelection {
|
||||
currVoxelPos.z = currVoxelPos.z + BlockChunkData.CHUNK_DATA_WIDTH;
|
||||
}
|
||||
if(!chunkData.isEmpty(currVoxelPos)){
|
||||
if(increment % 2 == 0){
|
||||
expandPositive = false;
|
||||
} else {
|
||||
expandNegative = false;
|
||||
switch(increment % 6){
|
||||
case 0: {
|
||||
if(expandPositiveX){
|
||||
expandPositiveX = false;
|
||||
if(endOffset.x > 1){
|
||||
endOffset.x--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 1: {
|
||||
if(expandPositiveY){
|
||||
expandPositiveY = false;
|
||||
if(endOffset.y > 1){
|
||||
endOffset.y--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 2: {
|
||||
if(expandPositiveZ){
|
||||
expandPositiveZ = false;
|
||||
if(endOffset.z > 1){
|
||||
endOffset.z--;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 3: {
|
||||
if(expandNegativeX){
|
||||
expandNegativeX = false;
|
||||
if(startOffset.x < 0){
|
||||
startOffset.x++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 4: {
|
||||
if(expandNegativeY){
|
||||
expandNegativeY = false;
|
||||
if(startOffset.y < 0){
|
||||
startOffset.y++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case 5: {
|
||||
if(expandNegativeZ){
|
||||
expandNegativeZ = false;
|
||||
if(startOffset.z < 0){
|
||||
startOffset.z++;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(increment % 2 == 0){
|
||||
if(expandPositive){
|
||||
radEnd++;
|
||||
}
|
||||
} else {
|
||||
if(expandNegative){
|
||||
radStart--;
|
||||
}
|
||||
}
|
||||
increment++;
|
||||
}
|
||||
|
||||
//loops only break on the iteration where we encounter a barrier, so need to roll the radius values back by 1
|
||||
//in order to not include the blocks that caused the break itself
|
||||
if(radEnd > 1){
|
||||
radEnd--;
|
||||
}
|
||||
if(radStart < 0){
|
||||
radStart++;
|
||||
}
|
||||
// if(endOffset.x > 1){
|
||||
// endOffset.x--;
|
||||
// }
|
||||
// if(endOffset.y > 1){
|
||||
// endOffset.y--;
|
||||
// }
|
||||
// if(endOffset.z > 1){
|
||||
// endOffset.z--;
|
||||
// }
|
||||
// if(startOffset.x < 0){
|
||||
// startOffset.x++;
|
||||
// }
|
||||
// if(startOffset.y < 0){
|
||||
// startOffset.y++;
|
||||
// }
|
||||
// if(startOffset.z < 0){
|
||||
// startOffset.z++;
|
||||
// }
|
||||
|
||||
Vector3d startPos = new Vector3d(Globals.clientWorldData.convertBlockToRealSpace(chunkPos, blockPos))
|
||||
.add(
|
||||
radStart * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
radStart * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
radStart * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||
startOffset.x * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
startOffset.y * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
startOffset.z * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||
);
|
||||
Vector3d endPos = new Vector3d(Globals.clientWorldData.convertBlockToRealSpace(chunkPos, blockPos))
|
||||
.add(
|
||||
radEnd * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
radEnd * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
radEnd * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||
endOffset.x * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
endOffset.y * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||
endOffset.z * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||
);
|
||||
|
||||
rVal = AreaSelection.createRect(startPos, endPos);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user