move lots of global state to clientState
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
f7790931bc
commit
bf982f0a87
@ -1806,9 +1806,8 @@ Properly reset ClientState
|
||||
Move clientWorldData to clientState
|
||||
Move clientScene to clientState
|
||||
Move clientSceneWrapper to clientState
|
||||
Move clientSimulation to clientState
|
||||
Move clientSynchronizationMAnager to clientState
|
||||
Move clientConnection to clientState
|
||||
Move lots of global state to clientState
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,15 @@
|
||||
package electrosphere.client;
|
||||
|
||||
import electrosphere.client.block.ClientBlockManager;
|
||||
import electrosphere.client.chemistry.ClientChemistryCollisionCallback;
|
||||
import electrosphere.client.entity.character.ClientCharacterManager;
|
||||
import electrosphere.client.fluid.manager.ClientFluidManager;
|
||||
import electrosphere.client.scene.ClientSceneWrapper;
|
||||
import electrosphere.client.scene.ClientWorldData;
|
||||
import electrosphere.client.sim.ClientSimulation;
|
||||
import electrosphere.client.terrain.foliage.FoliageCellManager;
|
||||
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.entity.scene.Scene;
|
||||
import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.net.synchronization.client.ClientSynchronizationManager;
|
||||
@ -20,7 +27,7 @@ public class ClientState {
|
||||
/**
|
||||
* The scene on the client
|
||||
*/
|
||||
public Scene clientScene;
|
||||
public Scene clientScene = new Scene();
|
||||
|
||||
/**
|
||||
* The client scene wrapper
|
||||
@ -42,4 +49,36 @@ public class ClientState {
|
||||
*/
|
||||
public ClientNetworking clientConnection;
|
||||
|
||||
/**
|
||||
* The foliage cell manager
|
||||
*/
|
||||
public FoliageCellManager foliageCellManager;
|
||||
|
||||
/**
|
||||
* Manages characters on the client
|
||||
*/
|
||||
public ClientCharacterManager clientCharacterManager = new ClientCharacterManager();
|
||||
|
||||
/**
|
||||
* Manages terrain data on client
|
||||
*/
|
||||
public ClientTerrainManager clientTerrainManager = new ClientTerrainManager();
|
||||
|
||||
/**
|
||||
* Manages fluid data on client
|
||||
*/
|
||||
public ClientFluidManager clientFluidManager = new ClientFluidManager();
|
||||
|
||||
/**
|
||||
* Manages block data on client
|
||||
*/
|
||||
public ClientBlockManager clientBlockManager = new ClientBlockManager();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public ClientState(){
|
||||
this.clientSceneWrapper = new ClientSceneWrapper(this.clientScene, new CollisionEngine(), CollisionEngine.create(new ClientChemistryCollisionCallback()), new CollisionEngine());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public class ClientBlockSelection {
|
||||
for(int z = 0; z < Globals.clientState.clientWorldData.getWorldDiscreteSize(); z++){
|
||||
chunkPos = new Vector3i(x,y,z);
|
||||
|
||||
BlockChunkData blockChunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(chunkPos, 0);
|
||||
BlockChunkData blockChunkData = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(chunkPos, 0);
|
||||
if(blockChunkData.getHomogenousValue() == BlockChunkData.BLOCK_TYPE_EMPTY){
|
||||
continue;
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class ClientBlockSelection {
|
||||
Vector3i blockStart = Globals.clientState.clientWorldData.convertRealToBlockSpace(selection.getRectStart());
|
||||
Vector3i blockEnd = Globals.clientState.clientWorldData.convertRealToBlockSpace(selection.getRectEnd());
|
||||
|
||||
BlockChunkData chunk = Globals.clientBlockManager.getChunkDataAtWorldPoint(startChunk, 0);
|
||||
BlockChunkData chunk = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(startChunk, 0);
|
||||
if(chunk == null){
|
||||
throw new Error("Failed to grab chunk at " + startChunk);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ public class BlockDrawCell {
|
||||
public void generateDrawableEntity(BlockTextureAtlas atlas, int lod){
|
||||
boolean success = true;
|
||||
if(chunkData == null){
|
||||
BlockChunkData currentChunk = Globals.clientBlockManager.getChunkDataAtWorldPoint(
|
||||
BlockChunkData currentChunk = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(
|
||||
worldPos.x,
|
||||
worldPos.y,
|
||||
worldPos.z,
|
||||
|
||||
@ -711,11 +711,11 @@ public class ClientBlockCellManager {
|
||||
worldPos.y < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
worldPos.z >= 0 &&
|
||||
worldPos.z < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
!Globals.clientBlockManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)
|
||||
!Globals.clientState.clientBlockManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)
|
||||
){
|
||||
//client should request chunk data from server for each chunk necessary to create the model
|
||||
LoggerInterface.loggerNetworking.DEBUG("(Client) Send Request for block data at " + worldPos);
|
||||
if(!Globals.clientBlockManager.requestChunk(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
if(!Globals.clientState.clientBlockManager.requestChunk(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -731,7 +731,7 @@ public class ClientBlockCellManager {
|
||||
BlockDrawCell cell = node.getData();
|
||||
int lod = this.chunkTree.getMaxLevel() - node.getLevel();
|
||||
Vector3i worldPos = cell.getWorldPos();
|
||||
if(!Globals.clientBlockManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
if(!Globals.clientState.clientBlockManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -65,7 +65,7 @@ public class FluidCell {
|
||||
Globals.clientState.clientScene.deregisterEntity(modelEntity);
|
||||
}
|
||||
|
||||
FluidChunkData currentChunk = Globals.clientFluidManager.getChunkDataAtWorldPoint(worldPos);
|
||||
FluidChunkData currentChunk = Globals.clientState.clientFluidManager.getChunkDataAtWorldPoint(worldPos);
|
||||
if(!currentChunk.isHomogenous()){
|
||||
this.fillInData(currentChunk);
|
||||
modelEntity = FluidChunk.clientCreateFluidChunkEntity(weights);
|
||||
|
||||
@ -169,7 +169,7 @@ public class FluidCellManager {
|
||||
if(containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z)){
|
||||
FluidCell cell = FluidCell.generateFluidCell(
|
||||
worldPos,
|
||||
Globals.clientFluidManager.getChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z),
|
||||
Globals.clientState.clientFluidManager.getChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z),
|
||||
program
|
||||
);
|
||||
cells.add(cell);
|
||||
@ -399,8 +399,8 @@ public class FluidCellManager {
|
||||
}
|
||||
|
||||
boolean containsChunkDataAtWorldPoint(int worldX, int worldY, int worldZ){
|
||||
if(Globals.clientFluidManager != null){
|
||||
return Globals.clientFluidManager.containsChunkDataAtWorldPoint(worldX,worldY,worldZ);
|
||||
if(Globals.clientState.clientFluidManager != null){
|
||||
return Globals.clientState.clientFluidManager.containsChunkDataAtWorldPoint(worldX,worldY,worldZ);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -413,7 +413,7 @@ public class FluidCellManager {
|
||||
* @return The chunk data at the specified points
|
||||
*/
|
||||
ChunkData getChunkDataAtPoint(int worldX, int worldY, int worldZ){
|
||||
return Globals.clientTerrainManager.getChunkDataAtWorldPoint(worldX,worldY,worldZ,ChunkData.NO_STRIDE);
|
||||
return Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(worldX,worldY,worldZ,ChunkData.NO_STRIDE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -277,7 +277,7 @@ public class ClientInteractionEngine {
|
||||
collisionPosition.x >= 0 && collisionPosition.y >= 0 && collisionPosition.z >= 0
|
||||
){
|
||||
//grab block at point
|
||||
BlockChunkData blockChunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(Globals.clientState.clientWorldData.convertRealToWorldSpace(collisionPosition), 0);
|
||||
BlockChunkData blockChunkData = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(Globals.clientState.clientWorldData.convertRealToWorldSpace(collisionPosition), 0);
|
||||
if(blockChunkData != null){
|
||||
Vector3i blockPos = Globals.clientState.clientWorldData.convertRealToBlockSpace(new Vector3d(collisionPosition).add(new Vector3d(eyePos).mul(-BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0f)));
|
||||
if(!blockChunkData.isEmpty(blockPos.x, blockPos.y, blockPos.z)){
|
||||
@ -291,7 +291,7 @@ public class ClientInteractionEngine {
|
||||
}
|
||||
//if we didn't find a block type, try terrain
|
||||
if(!set){
|
||||
ChunkData chunkData = Globals.clientTerrainManager.getChunkDataAtWorldPoint(Globals.clientState.clientWorldData.convertRealToWorldSpace(collisionPosition), 0);
|
||||
ChunkData chunkData = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(Globals.clientState.clientWorldData.convertRealToWorldSpace(collisionPosition), 0);
|
||||
if(chunkData != null){
|
||||
int voxelType = chunkData.getType(Globals.clientState.clientWorldData.convertRealToVoxelSpace(new Vector3d(collisionPosition).add(new Vector3d(ServerTerrainChunk.VOXEL_SIZE / 2.0f))));
|
||||
if(voxelType != ServerTerrainChunk.VOXEL_TYPE_AIR){
|
||||
|
||||
@ -204,7 +204,7 @@ public class AreaSelection {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
BlockChunkData chunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(currChunkPos, BlockChunkData.LOD_FULL_RES);
|
||||
BlockChunkData chunkData = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(currChunkPos, BlockChunkData.LOD_FULL_RES);
|
||||
if(chunkData == null){
|
||||
switch(increment % 6){
|
||||
case 0: {
|
||||
|
||||
@ -42,6 +42,13 @@ public class ClientSimulation {
|
||||
* Main simulation function
|
||||
*/
|
||||
public void simulate(){
|
||||
|
||||
//
|
||||
//check for dependencies
|
||||
if(Globals.clientState.clientSceneWrapper == null){
|
||||
return;
|
||||
}
|
||||
|
||||
Globals.profiler.beginCpuSample("simulate");
|
||||
|
||||
//
|
||||
@ -88,8 +95,8 @@ public class ClientSimulation {
|
||||
Globals.profiler.endCpuSample();
|
||||
//
|
||||
//update foliage
|
||||
if(Globals.foliageCellManager != null){
|
||||
Globals.foliageCellManager.update();
|
||||
if(Globals.clientState.foliageCellManager != null){
|
||||
Globals.clientState.foliageCellManager.update();
|
||||
}
|
||||
//
|
||||
//targeting crosshair
|
||||
@ -173,16 +180,16 @@ public class ClientSimulation {
|
||||
*/
|
||||
public void loadTerrain(){
|
||||
Globals.profiler.beginCpuSample("ClientSimulation.loadTerrain");
|
||||
if(Globals.clientTerrainManager != null){
|
||||
Globals.clientTerrainManager.handleMessages();
|
||||
if(Globals.clientState.clientTerrainManager != null){
|
||||
Globals.clientState.clientTerrainManager.handleMessages();
|
||||
this.updateTerrainCellManager();
|
||||
}
|
||||
if(Globals.clientFluidManager != null && Globals.RUN_FLUIDS){
|
||||
Globals.clientFluidManager.handleMessages();
|
||||
if(Globals.clientState.clientFluidManager != null && Globals.RUN_FLUIDS){
|
||||
Globals.clientState.clientFluidManager.handleMessages();
|
||||
this.updateFluidCellManager();
|
||||
}
|
||||
if(Globals.clientBlockManager != null){
|
||||
Globals.clientBlockManager.handleMessages();
|
||||
if(Globals.clientState.clientBlockManager != null){
|
||||
Globals.clientState.clientBlockManager.handleMessages();
|
||||
this.updateBlockCellManager();
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
@ -848,11 +848,11 @@ public class ClientDrawCellManager {
|
||||
worldPos.y < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
worldPos.z >= 0 &&
|
||||
worldPos.z < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
!Globals.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)
|
||||
!Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)
|
||||
){
|
||||
//client should request chunk data from server for each chunk necessary to create the model
|
||||
LoggerInterface.loggerNetworking.DEBUG("(Client) Send Request for terrain at " + worldPos);
|
||||
if(!Globals.clientTerrainManager.requestChunk(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
if(!Globals.clientState.clientTerrainManager.requestChunk(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -892,10 +892,10 @@ public class ClientDrawCellManager {
|
||||
posToCheck.y < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
posToCheck.z >= 0 &&
|
||||
posToCheck.z < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
!Globals.clientTerrainManager.containsChunkDataAtWorldPoint(posToCheck.x, posToCheck.y, posToCheck.z, highResLod)
|
||||
!Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(posToCheck.x, posToCheck.y, posToCheck.z, highResLod)
|
||||
){
|
||||
LoggerInterface.loggerNetworking.DEBUG("(Client) Send Request for terrain at " + posToCheck);
|
||||
if(!Globals.clientTerrainManager.requestChunk(posToCheck.x, posToCheck.y, posToCheck.z, highResLod)){
|
||||
if(!Globals.clientState.clientTerrainManager.requestChunk(posToCheck.x, posToCheck.y, posToCheck.z, highResLod)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -917,7 +917,7 @@ public class ClientDrawCellManager {
|
||||
int lod = this.chunkTree.getMaxLevel() - node.getLevel();
|
||||
int spacingFactor = (int)Math.pow(2,lod);
|
||||
Vector3i worldPos = cell.getWorldPos();
|
||||
if(!Globals.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
if(!Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, lod)){
|
||||
return false;
|
||||
}
|
||||
int highResLod = this.chunkTree.getMaxLevel() - (node.getLevel() + 1);
|
||||
@ -956,7 +956,7 @@ public class ClientDrawCellManager {
|
||||
posToCheck.y < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
posToCheck.z >= 0 &&
|
||||
posToCheck.z < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
!Globals.clientTerrainManager.containsChunkDataAtWorldPoint(posToCheck.x, posToCheck.y, posToCheck.z, highResLod)
|
||||
!Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(posToCheck.x, posToCheck.y, posToCheck.z, highResLod)
|
||||
){
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -147,7 +147,7 @@ public class DrawCell {
|
||||
public void generateDrawableEntity(VoxelTextureAtlas atlas, int lod, List<DrawCellFace> higherLODFaces){
|
||||
boolean success = true;
|
||||
if(chunkData == null){
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
worldPos.x,
|
||||
worldPos.y,
|
||||
worldPos.z,
|
||||
@ -292,7 +292,7 @@ public class DrawCell {
|
||||
//implicitly performing transforms to adapt from face-space to world & local space
|
||||
switch(higherLODFace){
|
||||
case X_POSITIVE: {
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
new Vector3i(
|
||||
worldPos.x + mainSpacing,
|
||||
worldPos.y + worldCoordOffset1,
|
||||
@ -318,7 +318,7 @@ public class DrawCell {
|
||||
}
|
||||
} break;
|
||||
case X_NEGATIVE: {
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
new Vector3i(
|
||||
worldPos.x,
|
||||
worldPos.y + worldCoordOffset1,
|
||||
@ -344,7 +344,7 @@ public class DrawCell {
|
||||
}
|
||||
} break;
|
||||
case Y_POSITIVE: {
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
new Vector3i(
|
||||
worldPos.x + worldCoordOffset1,
|
||||
worldPos.y + mainSpacing,
|
||||
@ -370,7 +370,7 @@ public class DrawCell {
|
||||
}
|
||||
} break;
|
||||
case Y_NEGATIVE: {
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
new Vector3i(
|
||||
worldPos.x + worldCoordOffset1,
|
||||
worldPos.y,
|
||||
@ -396,7 +396,7 @@ public class DrawCell {
|
||||
}
|
||||
} break;
|
||||
case Z_POSITIVE: {
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
new Vector3i(
|
||||
worldPos.x + worldCoordOffset1,
|
||||
worldPos.y + worldCoordOffset2,
|
||||
@ -422,7 +422,7 @@ public class DrawCell {
|
||||
}
|
||||
} break;
|
||||
case Z_NEGATIVE: {
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
new Vector3i(
|
||||
worldPos.x + worldCoordOffset1,
|
||||
worldPos.y + worldCoordOffset2,
|
||||
|
||||
@ -226,7 +226,7 @@ public class FoliageCell {
|
||||
public void generateDrawableEntity(int lod){
|
||||
boolean success = true;
|
||||
if(chunkData == null){
|
||||
ChunkData currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
ChunkData currentChunk = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(
|
||||
worldPos.x,
|
||||
worldPos.y,
|
||||
worldPos.z,
|
||||
|
||||
@ -814,11 +814,11 @@ public class FoliageCellManager {
|
||||
worldPos.y < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
worldPos.z >= 0 &&
|
||||
worldPos.z < Globals.clientState.clientWorldData.getWorldDiscreteSize() &&
|
||||
!Globals.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)
|
||||
!Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)
|
||||
){
|
||||
//client should request chunk data from server for each chunk necessary to create the model
|
||||
LoggerInterface.loggerNetworking.DEBUG("(Client) Send Request for terrain at " + worldPos);
|
||||
if(!Globals.clientTerrainManager.requestChunk(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)){
|
||||
if(!Globals.clientState.clientTerrainManager.requestChunk(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -833,7 +833,7 @@ public class FoliageCellManager {
|
||||
private boolean containsDataToGenerate(WorldOctTree.WorldOctTreeNode<FoliageCell> node){
|
||||
FoliageCell cell = node.getData();
|
||||
Vector3i worldPos = cell.getWorldPos();
|
||||
return Globals.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE);
|
||||
return Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -212,7 +212,7 @@ public class FoliageModel {
|
||||
currVoxelPos.y + currWorldPos.y * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET,
|
||||
currVoxelPos.z + currWorldPos.z * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET
|
||||
);
|
||||
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(currWorldPos,ChunkData.NO_STRIDE);
|
||||
ChunkData data = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(currWorldPos,ChunkData.NO_STRIDE);
|
||||
if(data == null){
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ public class ClientTerrainManager {
|
||||
if(message.getchunkResolution() == ChunkData.NO_STRIDE && terrainCache.containsChunkDataAtWorldPoint(message.getworldX(), message.getworldY(), message.getworldZ(), ChunkData.NO_STRIDE)){
|
||||
//this is a full-res chunk, and we already had this chunk in cache
|
||||
//need to flag foliage cell to update these positions given that we have changed terrain values
|
||||
Globals.foliageCellManager.markUpdateable(message.getworldX(), message.getworldY(), message.getworldZ());
|
||||
Globals.clientState.foliageCellManager.markUpdateable(message.getworldX(), message.getworldY(), message.getworldZ());
|
||||
}
|
||||
terrainCache.addChunkDataToCache(
|
||||
message.getworldX(), message.getworldY(), message.getworldZ(),
|
||||
|
||||
@ -37,8 +37,8 @@ public class ClientVoxelSampler {
|
||||
int voxelId = 0;
|
||||
Vector3i chunkSpacePos = Globals.clientState.clientWorldData.convertRealToWorldSpace(realPos);
|
||||
Vector3i voxelSpacePos = Globals.clientState.clientWorldData.convertRealToVoxelSpace(realPos);
|
||||
if(Globals.clientTerrainManager.containsChunkDataAtWorldPoint(chunkSpacePos, ChunkData.NO_STRIDE)){
|
||||
ChunkData chunkData = Globals.clientTerrainManager.getChunkDataAtWorldPoint(chunkSpacePos, ChunkData.NO_STRIDE);
|
||||
if(Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(chunkSpacePos, ChunkData.NO_STRIDE)){
|
||||
ChunkData chunkData = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(chunkSpacePos, ChunkData.NO_STRIDE);
|
||||
voxelId = chunkData.getType(voxelSpacePos);
|
||||
} else {
|
||||
return INVALID_POSITION;
|
||||
|
||||
@ -40,13 +40,13 @@ public class ImGuiChunkMonitor {
|
||||
if(Globals.clientBlockCellManager != null){
|
||||
ImGui.text("Block node count: " + Globals.clientBlockCellManager.getNodeCount());
|
||||
}
|
||||
if(Globals.foliageCellManager != null){
|
||||
ImGui.text("Foliage node count: " + Globals.foliageCellManager.getNodeCount());
|
||||
if(Globals.clientState.foliageCellManager != null){
|
||||
ImGui.text("Foliage node count: " + Globals.clientState.foliageCellManager.getNodeCount());
|
||||
}
|
||||
if(ImGui.button("Break at chunk")){
|
||||
if(Globals.foliageCellManager != null){
|
||||
if(Globals.clientState.foliageCellManager != null){
|
||||
Vector3i absVoxelPos = Globals.clientState.clientWorldData.convertRealToAbsoluteVoxelSpace(EntityUtils.getPosition(Globals.playerEntity));
|
||||
Globals.foliageCellManager.addBreakPoint(absVoxelPos);
|
||||
Globals.clientState.foliageCellManager.addBreakPoint(absVoxelPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class ImGuiClientServices {
|
||||
LoggerInterface.loggerEngine.WARNING("" + cell);
|
||||
|
||||
LoggerInterface.loggerEngine.WARNING("Chunk topology:");
|
||||
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(cameraWorldPos, 1);
|
||||
ChunkData data = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(cameraWorldPos, 1);
|
||||
if(data != null){
|
||||
for(int x = 0; x < ChunkData.CHUNK_DATA_SIZE; x++){
|
||||
String line = "";
|
||||
@ -61,17 +61,17 @@ public class ImGuiClientServices {
|
||||
}
|
||||
if(ImGui.button("Print debug info for FoliageCell at camera position")){
|
||||
Vector3i cameraWorldPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
FoliageCell cell = Globals.clientState.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
LoggerInterface.loggerEngine.WARNING("" + cell);
|
||||
}
|
||||
if(ImGui.button("Debug FoliageCell evaluation at camera position")){
|
||||
Vector3i cameraWorldPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
FoliageCell cell = Globals.clientState.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
cell.setTripDebug(true);
|
||||
}
|
||||
if(ImGui.button("Request terrain at camera position")){
|
||||
Vector3i cameraWorldPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Globals.clientTerrainManager.requestChunk(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z, 0);
|
||||
Globals.clientState.clientTerrainManager.requestChunk(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ public class ImGuiEntityFoliageTab {
|
||||
}
|
||||
|
||||
if(ImGui.button("Regenerate All Grass")){
|
||||
Globals.foliageCellManager.evictAll();
|
||||
Globals.clientState.foliageCellManager.evictAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class ImGuiFluidMonitor {
|
||||
ImGui.text("Undrawable size: " + fluidCellManager.getUndrawableSize());
|
||||
ImGui.text("Unrequested size: " + fluidCellManager.getUnrequestedSize());
|
||||
|
||||
ClientFluidManager clientFluidManager = Globals.clientFluidManager;
|
||||
ClientFluidManager clientFluidManager = Globals.clientState.clientFluidManager;
|
||||
ImGui.text("ClientFluidManager Data");
|
||||
ImGui.text("Message Count (This Frame): " + clientFluidManager.getMessageCount());
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public class ImGuiTestGen {
|
||||
|
||||
//clear client
|
||||
Globals.clientDrawCellManager.evictAll();
|
||||
Globals.clientTerrainManager.evictAll();
|
||||
Globals.clientState.clientTerrainManager.evictAll();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ public class MenuCharacterCreation {
|
||||
|
||||
//the list of characters
|
||||
Div selectContainer = Div.createCol();
|
||||
if(Globals.clientCharacterManager.getCharacterList() != null){
|
||||
for(CharacterDescriptionDTO description : Globals.clientCharacterManager.getCharacterList().getCharacters()){
|
||||
if(Globals.clientState.clientCharacterManager.getCharacterList() != null){
|
||||
for(CharacterDescriptionDTO description : Globals.clientState.clientCharacterManager.getCharacterList().getCharacters()){
|
||||
String buttonTitle = "Character " + description.getId();
|
||||
Div charNameContainer = Div.createRow(Button.createButton(buttonTitle, () -> {
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(description.getId()));
|
||||
|
||||
@ -13,21 +13,16 @@ import electrosphere.audio.collision.HitboxAudioService;
|
||||
import electrosphere.audio.movement.MovementAudioService;
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.client.ClientState;
|
||||
import electrosphere.client.block.ClientBlockManager;
|
||||
import electrosphere.client.block.cells.BlockTextureAtlas;
|
||||
import electrosphere.client.block.cells.ClientBlockCellManager;
|
||||
import electrosphere.client.chemistry.ClientChemistryCollisionCallback;
|
||||
import electrosphere.client.entity.character.ClientCharacterManager;
|
||||
import electrosphere.client.entity.particle.ParticleService;
|
||||
import electrosphere.client.fluid.cells.FluidCellManager;
|
||||
import electrosphere.client.fluid.manager.ClientFluidManager;
|
||||
import electrosphere.client.player.ClientPlayerData;
|
||||
import electrosphere.client.scene.ClientLevelEditorData;
|
||||
import electrosphere.client.scene.ClientSceneWrapper;
|
||||
import electrosphere.client.terrain.cells.ClientDrawCellManager;
|
||||
import electrosphere.client.terrain.cells.VoxelTextureAtlas;
|
||||
import electrosphere.client.terrain.foliage.FoliageCellManager;
|
||||
import electrosphere.client.terrain.manager.ClientTerrainManager;
|
||||
import electrosphere.client.ui.menu.WindowUtils;
|
||||
import electrosphere.collision.CollisionEngine;
|
||||
import electrosphere.collision.CollisionWorldData;
|
||||
@ -336,18 +331,6 @@ public class Globals {
|
||||
|
||||
//instanced actor manager
|
||||
public static InstanceManager clientInstanceManager = new InstanceManager();
|
||||
|
||||
//client side foliage manager
|
||||
// public static ClientFoliageManager clientFoliageManager;
|
||||
public static FoliageCellManager foliageCellManager;
|
||||
|
||||
//client world data
|
||||
public static ClientCharacterManager clientCharacterManager = new ClientCharacterManager();
|
||||
|
||||
//client gridded manager
|
||||
public static ClientTerrainManager clientTerrainManager;
|
||||
public static ClientFluidManager clientFluidManager;
|
||||
public static ClientBlockManager clientBlockManager;
|
||||
|
||||
//client player data
|
||||
public static ClientPlayerData clientPlayerData = new ClientPlayerData();
|
||||
@ -496,9 +479,6 @@ public class Globals {
|
||||
//load in shader options map
|
||||
shaderOptionMap = FileUtils.loadObjectFromAssetPath("Shaders/shaderoptions.json", ShaderOptionMap.class);
|
||||
shaderOptionMap.debug();
|
||||
//client scene wrapper
|
||||
Globals.clientState.clientScene = new Scene();
|
||||
Globals.clientState.clientSceneWrapper = new ClientSceneWrapper(Globals.clientState.clientScene, new CollisionEngine(), CollisionEngine.create(new ClientChemistryCollisionCallback()), new CollisionEngine());
|
||||
//temporary hold for skybox colors
|
||||
skyboxColors = new ArrayList<Vector3f>();
|
||||
//load asset manager
|
||||
@ -508,10 +488,6 @@ public class Globals {
|
||||
//realm & data cell manager
|
||||
realmManager = new RealmManager();
|
||||
entityDataCellMapper = new EntityDataCellMapper();
|
||||
//gridded managers
|
||||
Globals.clientTerrainManager = new ClientTerrainManager();
|
||||
Globals.clientFluidManager = new ClientFluidManager();
|
||||
Globals.clientBlockManager = new ClientBlockManager();
|
||||
//game config
|
||||
gameConfigDefault = electrosphere.data.Config.loadDefaultConfig();
|
||||
gameConfigCurrent = gameConfigDefault;
|
||||
|
||||
@ -348,7 +348,7 @@ public class ClientLoading {
|
||||
){
|
||||
i++;
|
||||
if(i % DRAW_CELL_UPDATE_RATE == 0){
|
||||
WindowUtils.updateLoadingWindow("WAITING ON SERVER TO SEND TERRAIN (" + Globals.clientTerrainManager.getAllChunks().size() + ")");
|
||||
WindowUtils.updateLoadingWindow("WAITING ON SERVER TO SEND TERRAIN (" + Globals.clientState.clientTerrainManager.getAllChunks().size() + ")");
|
||||
}
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
@ -374,7 +374,7 @@ public class ClientLoading {
|
||||
}
|
||||
|
||||
//initialize draw cell manager
|
||||
Globals.fluidCellManager = new FluidCellManager(Globals.clientTerrainManager, 0, 0, 0);
|
||||
Globals.fluidCellManager = new FluidCellManager(Globals.clientState.clientTerrainManager, 0, 0, 0);
|
||||
Globals.fluidCellManager.setGenerateDrawables(true);
|
||||
Globals.clientState.clientSimulation.setLoadingTerrain(true);
|
||||
|
||||
@ -432,7 +432,7 @@ public class ClientLoading {
|
||||
){
|
||||
i++;
|
||||
if(i % DRAW_CELL_UPDATE_RATE == 0){
|
||||
WindowUtils.updateLoadingWindow("WAITING ON SERVER TO SEND BLOCKS (" + Globals.clientTerrainManager.getAllChunks().size() + ")");
|
||||
WindowUtils.updateLoadingWindow("WAITING ON SERVER TO SEND BLOCKS (" + Globals.clientState.clientTerrainManager.getAllChunks().size() + ")");
|
||||
}
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
@ -446,8 +446,8 @@ public class ClientLoading {
|
||||
* Starts up the foliage manager
|
||||
*/
|
||||
private static void initFoliageManager(){
|
||||
Globals.foliageCellManager = new FoliageCellManager(Globals.clientState.clientWorldData.getWorldDiscreteSize());
|
||||
Globals.foliageCellManager.init();
|
||||
Globals.clientState.foliageCellManager = new FoliageCellManager(Globals.clientState.clientWorldData.getWorldDiscreteSize());
|
||||
Globals.clientState.foliageCellManager.init();
|
||||
// Globals.foliageCellManager.start();
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public class ClientPhysicsSyncTree implements BehaviorTree {
|
||||
if(parent == Globals.playerEntity){
|
||||
if(position.distance(EntityUtils.getPosition(parent)) > FoliageCellManager.TELEPORT_DISTANCE){
|
||||
Globals.clientDrawCellManager.bustDistanceCache();
|
||||
Globals.foliageCellManager.bustDistanceCache();
|
||||
Globals.clientState.foliageCellManager.bustDistanceCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ public class CharacterProtocol implements ClientProtocolTemplate<CharacterMessag
|
||||
Globals.threadManager.start(clientThread);
|
||||
} break;
|
||||
case RESPONSECHARACTERLIST: {
|
||||
Globals.clientCharacterManager.setCharacterList(new Gson().fromJson(message.getdata(), ClientCharacterListDTO.class));
|
||||
Globals.clientState.clientCharacterManager.setCharacterList(new Gson().fromJson(message.getdata(), ClientCharacterListDTO.class));
|
||||
Globals.signalSystem.post(SignalType.UI_MODIFICATION,() -> {
|
||||
WindowUtils.replaceMainMenuContents(MenuCharacterCreation.createCharacterSelectionWindow());
|
||||
});
|
||||
|
||||
@ -53,15 +53,15 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
break;
|
||||
case SENDCHUNKDATA: {
|
||||
LoggerInterface.loggerNetworking.DEBUG("(Client) Received terrain at " + message.getworldX() + " " + message.getworldY() + " " + message.getworldZ());
|
||||
Globals.clientTerrainManager.attachTerrainMessage(message);
|
||||
Globals.clientState.clientTerrainManager.attachTerrainMessage(message);
|
||||
} break;
|
||||
case SENDREDUCEDCHUNKDATA: {
|
||||
LoggerInterface.loggerNetworking.DEBUG("(Client) Received terrain at " + message.getworldX() + " " + message.getworldY() + " " + message.getworldZ() + " " + message.getchunkResolution());
|
||||
Globals.clientTerrainManager.attachTerrainMessage(message);
|
||||
Globals.clientState.clientTerrainManager.attachTerrainMessage(message);
|
||||
} break;
|
||||
case SENDREDUCEDBLOCKDATA: {
|
||||
LoggerInterface.loggerNetworking.DEBUG("(Client) Received blocks at " + message.getworldX() + " " + message.getworldY() + " " + message.getworldZ() + " " + message.getchunkResolution());
|
||||
Globals.clientBlockManager.attachTerrainMessage(message);
|
||||
Globals.clientState.clientBlockManager.attachTerrainMessage(message);
|
||||
} break;
|
||||
case UPDATEVOXEL: {
|
||||
//
|
||||
@ -95,8 +95,8 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
}
|
||||
//
|
||||
//update the terrain cache
|
||||
if(Globals.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)){
|
||||
ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE);
|
||||
if(Globals.clientState.clientTerrainManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)){
|
||||
ChunkData data = Globals.clientState.clientTerrainManager.getChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE);
|
||||
if(data != null){
|
||||
data.updatePosition(
|
||||
message.getvoxelX(),
|
||||
@ -121,29 +121,29 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
|
||||
//
|
||||
//update foliage manager
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX(), message.getvoxelY(), message.getvoxelZ()
|
||||
);
|
||||
if(message.getvoxelX() > 0){
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX() - 1, message.getvoxelY(), message.getvoxelZ()
|
||||
);
|
||||
if(message.getvoxelY() > 0){
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX() - 1, message.getvoxelY() - 1, message.getvoxelZ()
|
||||
);
|
||||
if(message.getvoxelZ() > 0){
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX() - 1, message.getvoxelY() - 1, message.getvoxelZ() - 1
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if(message.getvoxelZ() > 0){
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX() - 1, message.getvoxelY(), message.getvoxelZ() - 1
|
||||
);
|
||||
@ -151,19 +151,19 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
}
|
||||
} else {
|
||||
if(message.getvoxelY() > 0){
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX(), message.getvoxelY() - 1, message.getvoxelZ()
|
||||
);
|
||||
if(message.getvoxelZ() > 0){
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX(), message.getvoxelY() - 1, message.getvoxelZ() - 1
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if(message.getvoxelZ() > 0){
|
||||
Globals.foliageCellManager.markUpdateable(
|
||||
Globals.clientState.foliageCellManager.markUpdateable(
|
||||
worldPosToUpdate.x, worldPosToUpdate.y, worldPosToUpdate.z,
|
||||
message.getvoxelX(), message.getvoxelY(), message.getvoxelZ() - 1
|
||||
);
|
||||
@ -205,8 +205,8 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
}
|
||||
//
|
||||
//update the block cache
|
||||
if(Globals.clientBlockManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)){
|
||||
BlockChunkData data = Globals.clientBlockManager.getChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE);
|
||||
if(Globals.clientState.clientBlockManager.containsChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE)){
|
||||
BlockChunkData data = Globals.clientState.clientBlockManager.getChunkDataAtWorldPoint(worldPos.x, worldPos.y, worldPos.z, ChunkData.NO_STRIDE);
|
||||
if(data != null){
|
||||
data.setType(
|
||||
message.getvoxelX(),
|
||||
@ -235,10 +235,10 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
|
||||
}
|
||||
} break;
|
||||
case SENDFLUIDDATA: {
|
||||
Globals.clientFluidManager.attachFluidMessage(message);
|
||||
Globals.clientState.clientFluidManager.attachFluidMessage(message);
|
||||
} break;
|
||||
case UPDATEFLUIDDATA: {
|
||||
Globals.clientFluidManager.attachFluidMessage(message);
|
||||
Globals.clientState.clientFluidManager.attachFluidMessage(message);
|
||||
} break;
|
||||
default: {
|
||||
LoggerInterface.loggerNetworking.WARNING("Client networking: Unhandled message of type: " + message.getMessageSubtype());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user