What exactly does “Contains” mean in XNA?
Question
A pretty specific question if anyone knows the answer: What exactly does "contains" mean, in the context of BoundingSphere1.Contains(BoundingSphere2)?
If i have a smaller sphere inside a larger sphere, does the smaller sphere "contain" the larger sphere as in the entirety of its volume is also the volume of the larger sphere? Would that return a ContainmentType.Contains?
Thanks!
Solution
From the MSDN page for the BoundingSphere.Contains method that takes a BoundingSphere parameter:
Checks whether the current BoundingSphere contains the specified BoundingSphere.
It returns a ContainmentType enumeration which
Indicates the extent to which bounding volumes intersect or contain one another.
Specifically:
Contains: Indicates that one bounding volume completely contains the other.
Disjoint: Indicates there is no overlap between the bounding volumes.
Intersects: Indicates that the bounding volumes partially overlap.
If BoundingSphere1 is smaller than BoundingSphere2 then I suppose BoundingSphere1.Contains(BoundingSphere2)
would return a ContainmentType.Intersects result instead of a ContainmentType.Contains result since it doesn't "completely" contain the other. On the other hand, BoundingSphere2.Contains(BoundingSphere1)
should return ContainmentType.Contains since it "completely contains the other."
EDIT: I've updated my answer after reviewing the documentation again. Initially something sounded vague but now I think the emphasis in the enumeration details of "completely" and "partially" for Contains and Intersects, respectively, strengthen my expectations. I can't test this but this sounds reasonable.
OTHER TIPS
As far as I can tell this is how I am interpreting your assumptions.
BoundingSphere1 is a big circle. BoundingSphere2 is a small circle.
Lets say BoundingSphere2 is entirely contained within BoundingSphere1. From what I understand, you think BoundingSphere2 "contains" BoundingSphere1.
In actuality, BoundingSphere1 "contains" BoundingSphere2 because all of BoundingSphere2 is within BoundingSphere1.
You are basically trying to found out if a Sphere is within another Sphere.
so BoundingSphere1.contains(BoundingSphere2) will be true, but BoundingSphere2.contains(BoundingSphere1) would be false.