refactor: hot systems perf
This commit is contained in:
parent
70cc56c7b6
commit
a2a33536e7
|
@ -23,18 +23,16 @@ export default class IntegratePhysics extends System {
|
||||||
if (!Forces || !Position) {
|
if (!Forces || !Position) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Position.lastX = Position.$$x;
|
const xd = elapsed * (Forces.$$impulseX + Forces.$$forceX);
|
||||||
Position.$$x += elapsed * (Forces.$$impulseX + Forces.$$forceX);
|
if (xd) {
|
||||||
Position.lastY = Position.$$y;
|
Position.lastX = Position.$$x;
|
||||||
Position.$$y += elapsed * (Forces.$$impulseY + Forces.$$forceY);
|
Position.x = Position.$$x + xd;
|
||||||
this.ecs.markChange(
|
}
|
||||||
entity.id, {
|
const yd = elapsed * (Forces.$$impulseY + Forces.$$forceY);;
|
||||||
Position: {
|
if (yd) {
|
||||||
x: Position.$$x,
|
Position.lastY = Position.$$y;
|
||||||
y: Position.$$y,
|
Position.y = Position.$$y + yd;
|
||||||
},
|
}
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,16 +27,12 @@ export default class ResetForces extends System {
|
||||||
if (!Forces) {
|
if (!Forces) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Forces.$$impulseX = 0;
|
if (Forces.$$impulseX) {
|
||||||
Forces.$$impulseY = 0;
|
Forces.impulseX = 0;
|
||||||
this.ecs.markChange(
|
}
|
||||||
entity.id, {
|
if (Forces.$$impulseY) {
|
||||||
Forces: {
|
Forces.impulseY = 0;
|
||||||
impulseX: Forces.$$impulseX,
|
}
|
||||||
impulseY: Forces.$$impulseY,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user