support multichunk select all blocks
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
3323e16971
commit
3ef6f88758
@ -1882,6 +1882,8 @@ Macro data is injected into voxel chunk generators
|
|||||||
Close macro objects injected into voxel chunk gen instead of all data
|
Close macro objects injected into voxel chunk gen instead of all data
|
||||||
Fix spline3d mat storing calculations when getting positions
|
Fix spline3d mat storing calculations when getting positions
|
||||||
Roads applied to terrain voxel gen
|
Roads applied to terrain voxel gen
|
||||||
|
Support lack of macro data for chunk gens
|
||||||
|
Support multichunk select all blocks
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import electrosphere.client.interact.select.AreaSelection.AreaSelectionType;
|
|||||||
import electrosphere.client.scene.ClientWorldData;
|
import electrosphere.client.scene.ClientWorldData;
|
||||||
import electrosphere.data.block.fab.BlockFab;
|
import electrosphere.data.block.fab.BlockFab;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.server.datacell.ServerWorldData;
|
||||||
import electrosphere.util.math.HashUtils;
|
import electrosphere.util.math.HashUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,38 +97,42 @@ public class ClientBlockSelection {
|
|||||||
*/
|
*/
|
||||||
public static BlockFab convertSelectionToFab(){
|
public static BlockFab convertSelectionToFab(){
|
||||||
AreaSelection selection = Globals.cursorState.getAreaSelection();
|
AreaSelection selection = Globals.cursorState.getAreaSelection();
|
||||||
Vector3i startChunk = Globals.clientState.clientWorldData.convertRealToWorldSpace(selection.getRectStart());
|
|
||||||
Vector3i endChunk = Globals.clientState.clientWorldData.convertRealToWorldSpace(selection.getRectEnd());
|
|
||||||
if(!startChunk.equals(endChunk)){
|
|
||||||
throw new Error("Unsupported case! Selected are coverts multiple chunks.. " + startChunk + " " + endChunk);
|
|
||||||
}
|
|
||||||
Vector3i blockStart = ClientWorldData.convertRealToLocalBlockSpace(selection.getRectStart());
|
|
||||||
Vector3i blockEnd = ClientWorldData.convertRealToLocalBlockSpace(selection.getRectEnd());
|
|
||||||
|
|
||||||
BlockChunkData chunk = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(startChunk, 0);
|
//get dims
|
||||||
if(chunk == null){
|
int dimX = (int)((selection.getRectEnd().x - selection.getRectStart().x) * BlockChunkData.BLOCKS_PER_UNIT_DISTANCE);
|
||||||
throw new Error("Failed to grab chunk at " + startChunk);
|
int dimY = (int)((selection.getRectEnd().y - selection.getRectStart().y) * BlockChunkData.BLOCKS_PER_UNIT_DISTANCE);
|
||||||
}
|
int dimZ = (int)((selection.getRectEnd().z - selection.getRectStart().z) * BlockChunkData.BLOCKS_PER_UNIT_DISTANCE);
|
||||||
|
|
||||||
int blockCount = (blockEnd.x - blockStart.x) * (blockEnd.y - blockStart.y) * (blockEnd.z - blockStart.z);
|
Vector3d posCurr = new Vector3d();
|
||||||
|
Vector3i chunkPos = null;
|
||||||
|
Vector3i blockPos = null;
|
||||||
|
|
||||||
|
int blockCount = dimX * dimY * dimZ;
|
||||||
short[] types = new short[blockCount];
|
short[] types = new short[blockCount];
|
||||||
short[] metadata = new short[blockCount];
|
short[] metadata = new short[blockCount];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(int x = blockStart.x; x < blockEnd.x; x++){
|
for(int x = 0; x < dimX; x++){
|
||||||
for(int y = blockStart.y; y < blockEnd.y; y++){
|
for(int y = 0; y < dimY; y++){
|
||||||
for(int z = blockStart.z; z < blockEnd.z; z++){
|
for(int z = 0; z < dimZ; z++){
|
||||||
types[i] = chunk.getType(x, y, z);
|
posCurr.set(selection.getRectStart()).add(
|
||||||
metadata[i] = chunk.getMetadata(x, y, z);
|
x * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
|
y * BlockChunkData.BLOCK_SIZE_MULTIPLIER,
|
||||||
|
z * BlockChunkData.BLOCK_SIZE_MULTIPLIER
|
||||||
|
);
|
||||||
|
chunkPos = ServerWorldData.convertRealToChunkSpace(posCurr);
|
||||||
|
BlockChunkData chunk = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(chunkPos, 0);
|
||||||
|
if(chunk == null){
|
||||||
|
throw new Error("Failed to grab chunk at " + chunkPos);
|
||||||
|
}
|
||||||
|
blockPos = ServerWorldData.convertRealToLocalBlockSpace(posCurr);
|
||||||
|
types[i] = chunk.getType(blockPos.x, blockPos.y, blockPos.z);
|
||||||
|
metadata[i] = chunk.getMetadata(blockPos.x, blockPos.y, blockPos.z);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3i dimensions = new Vector3i(
|
Vector3i dimensions = new Vector3i(dimX, dimY, dimZ);
|
||||||
(blockEnd.x - blockStart.x),
|
|
||||||
(blockEnd.y - blockStart.y),
|
|
||||||
(blockEnd.z - blockStart.z)
|
|
||||||
);
|
|
||||||
|
|
||||||
BlockFab fab = BlockFab.create(dimensions, types, metadata);
|
BlockFab fab = BlockFab.create(dimensions, types, metadata);
|
||||||
return fab;
|
return fab;
|
||||||
|
|||||||
@ -217,7 +217,7 @@ public class ProceduralChunkGenerator implements ChunkGenerator {
|
|||||||
values[x][y][z] = voxel.type;
|
values[x][y][z] = voxel.type;
|
||||||
}
|
}
|
||||||
//apply macro data
|
//apply macro data
|
||||||
if(this.applyMacroData(macroData, realX, realY, realZ, voxel)){
|
if(macroData != null && this.applyMacroData(macroData, realX, realY, realZ, voxel)){
|
||||||
weights[x][y][z] = voxel.weight;
|
weights[x][y][z] = voxel.weight;
|
||||||
values[x][y][z] = voxel.type;
|
values[x][y][z] = voxel.type;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -306,7 +306,10 @@ public class ServerTerrainManager {
|
|||||||
}
|
}
|
||||||
//generate if it does not exist
|
//generate if it does not exist
|
||||||
if(returnedChunk == null){
|
if(returnedChunk == null){
|
||||||
List<MacroObject> objects = this.macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldX, worldY, worldZ));
|
List<MacroObject> objects = null;
|
||||||
|
if(macroData != null){
|
||||||
|
objects = this.macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldX, worldY, worldZ));
|
||||||
|
}
|
||||||
returnedChunk = chunkGenerator.generateChunk(objects, worldX, worldY, worldZ, ChunkData.NO_STRIDE);
|
returnedChunk = chunkGenerator.generateChunk(objects, worldX, worldY, worldZ, ChunkData.NO_STRIDE);
|
||||||
}
|
}
|
||||||
this.chunkCache.add(worldX, worldY, worldZ, ChunkData.NO_STRIDE, returnedChunk);
|
this.chunkCache.add(worldX, worldY, worldZ, ChunkData.NO_STRIDE, returnedChunk);
|
||||||
@ -354,7 +357,10 @@ public class ServerTerrainManager {
|
|||||||
*/
|
*/
|
||||||
public void getChunkAsync(int worldX, int worldY, int worldZ, int stride, Consumer<ServerTerrainChunk> onLoad){
|
public void getChunkAsync(int worldX, int worldY, int worldZ, int stride, Consumer<ServerTerrainChunk> onLoad){
|
||||||
Globals.profiler.beginAggregateCpuSample("ServerTerrainManager.getChunkAsync");
|
Globals.profiler.beginAggregateCpuSample("ServerTerrainManager.getChunkAsync");
|
||||||
List<MacroObject> objects = this.macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldX, worldY, worldZ));
|
List<MacroObject> objects = null;
|
||||||
|
if(this.macroData != null){
|
||||||
|
objects = this.macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldX, worldY, worldZ));
|
||||||
|
}
|
||||||
chunkExecutorService.submit(new ChunkGenerationThread(objects, chunkDiskMap, chunkCache, chunkGenerator, worldX, worldY, worldZ, stride, onLoad));
|
chunkExecutorService.submit(new ChunkGenerationThread(objects, chunkDiskMap, chunkCache, chunkGenerator, worldX, worldY, worldZ, stride, onLoad));
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user