diff --git a/assets/Data/creatures/human.json b/assets/Data/creatures/human.json index 2077afca..5ef32376 100644 --- a/assets/Data/creatures/human.json +++ b/assets/Data/creatures/human.json @@ -376,7 +376,8 @@ "rotW": 1, "offsetX" : 0, "offsetY" : 0.4, - "offsetZ" : 0 + "offsetZ" : 0, + "angularlyStatic" : true }, "attackMoves" : [ { diff --git a/docs/src/progress/currenttarget.md b/docs/src/progress/currenttarget.md index 8a63ba11..0f8177a5 100644 --- a/docs/src/progress/currenttarget.md +++ b/docs/src/progress/currenttarget.md @@ -19,7 +19,6 @@ Ticketed randomizer node for BTs to more heavily weight attacking and waiting + bug fixes - Fix physics freakout for vertically aligned entities Fix entities running to edge of map causing audio engine to break Fix broken rendering pipeline when creating new level diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index d32980d4..668413dd 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -594,6 +594,7 @@ Fix unequipping item hard crashing engine Fix terrain editing hard crashing engine Fix attack animation mayyybe caching on non-local clients ?? Fix sword double-swing +Fix physics freakout for vertically aligned entities # TODO diff --git a/src/main/java/electrosphere/collision/CollisionEngine.java b/src/main/java/electrosphere/collision/CollisionEngine.java index bfb5ea8f..4955d566 100644 --- a/src/main/java/electrosphere/collision/CollisionEngine.java +++ b/src/main/java/electrosphere/collision/CollisionEngine.java @@ -880,6 +880,21 @@ public class CollisionEngine { spaceLock.release(); } + /** + * Sets whether the body is angularly static or not + * @param body The body + * @param angularlyStatic true if angularly static, false otherwise + */ + protected void setAngularlyStatic(DBody body, boolean angularlyStatic){ + spaceLock.acquireUninterruptibly(); + if(angularlyStatic){ + body.setMaxAngularSpeed(0); + } else { + body.setMaxAngularSpeed(1000); + } + spaceLock.release(); + } + /** * Removes the geometry from the body * @param body the body diff --git a/src/main/java/electrosphere/collision/PhysicsEntityUtils.java b/src/main/java/electrosphere/collision/PhysicsEntityUtils.java index a5c635a6..26986def 100644 --- a/src/main/java/electrosphere/collision/PhysicsEntityUtils.java +++ b/src/main/java/electrosphere/collision/PhysicsEntityUtils.java @@ -56,6 +56,9 @@ public class PhysicsEntityUtils { physicsTemplate.getOffsetX(), physicsTemplate.getOffsetY(), physicsTemplate.getOffsetZ(), //translate physicsTemplate.getRotX(), physicsTemplate.getRotY(), physicsTemplate.getRotZ(), physicsTemplate.getRotW() //rotate ); + if(physicsTemplate.isAngularlyStatic()){ + Globals.clientSceneWrapper.getCollisionEngine().setAngularlyStatic(rigidBody, true); + } rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_TRANSFORM, offsetTransform); rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate); rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable); @@ -80,6 +83,9 @@ public class PhysicsEntityUtils { physicsTemplate.getRotX(), physicsTemplate.getRotY(), physicsTemplate.getRotZ(), physicsTemplate.getRotW(), //rotate 1, 1, 1 //scale ); + if(physicsTemplate.isAngularlyStatic()){ + Globals.clientSceneWrapper.getCollisionEngine().setAngularlyStatic(rigidBody, true); + } rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_TRANSFORM, offsetTransform); rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate); rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable); @@ -129,6 +135,9 @@ public class PhysicsEntityUtils { physicsTemplate.getRotX(), physicsTemplate.getRotY(), physicsTemplate.getRotZ(), physicsTemplate.getRotW(), //rotate 1, 1, 1 //scale ); + if(physicsTemplate.isAngularlyStatic()){ + realm.getCollisionEngine().setAngularlyStatic(rigidBody, true); + } rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_TRANSFORM, offsetTransform); rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate); rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable); @@ -149,6 +158,9 @@ public class PhysicsEntityUtils { physicsTemplate.getRotX(), physicsTemplate.getRotY(), physicsTemplate.getRotZ(), physicsTemplate.getRotW(), //rotate 1, 1, 1 //scale ); + if(physicsTemplate.isAngularlyStatic()){ + realm.getCollisionEngine().setAngularlyStatic(rigidBody, true); + } rVal.putData(EntityDataStrings.PHYSICS_COLLISION_BODY_TRANSFORM, offsetTransform); rVal.putData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE, physicsTemplate); rVal.putData(EntityDataStrings.PHYSICS_COLLIDABLE, collidable); diff --git a/src/main/java/electrosphere/entity/state/physicssync/upright/ClientAlwaysUprightTree.java b/src/main/java/electrosphere/entity/state/physicssync/upright/ClientAlwaysUprightTree.java index b07fab86..c063a2ff 100644 --- a/src/main/java/electrosphere/entity/state/physicssync/upright/ClientAlwaysUprightTree.java +++ b/src/main/java/electrosphere/entity/state/physicssync/upright/ClientAlwaysUprightTree.java @@ -39,7 +39,6 @@ public class ClientAlwaysUprightTree implements BehaviorTree { Vector3d angularForce = new Vector3d(); //make sure rotation is vertical - body.setMaxAngularSpeed(0); // sourceRotation = sourceRotation.mul(0.001, 1, 0.001, 1).normalize(); EntityUtils.getPosition(parent).set(position); diff --git a/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java b/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java index 1db64112..288b16d2 100644 --- a/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java +++ b/src/main/java/electrosphere/entity/state/physicssync/upright/ServerAlwaysUprightTree.java @@ -42,7 +42,6 @@ public class ServerAlwaysUprightTree implements BehaviorTree { Vector3d angularForce = new Vector3d(); //make sure rotation is vertical - body.setMaxAngularSpeed(0); // sourceRotation = sourceRotation.mul(0.001, 0.001, 0.001, 1).normalize(); EntityUtils.getPosition(parent).set(position); diff --git a/src/main/java/electrosphere/game/data/collidable/CollidableTemplate.java b/src/main/java/electrosphere/game/data/collidable/CollidableTemplate.java index 2a6e1d71..35324de5 100644 --- a/src/main/java/electrosphere/game/data/collidable/CollidableTemplate.java +++ b/src/main/java/electrosphere/game/data/collidable/CollidableTemplate.java @@ -20,6 +20,11 @@ public class CollidableTemplate { float offsetY; float offsetZ; + /** + * Controls whether the body can rotate or not + */ + boolean angularlyStatic; + public String getType() { return type; } @@ -63,6 +68,14 @@ public class CollidableTemplate { public float getOffsetZ() { return offsetZ; } + + /** + * Gets if the body should always be allowed to rotate or not + * @return true if should always be allowed to rotate, false otherwise + */ + public boolean isAngularlyStatic(){ + return this.angularlyStatic; + }