Exemple #1
0
        public CollisionResult CheckCollision(RayEntity ray)
        {
            if (Polygons.Count() != 2)
            {
                throw new Exception("Quad must contain only two polygons!");
            }

            foreach (var polygon in Polygons)
            {
                var collision = ray.IntersectTriangle(polygon.VertexA, polygon.VertexB, polygon.VertexC, polygon.Normal);

                if (collision.HasValue)
                {
                    return(new CollisionResult()
                    {
                        Point = collision.Value.Point,
                        Normal = polygon.Normal,
                    });
                }
            }

            return(null);
        }