small improvements
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
de6876bf2f
commit
a413b9aa79
@ -1992,6 +1992,8 @@ Performance improvements
|
|||||||
- Undo most object pooling
|
- Undo most object pooling
|
||||||
- ServerBlockChunkDiskMap uses short pool
|
- ServerBlockChunkDiskMap uses short pool
|
||||||
- Client leverages block chunk short pool
|
- Client leverages block chunk short pool
|
||||||
|
- Client doesn't load physics on entities by default
|
||||||
|
- Block chunk disk map writes files without allocating a buffer
|
||||||
Increase human move speed
|
Increase human move speed
|
||||||
LOD components re-attach physics
|
LOD components re-attach physics
|
||||||
VectorPool->JomlPool
|
VectorPool->JomlPool
|
||||||
|
|||||||
@ -187,6 +187,12 @@ public class CollisionEngine {
|
|||||||
* Number of geometries
|
* Number of geometries
|
||||||
*/
|
*/
|
||||||
private int geomCount = 0;
|
private int geomCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* buffer for storing potential collisions
|
||||||
|
*/
|
||||||
|
private DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -432,8 +438,8 @@ public class CollisionEngine {
|
|||||||
|
|
||||||
Globals.profiler.beginAggregateCpuSample("CollisionEngine.nearCallback - Full collision phase");
|
Globals.profiler.beginAggregateCpuSample("CollisionEngine.nearCallback - Full collision phase");
|
||||||
try {
|
try {
|
||||||
//creates a buffer to store potential collisions
|
//null out the contact buffer
|
||||||
DContactBuffer contacts = new DContactBuffer(MAX_CONTACTS); // up to MAX_CONTACTS contacts per box-box
|
contacts.nullify();
|
||||||
SurfaceParams surfaceParams = c1.getSurfaceParams();
|
SurfaceParams surfaceParams = c1.getSurfaceParams();
|
||||||
for (int i=0; i<MAX_CONTACTS; i++) {
|
for (int i=0; i<MAX_CONTACTS; i++) {
|
||||||
DContact contact = contacts.get(i);
|
DContact contact = contacts.get(i);
|
||||||
|
|||||||
@ -52,6 +52,11 @@ public class PhysicsEntityUtils {
|
|||||||
*/
|
*/
|
||||||
static final double WORLD_MARGIN = 0.001;
|
static final double WORLD_MARGIN = 0.001;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Distance after which client does not generate collidables by default
|
||||||
|
*/
|
||||||
|
public static final double CLIENT_LOD_DIST = 50;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [CLIENT ONLY] Attaches a collidable template to a given entity
|
* [CLIENT ONLY] Attaches a collidable template to a given entity
|
||||||
* @param rVal The entity
|
* @param rVal The entity
|
||||||
|
|||||||
@ -3,9 +3,11 @@ package electrosphere.entity.state.lod;
|
|||||||
|
|
||||||
import electrosphere.collision.PhysicsEntityUtils;
|
import electrosphere.collision.PhysicsEntityUtils;
|
||||||
import electrosphere.collision.PhysicsUtils;
|
import electrosphere.collision.PhysicsUtils;
|
||||||
|
import electrosphere.data.entity.collidable.CollidableTemplate;
|
||||||
import electrosphere.data.entity.common.CommonEntityType;
|
import electrosphere.data.entity.common.CommonEntityType;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
|
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
|
||||||
import electrosphere.entity.btree.BehaviorTree;
|
import electrosphere.entity.btree.BehaviorTree;
|
||||||
@ -37,6 +39,18 @@ public class ClientLODComponent implements BehaviorTree {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate(float deltaTime) {
|
public void simulate(float deltaTime) {
|
||||||
|
if(this.lodLevel == ServerLODComponent.FULL_RES){
|
||||||
|
CommonEntityType commonData = CommonEntityUtils.getCommonData(this.parent);
|
||||||
|
if(
|
||||||
|
commonData.getCollidable() != null &&
|
||||||
|
PhysicsEntityUtils.getCollidable(this.parent) == null &&
|
||||||
|
Globals.clientState.playerEntity != null &&
|
||||||
|
EntityUtils.getPosition(Globals.clientState.playerEntity).distance(EntityUtils.getPosition(this.parent)) < ServerLODComponent.LOD_RADIUS
|
||||||
|
){
|
||||||
|
CollidableTemplate physicsTemplate = commonData.getCollidable();
|
||||||
|
PhysicsEntityUtils.clientAttachCollidableTemplate(this.parent, physicsTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(cachedLodLevel != lodLevel){
|
if(cachedLodLevel != lodLevel){
|
||||||
cachedLodLevel = lodLevel;
|
cachedLodLevel = lodLevel;
|
||||||
if(cachedLodLevel == ServerLODComponent.FULL_RES){
|
if(cachedLodLevel == ServerLODComponent.FULL_RES){
|
||||||
|
|||||||
@ -188,8 +188,6 @@ public class CommonEntityUtils {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
if(rawType.getCollidable() != null){
|
if(rawType.getCollidable() != null){
|
||||||
CollidableTemplate physicsTemplate = rawType.getCollidable();
|
|
||||||
PhysicsEntityUtils.clientAttachCollidableTemplate(entity, physicsTemplate);
|
|
||||||
ClientLODComponent.attachTree(entity);
|
ClientLODComponent.attachTree(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package electrosphere.server.physics.block.diskmap;
|
package electrosphere.server.physics.block.diskmap;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
@ -214,43 +215,38 @@ public class ServerBlockChunkDiskMap {
|
|||||||
} else {
|
} else {
|
||||||
fileName = BLOCK_DATA_DIR + chunkKey + "b.dat";
|
fileName = BLOCK_DATA_DIR + chunkKey + "b.dat";
|
||||||
}
|
}
|
||||||
//generate binary for the file
|
|
||||||
short[] type = chunkData.getType();
|
|
||||||
short[] metadata = chunkData.getMetadata();
|
|
||||||
|
|
||||||
//allocate buffer
|
|
||||||
ByteBuffer buffer = null;
|
|
||||||
if(chunkData.getHomogenousValue() == BlockChunkData.NOT_HOMOGENOUS){
|
|
||||||
buffer = ByteBuffer.allocate(ServerBlockChunkDiskMap.FILE_HEADER + BlockChunkData.TOTAL_DATA_WIDTH * 2 * 2);
|
|
||||||
} else {
|
|
||||||
buffer = ByteBuffer.allocate(ServerBlockChunkDiskMap.FILE_HEADER + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//push data
|
|
||||||
if(chunkData.getHomogenousValue() == BlockChunkData.NOT_HOMOGENOUS){
|
|
||||||
//put header
|
|
||||||
buffer.putInt(HEADER_NON_HOMOGENOUS);
|
|
||||||
//put data
|
|
||||||
ShortBuffer shortView = buffer.asShortBuffer();
|
|
||||||
for(int i = 0; i < BlockChunkData.TOTAL_DATA_WIDTH; i++){
|
|
||||||
shortView.put(type[i]);
|
|
||||||
}
|
|
||||||
for(int i = 0; i < BlockChunkData.TOTAL_DATA_WIDTH; i++){
|
|
||||||
shortView.put(metadata[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//put header
|
|
||||||
buffer.putInt(HEADER_HOMOGENOUS);
|
|
||||||
//put data
|
|
||||||
buffer.putShort(chunkData.getHomogenousValue());
|
|
||||||
}
|
|
||||||
//compress
|
//compress
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
DeflaterOutputStream deflaterInputStream = new DeflaterOutputStream(out);
|
DeflaterOutputStream deflaterOutStream = new DeflaterOutputStream(out);
|
||||||
|
DataOutputStream dataOut = new DataOutputStream(deflaterOutStream);
|
||||||
try {
|
try {
|
||||||
deflaterInputStream.write(buffer.array());
|
|
||||||
deflaterInputStream.flush();
|
|
||||||
deflaterInputStream.close();
|
//generate binary for the file
|
||||||
|
short[] type = chunkData.getType();
|
||||||
|
short[] metadata = chunkData.getMetadata();
|
||||||
|
|
||||||
|
//push data
|
||||||
|
if(chunkData.getHomogenousValue() == BlockChunkData.NOT_HOMOGENOUS){
|
||||||
|
//put header
|
||||||
|
dataOut.writeInt(HEADER_NON_HOMOGENOUS);
|
||||||
|
//put data
|
||||||
|
for(int i = 0; i < BlockChunkData.TOTAL_DATA_WIDTH; i++){
|
||||||
|
dataOut.writeShort(type[i]);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < BlockChunkData.TOTAL_DATA_WIDTH; i++){
|
||||||
|
dataOut.writeShort(metadata[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//put header
|
||||||
|
dataOut.writeInt(HEADER_HOMOGENOUS);
|
||||||
|
//put data
|
||||||
|
dataOut.writeShort(chunkData.getHomogenousValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
dataOut.flush();
|
||||||
|
dataOut.close();
|
||||||
//write to disk
|
//write to disk
|
||||||
FileUtils.saveBinaryToSavePath(Globals.serverState.currentSave.getName(), fileName, out.toByteArray());
|
FileUtils.saveBinaryToSavePath(Globals.serverState.currentSave.getName(), fileName, out.toByteArray());
|
||||||
//save to the map of filenames
|
//save to the map of filenames
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user