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) {
|
||||
return;
|
||||
}
|
||||
Position.lastX = Position.$$x;
|
||||
Position.$$x += elapsed * (Forces.$$impulseX + Forces.$$forceX);
|
||||
Position.lastY = Position.$$y;
|
||||
Position.$$y += elapsed * (Forces.$$impulseY + Forces.$$forceY);
|
||||
this.ecs.markChange(
|
||||
entity.id, {
|
||||
Position: {
|
||||
x: Position.$$x,
|
||||
y: Position.$$y,
|
||||
},
|
||||
},
|
||||
);
|
||||
const xd = elapsed * (Forces.$$impulseX + Forces.$$forceX);
|
||||
if (xd) {
|
||||
Position.lastX = Position.$$x;
|
||||
Position.x = Position.$$x + xd;
|
||||
}
|
||||
const yd = elapsed * (Forces.$$impulseY + Forces.$$forceY);;
|
||||
if (yd) {
|
||||
Position.lastY = Position.$$y;
|
||||
Position.y = Position.$$y + yd;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,16 +27,12 @@ export default class ResetForces extends System {
|
|||
if (!Forces) {
|
||||
return;
|
||||
}
|
||||
Forces.$$impulseX = 0;
|
||||
Forces.$$impulseY = 0;
|
||||
this.ecs.markChange(
|
||||
entity.id, {
|
||||
Forces: {
|
||||
impulseX: Forces.$$impulseX,
|
||||
impulseY: Forces.$$impulseY,
|
||||
},
|
||||
},
|
||||
);
|
||||
if (Forces.$$impulseX) {
|
||||
Forces.impulseX = 0;
|
||||
}
|
||||
if (Forces.$$impulseY) {
|
||||
Forces.impulseY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user