Ejemplo n.º 1
0
        /// <summary>
        /// Performs an intersection query on this scene.
        /// </summary>
        /// <param name="ray">The ray structure to use.</param>
        /// <param name="activityMask">The ray activity mask.</param>
        public unsafe void Intersection16(RayStruct16 *ray, uint *activityMask)
        {
            #if DEBUG
            CheckDisposed();

            if (!AlgorithmFlags.HasFlag(AlgorithmFlags.Intersect16))
            {
                throw new InvalidOperationException("AlgorithmFlags.Intersect16 not set.");
            }
            #endif

            RTC.Intersect16(activityMask, NativePtr, ray);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs an intersection test against a packet of 16 rays.
        /// </summary>
        public unsafe RTC.RayPacket16 Intersects16 <Ray>(Ray[] rays, float near = 0, float far = float.PositiveInfinity, float time = 0) where Ray : IEmbreeRay
        {
            #if DEBUG
            if (!traversalFlags.HasFlag(TraversalFlags.Packet16))
            {
                throw new InvalidOperationException("Traversal flags forbid 16-ray packet traversal");
            }
            #endif

            var p = RTC.RayInterop.Packet16;
            var a = RTC.RayInterop.Activity;

            for (var t = 0; t < 16; ++t)
            {
                if (rays[t] != null)
                {
                    a[t] = RTC.RayInterop.Active;
                }
                else
                {
                    a[t] = RTC.RayInterop.Inactive;
                    continue;
                }

                var o = rays[t].Origin;
                var d = rays[t].Direction;

                p->orgX[t] = o.X; p->orgY[t] = o.Y; p->orgZ[t] = o.Z;
                p->dirX[t] = d.X; p->dirY[t] = d.Y; p->dirZ[t] = d.Z;

                p->geomID[t] = RTC.InvalidGeometryID;
                p->primID[t] = RTC.InvalidGeometryID;
                p->instID[t] = RTC.InvalidGeometryID;

                p->time[t]  = time;
                p->tnear[t] = near;
                p->tfar[t]  = far;
            }

            RTC.Intersect16(a, scenePtr, p);

            return(*p);
        }