Radegast.Rendering.SceneWindow.FindClosestDistanceSquared C# (CSharp) Method

FindClosestDistanceSquared() private method

Finds the closest distance between the given pos and an object (Assumes that the object is a box slightly)
private FindClosestDistanceSquared ( Vector3 calcPos, SceneObject p ) : float
calcPos Vector3
p SceneObject
return float
        private float FindClosestDistanceSquared(Vector3 calcPos, SceneObject p)
        {
            if (p.BoundingVolume == null
                || !RenderSettings.HeavierDistanceChecking
                || p.BoundingVolume.ScaledR < 10f
                )
                return Vector3.DistanceSquared(calcPos, p.RenderPosition);

            Vector3 posToCheckFrom = Vector3.Zero;
            //Get the bounding boxes for this prim
            Vector3 boundingBoxMin = p.RenderPosition + p.BoundingVolume.ScaledMin;
            Vector3 boundingBoxMax = p.RenderPosition + p.BoundingVolume.ScaledMax;
            posToCheckFrom.X = (calcPos.X < boundingBoxMin.X) ? boundingBoxMin.X : (calcPos.X > boundingBoxMax.X) ? boundingBoxMax.X : calcPos.X;
            posToCheckFrom.Y = (calcPos.Y < boundingBoxMin.Y) ? boundingBoxMin.Y : (calcPos.Y > boundingBoxMax.Y) ? boundingBoxMax.Y : calcPos.Y;
            posToCheckFrom.Z = (calcPos.Z < boundingBoxMin.Z) ? boundingBoxMin.Z : (calcPos.Z > boundingBoxMax.Z) ? boundingBoxMax.Z : calcPos.Z;
            return Vector3.DistanceSquared(calcPos, posToCheckFrom);
        }
SceneWindow