v0.4.2: performance improvements to visibility checking

This commit is contained in:
Evan Debenham 2016-08-30 01:14:12 -04:00
parent 926b02ce65
commit 6627ba4736
2 changed files with 14 additions and 6 deletions

View File

@ -64,7 +64,7 @@ public class Gizmo {
if (camera != null) {
return camera;
} else if (parent != null) {
return parent.camera();
return this.camera = parent.camera();
} else {
return null;
}

View File

@ -240,10 +240,18 @@ public class Visual extends Gizmo {
if (c == null || !visible) return false;
float cx = c.scroll.x;
float cy = c.scroll.y;
float w = width();
float h = height();
return x + w >= cx && y + h >= cy && x < cx + c.width && y < cy + c.height;
//x coord
if (x > c.scroll.x + c.width)
return false;
else if (!(x >= c.scroll.x || x + width() >= c.scroll.x))
return false;
//y coord
if (y > c.scroll.y + c.height)
return false;
else if (!(y >= c.scroll.y || y + height() >= c.scroll.y))
return false;
return true;
}
}