animation memory optimization
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
63bcb259ad
commit
545fb1ee8a
@ -1988,6 +1988,7 @@ Performance improvements
|
||||
- Reduce bones on LOD human model
|
||||
- Shallow clone on physics cell creation
|
||||
- More vector pool usage
|
||||
- Model anim calculations no longer allocate new matrix4d's
|
||||
Increase human move speed
|
||||
LOD components re-attach physics
|
||||
VectorPool->JomlPool
|
||||
|
||||
@ -457,9 +457,9 @@ public class Model {
|
||||
* @param staticMorph The static morph to apply
|
||||
*/
|
||||
private void updateNodeTransform(AnimNode n, Map<String,ActorBoneRotator> boneRotators, ActorStaticMorph staticMorph){
|
||||
Matrix4d parentTransform = new Matrix4d();
|
||||
Matrix4d currentTransform = n.getTransform().identity();
|
||||
if(n.parent != null){
|
||||
parentTransform = new Matrix4d(n.parent.getTransform());
|
||||
currentTransform.set(n.parent.getTransform());
|
||||
}
|
||||
if(n.is_bone){
|
||||
//
|
||||
@ -472,7 +472,7 @@ public class Model {
|
||||
message = message + "bone map key set: " + boneMap.keySet() + "\n";
|
||||
throw new Error(message);
|
||||
}
|
||||
Matrix4d currentTransform = parentTransform.mul(target_bone.getDeform());
|
||||
currentTransform.mul(target_bone.getDeform());
|
||||
if(boneRotators.containsKey(target_bone.boneID)){
|
||||
currentTransform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
||||
}
|
||||
@ -483,16 +483,16 @@ public class Model {
|
||||
}
|
||||
|
||||
//
|
||||
Matrix4d bone_matrix = new Matrix4d(currentTransform);
|
||||
Matrix4d bone_matrix = currentTransform;
|
||||
n.setTransform(currentTransform);
|
||||
//
|
||||
//Calculate final offset from initial bone
|
||||
//https://stackoverflow.com/a/59869381
|
||||
bone_matrix.mul(target_bone.getMOffset());
|
||||
bone_matrix = new Matrix4d(globalInverseTransform).mul(bone_matrix);
|
||||
bone_matrix = globalInverseTransform.mul(bone_matrix, bone_matrix);
|
||||
target_bone.setFinalTransform(bone_matrix);
|
||||
} else {
|
||||
n.setTransform(parentTransform.mul(electrosphere.util.Utilities.convertAIMatrix(n.raw_data.mTransformation())));
|
||||
n.setTransform(currentTransform.mul(electrosphere.util.Utilities.convertAIMatrix(n.raw_data.mTransformation())));
|
||||
}
|
||||
Iterator<AnimNode> node_iterator = n.children.iterator();
|
||||
while(node_iterator.hasNext()){
|
||||
|
||||
@ -201,9 +201,9 @@ public class PoseModel {
|
||||
*/
|
||||
private void updateNodeTransform(AnimNode n, Map<String,ActorBoneRotator> boneRotators, ActorStaticMorph staticMorph){
|
||||
//grab parent transform if exists
|
||||
Matrix4d parentTransform = new Matrix4d();
|
||||
Matrix4d currentTransform = n.getTransform().identity();
|
||||
if(n.parent != null){
|
||||
parentTransform = new Matrix4d(n.parent.getTransform());
|
||||
currentTransform.set(n.parent.getTransform());
|
||||
}
|
||||
//if this is a bone, calculate the transform for the bone
|
||||
if(n.is_bone){
|
||||
@ -215,24 +215,23 @@ public class PoseModel {
|
||||
message = message + "bone map key set: " + boneMap.keySet() + "\n";
|
||||
throw new Error(message);
|
||||
}
|
||||
Matrix4d deformTransform = parentTransform.mul(target_bone.getDeform());
|
||||
currentTransform.mul(target_bone.getDeform());
|
||||
if(boneRotators.containsKey(target_bone.boneID)){
|
||||
deformTransform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
||||
currentTransform.rotate(boneRotators.get(target_bone.boneID).getRotation());
|
||||
}
|
||||
Matrix4d bone_matrix = new Matrix4d(deformTransform);
|
||||
n.setTransform(currentTransform);
|
||||
if(staticMorph != null && staticMorph.getBoneTransforms(n.id) != null){
|
||||
bone_matrix.mul(staticMorph.getBoneTransforms(n.id).getTransform());
|
||||
currentTransform.mul(staticMorph.getBoneTransforms(n.id).getTransform());
|
||||
}
|
||||
n.setTransform(deformTransform);
|
||||
//
|
||||
//Calculate final offset from initial bone
|
||||
//https://stackoverflow.com/a/59869381
|
||||
bone_matrix.mul(target_bone.getMOffset());
|
||||
bone_matrix = new Matrix4d(globalInverseTransform).mul(bone_matrix);
|
||||
target_bone.setFinalTransform(bone_matrix);
|
||||
currentTransform.mul(target_bone.getMOffset());
|
||||
currentTransform = globalInverseTransform.mul(currentTransform, currentTransform);
|
||||
target_bone.setFinalTransform(currentTransform);
|
||||
} else {
|
||||
//not a bone, so use transform directly from data
|
||||
n.setTransform(parentTransform.mul(electrosphere.util.Utilities.convertAIMatrix(n.raw_data.mTransformation())));
|
||||
n.setTransform(currentTransform.mul(electrosphere.util.Utilities.convertAIMatrix(n.raw_data.mTransformation())));
|
||||
}
|
||||
//update all children accordingly
|
||||
Iterator<AnimNode> node_iterator = n.children.iterator();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user