shallow clone block data
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-25 14:06:58 -04:00
parent cf9dceff42
commit feac1383da
4 changed files with 36 additions and 21 deletions

View File

@ -1986,6 +1986,7 @@ Performance improvements
- Foliage cell quits earlier
- Behavior tree addition/subtraction from scene optimization
- Reduce bones on LOD human model
- Shallow clone on physics cell creation
Increase human move speed
LOD components re-attach physics

View File

@ -86,38 +86,38 @@ public class BlockChunkData implements BlockMeshgenData {
/**
* The type of block at a given position
*/
short[] type;
private short[] type;
/**
* Metadata about a block
* first 4 bits are the rotation of the block)
*/
short[] metadata;
private short[] metadata;
/**
* If this block chunk is homogenously a single value, it will be the value of this short. Otherwise is
*/
short homogenousValue = NOT_HOMOGENOUS;
private short homogenousValue = NOT_HOMOGENOUS;
/**
* The level of detail of the block data
*/
int lod;
private int lod;
/**
* The x coordinate of the world position of the chunk
*/
int worldX;
private int worldX;
/**
* The y coordinate of the world position of the chunk
*/
int worldY;
private int worldY;
/**
* The z coordinate of the world position of the chunk
*/
int worldZ;
private int worldZ;
/**
* Constructor
@ -152,6 +152,27 @@ public class BlockChunkData implements BlockMeshgenData {
this.setMetadata(BlockChunkPool.getShort());
}
/**
* Clones a block chunk data
* @param other The data to clone
* @return The cloned data
*/
public static BlockChunkData cloneShallow(BlockChunkData other){
BlockChunkData rVal = new BlockChunkData();
if(other.type != null){
rVal.type = other.type;
}
if(other.metadata != null){
rVal.metadata = other.metadata;
}
rVal.homogenousValue = other.homogenousValue;
rVal.lod = other.lod;
rVal.worldX = other.worldX;
rVal.worldY = other.worldY;
rVal.worldZ = other.worldZ;
return rVal;
}
/**
* Gets the type data for the chunk
* @return The type data

View File

@ -384,7 +384,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
//the server will not be able to synchronize it properly.
ServerEntityUtils.initiallyPositionEntity(parent,blockEntity,realPos);
ServerEntityUtils.initiallyPositionEntity(parent,terrainEntity,realPos);
PhysicsDataCell cell = PhysicsDataCell.createPhysicsCell(worldPos, terrainEntity, blockEntity);
PhysicsDataCell cell = PhysicsDataCell.createPhysicsCell(terrainEntity, blockEntity);
cell.setTerrainChunk(terrainChunk);
cell.setBlockChunk(blockChunkData);
cell.generatePhysics();
@ -819,7 +819,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
ServerEntityUtils.initiallyPositionEntity(realm,blockEntity,realPos);
ServerEntityUtils.initiallyPositionEntity(realm,terrainEntity,realPos);
PhysicsDataCell targetCell = PhysicsDataCell.createPhysicsCell(worldPos, terrainEntity, blockEntity);
PhysicsDataCell targetCell = PhysicsDataCell.createPhysicsCell(terrainEntity, blockEntity);
if(cell == null){
posPhysicsMap.put(key, targetCell);
} else {

View File

@ -14,26 +14,19 @@ import electrosphere.renderer.meshgen.BlockMeshgen.BlockMeshData;
import electrosphere.server.datacell.Realm;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
import org.joml.Vector3i;
import org.ode4j.ode.DBody;
/**
* An entity which contains physics for terrain for a given chunk on the server
*/
public class PhysicsDataCell {
Vector3i worldPos;
Entity physicsEntity;
Entity blockPhysicsEntity;
ServerTerrainChunk terrainChunk;
BlockChunkData blockChunk;
DBody physicsObject;
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];
int[][][] types = new int[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];
float[][][] weights;
int[][][] types;
/**
* The terrain vertex data
@ -52,7 +45,6 @@ public class PhysicsDataCell {
* @return The cell
*/
public static PhysicsDataCell createPhysicsCell(
Vector3i worldPos,
Entity physicsEntity,
Entity blockPhysicsEntity
@ -60,7 +52,6 @@ public class PhysicsDataCell {
PhysicsDataCell rVal = new PhysicsDataCell();
rVal.physicsEntity = physicsEntity;
rVal.blockPhysicsEntity = blockPhysicsEntity;
rVal.worldPos = worldPos;
return rVal;
}
@ -123,6 +114,8 @@ public class PhysicsDataCell {
//fill in data
//
//main chunk
this.weights = new float[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];
this.types = new int[ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE][ServerTerrainChunk.CHUNK_DATA_GENERATOR_SIZE];
for(int x = 0; x < ChunkData.CHUNK_DATA_SIZE; x++){
for(int y = 0; y < ChunkData.CHUNK_DATA_SIZE; y++){
for(int z = 0; z < ChunkData.CHUNK_DATA_SIZE; z++){
@ -257,7 +250,7 @@ public class PhysicsDataCell {
* @param blockChunk The block chunk data
*/
public void setBlockChunk(BlockChunkData blockChunk) {
this.blockChunk = blockChunk;
this.blockChunk = BlockChunkData.cloneShallow(blockChunk);
}
/**