Fix motion trail on null objects

Fix IK not always resolving correctly
This commit is contained in:
JannisX11 2021-12-09 23:09:08 +01:00
parent d06f83922b
commit 207353d8c8
2 changed files with 18 additions and 9 deletions

View File

@ -885,7 +885,6 @@ const Animator = {
start_time = Math.clamp(currentTime - 8, 0, Infinity);
max_time = Math.min(max_time, currentTime + 8);
}
let multiplier = animation.blend_weight ? Math.clamp(Animator.MolangParser.parse(animation.blend_weight), 0, Infinity) : 1;
let geometry = new THREE.BufferGeometry();
let bone_stack = [];
let iterate = g => {
@ -906,12 +905,21 @@ const Animator = {
function displayTime(time) {
Timeline.time = time;
bone_stack.forEach(group => {
var mesh = group.mesh;
let multiplier = animation.blend_weight ? Math.clamp(Animator.MolangParser.parse(animation.blend_weight), 0, Infinity) : 1;
bone_stack.forEach(node => {
let mesh = node.mesh;
let ba = animation.getBoneAnimator(node)
if (mesh.fix_rotation) mesh.rotation.copy(mesh.fix_rotation)
if (mesh.fix_position) mesh.position.copy(mesh.fix_position)
if (node instanceof NullObject) {
if (!ba.muted.position) ba.displayPosition(ba.interpolate('position'), multiplier);
} else {
mesh.scale.x = mesh.scale.y = mesh.scale.z = 1;
animation.getBoneAnimator(group).displayFrame(multiplier);
ba.displayFrame(multiplier);
}
})
target.mesh.updateWorldMatrix(true, false)
}
@ -925,7 +933,7 @@ const Animator = {
displayTime(time);
let position = target instanceof Group
? THREE.fastWorldPosition(target.mesh, new THREE.Vector3())
: target.getWorldCenter();
: target.getWorldCenter(true);
position = position.toArray();
line_positions.push(...position);

View File

@ -481,9 +481,6 @@ class NullObjectAnimator extends BoneAnimator {
let bone_references = [];
let current = target.parent;
this.solver.clear();
this.chain.clear();
while (current !== null_object.parent) {
bones.push(current);
current = current.parent;
@ -545,6 +542,10 @@ class NullObjectAnimator extends BoneAnimator {
}
}
})
this.solver.clear();
this.chain.clear();
this.chain.lastTargetLocation.set(1e9, 0, 0);
if (get_samples) return results;
}
displayFrame(multiplier = 1) {