Example #1
0
        public float GetDistance(Vector position)
        {
            var boxDist = Utils3D.BoxTest(position, boxMin, boxMax);

            if (boxDist > 1f)
            {
                return(boxDist);
            }

            Vector f = position; // Flattened position (z=0)

            f.z = 0;

            float distance = float.MaxValue;

            foreach (var obj in objects)
            {
                distance = Utils3D.min(distance, obj.GetDistance(f));
            }

            return((float)Math.Pow(Utils3D.Pow8(distance) + Utils3D.Pow8(position.z), 0.125f) - 0.5f);
        }
Example #2
0
        public float GetDistance(Vector position)
        {
            position.x -= this.posX;

            var boxDist = Utils3D.BoxTest(position, boxMin, boxMax);

            if (boxDist > 1f)
            {
                return(boxDist);
            }

            Vector f = position; // Flattened position (z=0)

            f.z = 0;

            float distance = float.MaxValue;

            foreach (var obj in objects)
            {
                distance = Utils3D.min(distance, obj.GetDistance(f));
            }

            return(distance);
        }
Example #3
0
        public float GetDistance(Vector position)
        {
            Vector o = position - (begin + end * Utils3D.min(-Utils3D.min((begin - position) % end / (end % end), 0), 1));

            return((float)Math.Sqrt(o % o));
        }