Open stovenator opened 7 years ago
Nice spot - I'll take a look at this and see what I can do to maintain compatibility. This as you can probably tell is a caching technique to prevent unnecessary projection calculations but it looks like it's not doing its job!
I also noticed that in the Body postUpdate, there's no dirty check. I adjusted it in mine to look like this, but likely it could be optimized more:
if(this._dx !== 0 || this._dy !== 0 || this._dx !== 0){
this.sprite.isoX += this._dx;
this.sprite.isoY += this._dy;
this.sprite.isoZ += this._dz;
}
...
if (this.position.x !== this.prev.x || this.position.y !== this.prev.y || this.position.z !== this.prev.z){
this.prev.x = this.position.x;
this.prev.y = this.position.y;
this.prev.z = this.position.z;
}
In the prototype for isoSprite , there's no way for _isoSpriteChanged to ever get set false, so every update cycle the it updates the isoSprite, regardless of need and has to re-do the math for resetBounds and depth.
This can be changed to be:
After this change, it requires that isoSprite positioning is changed only using isoSprite.isoX, isoSprite.isoY, and isoSprite.isoZ because those setters update the _isoPositionChanged flag, or with body.reset if there is a body.
If the position is updated using isoSprite.isoPosition.setTo(x,y,z) , _isoPositionChanged never gets set and thus the position.x, position.y remain unchanged.