From b48501652c85c566b9270620b5f648f2a188098f Mon Sep 17 00:00:00 2001 From: austin Date: Mon, 12 Aug 2024 15:26:38 -0400 Subject: [PATCH] fix server animation reset bug --- docs/src/progress/currenttarget.md | 6 ++++- docs/src/progress/renderertodo.md | 1 + .../entity/types/attach/AttachUtils.java | 25 +++---------------- .../server/poseactor/PoseModel.java | 6 ++++- .../server/simulation/MicroSimulation.java | 6 +++-- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/docs/src/progress/currenttarget.md b/docs/src/progress/currenttarget.md index c8445579..73d09aff 100644 --- a/docs/src/progress/currenttarget.md +++ b/docs/src/progress/currenttarget.md @@ -7,7 +7,9 @@ + when popup is accepted, spawn an enemy with an effect enemy ai review combat code (lifestate, damage calculation, etc) - - Allow block hotboxxes to block damage + - Damage event accumulator each frame on server side + Use accumulator to negate all damage if block box was hit + I-frames audio fx for everything + rearchitecture @@ -17,4 +19,6 @@ Hitboxes between server and client feel wayyyy off + bug fixes + Capsule hitboxes aren't connecting correctly + diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index def9e6d2..d81af51a 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -541,6 +541,7 @@ Pass at client-server physics synchronization Fix server animation playing at reduced timescale Block override concept for hitboxes Block sfx +Fix server hitboxes freaking out at animation end # TODO diff --git a/src/main/java/electrosphere/entity/types/attach/AttachUtils.java b/src/main/java/electrosphere/entity/types/attach/AttachUtils.java index 52cbb2c8..c478bb78 100644 --- a/src/main/java/electrosphere/entity/types/attach/AttachUtils.java +++ b/src/main/java/electrosphere/entity/types/attach/AttachUtils.java @@ -67,8 +67,6 @@ public class AttachUtils { String targetBone; if((targetBone = getTargetBone(currentEntity))!=null){ PoseActor parentActor = EntityUtils.getPoseActor(parent); - //set rotation - Vector3d facingAngle = CreatureUtils.getFacingVector(parent); //manual offset Vector3d offset = AttachUtils.getVectorOffset(currentEntity); @@ -84,8 +82,7 @@ public class AttachUtils { new Quaterniond(parentActor.getBoneRotation(targetBone)), new Vector3d(EntityUtils.getPosition(parent)), new Quaterniond(EntityUtils.getRotation(parent)), - new Vector3d(EntityUtils.getScale(parent)), - new Vector3d(facingAngle) + new Vector3d(EntityUtils.getScale(parent)) ); } } else if(currentEntity.getData(EntityDataStrings.ATTACH_TARGET_BASE)!=null){ @@ -205,13 +202,6 @@ public class AttachUtils { if((targetBone = getTargetBone(child))!=null){ Actor parentActor = EntityUtils.getActor(parent); - Vector3d facingAngle; - if(parent == Globals.firstPersonEntity){ - facingAngle = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera)).mul(1,0,1).normalize(); - } else { - facingAngle = CreatureUtils.getFacingVector(parent); - } - //manual offset Vector3d offset = AttachUtils.getVectorOffset(child); if(offset == null){ @@ -226,8 +216,7 @@ public class AttachUtils { new Quaterniond(parentActor.getBoneRotation(targetBone)), new Vector3d(EntityUtils.getPosition(parent)), new Quaterniond(EntityUtils.getRotation(parent)), - new Vector3d(EntityUtils.getScale(parent)), - new Vector3d(facingAngle) + new Vector3d(EntityUtils.getScale(parent)) ); } } @@ -306,10 +295,7 @@ public class AttachUtils { //parent transforms Vector3d parentPosition, Quaterniond parentRotation, - Vector3d parentScale, - - //the parent's facing vector - Vector3d facingVector + Vector3d parentScale ){ //transform bone space Vector3d position = new Vector3d(offsetVector); @@ -321,11 +307,6 @@ public class AttachUtils { position.add(parentPosition); //set EntityUtils.getPosition(child).set(position); - //set rotation - Vector3d facingAngle = facingVector; - if(facingAngle == null){ - facingAngle = MathUtils.getOriginVector(); - } //calculate rotation of model EntityUtils.getRotation(child) .identity() diff --git a/src/main/java/electrosphere/server/poseactor/PoseModel.java b/src/main/java/electrosphere/server/poseactor/PoseModel.java index 8935dea9..d6335075 100644 --- a/src/main/java/electrosphere/server/poseactor/PoseModel.java +++ b/src/main/java/electrosphere/server/poseactor/PoseModel.java @@ -33,6 +33,7 @@ public class PoseModel { List bones; Map boneMap; Matrix4d globalInverseTransform; + Matrix4d rootTransform; Map nodeMap; AnimNode rootAnimNode; List animations; @@ -80,9 +81,12 @@ public class PoseModel { //parse animation nodes and form hierarchy // AINode rootNode = scene.mRootNode(); - globalInverseTransform = electrosphere.util.Utilities.convertAIMatrixd(rootNode.mTransformation()); + rootTransform = electrosphere.util.Utilities.convertAIMatrixd(rootNode.mTransformation()); if(globalTransform != null){ + globalInverseTransform = new Matrix4d(rootTransform).invert().scale(globalTransform.getScale()); globalInverseTransform.scale(globalTransform.getScale()); + } else { + globalInverseTransform = new Matrix4d(); } rootAnimNode = buildAnimNodeMap(scene.mRootNode(),null); diff --git a/src/main/java/electrosphere/server/simulation/MicroSimulation.java b/src/main/java/electrosphere/server/simulation/MicroSimulation.java index 1688d441..d6f511d7 100644 --- a/src/main/java/electrosphere/server/simulation/MicroSimulation.java +++ b/src/main/java/electrosphere/server/simulation/MicroSimulation.java @@ -55,10 +55,12 @@ public class MicroSimulation { // tree.simulate(Main.deltaFrames); ParticleUtils.makeParticleBillboardFaceCamera(particle); } - //update attached entity positions - AttachUtils.serverUpdateAttachedEntityPositions(dataCell); //simulate behavior trees dataCell.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime()); + //update attached entity positions + //!!This must come after simulating behavior trees!! + //if it does not come after queueing animations, the attach positions might not represent the animation of the parent + AttachUtils.serverUpdateAttachedEntityPositions(dataCell); //sum collidable impulses for(Entity collidable : dataCell.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE)){ ServerCollidableTree.getServerCollidableTree(collidable).simulate((float)Globals.timekeeper.getSimFrameTime());