Timekeeping update
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
7ab6cf96d9
commit
39134f9693
@ -127,8 +127,8 @@
|
|||||||
"movementSystems" : [
|
"movementSystems" : [
|
||||||
{
|
{
|
||||||
"type" : "GROUND",
|
"type" : "GROUND",
|
||||||
"acceleration" : 10.0,
|
"acceleration" : 100.0,
|
||||||
"maxVelocity" : 0.035,
|
"maxVelocity" : 3.5,
|
||||||
"animationStartup" : {
|
"animationStartup" : {
|
||||||
"name" : "Jog",
|
"name" : "Jog",
|
||||||
"length" : 1,
|
"length" : 1,
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
- @subpage worldstorageindex
|
- @subpage worldstorageindex
|
||||||
- @subpage uiarch
|
- @subpage uiarch
|
||||||
- @subpage audioengine
|
- @subpage audioengine
|
||||||
|
- @subpage timekeeper
|
||||||
|
|
||||||
|
|
||||||
# What is this section
|
# What is this section
|
||||||
|
|||||||
3
docs/src/architecture/time/timekeeper.md
Normal file
3
docs/src/architecture/time/timekeeper.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@page timekeeper Timekeeper
|
||||||
|
|
||||||
|
Explanation of how it works: https://gafferongames.com/post/fix_your_timestep/
|
||||||
@ -131,9 +131,10 @@ Bake in imgui
|
|||||||
(03/07/2024)
|
(03/07/2024)
|
||||||
Server frametime bar graph
|
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
|
# 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)
|
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
|
- 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
|
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
|
Overhaul mesh class
|
||||||
- remove unused stuff
|
- remove unused stuff
|
||||||
- private constructor
|
- private constructor
|
||||||
|
|||||||
@ -24,14 +24,14 @@ public class ClientSimulation {
|
|||||||
|
|
||||||
public void simulate(){
|
public void simulate(){
|
||||||
//simulate bullet physics engine step
|
//simulate bullet physics engine step
|
||||||
Globals.clientSceneWrapper.getCollisionEngine().simulatePhysics(Main.deltaFrames);
|
Globals.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
|
||||||
//update actor animations
|
//update actor animations
|
||||||
for(Entity currentEntity : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
|
for(Entity currentEntity : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||||
//fetch actor
|
//fetch actor
|
||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//increment animations
|
//increment animations
|
||||||
if(currentActor.isPlayingAnimation()){
|
if(currentActor.isPlayingAnimation()){
|
||||||
currentActor.incrementAnimationTime(Main.deltaFrames / Main.targetFrameRate);
|
currentActor.incrementAnimationTime((float)Globals.timekeeper.getSimFrameTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//make items play idle animation
|
//make items play idle animation
|
||||||
@ -59,7 +59,7 @@ public class ClientSimulation {
|
|||||||
//update audio engine
|
//update audio engine
|
||||||
if(Globals.audioEngine!=null){
|
if(Globals.audioEngine!=null){
|
||||||
Globals.audioEngine.update();
|
Globals.audioEngine.update();
|
||||||
Globals.virtualAudioSourceManager.update(Main.deltaFrames);
|
Globals.virtualAudioSourceManager.update((float)Globals.timekeeper.getSimFrameTime());
|
||||||
}
|
}
|
||||||
//update foliage
|
//update foliage
|
||||||
Globals.clientFoliageManager.update();
|
Globals.clientFoliageManager.update();
|
||||||
@ -72,10 +72,10 @@ public class ClientSimulation {
|
|||||||
Crosshair.checkTargetable();
|
Crosshair.checkTargetable();
|
||||||
Crosshair.updateTargetCrosshairPosition();
|
Crosshair.updateTargetCrosshairPosition();
|
||||||
//simulate behavior trees
|
//simulate behavior trees
|
||||||
Globals.clientSceneWrapper.getScene().simulateBehaviorTrees(Main.deltaFrames);
|
Globals.clientSceneWrapper.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
|
||||||
//sum collidable impulses
|
//sum collidable impulses
|
||||||
for(Entity collidable : Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE)){
|
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
|
//clear collidable impulse lists
|
||||||
Globals.clientSceneWrapper.getCollisionEngine().clearCollidableImpulseLists();
|
Globals.clientSceneWrapper.getCollisionEngine().clearCollidableImpulseLists();
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class CameraHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateGlobalCamera(){
|
public void updateGlobalCamera(){
|
||||||
cameraSpeed = 2.5f * Main.deltaFrames;
|
cameraSpeed = 2.5f * (float)Globals.timekeeper.getMostRecentRawFrametime();
|
||||||
|
|
||||||
if(Crosshair.getCrosshairActive()){
|
if(Crosshair.getCrosshairActive()){
|
||||||
|
|
||||||
|
|||||||
@ -1255,10 +1255,10 @@ public class ControlHandler {
|
|||||||
if(!control.isState()){
|
if(!control.isState()){
|
||||||
//on press
|
//on press
|
||||||
control.onPress();
|
control.onPress();
|
||||||
control.setPressFrame(Main.getCurrentFrame());
|
control.setPressFrame((float)Globals.timekeeper.getMostRecentRawFrametime());
|
||||||
} else {
|
} else {
|
||||||
//on repeat
|
//on repeat
|
||||||
if(Main.getCurrentFrame() - control.getPressFrame() > control.getRepeatTimeout()){
|
if((float)Globals.timekeeper.getMostRecentRawFrametime() - control.getPressFrame() > control.getRepeatTimeout()){
|
||||||
control.onRepeat();
|
control.onRepeat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1268,7 +1268,7 @@ public class ControlHandler {
|
|||||||
//on release
|
//on release
|
||||||
control.onRelease();
|
control.onRelease();
|
||||||
//on click
|
//on click
|
||||||
if(Main.getCurrentFrame() - control.getPressFrame() < control.getRepeatTimeout()){
|
if((float)Globals.timekeeper.getMostRecentRawFrametime() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||||
control.onClick();
|
control.onClick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1281,7 +1281,7 @@ public class ControlHandler {
|
|||||||
if(!control.isState()){
|
if(!control.isState()){
|
||||||
//on press
|
//on press
|
||||||
control.onPress();
|
control.onPress();
|
||||||
control.setPressFrame(Main.getCurrentFrame());
|
control.setPressFrame((float)Globals.timekeeper.getMostRecentRawFrametime());
|
||||||
} else {
|
} else {
|
||||||
//on repeat
|
//on repeat
|
||||||
control.onRepeat();
|
control.onRepeat();
|
||||||
@ -1291,7 +1291,7 @@ public class ControlHandler {
|
|||||||
if(control.isState()){
|
if(control.isState()){
|
||||||
//on release
|
//on release
|
||||||
control.onRelease();
|
control.onRelease();
|
||||||
if(Main.getCurrentFrame() - control.getPressFrame() < control.getRepeatTimeout()){
|
if((float)Globals.timekeeper.getMostRecentRawFrametime() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||||
control.onClick();
|
control.onClick();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import electrosphere.controls.MouseCallback;
|
|||||||
import electrosphere.engine.assetmanager.AssetDataStrings;
|
import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||||
import electrosphere.engine.assetmanager.AssetManager;
|
import electrosphere.engine.assetmanager.AssetManager;
|
||||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||||
|
import electrosphere.engine.time.Timekeeper;
|
||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.Scene;
|
import electrosphere.entity.Scene;
|
||||||
import electrosphere.entity.types.hitbox.HitboxManager;
|
import electrosphere.entity.types.hitbox.HitboxManager;
|
||||||
@ -81,6 +82,11 @@ public class Globals {
|
|||||||
//Top level user settings object
|
//Top level user settings object
|
||||||
//
|
//
|
||||||
public static UserSettings userSettings;
|
public static UserSettings userSettings;
|
||||||
|
|
||||||
|
//
|
||||||
|
//Timekeeper
|
||||||
|
//
|
||||||
|
public static Timekeeper timekeeper;
|
||||||
|
|
||||||
//
|
//
|
||||||
//Rendering Engine
|
//Rendering Engine
|
||||||
@ -374,6 +380,8 @@ public class Globals {
|
|||||||
|
|
||||||
public static void initGlobals(){
|
public static void initGlobals(){
|
||||||
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
LoggerInterface.loggerStartup.INFO("Initialize global variables");
|
||||||
|
//timekeeper
|
||||||
|
timekeeper = new Timekeeper();
|
||||||
//load in default texture map
|
//load in default texture map
|
||||||
textureMapDefault = FileUtils.loadObjectFromAssetPath("Textures/default_texture_map.json", TextureMap.class);
|
textureMapDefault = FileUtils.loadObjectFromAssetPath("Textures/default_texture_map.json", TextureMap.class);
|
||||||
//load model pretransforms
|
//load model pretransforms
|
||||||
|
|||||||
@ -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;
|
public static boolean running = true;
|
||||||
|
|
||||||
@ -76,14 +69,14 @@ public class Main {
|
|||||||
|
|
||||||
//load user settings
|
//load user settings
|
||||||
UserSettings.loadUserSettings();
|
UserSettings.loadUserSettings();
|
||||||
|
|
||||||
|
//init global variables
|
||||||
|
Globals.initGlobals();
|
||||||
|
|
||||||
//controls
|
//controls
|
||||||
if(Globals.RUN_CLIENT){
|
if(Globals.RUN_CLIENT){
|
||||||
initControlHandler();
|
initControlHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
//init global variables
|
|
||||||
Globals.initGlobals();
|
|
||||||
|
|
||||||
//init ODE
|
//init ODE
|
||||||
OdeHelper.initODE();
|
OdeHelper.initODE();
|
||||||
@ -183,6 +176,9 @@ public class Main {
|
|||||||
Globals.initDefaultAudioResources();
|
Globals.initDefaultAudioResources();
|
||||||
// Globals.audioEngine.setGain(0.1f);
|
// Globals.audioEngine.setGain(0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//init timekeeper
|
||||||
|
Globals.timekeeper.init(targetFramePeriod);
|
||||||
|
|
||||||
//fire off a loading thread for the title menus/screen
|
//fire off a loading thread for the title menus/screen
|
||||||
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
||||||
@ -225,20 +221,12 @@ public class Main {
|
|||||||
LoggerInterface.loggerEngine.DEBUG("Begin Main Loop Frame");
|
LoggerInterface.loggerEngine.DEBUG("Begin Main Loop Frame");
|
||||||
|
|
||||||
//sets whether to capture framerates of current frame
|
//sets whether to capture framerates of current frame
|
||||||
captureFramerate = frameCount % 10 == 0;
|
captureFramerate = Globals.timekeeper.getNumberOfRenderFramesElapsed() % 10 == 0;
|
||||||
|
|
||||||
/*
|
//
|
||||||
Frame calculation
|
//Update timekeeper
|
||||||
*/
|
//
|
||||||
double currentTime = 0;
|
Globals.timekeeper.update();
|
||||||
if(Globals.HEADLESS){
|
|
||||||
currentTime = System.currentTimeMillis();
|
|
||||||
} else {
|
|
||||||
currentTime = glfwGetTime();
|
|
||||||
}
|
|
||||||
deltaTime = currentTime - lastFrame;
|
|
||||||
deltaFrames = targetFrameRate * (float)deltaTime;
|
|
||||||
lastFrame = currentTime;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -246,7 +234,7 @@ public class Main {
|
|||||||
// track total frametiime in debug graph
|
// track total frametiime in debug graph
|
||||||
//
|
//
|
||||||
if(captureFramerate){
|
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");
|
/// M A I N S I M U L A T I O N I N N E R L O O P
|
||||||
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
|
|
||||||
///
|
while(Globals.timekeeper.pullFromAccumulator()){
|
||||||
LoggerInterface.loggerEngine.DEBUG("Begin server micro simulation");
|
///
|
||||||
if(!!Globals.HEADLESS && captureFramerate){
|
/// C L I E N T S I M U L A T I O N S T U F F
|
||||||
functionTrackTimeStart = glfwGetTime();
|
///
|
||||||
}
|
LoggerInterface.loggerEngine.DEBUG("Begin client simulation");
|
||||||
if(Globals.realmManager != null){
|
if(!Globals.HEADLESS && captureFramerate){
|
||||||
Globals.realmManager.simulate();
|
functionTrackTimeStart = glfwGetTime();
|
||||||
}
|
}
|
||||||
|
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
|
||||||
///
|
ClientFunctions.runBeforeSimulationFunctions();
|
||||||
/// M A C R O S I M U L A T I O N S T U F F
|
}
|
||||||
///
|
if(Globals.clientSimulation != null && Globals.clientSimulation.isLoadingTerrain() && framestep > 0){
|
||||||
LoggerInterface.loggerEngine.DEBUG("Begin server macro simulation");
|
ClientFunctions.loadTerrain();
|
||||||
if(Globals.macroSimulation != null && Globals.macroSimulation.isReady() && framestep > 0){
|
}
|
||||||
Globals.macroSimulation.simulate();
|
if(Globals.clientSimulation != null && Globals.clientSimulation.isReady() && framestep > 0){
|
||||||
}
|
Globals.clientSimulation.simulate();
|
||||||
if(!Globals.HEADLESS && captureFramerate){
|
}
|
||||||
ImGuiWindowMacros.addGlobalFramerateDatapoint("serversim",(glfwGetTime()-functionTrackTimeStart)*1000);
|
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
|
// C L E A N U P T I M E V A R I A B L E S
|
||||||
//
|
//
|
||||||
if(deltaTime < targetFramePeriod){
|
if(Globals.timekeeper.getMostRecentRawFrametime() < targetFramePeriod){
|
||||||
sleep((int)(1000.0 * (targetFramePeriod - deltaTime)));
|
sleep((int)(1000.0 * (targetFramePeriod - Globals.timekeeper.getMostRecentRawFrametime())));
|
||||||
} else {
|
} else {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
frameCount++;
|
Globals.timekeeper.numberOfRenderedFrames++;
|
||||||
|
|
||||||
if(maxFrames > 0 && frameCount > maxFrames){
|
if(maxFrames > 0 && Globals.timekeeper.numberOfRenderedFrames > maxFrames){
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,10 +430,6 @@ public class Main {
|
|||||||
OdeHelper.closeODE();
|
OdeHelper.closeODE();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getCurrentFrame(){
|
|
||||||
return frameCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sleep(int i) {
|
static void sleep(int i) {
|
||||||
try {
|
try {
|
||||||
TimeUnit.MILLISECONDS.sleep(i);
|
TimeUnit.MILLISECONDS.sleep(i);
|
||||||
|
|||||||
132
src/main/java/electrosphere/engine/time/Timekeeper.java
Normal file
132
src/main/java/electrosphere/engine/time/Timekeeper.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -153,7 +153,7 @@ public class AttackTree implements BehaviorTree {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate(float deltaTime){
|
public void simulate(float deltaTime){
|
||||||
frameCurrent = frameCurrent + Main.deltaFrames;
|
frameCurrent = frameCurrent + (float)Globals.timekeeper.getSimFrameTime();
|
||||||
float velocity = CreatureUtils.getVelocity(parent);
|
float velocity = CreatureUtils.getVelocity(parent);
|
||||||
Actor entityActor = EntityUtils.getActor(parent);
|
Actor entityActor = EntityUtils.getActor(parent);
|
||||||
Vector3d position = EntityUtils.getPosition(parent);
|
Vector3d position = EntityUtils.getPosition(parent);
|
||||||
@ -215,7 +215,7 @@ public class AttackTree implements BehaviorTree {
|
|||||||
case DRIFT:
|
case DRIFT:
|
||||||
if(currentMove != null){
|
if(currentMove != null){
|
||||||
//calculate the vector of movement
|
//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()){
|
if(frameCurrent > currentMove.getDriftFrameEnd()){
|
||||||
driftState = AttackTreeDriftState.NO_DRIFT;
|
driftState = AttackTreeDriftState.NO_DRIFT;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,7 +156,7 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void simulate(float deltaTime){
|
public void simulate(float deltaTime){
|
||||||
frameCurrent = frameCurrent + Main.deltaFrames;
|
frameCurrent = frameCurrent + (float)Globals.timekeeper.getSimFrameTime();
|
||||||
float velocity = CreatureUtils.getVelocity(parent);
|
float velocity = CreatureUtils.getVelocity(parent);
|
||||||
PoseActor entityPoseActor = EntityUtils.getPoseActor(parent);
|
PoseActor entityPoseActor = EntityUtils.getPoseActor(parent);
|
||||||
Vector3d position = EntityUtils.getPosition(parent);
|
Vector3d position = EntityUtils.getPosition(parent);
|
||||||
@ -218,7 +218,7 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
case DRIFT:
|
case DRIFT:
|
||||||
if(currentMove != null){
|
if(currentMove != null){
|
||||||
//calculate the vector of movement
|
//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()){
|
if(frameCurrent > currentMove.getDriftFrameEnd()){
|
||||||
driftState = AttackTreeDriftState.NO_DRIFT;
|
driftState = AttackTreeDriftState.NO_DRIFT;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,7 +117,7 @@ public class LifeState implements BehaviorTree {
|
|||||||
Vector3d position = EntityUtils.getPosition(parent);
|
Vector3d position = EntityUtils.getPosition(parent);
|
||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructKillMessage(
|
EntityMessage.constructKillMessage(
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
parent.getId()
|
parent.getId()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -144,7 +144,7 @@ public class LifeState implements BehaviorTree {
|
|||||||
if(Globals.RUN_CLIENT){
|
if(Globals.RUN_CLIENT){
|
||||||
state = LifeStateEnum.DYING;
|
state = LifeStateEnum.DYING;
|
||||||
lifeCurrent = 0;
|
lifeCurrent = 0;
|
||||||
int frameskip = (int)(Main.getCurrentFrame() - message.gettime());
|
int frameskip = (int)(Globals.timekeeper.getNumberOfSimFramesElapsed() - message.gettime());
|
||||||
deathFrameCurrent = frameskip;
|
deathFrameCurrent = frameskip;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -225,7 +225,7 @@ public class AirplaneMovementTree implements BehaviorTree {
|
|||||||
*/
|
*/
|
||||||
void addMovementForce(float velocity, Quaterniond rotation, Collidable collidable){
|
void addMovementForce(float velocity, Quaterniond rotation, Collidable collidable){
|
||||||
Vector3d impulseDir = rotation.transform(new Vector3d(0,0,1));
|
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(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
|
|||||||
@ -106,7 +106,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
Globals.clientConnection.queueOutgoingMessage(
|
Globals.clientConnection.queueOutgoingMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
@ -136,7 +136,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
Globals.clientConnection.queueOutgoingMessage(
|
Globals.clientConnection.queueOutgoingMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
@ -262,7 +262,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//run startup code
|
//run startup code
|
||||||
velocity = velocity + acceleration * Main.deltaFrames;
|
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||||
//check if can transition state
|
//check if can transition state
|
||||||
if(velocity >= maxNaturalVelocity){
|
if(velocity >= maxNaturalVelocity){
|
||||||
velocity = maxNaturalVelocity;
|
velocity = maxNaturalVelocity;
|
||||||
@ -270,7 +270,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
CreatureUtils.setVelocity(parent, velocity);
|
||||||
// //actually update
|
// //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);
|
// position.set(newPosition);
|
||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
velocity = maxNaturalVelocity;
|
velocity = maxNaturalVelocity;
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
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);
|
// position.set(newPosition);
|
||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//velocity stuff
|
//velocity stuff
|
||||||
velocity = velocity - acceleration * Main.deltaFrames;
|
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||||
//check if can transition state
|
//check if can transition state
|
||||||
if(velocity <= 0){
|
if(velocity <= 0){
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
@ -329,7 +329,7 @@ public class GroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
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);
|
// position.set(newPosition);
|
||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
@ -136,7 +136,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
@ -253,7 +253,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//run startup code
|
//run startup code
|
||||||
velocity = velocity + acceleration * Main.deltaFrames;
|
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||||
//check if can transition state
|
//check if can transition state
|
||||||
if(velocity >= maxNaturalVelocity){
|
if(velocity >= maxNaturalVelocity){
|
||||||
velocity = maxNaturalVelocity;
|
velocity = maxNaturalVelocity;
|
||||||
@ -261,7 +261,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
CreatureUtils.setVelocity(parent, velocity);
|
||||||
// //actually update
|
// //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);
|
// position.set(newPosition);
|
||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
@ -301,7 +301,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
velocity = maxNaturalVelocity;
|
velocity = maxNaturalVelocity;
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
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);
|
// position.set(newPosition);
|
||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
@ -337,7 +337,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//velocity stuff
|
//velocity stuff
|
||||||
velocity = velocity - acceleration * Main.deltaFrames;
|
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||||
//check if can transition state
|
//check if can transition state
|
||||||
if(velocity <= 0){
|
if(velocity <= 0){
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
@ -350,7 +350,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
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);
|
// position.set(newPosition);
|
||||||
rotation.set(movementQuaternion);
|
rotation.set(movementQuaternion);
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
|||||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||||
EntityMessage.constructmoveUpdateMessage(
|
EntityMessage.constructmoveUpdateMessage(
|
||||||
parent.getId(),
|
parent.getId(),
|
||||||
Main.getCurrentFrame(),
|
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||||
position.x,
|
position.x,
|
||||||
position.y,
|
position.y,
|
||||||
position.z,
|
position.z,
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public class LoggerInterface {
|
|||||||
loggerEngine = new Logger(LogLevel.WARNING);
|
loggerEngine = new Logger(LogLevel.WARNING);
|
||||||
loggerAuth = new Logger(LogLevel.WARNING);
|
loggerAuth = new Logger(LogLevel.WARNING);
|
||||||
loggerDB = new Logger(LogLevel.WARNING);
|
loggerDB = new Logger(LogLevel.WARNING);
|
||||||
loggerAudio = new Logger(LogLevel.DEBUG);
|
loggerAudio = new Logger(LogLevel.WARNING);
|
||||||
loggerStartup.INFO("Initialized loggers");
|
loggerStartup.INFO("Initialized loggers");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -731,8 +731,8 @@ public class Mesh {
|
|||||||
glUniformMatrix4fv(Globals.renderingEngine.getActiveShader().shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
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)));
|
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]));
|
glUniformMatrix4fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||||
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "frame"), (int)Main.getCurrentFrame());
|
glUniform1i(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "frame"), (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||||
glUniform1f(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "time"), (float)Main.getCurrentFrame());
|
glUniform1f(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "time"), (float)Globals.timekeeper.getCurrentRendererTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(renderPipelineState.getBufferNonStandardUniforms()){
|
if(renderPipelineState.getBufferNonStandardUniforms()){
|
||||||
|
|||||||
@ -159,7 +159,7 @@ public class Realm {
|
|||||||
ImGuiWindowMacros.clearServerFrametime();
|
ImGuiWindowMacros.clearServerFrametime();
|
||||||
//simulate bullet physics engine step
|
//simulate bullet physics engine step
|
||||||
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());
|
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());
|
||||||
collisionEngine.simulatePhysics(Main.deltaFrames);
|
collisionEngine.simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
|
||||||
ImGuiWindowMacros.clockServerFrametimeTrackerFlame("physics", System.currentTimeMillis());
|
ImGuiWindowMacros.clockServerFrametimeTrackerFlame("physics", System.currentTimeMillis());
|
||||||
//main simulation
|
//main simulation
|
||||||
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());
|
ImGuiWindowMacros.startServerFrametimeTrackerFlame(System.currentTimeMillis());
|
||||||
|
|||||||
@ -59,7 +59,7 @@ public class MicroSimulation {
|
|||||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||||
//increment animations
|
//increment animations
|
||||||
if(currentActor.isPlayingAnimation()){
|
if(currentActor.isPlayingAnimation()){
|
||||||
currentActor.incrementAnimationTime(Main.deltaFrames / Main.targetFrameRate);
|
currentActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime() / Main.targetFrameRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//make items play idle animation
|
//make items play idle animation
|
||||||
@ -90,10 +90,10 @@ public class MicroSimulation {
|
|||||||
// tree.simulate(Main.deltaFrames);
|
// tree.simulate(Main.deltaFrames);
|
||||||
// }
|
// }
|
||||||
//simulate behavior trees
|
//simulate behavior trees
|
||||||
dataCell.getScene().simulateBehaviorTrees(Main.deltaFrames);
|
dataCell.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
|
||||||
//sum collidable impulses
|
//sum collidable impulses
|
||||||
for(Entity collidable : dataCell.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE)){
|
for(Entity collidable : dataCell.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE)){
|
||||||
ServerCollidableTree.getServerCollidableTree(collidable).simulate(Main.deltaFrames);
|
ServerCollidableTree.getServerCollidableTree(collidable).simulate((float)Globals.timekeeper.getSimFrameTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user