示例#1
0
        public Vector3[] GetCollisions(Ray ray, Matrix transform)
        {
            var results = new List <Vector3>(1);

            foreach (var face in _faces)
            {
                var v0 = Vector3.Transform(face[0], transform);
                var v1 = Vector3.Transform(face[1], transform);
                var v2 = Vector3.Transform(face[2], transform);
                var(hit, pos) = CollisionMath.CollideTri(
                    ray,
                    v0,
                    v1,
                    v2
                    );
                //Console.WriteLine($"Faces: ({face[0]}), ({face[1]}), ({face[2]})");
                //Console.WriteLine($"Pos: {ray.Position}  Direction: {ray.Direction}");
                if (hit)
                {
                    //Console.WriteLine($"hit {v0} {v1} {v2}       {pos}");

                    results.Add(pos);
                }
            }
            return(results.ToArray());
        }