public HitInfo(Geometry hitObj, Vector3D hitPoint, Ray ray) { this.hitObj = hitObj; this.hitPoint = hitPoint; this.ray = ray; }
private HitInfo FindHitObject(Ray ray, Geometry originator, HitMode mode) { Vector3D intPoint = new Vector3D(double.MaxValue, double.MaxValue, double.MaxValue); HitInfo info = new HitInfo(null, intPoint, ray); double dist = double.MaxValue; foreach (Geometry geom in Scene.Geoms) { if (geom != originator && geom.Intersects(ray, ref intPoint)) { double distToObj = Vector3D.Subtract(ray.Source, intPoint).Length; if (distToObj < dist) { info.hitPoint = intPoint; dist = distToObj; info.hitObj = geom; if (mode == HitMode.Any) { break; } } } } return info; }