Timekeeping update
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-03-09 17:05:40 -05:00
parent 7ab6cf96d9
commit 39134f9693
20 changed files with 268 additions and 135 deletions

View File

@ -127,8 +127,8 @@
"movementSystems" : [
{
"type" : "GROUND",
"acceleration" : 10.0,
"maxVelocity" : 0.035,
"acceleration" : 100.0,
"maxVelocity" : 3.5,
"animationStartup" : {
"name" : "Jog",
"length" : 1,

View File

@ -6,6 +6,7 @@
- @subpage worldstorageindex
- @subpage uiarch
- @subpage audioengine
- @subpage timekeeper
# What is this section

View File

@ -0,0 +1,3 @@
@page timekeeper Timekeeper
Explanation of how it works: https://gafferongames.com/post/fix_your_timestep/

View File

@ -131,9 +131,10 @@ Bake in imgui
(03/07/2024)
Server frametime bar graph
(03/09/2024)
Ability to attach ambient audio emitters to entities
Timekeeping class that defaults to gltf time and falls back to systemCurrentTimeMillis
@ -145,15 +146,13 @@ Server frametime bar graph
# TODO
Ability to attach ambient audio emitters to entities
Timekeeping class that defaults to gltf time and falls back to systemCurrentTimeMillis
Methods for sleeping physics bodies if nothing nearby them is dynamic (ie trees if there are no moving creatures near them)
- SAP2 space from ode4j specifically
De-dupe render calls via doing mutations in render pipeline status and dont call setting variables to values they are already set to
Clean up main method/class
Overhaul mesh class
- remove unused stuff
- private constructor

View File

@ -24,14 +24,14 @@ public class ClientSimulation {
public void simulate(){
//simulate bullet physics engine step
Globals.clientSceneWrapper.getCollisionEngine().simulatePhysics(Main.deltaFrames);
Globals.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
//update actor animations
for(Entity currentEntity : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
//fetch actor
Actor currentActor = EntityUtils.getActor(currentEntity);
//increment animations
if(currentActor.isPlayingAnimation()){
currentActor.incrementAnimationTime(Main.deltaFrames / Main.targetFrameRate);
currentActor.incrementAnimationTime((float)Globals.timekeeper.getSimFrameTime());
}
}
//make items play idle animation
@ -59,7 +59,7 @@ public class ClientSimulation {
//update audio engine
if(Globals.audioEngine!=null){
Globals.audioEngine.update();
Globals.virtualAudioSourceManager.update(Main.deltaFrames);
Globals.virtualAudioSourceManager.update((float)Globals.timekeeper.getSimFrameTime());
}
//update foliage
Globals.clientFoliageManager.update();
@ -72,10 +72,10 @@ public class ClientSimulation {
Crosshair.checkTargetable();
Crosshair.updateTargetCrosshairPosition();
//simulate behavior trees
Globals.clientSceneWrapper.getScene().simulateBehaviorTrees(Main.deltaFrames);
Globals.clientSceneWrapper.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
//sum collidable impulses
for(Entity collidable : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE)){
ClientCollidableTree.getClientCollidableTree(collidable).simulate(Main.deltaFrames);
ClientCollidableTree.getClientCollidableTree(collidable).simulate((float)Globals.timekeeper.getSimFrameTime());
}
//clear collidable impulse lists
Globals.clientSceneWrapper.getCollisionEngine().clearCollidableImpulseLists();

View File

@ -43,7 +43,7 @@ public class CameraHandler {
}
public void updateGlobalCamera(){
cameraSpeed = 2.5f * Main.deltaFrames;
cameraSpeed = 2.5f * (float)Globals.timekeeper.getMostRecentRawFrametime();
if(Crosshair.getCrosshairActive()){

View File

@ -1255,10 +1255,10 @@ public class ControlHandler {
if(!control.isState()){
//on press
control.onPress();
control.setPressFrame(Main.getCurrentFrame());
control.setPressFrame((float)Globals.timekeeper.getMostRecentRawFrametime());
} else {
//on repeat
if(Main.getCurrentFrame() - control.getPressFrame() > control.getRepeatTimeout()){
if((float)Globals.timekeeper.getMostRecentRawFrametime() - control.getPressFrame() > control.getRepeatTimeout()){
control.onRepeat();
}
}
@ -1268,7 +1268,7 @@ public class ControlHandler {
//on release
control.onRelease();
//on click
if(Main.getCurrentFrame() - control.getPressFrame() < control.getRepeatTimeout()){
if((float)Globals.timekeeper.getMostRecentRawFrametime() - control.getPressFrame() < control.getRepeatTimeout()){
control.onClick();
}
} else {
@ -1281,7 +1281,7 @@ public class ControlHandler {
if(!control.isState()){
//on press
control.onPress();
control.setPressFrame(Main.getCurrentFrame());
control.setPressFrame((float)Globals.timekeeper.getMostRecentRawFrametime());
} else {
//on repeat
control.onRepeat();
@ -1291,7 +1291,7 @@ public class ControlHandler {
if(control.isState()){
//on release
control.onRelease();
if(Main.getCurrentFrame() - control.getPressFrame() < control.getRepeatTimeout()){
if((float)Globals.timekeeper.getMostRecentRawFrametime() - control.getPressFrame() < control.getRepeatTimeout()){
control.onClick();
}
} else {

View File

@ -29,6 +29,7 @@ import electrosphere.controls.MouseCallback;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.assetmanager.AssetManager;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.time.Timekeeper;
import electrosphere.entity.Entity;
import electrosphere.entity.Scene;
import electrosphere.entity.types.hitbox.HitboxManager;
@ -81,6 +82,11 @@ public class Globals {
//Top level user settings object
//
public static UserSettings userSettings;
//
//Timekeeper
//
public static Timekeeper timekeeper;
//
//Rendering Engine
@ -374,6 +380,8 @@ public class Globals {
public static void initGlobals(){
LoggerInterface.loggerStartup.INFO("Initialize global variables");
//timekeeper
timekeeper = new Timekeeper();
//load in default texture map
textureMapDefault = FileUtils.loadObjectFromAssetPath("Textures/default_texture_map.json", TextureMap.class);
//load model pretransforms

View File

@ -32,14 +32,7 @@ public class Main {
//
//Visualization Controls
//
//These are used in calculating the time between frames for visualization (camera) control and such
static double deltaTime = 0.0f;
static double lastFrame = 0.0f;
static long frameCount = 0;
public static float deltaFrames = 0;
public static boolean running = true;
@ -76,14 +69,14 @@ public class Main {
//load user settings
UserSettings.loadUserSettings();
//init global variables
Globals.initGlobals();
//controls
if(Globals.RUN_CLIENT){
initControlHandler();
}
//init global variables
Globals.initGlobals();
//init ODE
OdeHelper.initODE();
@ -183,6 +176,9 @@ public class Main {
Globals.initDefaultAudioResources();
// Globals.audioEngine.setGain(0.1f);
}
//init timekeeper
Globals.timekeeper.init(targetFramePeriod);
//fire off a loading thread for the title menus/screen
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
@ -225,20 +221,12 @@ public class Main {
LoggerInterface.loggerEngine.DEBUG("Begin Main Loop Frame");
//sets whether to capture framerates of current frame
captureFramerate = frameCount % 10 == 0;
captureFramerate = Globals.timekeeper.getNumberOfRenderFramesElapsed() % 10 == 0;
/*
Frame calculation
*/
double currentTime = 0;
if(Globals.HEADLESS){
currentTime = System.currentTimeMillis();
} else {
currentTime = glfwGetTime();
}
deltaTime = currentTime - lastFrame;
deltaFrames = targetFrameRate * (float)deltaTime;
lastFrame = currentTime;
//
//Update timekeeper
//
Globals.timekeeper.update();
@ -246,7 +234,7 @@ public class Main {
// track total frametiime in debug graph
//
if(captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("totalframerate",deltaTime * 1000);
ImGuiWindowMacros.addGlobalFramerateDatapoint("totalframerate",Globals.timekeeper.getMostRecentRawFrametime() * 1000);
}
@ -288,60 +276,66 @@ public class Main {
}
///
/// C L I E N T S I M U L A T I O N S T U F F
///
LoggerInterface.loggerEngine.DEBUG("Begin client simulation");
if(!Globals.HEADLESS && captureFramerate){
functionTrackTimeStart = glfwGetTime();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
ClientFunctions.runBeforeSimulationFunctions();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isLoadingTerrain() && framestep > 0){
ClientFunctions.loadTerrain();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
Globals.clientSimulation.simulate();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
ClientFunctions.runClientFunctions();
}
if(!Globals.HEADLESS && captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("clientsim",(glfwGetTime()-functionTrackTimeStart)*1000);
}
/// M A I N S I M U L A T I O N I N N E R L O O P
///
/// S E R V E R M I C R O S I M U L A T I O N
///
LoggerInterface.loggerEngine.DEBUG("Begin server micro simulation");
if(!!Globals.HEADLESS && captureFramerate){
functionTrackTimeStart = glfwGetTime();
}
if(Globals.realmManager != null){
Globals.realmManager.simulate();
}
///
/// M A C R O S I M U L A T I O N S T U F F
///
LoggerInterface.loggerEngine.DEBUG("Begin server macro simulation");
if(Globals.macroSimulation != null && Globals.macroSimulation.isReady() && framestep > 0){
Globals.macroSimulation.simulate();
}
if(!Globals.HEADLESS && captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("serversim",(glfwGetTime()-functionTrackTimeStart)*1000);
while(Globals.timekeeper.pullFromAccumulator()){
///
/// C L I E N T S I M U L A T I O N S T U F F
///
LoggerInterface.loggerEngine.DEBUG("Begin client simulation");
if(!Globals.HEADLESS && captureFramerate){
functionTrackTimeStart = glfwGetTime();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
ClientFunctions.runBeforeSimulationFunctions();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isLoadingTerrain() && framestep > 0){
ClientFunctions.loadTerrain();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
Globals.clientSimulation.simulate();
}
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
ClientFunctions.runClientFunctions();
}
if(!Globals.HEADLESS && captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("clientsim",(glfwGetTime()-functionTrackTimeStart)*1000);
}
///
/// S E R V E R M I C R O S I M U L A T I O N
///
LoggerInterface.loggerEngine.DEBUG("Begin server micro simulation");
if(!!Globals.HEADLESS && captureFramerate){
functionTrackTimeStart = glfwGetTime();
}
if(Globals.realmManager != null){
Globals.realmManager.simulate();
}
///
/// M A C R O S I M U L A T I O N S T U F F
///
LoggerInterface.loggerEngine.DEBUG("Begin server macro simulation");
if(Globals.macroSimulation != null && Globals.macroSimulation.isReady() && framestep > 0){
Globals.macroSimulation.simulate();
}
if(!Globals.HEADLESS && captureFramerate){
ImGuiWindowMacros.addGlobalFramerateDatapoint("serversim",(glfwGetTime()-functionTrackTimeStart)*1000);
}
}
@ -392,14 +386,14 @@ public class Main {
//
// C L E A N U P T I M E V A R I A B L E S
//
if(deltaTime < targetFramePeriod){
sleep((int)(1000.0 * (targetFramePeriod - deltaTime)));
if(Globals.timekeeper.getMostRecentRawFrametime() < targetFramePeriod){
sleep((int)(1000.0 * (targetFramePeriod - Globals.timekeeper.getMostRecentRawFrametime())));
} else {
sleep(1);
}
frameCount++;
Globals.timekeeper.numberOfRenderedFrames++;
if(maxFrames > 0 && frameCount > maxFrames){
if(maxFrames > 0 && Globals.timekeeper.numberOfRenderedFrames > maxFrames){
running = false;
}
@ -436,10 +430,6 @@ public class Main {
OdeHelper.closeODE();
}
public static long getCurrentFrame(){
return frameCount;
}
static void sleep(int i) {
try {
TimeUnit.MILLISECONDS.sleep(i);

View File

@ -0,0 +1,132 @@
package electrosphere.engine.time;
import org.lwjgl.glfw.GLFW;
import electrosphere.engine.Globals;
/**
* Service that keeps track of time for main thread activities.
*/
public class Timekeeper {
//the time a single simulation frame should simulate for (this is fixed)
double simFrameTime = 0.0;
//the time that the system started (0 if using glfw reference, current system time if using java reference)
double engineStartTime = 0.0;
//the system time at the last call to update()
double currentTime = 0.0;
//accumulates time between current frame and next frame
double frameAccumulator = 0.0;
//the number of frames that have elapsed
long numberOfSimFramesElapsed = 0;
//the number of times the render pipeline has rendered a frame
public long numberOfRenderedFrames = 0;
//the raw (not simulation) frametime of the most recent frame
double mostRecentRawFrametime = 0;
/**
* Gets the time since the engine started from the system
* @return The time (in seconds)
*/
private double getTime(){
if(Globals.HEADLESS){
return System.currentTimeMillis() - engineStartTime;
} else {
return GLFW.glfwGetTime();
}
}
/**
* Inits the timekeeper
* @param simFrameTime The amount of time that a frame should take
*/
public void init(double simFrameTime){
this.simFrameTime = simFrameTime;
if(Globals.HEADLESS){
engineStartTime = System.currentTimeMillis();
}
currentTime = getTime();
}
/**
* Updates the timekeeper to track last frametime, etc
*/
public void update(){
//calculate frametime, set current time
double newTime = getTime();
double frameTime = newTime - currentTime;
mostRecentRawFrametime = frameTime;
if(frameTime > 0.25){
frameTime = 0.25;
}
currentTime = newTime;
//add to accumulator
frameAccumulator += frameTime;
}
/**
* Tries to pull a single frametime out of the accumulator
* If the accumulator holds at least a frametime's worth of time, the function returns true
* If the accumulator has not accumulated a simframetime's worth of time, the function returns false
* @return True if the accumulator has at least a simulation frame's amount of time inside it
*/
public boolean pullFromAccumulator(){
boolean rVal = false;
if(frameAccumulator >= simFrameTime){
rVal = true;
frameAccumulator -= simFrameTime;
numberOfSimFramesElapsed++;
}
return rVal;
}
/**
* Gets the amount of time a single simulation frame should take
* @return The time
*/
public double getSimFrameTime(){
return this.simFrameTime;
}
/**
* Gets the number of simulation frames that have elapsed
* @return the number of frames
*/
public long getNumberOfSimFramesElapsed(){
return numberOfSimFramesElapsed;
}
/**
* The number of rendered frames that have elapsed
* @return the frame number
*/
public long getNumberOfRenderFramesElapsed(){
return numberOfRenderedFrames;
}
/**
* Gets the most recent raw frametime
* @return the frametime
*/
public double getMostRecentRawFrametime(){
return mostRecentRawFrametime;
}
/**
* Gets the current time of the renderer since the engine started
* @return The current time
*/
public double getCurrentRendererTime(){
return currentTime;
}
}

View File

@ -153,7 +153,7 @@ public class AttackTree implements BehaviorTree {
@Override
public void simulate(float deltaTime){
frameCurrent = frameCurrent + Main.deltaFrames;
frameCurrent = frameCurrent + (float)Globals.timekeeper.getSimFrameTime();
float velocity = CreatureUtils.getVelocity(parent);
Actor entityActor = EntityUtils.getActor(parent);
Vector3d position = EntityUtils.getPosition(parent);
@ -215,7 +215,7 @@ public class AttackTree implements BehaviorTree {
case DRIFT:
if(currentMove != null){
//calculate the vector of movement
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Main.deltaFrames, "movement"));
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Globals.timekeeper.getSimFrameTime(), "movement"));
if(frameCurrent > currentMove.getDriftFrameEnd()){
driftState = AttackTreeDriftState.NO_DRIFT;
}

View File

@ -156,7 +156,7 @@ public class ServerAttackTree implements BehaviorTree {
@Override
public void simulate(float deltaTime){
frameCurrent = frameCurrent + Main.deltaFrames;
frameCurrent = frameCurrent + (float)Globals.timekeeper.getSimFrameTime();
float velocity = CreatureUtils.getVelocity(parent);
PoseActor entityPoseActor = EntityUtils.getPoseActor(parent);
Vector3d position = EntityUtils.getPosition(parent);
@ -218,7 +218,7 @@ public class ServerAttackTree implements BehaviorTree {
case DRIFT:
if(currentMove != null){
//calculate the vector of movement
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Main.deltaFrames, "movement"));
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Globals.timekeeper.getSimFrameTime(), "movement"));
if(frameCurrent > currentMove.getDriftFrameEnd()){
driftState = AttackTreeDriftState.NO_DRIFT;
}

View File

@ -117,7 +117,7 @@ public class LifeState implements BehaviorTree {
Vector3d position = EntityUtils.getPosition(parent);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructKillMessage(
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
parent.getId()
)
);
@ -144,7 +144,7 @@ public class LifeState implements BehaviorTree {
if(Globals.RUN_CLIENT){
state = LifeStateEnum.DYING;
lifeCurrent = 0;
int frameskip = (int)(Main.getCurrentFrame() - message.gettime());
int frameskip = (int)(Globals.timekeeper.getNumberOfSimFramesElapsed() - message.gettime());
deathFrameCurrent = frameskip;
}
break;

View File

@ -225,7 +225,7 @@ public class AirplaneMovementTree implements BehaviorTree {
*/
void addMovementForce(float velocity, Quaterniond rotation, Collidable collidable){
Vector3d impulseDir = rotation.transform(new Vector3d(0,0,1));
collidable.addImpulse(new Impulse(new Vector3d(impulseDir), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
collidable.addImpulse(new Impulse(new Vector3d(impulseDir), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Globals.timekeeper.getSimFrameTime(), "movement"));
}
/**
@ -248,7 +248,7 @@ public class AirplaneMovementTree implements BehaviorTree {
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,

View File

@ -106,7 +106,7 @@ public class GroundMovementTree implements BehaviorTree {
Globals.clientConnection.queueOutgoingMessage(
EntityMessage.constructmoveUpdateMessage(
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
@ -136,7 +136,7 @@ public class GroundMovementTree implements BehaviorTree {
Globals.clientConnection.queueOutgoingMessage(
EntityMessage.constructmoveUpdateMessage(
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
@ -262,7 +262,7 @@ public class GroundMovementTree implements BehaviorTree {
}
}
//run startup code
velocity = velocity + acceleration * Main.deltaFrames;
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
//check if can transition state
if(velocity >= maxNaturalVelocity){
velocity = maxNaturalVelocity;
@ -270,7 +270,7 @@ public class GroundMovementTree implements BehaviorTree {
}
CreatureUtils.setVelocity(parent, velocity);
// //actually update
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Globals.timekeeper.getSimFrameTime(), "movement"));
// position.set(newPosition);
rotation.set(movementQuaternion);
@ -295,7 +295,7 @@ public class GroundMovementTree implements BehaviorTree {
velocity = maxNaturalVelocity;
CreatureUtils.setVelocity(parent, velocity);
}
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Globals.timekeeper.getSimFrameTime(), "movement"));
// position.set(newPosition);
rotation.set(movementQuaternion);
@ -316,7 +316,7 @@ public class GroundMovementTree implements BehaviorTree {
}
}
//velocity stuff
velocity = velocity - acceleration * Main.deltaFrames;
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
//check if can transition state
if(velocity <= 0){
velocity = 0;
@ -329,7 +329,7 @@ public class GroundMovementTree implements BehaviorTree {
}
}
CreatureUtils.setVelocity(parent, velocity);
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Globals.timekeeper.getSimFrameTime(), "movement"));
// position.set(newPosition);
rotation.set(movementQuaternion);

View File

@ -106,7 +106,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
@ -136,7 +136,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
@ -253,7 +253,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
}
}
//run startup code
velocity = velocity + acceleration * Main.deltaFrames;
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
//check if can transition state
if(velocity >= maxNaturalVelocity){
velocity = maxNaturalVelocity;
@ -261,7 +261,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
}
CreatureUtils.setVelocity(parent, velocity);
// //actually update
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Globals.timekeeper.getSimFrameTime(), "movement"));
// position.set(newPosition);
rotation.set(movementQuaternion);
@ -270,7 +270,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
@ -301,7 +301,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
velocity = maxNaturalVelocity;
CreatureUtils.setVelocity(parent, velocity);
}
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Globals.timekeeper.getSimFrameTime(), "movement"));
// position.set(newPosition);
rotation.set(movementQuaternion);
@ -310,7 +310,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,
@ -337,7 +337,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
}
}
//velocity stuff
velocity = velocity - acceleration * Main.deltaFrames;
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
//check if can transition state
if(velocity <= 0){
velocity = 0;
@ -350,7 +350,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
}
}
CreatureUtils.setVelocity(parent, velocity);
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
collidable.addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Globals.timekeeper.getSimFrameTime(), "movement"));
// position.set(newPosition);
rotation.set(movementQuaternion);
@ -359,7 +359,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
EntityMessage.constructmoveUpdateMessage(
parent.getId(),
Main.getCurrentFrame(),
Globals.timekeeper.getNumberOfSimFramesElapsed(),
position.x,
position.y,
position.z,

View File

@ -29,7 +29,7 @@ public class LoggerInterface {
loggerEngine = new Logger(LogLevel.WARNING);
loggerAuth = new Logger(LogLevel.WARNING);
loggerDB = new Logger(LogLevel.WARNING);
loggerAudio = new Logger(LogLevel.DEBUG);
loggerAudio = new Logger(LogLevel.WARNING);
loggerStartup.INFO("Initialized loggers");
}
}

View File

@ -731,8 +731,8 @@ public class Mesh {
glUniformMatrix4fv(Globals.renderingEngine.getActiveShader().shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
glUniform3fv(Globals.renderingEngine.getActiveShader().shaderVertexViewPosLoc, CameraEntityUtils.getCameraEye(Globals.playerCamera).get(BufferUtils.createFloatBuffer(3)));
glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "frame"), (int)Main.getCurrentFrame());
glUniform1f(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "time"), (float)Main.getCurrentFrame());
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
glUniform1f(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "time"), (float)Globals.timekeeper.getCurrentRendererTime());
}
if(renderPipelineState.getBufferNonStandardUniforms()){

View File

@ -159,7 +159,7 @@ public class Realm {
ImGuiWindowMacros.clearServerFrametime();
//simulate bullet physics engine step
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());
collisionEngine.simulatePhysics(Main.deltaFrames);
collisionEngine.simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
ImGuiWindowMacros.clockServerFrametimeTrackerFlame("physics", System.currentTimeMillis());
//main simulation
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());

View File

@ -59,7 +59,7 @@ public class MicroSimulation {
Actor currentActor = EntityUtils.getActor(currentEntity);
//increment animations
if(currentActor.isPlayingAnimation()){
currentActor.incrementAnimationTime(Main.deltaFrames / Main.targetFrameRate);
currentActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
}
}
//make items play idle animation
@ -90,10 +90,10 @@ public class MicroSimulation {
// tree.simulate(Main.deltaFrames);
// }
//simulate behavior trees
dataCell.getScene().simulateBehaviorTrees(Main.deltaFrames);
dataCell.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
//sum collidable impulses
for(Entity collidable : dataCell.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE)){
ServerCollidableTree.getServerCollidableTree(collidable).simulate(Main.deltaFrames);
ServerCollidableTree.getServerCollidableTree(collidable).simulate((float)Globals.timekeeper.getSimFrameTime());
}
}
}