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
|
Voxel placement improvements
|
||||||
Smaller wall section
|
Smaller wall section
|
||||||
First proper house~!
|
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){
|
public static AreaSelection selectRectangularBlockCavity(Vector3i chunkPos, Vector3i blockPos, int maxRadius){
|
||||||
AreaSelection rVal = null;
|
AreaSelection rVal = null;
|
||||||
|
|
||||||
int radStart = 0;
|
Vector3i startOffset = new Vector3i(0,0,0);
|
||||||
int radEnd = 1;
|
Vector3i endOffset = new Vector3i(1,1,1);
|
||||||
int increment = 0;
|
int increment = 0;
|
||||||
boolean expandPositive = true;
|
boolean expandPositiveX = true;
|
||||||
boolean expandNegative = true;
|
boolean expandPositiveY = true;
|
||||||
|
boolean expandPositiveZ = true;
|
||||||
|
boolean expandNegativeX = true;
|
||||||
|
boolean expandNegativeY = true;
|
||||||
|
boolean expandNegativeZ = true;
|
||||||
Vector3i currVoxelPos = new Vector3i();
|
Vector3i currVoxelPos = new Vector3i();
|
||||||
Vector3i currChunkPos = new Vector3i();
|
Vector3i currChunkPos = new Vector3i();
|
||||||
while(radStart > -maxRadius && radEnd < maxRadius && (expandPositive || expandNegative)){
|
while(
|
||||||
if(increment % 2 == 0){
|
startOffset.x > -maxRadius && startOffset.y > -maxRadius && startOffset.z > -maxRadius &&
|
||||||
if(!expandPositive){
|
endOffset.x < maxRadius && endOffset.y < maxRadius && endOffset.z < maxRadius &&
|
||||||
continue;
|
(
|
||||||
}
|
expandPositiveX || expandPositiveY || expandPositiveZ ||
|
||||||
|
expandNegativeX || expandNegativeY || expandNegativeZ
|
||||||
|
)){
|
||||||
|
increment++;
|
||||||
|
switch(increment % 6){
|
||||||
|
case 0: {
|
||||||
|
if(expandPositiveX){
|
||||||
|
endOffset.x = endOffset.x + 1;
|
||||||
} else {
|
} else {
|
||||||
if(!expandNegative){
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} break;
|
||||||
|
case 1: {
|
||||||
|
if(expandPositiveY){
|
||||||
|
endOffset.y = endOffset.y + 1;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
for(int x = radStart; x < radEnd; x++){
|
} break;
|
||||||
for(int y = radStart; y < radEnd; y++){
|
case 2: {
|
||||||
for(int z = radStart; z < radEnd; z++){
|
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 = 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);
|
currVoxelPos.set(blockPos).add(x,y,z);
|
||||||
currChunkPos.set(chunkPos).add(
|
currChunkPos.set(chunkPos).add(
|
||||||
currVoxelPos.x / BlockChunkData.CHUNK_DATA_WIDTH,
|
currVoxelPos.x / BlockChunkData.CHUNK_DATA_WIDTH,
|
||||||
@ -106,19 +152,109 @@ public class AreaSelection {
|
|||||||
currVoxelPos.z % BlockChunkData.CHUNK_DATA_WIDTH
|
currVoxelPos.z % BlockChunkData.CHUNK_DATA_WIDTH
|
||||||
);
|
);
|
||||||
if(!Globals.clientWorldData.chunkInBounds(currChunkPos)){
|
if(!Globals.clientWorldData.chunkInBounds(currChunkPos)){
|
||||||
if(increment % 2 == 0){
|
switch(increment % 6){
|
||||||
expandPositive = false;
|
case 0: {
|
||||||
} else {
|
if(expandPositiveX){
|
||||||
expandNegative = false;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
BlockChunkData chunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(currChunkPos, BlockChunkData.LOD_FULL_RES);
|
BlockChunkData chunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(currChunkPos, BlockChunkData.LOD_FULL_RES);
|
||||||
if(chunkData == null){
|
if(chunkData == null){
|
||||||
if(increment % 2 == 0){
|
switch(increment % 6){
|
||||||
expandPositive = false;
|
case 0: {
|
||||||
} else {
|
if(expandPositiveX){
|
||||||
expandNegative = false;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
@ -132,47 +268,94 @@ public class AreaSelection {
|
|||||||
currVoxelPos.z = currVoxelPos.z + BlockChunkData.CHUNK_DATA_WIDTH;
|
currVoxelPos.z = currVoxelPos.z + BlockChunkData.CHUNK_DATA_WIDTH;
|
||||||
}
|
}
|
||||||
if(!chunkData.isEmpty(currVoxelPos)){
|
if(!chunkData.isEmpty(currVoxelPos)){
|
||||||
if(increment % 2 == 0){
|
switch(increment % 6){
|
||||||
expandPositive = false;
|
case 0: {
|
||||||
} else {
|
if(expandPositiveX){
|
||||||
expandNegative = false;
|
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
|
//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
|
//in order to not include the blocks that caused the break itself
|
||||||
if(radEnd > 1){
|
// if(endOffset.x > 1){
|
||||||
radEnd--;
|
// endOffset.x--;
|
||||||
}
|
// }
|
||||||
if(radStart < 0){
|
// if(endOffset.y > 1){
|
||||||
radStart++;
|
// 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))
|
Vector3d startPos = new Vector3d(Globals.clientWorldData.convertBlockToRealSpace(chunkPos, blockPos))
|
||||||
.add(
|
.add(
|
||||||
radStart * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
startOffset.x * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
radStart * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
startOffset.y * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
radStart * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
startOffset.z * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||||
);
|
);
|
||||||
Vector3d endPos = new Vector3d(Globals.clientWorldData.convertBlockToRealSpace(chunkPos, blockPos))
|
Vector3d endPos = new Vector3d(Globals.clientWorldData.convertBlockToRealSpace(chunkPos, blockPos))
|
||||||
.add(
|
.add(
|
||||||
radEnd * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
endOffset.x * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
radEnd * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
endOffset.y * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
radEnd * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
endOffset.z * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||||
);
|
);
|
||||||
|
|
||||||
rVal = AreaSelection.createRect(startPos, endPos);
|
rVal = AreaSelection.createRect(startPos, endPos);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user