bugfixes
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-11-19 11:45:35 -05:00
parent 3a9eb0591d
commit 4d9047d8cf
9 changed files with 48 additions and 24 deletions

View File

@ -1075,6 +1075,13 @@ Voxel and Heightmap generators based on noise functions in files
Set all client terrain rigid bodies are kinematic Set all client terrain rigid bodies are kinematic
Add caves Add caves
Tweaking test2 noise definition Tweaking test2 noise definition
Add sleep to server socket thread
(11/19/2024)
Fix draw cells not deleting once all children have reported generation
Fix server data cells unloading before ready state
Fix terrain chunk generation trying to generate rigid body for no-vertex cell
Fix server homogenous chunk check on generation with variadic weights

View File

@ -26,7 +26,12 @@ public class DrawCell {
/** /**
* Number of frames to wait before destroying the chunk entity * Number of frames to wait before destroying the chunk entity
*/ */
public static final int FRAMES_TO_WAIT_BEFORE_DESTRUCTION = 15; public static final int FRAMES_TO_WAIT_BEFORE_DESTRUCTION = 25;
/**
* Number of child cells per parent cell
*/
static final int CHILD_CELLS_PER_PARENT = 8;
/** /**
* Enum for the different faces of a draw cell -- used when filling in data for higher LOD faces * Enum for the different faces of a draw cell -- used when filling in data for higher LOD faces
@ -215,7 +220,7 @@ public class DrawCell {
*/ */
public void alertToGeneration(){ public void alertToGeneration(){
this.generationAlertCount++; this.generationAlertCount++;
if(this.generationAlertCount > 8){ if(this.generationAlertCount >= CHILD_CELLS_PER_PARENT){
this.destroy(); this.destroy();
} }
} }

View File

@ -759,12 +759,13 @@ public class CollisionEngine {
//make uncollidable //make uncollidable
if(PhysicsEntityUtils.containsDBody(e)){ if(PhysicsEntityUtils.containsDBody(e)){
DBody rigidBody = PhysicsEntityUtils.getDBody(e); DBody rigidBody = PhysicsEntityUtils.getDBody(e);
if(rigidBody == null){
throw new Error("DBody key set to null rigid body! " + rigidBody);
}
this.deregisterCollisionObject(rigidBody,PhysicsEntityUtils.getCollidable(e)); this.deregisterCollisionObject(rigidBody,PhysicsEntityUtils.getCollidable(e));
e.removeData(EntityDataStrings.PHYSICS_COLLISION_BODY); e.removeData(EntityDataStrings.PHYSICS_COLLISION_BODY);
if(rigidBody != null){
this.destroyDBody(rigidBody); this.destroyDBody(rigidBody);
} }
}
if(ServerPhysicsSyncTree.hasTree(e)){ if(ServerPhysicsSyncTree.hasTree(e)){
ServerPhysicsSyncTree.detachTree(e, ServerPhysicsSyncTree.getTree(e)); ServerPhysicsSyncTree.detachTree(e, ServerPhysicsSyncTree.getTree(e));
} }

View File

@ -483,10 +483,10 @@ public class PhysicsEntityUtils {
*/ */
public static void clientAttachTerrainChunkRigidBody(Entity terrain, TerrainChunkData data){ public static void clientAttachTerrainChunkRigidBody(Entity terrain, TerrainChunkData data){
DBody terrainBody = CollisionBodyCreation.generateBodyFromTerrainData(Globals.clientSceneWrapper.getCollisionEngine(), data, Collidable.TYPE_STATIC_BIT); DBody terrainBody = CollisionBodyCreation.generateBodyFromTerrainData(Globals.clientSceneWrapper.getCollisionEngine(), data, Collidable.TYPE_STATIC_BIT);
if(terrainBody != null){ Collidable collidable = new Collidable(terrain,Collidable.TYPE_TERRAIN, false);
Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(terrainBody, new Collidable(terrain,Collidable.TYPE_TERRAIN, false)); Globals.clientSceneWrapper.getCollisionEngine().registerCollisionObject(terrainBody, collidable);
PhysicsEntityUtils.setDBody(terrain,terrainBody); PhysicsEntityUtils.setDBody(terrain,terrainBody);
} terrain.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable);
} }
@ -512,10 +512,12 @@ public class PhysicsEntityUtils {
*/ */
public static void serverRepositionEntities(CollisionEngine collisionEngine){ public static void serverRepositionEntities(CollisionEngine collisionEngine){
List<Entity> toReposition = new LinkedList<Entity>(); List<Entity> toReposition = new LinkedList<Entity>();
if(collisionEngine.getCollidables() == null){ List<Collidable> collidableList = collisionEngine.getCollidables();
if(collidableList == null){
collisionEngine.getCollidables();
throw new Error("Collision engine collidables are null!"); throw new Error("Collision engine collidables are null!");
} }
for(Collidable collidable : collisionEngine.getCollidables()){ for(Collidable collidable : collidableList){
Entity entity = collidable.getParent(); Entity entity = collidable.getParent();
DBody body = PhysicsEntityUtils.getDBody(entity); DBody body = PhysicsEntityUtils.getDBody(entity);
if(body != null && body.isEnabled() && !body.isKinematic()){ if(body != null && body.isEnabled() && !body.isKinematic()){
@ -551,6 +553,9 @@ public class PhysicsEntityUtils {
* @param body The body * @param body The body
*/ */
public static void setDBody(Entity entity, DBody body){ public static void setDBody(Entity entity, DBody body){
if(body == null){
throw new Error("Trying to set null DBody!");
}
entity.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, body); entity.putData(EntityDataStrings.PHYSICS_COLLISION_BODY, body);
} }

View File

@ -65,7 +65,7 @@ public class TerrainChunk {
if(Globals.clientScene.containsEntity(rVal)){ if(Globals.clientScene.containsEntity(rVal)){
String modelPath = ClientTerrainManager.queueTerrainGridGeneration(data, atlas, notifyTarget, toDelete); String modelPath = ClientTerrainManager.queueTerrainGridGeneration(data, atlas, notifyTarget, toDelete);
EntityCreationUtils.makeEntityDrawablePreexistingModel(rVal, modelPath); EntityCreationUtils.makeEntityDrawablePreexistingModel(rVal, modelPath);
if(levelOfDetail == ClientDrawCellManager.FULL_RES_LOD){ if(levelOfDetail == ClientDrawCellManager.FULL_RES_LOD && data.faceElements.size() > 0){
PhysicsEntityUtils.clientAttachTerrainChunkRigidBody(rVal, data); PhysicsEntityUtils.clientAttachTerrainChunkRigidBody(rVal, data);
CollisionObjUtils.clientPositionCharacter(rVal, new Vector3d(EntityUtils.getPosition(rVal)), new Quaterniond()); CollisionObjUtils.clientPositionCharacter(rVal, new Vector3d(EntityUtils.getPosition(rVal)), new Quaterniond());
} else { } else {

View File

@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
/** /**
* Lowest level networking class for the server * Lowest level networking class for the server
@ -96,6 +97,11 @@ public class Server implements Runnable {
} catch (IOException ex) { } catch (IOException ex) {
LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex); LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex);
} }
try {
TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException e) {
LoggerInterface.loggerEngine.DEBUG("Failed to sleep", e);
}
} }
this.isOpen = false; this.isOpen = false;
LoggerInterface.loggerNetworking.INFO("Server socket thread ended"); LoggerInterface.loggerNetworking.INFO("Server socket thread ended");

View File

@ -54,7 +54,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
/** /**
* The number of frames without players that must pass before a server data cell is unloaded * The number of frames without players that must pass before a server data cell is unloaded
*/ */
static final int UNLOAD_FRAME_THRESHOLD = 500; static final int UNLOAD_FRAME_THRESHOLD = 100;
/** /**
* Tracks whether this manager has been flagged to unload cells or not * Tracks whether this manager has been flagged to unload cells or not
@ -173,8 +173,6 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
LoggerInterface.loggerEngine.DEBUG("Creating new cell @ " + x + " " + y + " " + z); LoggerInterface.loggerEngine.DEBUG("Creating new cell @ " + x + " " + y + " " + z);
//create data cell //create data cell
this.createServerDataCell(targetPos); this.createServerDataCell(targetPos);
///generates physics for the cell in a dedicated thread then finally registers
this.runPhysicsGenerationThread(targetPos);
//add to loaded cells //add to loaded cells
cellPlayerlessFrameMap.put(groundDataCells.get(getServerDataCellKey(targetPos)),0); cellPlayerlessFrameMap.put(groundDataCells.get(getServerDataCellKey(targetPos)),0);
//add player //add player
@ -224,8 +222,6 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
loadedCellsLock.acquireUninterruptibly(); loadedCellsLock.acquireUninterruptibly();
//create data cell //create data cell
createServerDataCell(targetPos); createServerDataCell(targetPos);
//generates physics for the cell in a dedicated thread then finally registers
runPhysicsGenerationThread(targetPos);
//add to loaded cells //add to loaded cells
cellPlayerlessFrameMap.put(groundDataCells.get(getServerDataCellKey(targetPos)),0); cellPlayerlessFrameMap.put(groundDataCells.get(getServerDataCellKey(targetPos)),0);
//add player //add player
@ -344,8 +340,6 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
loadedCellsLock.acquireUninterruptibly(); loadedCellsLock.acquireUninterruptibly();
//create data cell //create data cell
this.createServerDataCell(targetPos); this.createServerDataCell(targetPos);
//generates physics for the cell in a dedicated thread then finally registers
this.runPhysicsGenerationThread(targetPos);
//add to loaded cells //add to loaded cells
cellPlayerlessFrameMap.put(groundDataCells.get(this.getServerDataCellKey(targetPos)),0); cellPlayerlessFrameMap.put(groundDataCells.get(this.getServerDataCellKey(targetPos)),0);
//add player //add player
@ -370,7 +364,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
//TODO: improve to make have less performance impact //TODO: improve to make have less performance impact
loadedCellsLock.acquireUninterruptibly(); loadedCellsLock.acquireUninterruptibly();
for(ServerDataCell cell : this.groundDataCells.values()){ for(ServerDataCell cell : this.groundDataCells.values()){
if(cell.getPlayers().size() < 1){ if(cell.isReady() && cell.getPlayers().size() < 1){
int frameCount = cellPlayerlessFrameMap.get(cell) + 1; int frameCount = cellPlayerlessFrameMap.get(cell) + 1;
cellPlayerlessFrameMap.put(cell,frameCount); cellPlayerlessFrameMap.put(cell,frameCount);
if(frameCount > UNLOAD_FRAME_THRESHOLD){ if(frameCount > UNLOAD_FRAME_THRESHOLD){
@ -501,8 +495,6 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
loadedCellsLock.acquireUninterruptibly(); loadedCellsLock.acquireUninterruptibly();
//create data cell //create data cell
this.createServerDataCell(worldPos); this.createServerDataCell(worldPos);
//generates physics for the cell in a dedicated thread then finally registers
this.runPhysicsGenerationThread(worldPos);
//add to loaded cells //add to loaded cells
cellPlayerlessFrameMap.put(groundDataCells.get(this.getServerDataCellKey(worldPos)),0); cellPlayerlessFrameMap.put(groundDataCells.get(this.getServerDataCellKey(worldPos)),0);
loadedCellsLock.release(); loadedCellsLock.release();
@ -614,6 +606,8 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
LoggerInterface.loggerEngine.DEBUG("Create server data cell with key " + cellKey); LoggerInterface.loggerEngine.DEBUG("Create server data cell with key " + cellKey);
cellPositionMap.put(rVal,new Vector3i(worldPos)); cellPositionMap.put(rVal,new Vector3i(worldPos));
serverContentManager.generateContentForDataCell(parent, worldPos, rVal, cellKey); serverContentManager.generateContentForDataCell(parent, worldPos, rVal, cellKey);
//generates physics for the cell in a dedicated thread then finally registers
this.runPhysicsGenerationThread(worldPos);
return rVal; return rVal;
} }

View File

@ -71,7 +71,7 @@ public class PhysicsDataCell {
// //
//fill in weights and types maps //fill in weights and types maps
// //
fillInData(); this.fillInData();
Vector3d realPos = new Vector3d( Vector3d realPos = new Vector3d(
worldPos.x * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET, worldPos.x * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET,

View File

@ -223,7 +223,13 @@ public class TestGenerationChunkGenerator implements ChunkGenerator {
} }
if(firstType == -2){ if(firstType == -2){
firstType = values[x][y][z]; firstType = values[x][y][z];
} else if(homogenous && firstType != values[x][y][z]){ } else if(
homogenous &&
(
firstType != values[x][y][z] ||
(weights[x][y][z] > -1.0f && weights[x][y][z] < 1.0f)
)
){
homogenous = false; homogenous = false;
} }
} }