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

View File

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