This commit is contained in:
parent
028b957b76
commit
c64c72e17c
@ -1357,6 +1357,10 @@ Fix block mesh ray casting bug due to trimesh overlap
|
|||||||
Fix block mesh samplers incorrectly buffering
|
Fix block mesh samplers incorrectly buffering
|
||||||
Fix block mesh gen algorithm merging quads incorrectly
|
Fix block mesh gen algorithm merging quads incorrectly
|
||||||
Make HitboxManager threadsafe
|
Make HitboxManager threadsafe
|
||||||
|
Don't simulate extra frames if we're taking too much time
|
||||||
|
Fluid sim toggle on client side
|
||||||
|
Lower duplicate physics frame count
|
||||||
|
Various code cleanup
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -136,7 +136,7 @@ public class ClientBlockCellManager {
|
|||||||
* Updates all cells in the chunk
|
* Updates all cells in the chunk
|
||||||
*/
|
*/
|
||||||
public void update(){
|
public void update(){
|
||||||
Globals.profiler.beginCpuSample("ClientDrawCellManager.update");
|
Globals.profiler.beginCpuSample("ClientBlockCellManager.update");
|
||||||
if(shouldUpdate && Globals.playerEntity != null){
|
if(shouldUpdate && Globals.playerEntity != null){
|
||||||
Vector3d playerPos = EntityUtils.getPosition(Globals.playerEntity);
|
Vector3d playerPos = EntityUtils.getPosition(Globals.playerEntity);
|
||||||
Vector3i playerWorldPos = Globals.clientWorldData.convertRealToWorldSpace(playerPos);
|
Vector3i playerWorldPos = Globals.clientWorldData.convertRealToWorldSpace(playerPos);
|
||||||
@ -148,7 +148,7 @@ public class ClientBlockCellManager {
|
|||||||
evaluationMap.clear();
|
evaluationMap.clear();
|
||||||
//update all full res cells
|
//update all full res cells
|
||||||
WorldOctTreeNode<BlockDrawCell> rootNode = this.chunkTree.getRoot();
|
WorldOctTreeNode<BlockDrawCell> rootNode = this.chunkTree.getRoot();
|
||||||
Globals.profiler.beginCpuSample("ClientDrawCellManager.update - full res cells");
|
Globals.profiler.beginCpuSample("ClientBlockCellManager.update - full res cells");
|
||||||
updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerWorldPos, evaluationMap, BlockChunkData.LOD_LOWEST_RES, distCache);
|
updatedLastFrame = this.recursivelyUpdateCells(rootNode, playerWorldPos, evaluationMap, BlockChunkData.LOD_LOWEST_RES, distCache);
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
if(!updatedLastFrame && !this.initialized){
|
if(!updatedLastFrame && !this.initialized){
|
||||||
|
|||||||
@ -171,7 +171,7 @@ public class ClientSimulation {
|
|||||||
Globals.clientTerrainManager.handleMessages();
|
Globals.clientTerrainManager.handleMessages();
|
||||||
this.updateTerrainCellManager();
|
this.updateTerrainCellManager();
|
||||||
}
|
}
|
||||||
if(Globals.clientFluidManager != null){
|
if(Globals.clientFluidManager != null && Globals.RUN_FLUIDS){
|
||||||
Globals.clientFluidManager.handleMessages();
|
Globals.clientFluidManager.handleMessages();
|
||||||
this.updateFluidCellManager();
|
this.updateFluidCellManager();
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ public class ClientSimulation {
|
|||||||
*/
|
*/
|
||||||
private void updateFluidCellManager(){
|
private void updateFluidCellManager(){
|
||||||
//fluid work
|
//fluid work
|
||||||
if(Globals.fluidCellManager != null && Globals.clientWorldData != null){
|
if(Globals.fluidCellManager != null && Globals.clientWorldData != null && Globals.RUN_FLUIDS){
|
||||||
Globals.fluidCellManager.update();
|
Globals.fluidCellManager.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class CollisionEngine {
|
|||||||
* IE, if this value is 3, every main game engine frame, the physics simulation will run 3 frames.
|
* IE, if this value is 3, every main game engine frame, the physics simulation will run 3 frames.
|
||||||
* This keeps the physics simulation much more stable than it would be otherwise.
|
* This keeps the physics simulation much more stable than it would be otherwise.
|
||||||
*/
|
*/
|
||||||
public static final int PHYSICS_SIMULATION_RESOLUTION = 5;
|
public static final int PHYSICS_SIMULATION_RESOLUTION = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Threshold after which the engine warns about collidable count
|
* Threshold after which the engine warns about collidable count
|
||||||
|
|||||||
@ -335,6 +335,11 @@ public class Main {
|
|||||||
int simFrameHardcapCounter = 0;
|
int simFrameHardcapCounter = 0;
|
||||||
while(Globals.timekeeper.pullFromAccumulator() && framestep > 0 && simFrameHardcapCounter < Timekeeper.SIM_FRAME_HARDCAP){
|
while(Globals.timekeeper.pullFromAccumulator() && framestep > 0 && simFrameHardcapCounter < Timekeeper.SIM_FRAME_HARDCAP){
|
||||||
|
|
||||||
|
//do not simulate extra frames if we're already behind schedule
|
||||||
|
if(Globals.timekeeper.getMostRecentRawFrametime() > Globals.timekeeper.getSimFrameTime() && simFrameHardcapCounter > 0){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//sim frame hard cap counter increment
|
//sim frame hard cap counter increment
|
||||||
simFrameHardcapCounter++;
|
simFrameHardcapCounter++;
|
||||||
//handle framestep
|
//handle framestep
|
||||||
|
|||||||
@ -377,7 +377,7 @@ public class ClientLoading {
|
|||||||
|
|
||||||
//wait for all the terrain data to arrive
|
//wait for all the terrain data to arrive
|
||||||
WindowUtils.updateLoadingWindow("REQUESTING FLUID CHUNKS FROM SERVER (" + Globals.fluidCellManager.getUnrequestedSize() + ")");
|
WindowUtils.updateLoadingWindow("REQUESTING FLUID CHUNKS FROM SERVER (" + Globals.fluidCellManager.getUnrequestedSize() + ")");
|
||||||
while(blockForInit && Globals.fluidCellManager.containsUnrequestedCell() && Globals.threadManager.shouldKeepRunning()){
|
while(blockForInit && Globals.fluidCellManager.containsUnrequestedCell() && Globals.threadManager.shouldKeepRunning() && Globals.RUN_FLUIDS){
|
||||||
try {
|
try {
|
||||||
TimeUnit.MILLISECONDS.sleep(10);
|
TimeUnit.MILLISECONDS.sleep(10);
|
||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import electrosphere.entity.state.attach.AttachUtils;
|
|||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -194,6 +195,14 @@ public class Scene {
|
|||||||
return this.entityIdMap.values();
|
return this.entityIdMap.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list of behavior trees attached to the scene
|
||||||
|
* @return The list of behavior trees attached to the scene
|
||||||
|
*/
|
||||||
|
public Collection<BehaviorTree> getBehaviorTrees(){
|
||||||
|
return Collections.unmodifiableList(this.behaviorTreeList);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes the scene in log messages
|
* Describes the scene in log messages
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -484,8 +484,8 @@ public class Actor {
|
|||||||
Vector3d rVal = new Vector3d();
|
Vector3d rVal = new Vector3d();
|
||||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||||
if(model != null){
|
if(model != null){
|
||||||
applyAnimationMasks(model);
|
this.applyAnimationMasks(model);
|
||||||
calculateNodeTransforms(model);
|
this.calculateNodeTransforms(model);
|
||||||
Bone currentBone = model.getBoneMap().get(boneName);
|
Bone currentBone = model.getBoneMap().get(boneName);
|
||||||
if(currentBone != null){
|
if(currentBone != null){
|
||||||
Vector4d result = new Matrix4d(currentBone.getFinalTransform()).transform(currentBone.getMOffset().invert().transform(new Vector4d(rVal.x,rVal.y,rVal.z,1)));
|
Vector4d result = new Matrix4d(currentBone.getFinalTransform()).transform(currentBone.getMOffset().invert().transform(new Vector4d(rVal.x,rVal.y,rVal.z,1)));
|
||||||
@ -495,11 +495,11 @@ public class Actor {
|
|||||||
} else {
|
} else {
|
||||||
String message = "Trying to get position of bone that does not exist on model!\n" +
|
String message = "Trying to get position of bone that does not exist on model!\n" +
|
||||||
"boneName: " + boneName;
|
"boneName: " + boneName;
|
||||||
throw new IllegalArgumentException(message);
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!Double.isFinite(rVal.x)){
|
if(!Double.isFinite(rVal.x)){
|
||||||
throw new IllegalStateException("Bone position that is not finite!");
|
throw new Error("Bone position that is not finite!");
|
||||||
}
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
@ -513,8 +513,8 @@ public class Actor {
|
|||||||
Quaterniond rVal = new Quaterniond();
|
Quaterniond rVal = new Quaterniond();
|
||||||
Model model = Globals.assetManager.fetchModel(modelPath);
|
Model model = Globals.assetManager.fetchModel(modelPath);
|
||||||
if(model != null){
|
if(model != null){
|
||||||
applyAnimationMasks(model);
|
this.applyAnimationMasks(model);
|
||||||
calculateNodeTransforms(model);
|
this.calculateNodeTransforms(model);
|
||||||
Bone currentBone = model.getBoneMap().get(boneName);
|
Bone currentBone = model.getBoneMap().get(boneName);
|
||||||
if(currentBone != null){
|
if(currentBone != null){
|
||||||
Quaterniond rotation = new Matrix4d(currentBone.getFinalTransform()).getNormalizedRotation(new Quaterniond());
|
Quaterniond rotation = new Matrix4d(currentBone.getFinalTransform()).getNormalizedRotation(new Quaterniond());
|
||||||
|
|||||||
@ -387,6 +387,13 @@ public class Model {
|
|||||||
//
|
//
|
||||||
//bone rotators (turrets, hair, etc)
|
//bone rotators (turrets, hair, etc)
|
||||||
Bone target_bone = boneMap.get(n.id);
|
Bone target_bone = boneMap.get(n.id);
|
||||||
|
if(target_bone == null){
|
||||||
|
String message = "Failed to locate bone!\n";
|
||||||
|
message = message + "bone id: " + n.id + "\n";
|
||||||
|
message = message + "bone map size: " + boneMap.size() + "\n";
|
||||||
|
message = message + "bone map key set: " + boneMap.keySet() + "\n";
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
Matrix4d currentTransform = parentTransform.mul(target_bone.getDeform());
|
Matrix4d currentTransform = parentTransform.mul(target_bone.getDeform());
|
||||||
if(boneRotators.containsKey(target_bone.boneID)){
|
if(boneRotators.containsKey(target_bone.boneID)){
|
||||||
currentTransform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
currentTransform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
||||||
|
|||||||
@ -208,6 +208,13 @@ public class PoseModel {
|
|||||||
//if this is a bone, calculate the transform for the bone
|
//if this is a bone, calculate the transform for the bone
|
||||||
if(n.is_bone){
|
if(n.is_bone){
|
||||||
Bone target_bone = boneMap.get(n.id);
|
Bone target_bone = boneMap.get(n.id);
|
||||||
|
if(target_bone == null){
|
||||||
|
String message = "Failed to locate bone!\n";
|
||||||
|
message = message + "bone id: " + n.id + "\n";
|
||||||
|
message = message + "bone map size: " + boneMap.size() + "\n";
|
||||||
|
message = message + "bone map key set: " + boneMap.keySet() + "\n";
|
||||||
|
throw new Error(message);
|
||||||
|
}
|
||||||
Matrix4d deformTransform = parentTransform.mul(target_bone.getDeform());
|
Matrix4d deformTransform = parentTransform.mul(target_bone.getDeform());
|
||||||
if(boneRotators.containsKey(target_bone.boneID)){
|
if(boneRotators.containsKey(target_bone.boneID)){
|
||||||
deformTransform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
deformTransform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
||||||
|
|||||||
@ -17,8 +17,14 @@ import electrosphere.server.poseactor.PoseActor;
|
|||||||
*/
|
*/
|
||||||
public class MicroSimulation {
|
public class MicroSimulation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tracks whether the micro simulation is ready or not
|
||||||
|
*/
|
||||||
boolean isReady = false;
|
boolean isReady = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
public MicroSimulation(){
|
public MicroSimulation(){
|
||||||
isReady = false;
|
isReady = false;
|
||||||
}
|
}
|
||||||
@ -28,7 +34,7 @@ public class MicroSimulation {
|
|||||||
* @param dataCell The data cell
|
* @param dataCell The data cell
|
||||||
*/
|
*/
|
||||||
public void simulate(ServerDataCell dataCell){
|
public void simulate(ServerDataCell dataCell){
|
||||||
Globals.profiler.beginAggregateCpuSample("MicroSimulation.simulate");
|
Globals.profiler.beginCpuSample("MicroSimulation.simulate");
|
||||||
if(dataCell.isReady()){
|
if(dataCell.isReady()){
|
||||||
//simulate ai
|
//simulate ai
|
||||||
Globals.aiManager.simulate();
|
Globals.aiManager.simulate();
|
||||||
@ -62,18 +68,32 @@ public class MicroSimulation {
|
|||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the micro simulation is ready or not
|
||||||
|
* @return true if it is ready, false otherwise
|
||||||
|
*/
|
||||||
public boolean isReady(){
|
public boolean isReady(){
|
||||||
return isReady;
|
return isReady;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether the micro simulation is ready or not
|
||||||
|
* @param ready true if it is ready, false otherwise
|
||||||
|
*/
|
||||||
public void setReady(boolean ready){
|
public void setReady(boolean ready){
|
||||||
isReady = ready;
|
isReady = ready;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Freezes the micro simulation
|
||||||
|
*/
|
||||||
public void freeze(){
|
public void freeze(){
|
||||||
isReady = false;
|
isReady = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unfreezes the micro simulation
|
||||||
|
*/
|
||||||
public void unfreeze(){
|
public void unfreeze(){
|
||||||
isReady = true;
|
isReady = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user