Closed cKrijgsman closed 1 year ago
good catch! I will fix this today
Sorry I said I could fix this in a day but this issue will take some more time to get right. I'm thinking the most efficient solution will be to utilize planck's world.queryAABB
method, like I did in my getSpritesAt
method.
For v3.9, I just implemented an unsophisticated algorithm for the _display
function that errors on the side of drawing, even if the entire sprite is offscreen.
I realized that an optimal solution for this would have to account for the scale of the sprite's image, not just the size of the sprite's collider.
I'll revisit this issue later to improve p5play's efficiency, thanks for bringing the error to my attention! Closing the issue for now.
let largestSide = Math.max(this._w, this._h);
// if the sprite is off screen, then it doesn't get drawn
// this is an unsophisticated algorithm that
// errors on the side of drawing
if (
this.shape != 'chain' &&
this.p.camera.active &&
(x + largestSide < this.p.camera.bound.min.x ||
x - largestSide > this.p.camera.bound.max.x ||
y + largestSide < this.p.camera.bound.min.y ||
y - largestSide > this.p.camera.bound.max.y)
) {
this._visible = null;
return;
}
https://github.com/quinton-ashley/p5play/blob/0259613058c0837ade6f0de24f3f0c2b2d75f191/p5play.js#L2421
When drawing a Sprite that has rotation off-screen, it will not consider the rotation when checking if it should be rendered.
Example: