Skip to content
Snippets Groups Projects
Commit 4e5d5a90 authored by Marshall Quander's avatar Marshall Quander
Browse files

Eliminate redundant work in character controller tick

parent f0c8acb9
No related branches found
No related tags found
No related merge requests found
......@@ -125,23 +125,25 @@ AFRAME.registerComponent("character-controller", {
yawMatrix.makeRotationAxis(rotationAxis, rotationDelta);
// Translate to middle of playspace (player rig)
root.applyMatrix(transInv);
root.matrix.multiplyMatrices(transInv, root.matrix);
// Zero playspace (player rig) rotation
root.applyMatrix(rotationInvMatrix);
root.matrix.multiplyMatrices(rotationInvMatrix, root.matrix);
// Zero pivot (camera/head) rotation
root.applyMatrix(pivotRotationInvMatrix);
root.matrix.multiplyMatrices(pivotRotationInvMatrix, root.matrix);
// Apply joystick translation
root.applyMatrix(move);
root.matrix.multiplyMatrices(move, root.matrix);
// Apply joystick yaw rotation
root.applyMatrix(yawMatrix);
root.matrix.multiplyMatrices(yawMatrix, root.matrix);
// Apply snap rotation if necessary
root.applyMatrix(this.pendingSnapRotationMatrix);
root.matrix.multiplyMatrices(this.pendingSnapRotationMatrix, root.matrix);
// Reapply pivot (camera/head) rotation
root.applyMatrix(pivotRotationMatrix);
root.matrix.multiplyMatrices(pivotRotationMatrix, root.matrix);
// Reapply playspace (player rig) rotation
root.applyMatrix(rotationMatrix);
root.matrix.multiplyMatrices(rotationMatrix, root.matrix);
// Reapply playspace (player rig) translation
root.applyMatrix(trans);
root.matrix.multiplyMatrices(trans, root.matrix);
root.matrix.decompose(root.position, root.quaternion, root.scale);
// TODO: the above matrix trnsfomraitons introduce some floating point errors in scale, this reverts them to
// avoid spamming network with fake scale updates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment