shallow clone block data
	
		
			
	
		
	
	
		
	
		
			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
							
								
									cf9dceff42
								
							
						
					
					
						commit
						feac1383da
					
				@ -1986,6 +1986,7 @@ Performance improvements
 | 
				
			|||||||
 - Foliage cell quits earlier
 | 
					 - Foliage cell quits earlier
 | 
				
			||||||
 - Behavior tree addition/subtraction from scene optimization
 | 
					 - Behavior tree addition/subtraction from scene optimization
 | 
				
			||||||
 - Reduce bones on LOD human model
 | 
					 - Reduce bones on LOD human model
 | 
				
			||||||
 | 
					 - Shallow clone on physics cell creation
 | 
				
			||||||
Increase human move speed
 | 
					Increase human move speed
 | 
				
			||||||
LOD components re-attach physics
 | 
					LOD components re-attach physics
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -86,38 +86,38 @@ public class BlockChunkData implements BlockMeshgenData {
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The type of block at a given position
 | 
					     * The type of block at a given position
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    short[] type;
 | 
					    private short[] type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Metadata about a block
 | 
					     * Metadata about a block
 | 
				
			||||||
     * first 4 bits are the rotation of the 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 
 | 
					     * 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
 | 
					     * The level of detail of the block data
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    int lod;
 | 
					    private int lod;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The x coordinate of the world position of the chunk
 | 
					     * 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
 | 
					     * 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
 | 
					     * The z coordinate of the world position of the chunk
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    int worldZ;
 | 
					    private int worldZ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Constructor
 | 
					     * Constructor
 | 
				
			||||||
@ -152,6 +152,27 @@ public class BlockChunkData implements BlockMeshgenData {
 | 
				
			|||||||
        this.setMetadata(BlockChunkPool.getShort());
 | 
					        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
 | 
					     * Gets the type data for the chunk
 | 
				
			||||||
     * @return The type data
 | 
					     * @return The type data
 | 
				
			||||||
 | 
				
			|||||||
@ -384,7 +384,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
 | 
				
			|||||||
        //the server will not be able to synchronize it properly.
 | 
					        //the server will not be able to synchronize it properly.
 | 
				
			||||||
        ServerEntityUtils.initiallyPositionEntity(parent,blockEntity,realPos);
 | 
					        ServerEntityUtils.initiallyPositionEntity(parent,blockEntity,realPos);
 | 
				
			||||||
        ServerEntityUtils.initiallyPositionEntity(parent,terrainEntity,realPos);
 | 
					        ServerEntityUtils.initiallyPositionEntity(parent,terrainEntity,realPos);
 | 
				
			||||||
        PhysicsDataCell cell = PhysicsDataCell.createPhysicsCell(worldPos, terrainEntity, blockEntity);
 | 
					        PhysicsDataCell cell = PhysicsDataCell.createPhysicsCell(terrainEntity, blockEntity);
 | 
				
			||||||
        cell.setTerrainChunk(terrainChunk);
 | 
					        cell.setTerrainChunk(terrainChunk);
 | 
				
			||||||
        cell.setBlockChunk(blockChunkData);
 | 
					        cell.setBlockChunk(blockChunkData);
 | 
				
			||||||
        cell.generatePhysics();
 | 
					        cell.generatePhysics();
 | 
				
			||||||
@ -819,7 +819,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
 | 
				
			|||||||
        ServerEntityUtils.initiallyPositionEntity(realm,blockEntity,realPos);
 | 
					        ServerEntityUtils.initiallyPositionEntity(realm,blockEntity,realPos);
 | 
				
			||||||
        ServerEntityUtils.initiallyPositionEntity(realm,terrainEntity,realPos);
 | 
					        ServerEntityUtils.initiallyPositionEntity(realm,terrainEntity,realPos);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        PhysicsDataCell targetCell = PhysicsDataCell.createPhysicsCell(worldPos, terrainEntity, blockEntity);
 | 
					        PhysicsDataCell targetCell = PhysicsDataCell.createPhysicsCell(terrainEntity, blockEntity);
 | 
				
			||||||
        if(cell == null){
 | 
					        if(cell == null){
 | 
				
			||||||
            posPhysicsMap.put(key, targetCell);
 | 
					            posPhysicsMap.put(key, targetCell);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
				
			|||||||
@ -14,26 +14,19 @@ import electrosphere.renderer.meshgen.BlockMeshgen.BlockMeshData;
 | 
				
			|||||||
import electrosphere.server.datacell.Realm;
 | 
					import electrosphere.server.datacell.Realm;
 | 
				
			||||||
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
 | 
					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
 | 
					 * An entity which contains physics for terrain for a given chunk on the server
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class PhysicsDataCell {
 | 
					public class PhysicsDataCell {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Vector3i worldPos;
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    Entity physicsEntity;
 | 
					    Entity physicsEntity;
 | 
				
			||||||
    Entity blockPhysicsEntity;
 | 
					    Entity blockPhysicsEntity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ServerTerrainChunk terrainChunk;
 | 
					    ServerTerrainChunk terrainChunk;
 | 
				
			||||||
    BlockChunkData blockChunk;
 | 
					    BlockChunkData blockChunk;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    DBody physicsObject;
 | 
					    float[][][] weights;
 | 
				
			||||||
 | 
					    int[][][] types;
 | 
				
			||||||
    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];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * The terrain vertex data
 | 
					     * The terrain vertex data
 | 
				
			||||||
@ -52,7 +45,6 @@ public class PhysicsDataCell {
 | 
				
			|||||||
     * @return The cell
 | 
					     * @return The cell
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static PhysicsDataCell createPhysicsCell(
 | 
					    public static PhysicsDataCell createPhysicsCell(
 | 
				
			||||||
        Vector3i worldPos,
 | 
					 | 
				
			||||||
        Entity physicsEntity,
 | 
					        Entity physicsEntity,
 | 
				
			||||||
        Entity blockPhysicsEntity
 | 
					        Entity blockPhysicsEntity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -60,7 +52,6 @@ public class PhysicsDataCell {
 | 
				
			|||||||
        PhysicsDataCell rVal = new PhysicsDataCell();
 | 
					        PhysicsDataCell rVal = new PhysicsDataCell();
 | 
				
			||||||
        rVal.physicsEntity = physicsEntity;
 | 
					        rVal.physicsEntity = physicsEntity;
 | 
				
			||||||
        rVal.blockPhysicsEntity = blockPhysicsEntity;
 | 
					        rVal.blockPhysicsEntity = blockPhysicsEntity;
 | 
				
			||||||
        rVal.worldPos = worldPos;
 | 
					 | 
				
			||||||
        return rVal;
 | 
					        return rVal;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
@ -123,6 +114,8 @@ public class PhysicsDataCell {
 | 
				
			|||||||
        //fill in data
 | 
					        //fill in data
 | 
				
			||||||
        //
 | 
					        //
 | 
				
			||||||
        //main chunk
 | 
					        //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 x = 0; x < ChunkData.CHUNK_DATA_SIZE; x++){
 | 
				
			||||||
            for(int y = 0; y < ChunkData.CHUNK_DATA_SIZE; y++){
 | 
					            for(int y = 0; y < ChunkData.CHUNK_DATA_SIZE; y++){
 | 
				
			||||||
                for(int z = 0; z < ChunkData.CHUNK_DATA_SIZE; z++){
 | 
					                for(int z = 0; z < ChunkData.CHUNK_DATA_SIZE; z++){
 | 
				
			||||||
@ -257,7 +250,7 @@ public class PhysicsDataCell {
 | 
				
			|||||||
     * @param blockChunk The block chunk data
 | 
					     * @param blockChunk The block chunk data
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public void setBlockChunk(BlockChunkData blockChunk) {
 | 
					    public void setBlockChunk(BlockChunkData blockChunk) {
 | 
				
			||||||
        this.blockChunk = blockChunk;
 | 
					        this.blockChunk = BlockChunkData.cloneShallow(blockChunk);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user