BoundingBox.contains

Hi,



small Question. Is the BoundingBox method “contains” is correct?

[java]

@Override

public boolean contains(Vector3f point) {

return FastMath.abs(center.x - point.x) < xExtent

&& FastMath.abs(center.y - point.y) < yExtent

&& FastMath.abs(center.z - point.z) < zExtent;

}

[/java]



I have a case where a point intersects a border of the bounding box and the contains method returns false because of the less than compare. I think a equal to or less than compare is better.



It is possible to fix this?

Thanks Mewel

1 Like

Contains requires that the point is actually inside the box. If it is on the edge, or “boundary”, it does not contain it.

However to compliment the contains method, BoundingBox should have an intersects(Vector3f point) method that tests “<=”.



I will add this method in to BoundingVolume and implement it for the sub classes, I will let you know when it has been committed.

ok it’s been committed. Check out the latest from SVN and you should have it :slight_smile:

Cool, thanks.