From 4eb4fba8a0f8f7c02f70384306f91b3971c2a54a Mon Sep 17 00:00:00 2001 From: austin Date: Fri, 13 Sep 2024 18:20:04 -0400 Subject: [PATCH] adjust physics numbers --- assets/Data/entity/creatures/human.json | 7 ++--- assets/Data/entity/objects/containers.json | 6 ++--- .../collision/CollisionEngine.java | 15 ++++++++--- .../collision/collidable/SurfaceParams.java | 2 +- .../collidable/ClientCollidableTree.java | 26 ------------------- 5 files changed, 20 insertions(+), 36 deletions(-) diff --git a/assets/Data/entity/creatures/human.json b/assets/Data/entity/creatures/human.json index 089a07bb..6e196139 100644 --- a/assets/Data/entity/creatures/human.json +++ b/assets/Data/entity/creatures/human.json @@ -133,8 +133,8 @@ "movementSystems" : [ { "type" : "GROUND", - "acceleration" : 100.0, - "maxVelocity" : 50.5, + "acceleration" : 4000.0, + "maxVelocity" : 20.5, "strafeMultiplier" : 1.0, "backpedalMultiplier" : 0.5, "footstepFirstAudioOffset" : 0.2, @@ -167,7 +167,7 @@ { "type" : "JUMP", "jumpFrames" : 3, - "jumpForce" : 20, + "jumpForce" : 1.3, "animationJump" : { "nameThirdPerson" : "Jump", "nameFirstPerson" : "Jump", @@ -371,6 +371,7 @@ "dimension1" : 0.2, "dimension2" : 1.6, "dimension3" : 0.2, + "mass": 0.3, "rotX": 0, "rotY": 0, "rotZ": 0, diff --git a/assets/Data/entity/objects/containers.json b/assets/Data/entity/objects/containers.json index b808ec64..51697332 100644 --- a/assets/Data/entity/objects/containers.json +++ b/assets/Data/entity/objects/containers.json @@ -12,9 +12,9 @@ ], "collidable": { "type" : "CUBE", - "mass": 1.0, - "rollingFriction": 100.0, - "linearFriction": 100.0, + "mass": 0.7, + "rollingFriction": 1.0, + "linearFriction": 0.001, "dimension1" : 2.0, "dimension2" : 2.0, "dimension3" : 2.0, diff --git a/src/main/java/electrosphere/collision/CollisionEngine.java b/src/main/java/electrosphere/collision/CollisionEngine.java index 151421fa..fbcb9d88 100644 --- a/src/main/java/electrosphere/collision/CollisionEngine.java +++ b/src/main/java/electrosphere/collision/CollisionEngine.java @@ -61,7 +61,7 @@ import electrosphere.logger.LoggerInterface; public class CollisionEngine { //gravity constant - public static final float GRAVITY_MAGNITUDE = 9.8f * 2; + public static final float GRAVITY_MAGNITUDE = 0.2f; /** * The damping applied to angular velocity @@ -87,7 +87,16 @@ public class CollisionEngine { private static Semaphore spaceLock = new Semaphore(1); private DJointGroup contactgroup; - private static final int MAX_CONTACTS = 64; // maximum number of contact points per body + // maximum number of contact points per body + /** + *

Maximum number of contact points per body

+ *

Note:

+ *

+ * This value must be sufficiently high (I'd recommend 64), in order for large bodies to not sink into other large bodies. + * I used a value of 10 for a long time and found that cubes were sinking into TriMeshes. + *

+ */ + private static final int MAX_CONTACTS = 64; //The list of dbodies ode should be tracking List bodies = new ArrayList(); @@ -116,7 +125,7 @@ public class CollisionEngine { public CollisionEngine(){ world = OdeHelper.createWorld(); space = OdeHelper.createBHVSpace(Collidable.TYPE_STATIC_BIT); - world.setGravity(0,-0.5,0); + world.setGravity(0,-GRAVITY_MAGNITUDE,0); // world.setAutoDisableFlag(true); // world.setContactMaxCorrectingVel(0.1); // world.setContactSurfaceLayer(0.001); diff --git a/src/main/java/electrosphere/collision/collidable/SurfaceParams.java b/src/main/java/electrosphere/collision/collidable/SurfaceParams.java index 463c4433..636d1b03 100644 --- a/src/main/java/electrosphere/collision/collidable/SurfaceParams.java +++ b/src/main/java/electrosphere/collision/collidable/SurfaceParams.java @@ -77,7 +77,7 @@ public class SurfaceParams { */ public SurfaceParams(){ mode = OdeConstants.dContactApprox1 & OdeConstants.dContactRolling & OdeConstants.dContactBounce; - mu = 0.01; + mu = 0.0001; rho = 10.0; rho2 = 10.0; rhoN = 10.0; diff --git a/src/main/java/electrosphere/entity/state/collidable/ClientCollidableTree.java b/src/main/java/electrosphere/entity/state/collidable/ClientCollidableTree.java index 1c83f7e0..4a260459 100644 --- a/src/main/java/electrosphere/entity/state/collidable/ClientCollidableTree.java +++ b/src/main/java/electrosphere/entity/state/collidable/ClientCollidableTree.java @@ -11,8 +11,6 @@ import electrosphere.entity.Entity; import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityUtils; import electrosphere.entity.btree.BehaviorTree; -import electrosphere.entity.state.gravity.ClientGravityTree; -import electrosphere.entity.state.movement.fall.ClientFallTree; /** * Client collidable tree @@ -44,31 +42,7 @@ public class ClientCollidableTree implements BehaviorTree { public void simulate(float deltaTime){ Vector3d position = EntityUtils.getPosition(parent); Quaterniond rotation = EntityUtils.getRotation(parent); - Vector3d offsetVector = new Vector3d(); Vector3d newPosition = new Vector3d(position); - //have we hit a terrain impulse? - boolean hitTerrain = false; - //handle impulses - for(Impulse impulse : collidable.getImpulses()){ -// collidable.getImpulses().remove(impulse); - Vector3d impulseForce = new Vector3d(impulse.getDirection()).mul(impulse.getForce()); - if(impulse.type.matches(Collidable.TYPE_TERRAIN)){ - hitTerrain = true; -// System.out.println("Impulse force: " + impulseForce); -// System.out.println("Position: " + position); - } -// if(impulse.type.matches(Collidable.TYPE_ITEM)){ -// if(ClientGravityTree.getClientGravityTree(parent)!=null){ -// ClientGravityTree.getClientGravityTree(parent).start(); -// } -// } -// if(impulse.type.matches(Collidable.TYPE_CREATURE)){ -// // System.out.println(System.currentTimeMillis() + " creature hit!"); -// if(ClientGravityTree.getClientGravityTree(parent)!=null){ -// ClientGravityTree.getClientGravityTree(parent).start(); -// } -// } - } //bound to world bounds if(Globals.clientWorldData != null){ if(newPosition.x < Globals.clientWorldData.getWorldBoundMin().x){