コード例 #1
0
        public Hoguera getClosestBonfire(TGCVector3 pos, float maxDistance)
        {
            var     minDist = float.MaxValue;
            TgcMesh minF    = null;

            foreach (var fuego in HoguerasMesh())
            {
                var distSq = TGCVector3.LengthSq(pos - fuego.BoundingBox.calculateBoxCenter());
                if (distSq < minDist)
                {
                    minDist = distSq;
                    minF    = fuego;
                }
            }

            if (minF != null)
            {
                if (maxDistance != 0 && TGCVector3.LengthSq(pos - minF.BoundingBox.calculateBoxCenter()) > (maxDistance * maxDistance))
                {
                    return(null);
                }
                foreach (Hoguera h in hogueras)
                {
                    if (h.MeshHoguera.GetHashCode() == minF.GetHashCode())
                    {
                        return(h);
                    }
                }
            }
            return(null);
        }