diff --git a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java index a1eb10c5..f1cac8b6 100644 --- a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java +++ b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java @@ -429,10 +429,12 @@ public class ServerAttackTree implements BehaviorTree { this.stateTransitionUtil.simulate(AttackTreeState.BLOCK_RECOIL); //deactivate hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); - for(Entity currentAttached : attachedEntities){ - if(HitboxCollectionState.hasHitboxState(currentAttached)){ - HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); - currentState.setActive(false); + if(attachedEntities != null){ + for(Entity currentAttached : attachedEntities){ + if(HitboxCollectionState.hasHitboxState(currentAttached)){ + HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); + currentState.setActive(false); + } } } if(this.currentMove.getActiveBones() != null && HitboxCollectionState.hasHitboxState(this.parent)){ @@ -451,10 +453,12 @@ public class ServerAttackTree implements BehaviorTree { this.stateTransitionUtil.simulate(AttackTreeState.COOLDOWN); //deactive hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); - for(Entity currentAttached : attachedEntities){ - if(HitboxCollectionState.hasHitboxState(currentAttached)){ - HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); - currentState.setActive(false); + if(attachedEntities != null){ + for(Entity currentAttached : attachedEntities){ + if(HitboxCollectionState.hasHitboxState(currentAttached)){ + HitboxCollectionState currentState = HitboxCollectionState.getHitboxState(currentAttached); + currentState.setActive(false); + } } } if(this.currentMove.getActiveBones() != null && HitboxCollectionState.hasHitboxState(this.parent)){ diff --git a/src/main/java/electrosphere/server/datacell/gridded/GriddedDataCellManager.java b/src/main/java/electrosphere/server/datacell/gridded/GriddedDataCellManager.java index 4a5d758e..030f54b5 100644 --- a/src/main/java/electrosphere/server/datacell/gridded/GriddedDataCellManager.java +++ b/src/main/java/electrosphere/server/datacell/gridded/GriddedDataCellManager.java @@ -606,9 +606,8 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager public void simulate(){ Globals.profiler.beginCpuSample("GriddedDataCellManager.simulate"); loadedCellsLock.lock(); - Collection groundCells = this.groundDataCells.values(); boolean runMicroSim = Globals.microSimulation != null && Globals.microSimulation.isReady(); - for(ServerDataCell cell : groundCells){ + for(ServerDataCell cell : this.groundDataCells.values()){ if(runMicroSim && this.shouldSimulate(cell)){ Globals.microSimulation.simulate(cell); } diff --git a/src/main/java/electrosphere/server/poseactor/PoseActor.java b/src/main/java/electrosphere/server/poseactor/PoseActor.java index 97b8dd7d..3d3674fb 100644 --- a/src/main/java/electrosphere/server/poseactor/PoseActor.java +++ b/src/main/java/electrosphere/server/poseactor/PoseActor.java @@ -96,11 +96,6 @@ public class PoseActor { for(ActorAnimationMask mask : toRemoveMasks){ animationQueue.remove(mask); } - PoseModel model = Globals.assetManager.fetchPoseModel(modelPath); - if(model != null){ - this.applyAnimationMasks(model); - this.calculateNodeTransforms(model); - } } /** @@ -354,18 +349,18 @@ public class PoseActor { * @param model The posemodel to apply the mask to */ void applyAnimationMasks(PoseModel model){ - List bonesUsed = new LinkedList(); - List currentAnimationMask = new LinkedList(); - for(ActorAnimationMask mask : animationQueue){ - currentAnimationMask.clear(); - for(String currentBone : mask.getBones()){ - if(!bonesUsed.contains(currentBone)){ - bonesUsed.add(currentBone); - currentAnimationMask.add(currentBone); - } + List bonesUsed = new LinkedList(); + List currentAnimationMask = new LinkedList(); + for(ActorAnimationMask mask : animationQueue){ + currentAnimationMask.clear(); + for(String currentBone : mask.getBones()){ + if(!bonesUsed.contains(currentBone)){ + bonesUsed.add(currentBone); + currentAnimationMask.add(currentBone); } - model.applyAnimationMask(mask.getAnimationName(), mask.getTime(), currentAnimationMask); } + model.applyAnimationMask(mask.getAnimationName(), mask.getTime(), currentAnimationMask); + } } /** @@ -392,6 +387,17 @@ public class PoseActor { } } + /** + * Updates the transform cache for this actor + */ + public void updateTransformCache(){ + PoseModel model = Globals.assetManager.fetchPoseModel(modelPath); + if(model != null){ + this.applyAnimationMasks(model); + this.calculateNodeTransforms(model); + } + } + /** * Sets the animation scalar * @param animationScalar The new animation scalar value diff --git a/src/main/java/electrosphere/server/simulation/MicroSimulation.java b/src/main/java/electrosphere/server/simulation/MicroSimulation.java index 4a0978aa..8cf86026 100644 --- a/src/main/java/electrosphere/server/simulation/MicroSimulation.java +++ b/src/main/java/electrosphere/server/simulation/MicroSimulation.java @@ -66,6 +66,16 @@ public class MicroSimulation { for(Entity collidable : collidables){ ServerCollidableTree.getServerCollidableTree(collidable).simulate((float)Globals.timekeeper.getSimFrameTime()); } + + //update actor transform caches + poseableEntities = dataCell.getScene().getEntitiesWithTag(EntityTags.POSEABLE); + if(poseableEntities != null){ + for(Entity currentEntity : dataCell.getScene().getEntitiesWithTag(EntityTags.POSEABLE)){ + //fetch actor + PoseActor currentPoseActor = EntityUtils.getPoseActor(currentEntity); + currentPoseActor.updateTransformCache(); + } + } } Globals.profiler.endCpuSample(); }