From 5c5ba32df7b3efdca927cb0bad35c71bfcbbb6a2 Mon Sep 17 00:00:00 2001 From: austin Date: Thu, 29 May 2025 21:09:40 -0400 Subject: [PATCH] sprinting/physics work --- assets/Data/entity/creatures/human.json | 2 +- docs/src/progress/renderertodo.md | 1 + src/main/java/electrosphere/client/sim/ClientSimulation.java | 2 +- src/main/java/electrosphere/collision/CollisionEngine.java | 5 ++--- src/main/java/electrosphere/engine/Main.java | 2 +- .../state/movement/groundmove/ServerGroundMovementTree.java | 5 ++++- src/main/java/electrosphere/server/datacell/Realm.java | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/assets/Data/entity/creatures/human.json b/assets/Data/entity/creatures/human.json index 6e1f78f1..832a6346 100644 --- a/assets/Data/entity/creatures/human.json +++ b/assets/Data/entity/creatures/human.json @@ -174,7 +174,7 @@ "priorityCategory" : "CORE_MOVEMENT" }, "sprintSystem" : { - "modifier" : 1.4, + "modifier" : 2.0, "staminaMax" : 500, "animationStartUp" : { "nameThirdPerson" : "Sprint", diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index bc8870c1..6c3dcd68 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2069,6 +2069,7 @@ Fix sprint animation data Color uniform on meshes Fall and gravity tree fixes Potential window fix +Sprinting/physics work diff --git a/src/main/java/electrosphere/client/sim/ClientSimulation.java b/src/main/java/electrosphere/client/sim/ClientSimulation.java index 1c1fd5c9..155e1a47 100644 --- a/src/main/java/electrosphere/client/sim/ClientSimulation.java +++ b/src/main/java/electrosphere/client/sim/ClientSimulation.java @@ -65,7 +65,7 @@ public class ClientSimulation { // //simulate bullet physics engine step if(EngineState.EngineFlags.RUN_PHYSICS){ - Globals.clientState.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime()); + Globals.clientState.clientSceneWrapper.getCollisionEngine().simulatePhysics(); Globals.clientState.clientSceneWrapper.getCollisionEngine().updateDynamicObjectTransforms(); } diff --git a/src/main/java/electrosphere/collision/CollisionEngine.java b/src/main/java/electrosphere/collision/CollisionEngine.java index 375e3b2c..89d54720 100644 --- a/src/main/java/electrosphere/collision/CollisionEngine.java +++ b/src/main/java/electrosphere/collision/CollisionEngine.java @@ -313,9 +313,8 @@ public class CollisionEngine { /** * Performs the collision and simulation phases for this collision engine - * @param time The time to increment the physics simulation by */ - public void simulatePhysics(float time){ + public void simulatePhysics(){ Globals.profiler.beginCpuSample("physics"); spaceLock.lock(); // remove all contact joints @@ -1217,7 +1216,7 @@ public class CollisionEngine { protected DBody createDBody(DGeom ...geom){ spaceLock.lock(); DBody body = OdeHelper.createBody(world); - body.setDamping(DEFAULT_LINEAR_DAMPING, DEFAULT_ANGULAR_DAMPING); + // body.setDamping(DEFAULT_LINEAR_DAMPING, DEFAULT_ANGULAR_DAMPING); body.setMaxAngularSpeed(DEFAULT_MAX_ANGULAR_SPEED); if(geom != null){ for(int i = 0; i < geom.length; i++){ diff --git a/src/main/java/electrosphere/engine/Main.java b/src/main/java/electrosphere/engine/Main.java index 5387c537..14a7fb06 100644 --- a/src/main/java/electrosphere/engine/Main.java +++ b/src/main/java/electrosphere/engine/Main.java @@ -64,7 +64,7 @@ public class Main { /** * target amount of time per frame */ - public static float targetFrameRate = 144.0f; + public static float targetFrameRate = 60.0f; /** * Target period per frame */ diff --git a/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java b/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java index 26dbb4b8..83891288 100644 --- a/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java @@ -264,7 +264,7 @@ public class ServerGroundMovementTree implements BehaviorTree { // System.out.println(movementVector + " " + velocity * Main.deltaTime); //state machine - switch(state){ + switch(this.state){ case STARTUP: { CreatureUtils.setFacingVector(parent, facingVector); rotation.set(movementQuaternion); @@ -431,6 +431,9 @@ public class ServerGroundMovementTree implements BehaviorTree { } break; case IDLE: { } break; + default: { + throw new Error("Unsupported state!? " + this.state); + } } } diff --git a/src/main/java/electrosphere/server/datacell/Realm.java b/src/main/java/electrosphere/server/datacell/Realm.java index 6298cffc..59b86ba9 100644 --- a/src/main/java/electrosphere/server/datacell/Realm.java +++ b/src/main/java/electrosphere/server/datacell/Realm.java @@ -243,7 +243,7 @@ public class Realm { // //simulate bullet physics engine step if(EngineState.EngineFlags.RUN_PHYSICS){ - collisionEngine.simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime()); + collisionEngine.simulatePhysics(); collisionEngine.updateDynamicObjectTransforms(); PhysicsEntityUtils.serverRepositionEntities(this,collisionEngine); chemistryEngine.collide();