TerrainDisplay.Collision.Intersection.IntersectSegmentPolyhedron C# (CSharp) Méthode

IntersectSegmentPolyhedron() public static méthode

public static IntersectSegmentPolyhedron ( System.Vector3 a, System.Vector3 b, Plane p, int n, float &tfirst, float &tlast ) : bool
a System.Vector3
b System.Vector3
p Plane
n int
tfirst float
tlast float
Résultat bool
        public static bool IntersectSegmentPolyhedron(Vector3 a, Vector3 b, Plane[] p, int n, ref float tfirst, ref float tlast)
        {
            var vector = b - a;
            tfirst = 0f;
            tlast = 1f;
            for (var i = 0; i < n; i++)
            {
                var num2 = Vector3.Dot(p[i].Normal, vector);
                var num3 = p[i].D - Vector3.Dot(p[i].Normal, a);
                if (num2 == 0f)
                {
                    if (num3 > 0f)
                    {
                        return false;
                    }
                }
                else
                {
                    var num4 = num3 / num2;
                    if (num2 < 0f)
                    {
                        if (num4 > tfirst)
                        {
                            tfirst = num4;
                        }
                    }
                    else if (num4 < tlast)
                    {
                        tlast = num4;
                    }
                    if (tfirst > tlast)
                    {
                        return false;
                    }
                }
            }
            return true;
        }