octree cache busting when sync teleport dist
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
e207269489
commit
756f3ead55
@ -1619,6 +1619,7 @@ Craftable wooden floor fab
|
||||
Using up charges destroys the item (including toolbar instances)
|
||||
Crafting can consume charges
|
||||
Products from crafting can add charges to existing items
|
||||
Cache busting when physics sync pulls player entity TELEPORT distances
|
||||
|
||||
|
||||
|
||||
|
||||
@ -147,6 +147,11 @@ public class ClientDrawCellManager {
|
||||
*/
|
||||
boolean initialized = false;
|
||||
|
||||
/**
|
||||
* Used to bust the distance cache from external calls
|
||||
*/
|
||||
boolean bustDistCache = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param voxelTextureAtlas The voxel texture atlas
|
||||
@ -171,6 +176,10 @@ public class ClientDrawCellManager {
|
||||
Vector3d playerPos = EntityUtils.getPosition(Globals.playerEntity);
|
||||
Vector3i playerWorldPos = Globals.clientWorldData.convertRealToWorldSpace(playerPos);
|
||||
int distCache = this.getDistCache(this.lastPlayerPos, playerWorldPos);
|
||||
if(this.bustDistCache){
|
||||
this.bustDistCache = false;
|
||||
distCache = this.chunkTree.getMaxLevel();
|
||||
}
|
||||
this.lastPlayerPos.set(playerWorldPos);
|
||||
//the sets to iterate through
|
||||
updatedLastFrame = true;
|
||||
@ -1084,6 +1093,13 @@ public class ClientDrawCellManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Busts the distance cache
|
||||
*/
|
||||
public void bustDistanceCache(){
|
||||
this.bustDistCache = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -158,6 +158,11 @@ public class FoliageCellManager {
|
||||
*/
|
||||
List<Vector3i> breakPoints = new LinkedList<Vector3i>();
|
||||
|
||||
/**
|
||||
* Used to bust the distance cache from external calls
|
||||
*/
|
||||
boolean bustDistCache = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param worldDim The size of the world in chunks
|
||||
@ -193,8 +198,9 @@ public class FoliageCellManager {
|
||||
Vector3d playerPos = EntityUtils.getPosition(Globals.playerEntity);
|
||||
Vector3i absVoxelPos = Globals.clientWorldData.convertRealToAbsoluteVoxelSpace(playerPos);
|
||||
int distCache = this.getDistCache(this.lastPlayerPos, absVoxelPos);
|
||||
if(absVoxelPos.distance(this.lastPlayerPos) > TELEPORT_DISTANCE){
|
||||
if(bustDistCache || absVoxelPos.distance(this.lastPlayerPos) > TELEPORT_DISTANCE){
|
||||
distCache = BUST_META_CELLS;
|
||||
bustDistCache = false;
|
||||
}
|
||||
this.lastPlayerPos.set(absVoxelPos);
|
||||
//the sets to iterate through
|
||||
@ -926,6 +932,13 @@ public class FoliageCellManager {
|
||||
public void addBreakPoint(Vector3i absVoxelPos){
|
||||
this.breakPoints.add(absVoxelPos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Busts the distance cache
|
||||
*/
|
||||
public void bustDistanceCache(){
|
||||
this.bustDistCache = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -63,11 +63,16 @@ public class ImGuiDrawCell {
|
||||
LoggerInterface.loggerEngine.WARNING("Chunk not in cache! " + cameraWorldPos);
|
||||
}
|
||||
}
|
||||
if(ImGui.button("Debug FoliageCell at camera position")){
|
||||
if(ImGui.button("Print debug info for FoliageCell at camera position")){
|
||||
Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
LoggerInterface.loggerEngine.WARNING("" + cell);
|
||||
}
|
||||
if(ImGui.button("Debug FoliageCell evaluation at camera position")){
|
||||
Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z);
|
||||
cell.setTripDebug(true);
|
||||
}
|
||||
if(ImGui.button("Request terrain at camera position")){
|
||||
Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||
Globals.clientTerrainManager.requestChunk(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z, 1);
|
||||
|
||||
@ -5,6 +5,7 @@ import org.joml.Vector3d;
|
||||
import org.ode4j.ode.DBody;
|
||||
|
||||
import electrosphere.client.entity.camera.CameraEntityUtils;
|
||||
import electrosphere.client.terrain.foliage.FoliageCellManager;
|
||||
import electrosphere.collision.PhysicsEntityUtils;
|
||||
import electrosphere.collision.PhysicsUtils;
|
||||
import electrosphere.engine.Globals;
|
||||
@ -20,13 +21,19 @@ import electrosphere.net.parser.net.message.EntityMessage;
|
||||
*/
|
||||
public class ClientPhysicsSyncTree implements BehaviorTree {
|
||||
|
||||
//The parent entity for the tree
|
||||
/**
|
||||
* The parent entity for the tree
|
||||
*/
|
||||
Entity parent;
|
||||
|
||||
//The most recent message received from the client
|
||||
/**
|
||||
* The most recent message received from the client
|
||||
*/
|
||||
EntityMessage latestMessage = null;
|
||||
|
||||
//checks if the message has been pushed to the physics engine or not
|
||||
/**
|
||||
* checks if the message has been pushed to the physics engine or not
|
||||
*/
|
||||
boolean hasPushesMessage = true;
|
||||
|
||||
/**
|
||||
@ -52,6 +59,15 @@ public class ClientPhysicsSyncTree implements BehaviorTree {
|
||||
Vector3d angularForce = new Vector3d();
|
||||
DBody body = PhysicsEntityUtils.getDBody(parent);
|
||||
|
||||
//
|
||||
//bust distance caches if this is the player's entity and we've traveled a long distance suddenly
|
||||
if(parent == Globals.playerEntity){
|
||||
if(position.distance(EntityUtils.getPosition(parent)) > FoliageCellManager.TELEPORT_DISTANCE){
|
||||
Globals.clientDrawCellManager.bustDistanceCache();
|
||||
Globals.foliageCellManager.bustDistanceCache();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//Synchronize data
|
||||
EntityUtils.getPosition(parent).set(position);
|
||||
|
||||
@ -87,6 +87,9 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
case COMMON: {
|
||||
EntityProtocol.spawnCommon(message);
|
||||
} break;
|
||||
case ENGINE: {
|
||||
throw new Error("Unsupported entity type!");
|
||||
}
|
||||
}
|
||||
Globals.clientConnection.release(message);
|
||||
} break;
|
||||
@ -159,6 +162,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
|
||||
// TODO
|
||||
//
|
||||
//
|
||||
case INTERACT:
|
||||
case UPDATEENTITYVIEWDIR:
|
||||
case KILL:
|
||||
//to be implemented
|
||||
|
||||
@ -26,9 +26,9 @@ public class PlayerProtocol implements ClientProtocolTemplate<PlayerMessage> {
|
||||
Globals.clientPlayer = new Player(message.getplayerID(), Player.CLIENT_DB_ID);
|
||||
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] Player ID is " + Globals.clientPlayer.getId());
|
||||
break;
|
||||
case SETINITIALDISCRETEPOSITION:
|
||||
case SETINITIALDISCRETEPOSITION: {
|
||||
Globals.clientPlayerData.setWorldPos(new Vector3i(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY(), message.getinitialDiscretePositionZ()));
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user