/// <summary> /// Performs an occlusion test against the specified ray. /// </summary> public unsafe Boolean Occludes <Ray>(Ray ray, float near = 0, float far = float.PositiveInfinity, float time = 0) where Ray : IEmbreeRay { #if DEBUG if (!traversalFlags.HasFlag(TraversalFlags.Single)) { throw new InvalidOperationException("Traversal flags forbid single-ray traversal"); } #endif var o = ray.Origin; var d = ray.Direction; var p = RTC.RayInterop.Packet1; p->orgX = o.X; p->orgY = o.Y; p->orgZ = o.Z; p->dirX = d.X; p->dirY = d.Y; p->dirZ = d.Z; p->geomID = RTC.InvalidGeometryID; p->primID = RTC.InvalidGeometryID; p->instID = RTC.InvalidGeometryID; p->time = time; p->tnear = near; p->tfar = far; RTC.Occluded1(scenePtr, p); return(p->geomID == 0); }
public static IEnumerable <Tuple <String, Action, Func <Double, String> > > Occlusions(Device device, SceneFlags sceneFlags, TraversalFlags traversalFlags, int numPhi, int w, int h) { Func <Double, String> timer = (t) => String.Format("{0:N3} Mrays/s", 1e-6 * w * h / t); using (var scene = new Scene <Sphere>(device, sceneFlags, traversalFlags)) { scene.Add(new Sphere(scene.Device, sceneFlags, traversalFlags, numPhi)); scene.Commit(); if (traversalFlags.HasFlag(TraversalFlags.Single)) { yield return(new Tuple <String, Action, Func <Double, String> >("coherent_occlusion1", () => CoherentOcclusion1(scene, w, h), timer)); } if (traversalFlags.HasFlag(TraversalFlags.Packet4)) { yield return(new Tuple <String, Action, Func <Double, String> >("coherent_occlusion4", () => CoherentOcclusion4(scene, w, h), timer)); } if (traversalFlags.HasFlag(TraversalFlags.Packet8)) { yield return(new Tuple <String, Action, Func <Double, String> >("coherent_occlusion8", () => CoherentOcclusion8(scene, w, h), timer)); } if (traversalFlags.HasFlag(TraversalFlags.Packet16)) { yield return(new Tuple <String, Action, Func <Double, String> >("coherent_occlusion16", () => CoherentOcclusion16(scene, w, h), timer)); } var random = new Random(); var rays = new Ray[w * h]; for (var t = 0; t < w * h; ++t) { rays[t] = new Ray(Vector.Zero, new Vector(2 * (float)random.NextDouble() - 1, 2 * (float)random.NextDouble() - 1, 2 * (float)random.NextDouble() - 1)); } if (traversalFlags.HasFlag(TraversalFlags.Single)) { yield return(new Tuple <String, Action, Func <Double, String> >("incoherent_occlusion1", () => IncoherentOcclusion1(scene, w * h, rays), timer)); } if (traversalFlags.HasFlag(TraversalFlags.Packet4)) { yield return(new Tuple <String, Action, Func <Double, String> >("incoherent_occlusion4", () => IncoherentOcclusion4(scene, w * h, rays), timer)); } if (traversalFlags.HasFlag(TraversalFlags.Packet8)) { yield return(new Tuple <String, Action, Func <Double, String> >("incoherent_occlusion8", () => IncoherentOcclusion8(scene, w * h, rays), timer)); } if (traversalFlags.HasFlag(TraversalFlags.Packet16)) { yield return(new Tuple <String, Action, Func <Double, String> >("incoherent_occlusion16", () => IncoherentOcclusion16(scene, w * h, rays), timer)); } } }
public static IEnumerable<Tuple<String, Action, Func<Double, String>>> Occlusions(SceneFlags sceneFlags, TraversalFlags traversalFlags, int numPhi, int w, int h) { Func<Double, String> timer = (t) => String.Format("{0:N3} Mrays/s", 1e-6 * w * h / t); using (var scene = new Scene<Sphere>(sceneFlags, traversalFlags)) { scene.Add(new Sphere(sceneFlags, traversalFlags, numPhi)); scene.Commit(); if (traversalFlags.HasFlag(TraversalFlags.Single)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion1", () => CoherentOcclusion1(scene, w, h), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet4)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion4", () => CoherentOcclusion4(scene, w, h), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet8)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion8", () => CoherentOcclusion8(scene, w, h), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet16)) yield return new Tuple<String, Action, Func<Double, String>>("coherent_occlusion16", () => CoherentOcclusion16(scene, w, h), timer); var random = new Random(); var rays = new Ray[w * h]; for (var t = 0; t < w * h; ++t) rays[t] = new Ray(Vector.Zero, new Vector(2 * (float)random.NextDouble() - 1, 2 * (float)random.NextDouble() - 1, 2 * (float)random.NextDouble() - 1)); if (traversalFlags.HasFlag(TraversalFlags.Single)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion1", () => IncoherentOcclusion1(scene, w * h, rays), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet4)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion4", () => IncoherentOcclusion4(scene, w * h, rays), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet8)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion8", () => IncoherentOcclusion8(scene, w * h, rays), timer); if (traversalFlags.HasFlag(TraversalFlags.Packet16)) yield return new Tuple<String, Action, Func<Double, String>>("incoherent_occlusion16", () => IncoherentOcclusion16(scene, w * h, rays), timer); } }