Skip to content

Commit

Permalink
Merge pull request #107 from LeXXik/ms-optimize
Browse files Browse the repository at this point in the history
Minor optimization to motion state math
  • Loading branch information
LeXXik authored Oct 29, 2024
2 parents 5f84799 + b116b18 commit a9c1c94
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/physics/jolt/back/motion-state.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Debug } from '../debug.mjs';

const v1 = { x: 0, y: 0, z: 0 };

class MotionState {
constructor(body) {
this._body = body;
Expand All @@ -23,21 +21,9 @@ class MotionState {
cp.x = bp.GetX(); cp.y = bp.GetY(); cp.z = bp.GetZ();
}

v1.x = cp.x * alpha;
v1.y = cp.y * alpha;
v1.z = cp.z * alpha;

position.x = v1.x;
position.y = v1.y;
position.z = v1.z;

v1.x = op.x * (1 - alpha);
v1.y = op.y * (1 - alpha);
v1.z = op.z * (1 - alpha);

position.x += v1.x;
position.y += v1.y;
position.z += v1.z;
position.x = cp.x * alpha + op.x * (1 - alpha);
position.y = cp.y * alpha + op.y * (1 - alpha);
position.z = cp.z * alpha + op.z * (1 - alpha);

if (!body.isCharacter) {
const r = this._rotation;
Expand Down

0 comments on commit a9c1c94

Please sign in to comment.