public GetBoundingBox ( int triangleIndex, Microsoft.Xna.Framework.BoundingBox &boundingBox ) : void | ||
triangleIndex | int | Index of the triangle in the data. |
boundingBox | Microsoft.Xna.Framework.BoundingBox | Bounding box of the triangle. |
return | void |
public void GetBoundingBox(int triangleIndex, out BoundingBox boundingBox)
{
Vector3 v1, v2, v3;
GetTriangle(triangleIndex, out v1, out v2, out v3);
Vector3.Min(ref v1, ref v2, out boundingBox.Min);
Vector3.Min(ref boundingBox.Min, ref v3, out boundingBox.Min);
Vector3.Max(ref v1, ref v2, out boundingBox.Max);
Vector3.Max(ref boundingBox.Max, ref v3, out boundingBox.Max);
}
///<summary>
internal override void Refit(MeshBoundingBoxTreeData data) { data.GetBoundingBox(LeafIndex, out BoundingBox); //Having an ever-so-slight margin allows the hierarchy use a volume metric even for degenerate shapes (consider a flat tessellated plane). BoundingBox.Max.X += LeafMargin; BoundingBox.Max.Y += LeafMargin; BoundingBox.Max.Z += LeafMargin; BoundingBox.Min.X -= LeafMargin; BoundingBox.Min.Y -= LeafMargin; BoundingBox.Min.Z -= LeafMargin; }