chore: Abstract physics world tick optimizations

This commit is contained in:
cha0s 2019-04-16 18:02:07 -05:00
parent ab937f2206
commit e1e537e5e1
2 changed files with 8 additions and 5 deletions

View File

@ -4,15 +4,15 @@
- ✔ Synchronized should be a mixin
- ✔ Behavior items should derive type/name
- ✔ Precompile behavior traversals
- ❌ Abstract physics world tick (no destructuring)
- ✔ Abstract physics world tick optimizations
- ❌ Cache current routine for Behaved tick
- ✔ Apply patches to matter.js
( https://github.com/liabru/matter-js/pulls?utf8=%E2%9C%93&q=is%3Apr+author%3Abchevalier )
- ✔ Inline traits into entity, remove Proxy
- ❌ entityList.fromJSON()
- ❌ Eliminate immutable.toJS()
- ❌ Cache dirty entity state (entityList.tick())
- ❌ Investigate visibleEntities path
- ❌ Investigate lookupEmitListeners path
- ❌ Investigate visibleBoundingBoxes path
- ❌ EventEmitter::emit is too hot
- ❌ entityList.fromJSON()

View File

@ -37,10 +37,13 @@ export class AbstractWorld extends decorate(class {}) {
// Propagate position updates.
for (let i = 0; i < this.entitiesList.length; ++i) {
const entity = this.entitiesList[i];
const [entityX, entityY] = entity.position;
const [bodyX, bodyY] = entity.body.position;
const entityPosition = entity.position;
const bodyPosition = entity.body.position;
// Hot.
if (entityX === bodyX && entityY === bodyY) {
if (
entityPosition[0] === bodyPosition[0]
&& entityPosition[1] === bodyPosition[1]
) {
continue;
}
entity.position = entity.body.position;