Beispiel #1
0
        public bool FindInconsistentPlacementCandidateR(ref Vec3 relativeCoords, float maxDist)
        {
            var c = ToPixelR(relativeCoords);

            int  maxDist2 = (int)(maxDist * CommonResolution);
            int  d2       = maxDist2;
            Int3 closest  = Int3.Zero;
            bool any      = false;

            for (int z = 0; z < Size.Z; z++)
            {
                for (int y = 0; y < Size.Y; y++)
                {
                    for (int x = 0; x < Size.X; x++)
                    {
                        if (!this[x, y, z])
                        {
                            continue;
                        }
                        var candidate = new Int3(x, y, z);
                        int dist      = Int3.GetChebyshevDistance(c, candidate);
                        if (dist >= d2)
                        {
                            continue;
                        }
                        d2      = dist;
                        any     = true;
                        closest = candidate;
                    }
                }
            }

            if (any)
            {
                relativeCoords = ToRelative(closest);
            }
            return(any);
        }