/// <summary>
			/// Pushes a culler onto the pre-culling stack (pre-culling cull tests occurs <i>before</i> the default onscreen Culler). Fast cull operations are usually added here
			/// </summary>
			public UsingPreCuller PushPreCuller(ICullPrimitive culler)
			{
				if (culler == null)
					throw new ArgumentNullException();
				state.preCullers[state.preCullerCount++] = culler;
				return PreCuller;
			}
		/// <summary>
		/// <para>Query the partition, returning instances that may potentially intersect the primitive</para>
		/// </summary>
		/// <param name="queryShape"></param>
		/// <param name="resultCallback">Callback for results. Return true to continue the query</param>
		public void Query(ICullPrimitive queryShape, Func<IDraw, bool> resultCallback)
		{
			if (RunQuery(queryBox, resultCallback))
				foreach (IDraw item in addList)
					if (!resultCallback(item))
						return;
		}
        /// <summary>
        /// Query the partition, returning all instances that intersect the primitive
        /// </summary>
        /// <param name="queryShape"></param>
        /// <param name="resultCallback">Callback for results. Return true to continue the query</param>
        protected override bool RunQuery(ICullPrimitive queryShape, Callback <bool, IDraw> resultCallback)
        {
            minBuffer[0] = this.boundsMin.X;
            minBuffer[1] = this.boundsMin.Y;
            minBuffer[2] = this.boundsMin.Z;

            maxBuffer[0] = this.boundsMax.X;
            maxBuffer[1] = this.boundsMax.Y;
            maxBuffer[2] = this.boundsMax.Z;

            return(allNodes[0].Query(queryShape, resultCallback, minBuffer, maxBuffer, 0, this.allChildren, this.allNodes));
        }
Beispiel #4
0
 /// <summary>
 /// <para>Query the partition, returning instances that may potentially intersect the primitive</para>
 /// </summary>
 /// <param name="queryShape"></param>
 /// <param name="resultCallback">Callback for results. Return true to continue the query</param>
 public void Query(ICullPrimitive queryShape, Callback <bool, IDraw> resultCallback)
 {
     if (RunQuery(queryBox, resultCallback))
     {
         foreach (IDraw item in addList)
         {
             if (!resultCallback(item))
             {
                 return;
             }
         }
     }
 }
		/// <summary>
		/// Query the partition, returning all instances that intersect the primitive
		/// </summary>
		/// <param name="queryShape"></param>
		/// <param name="resultCallback">Callback for results. Return true to continue the query</param>
		protected abstract bool RunQuery(ICullPrimitive queryShape, Func<IDraw, bool> resultCallback);
Beispiel #6
0
 /// <summary>
 /// Query the partition, returning all instances that intersect the primitive
 /// </summary>
 /// <param name="queryShape"></param>
 /// <param name="resultCallback">Callback for results. Return true to continue the query</param>
 protected abstract bool RunQuery(ICullPrimitive queryShape, Callback <bool, IDraw> resultCallback);
            //query with culling
            public bool Query(ICullPrimitive cull, Callback <bool, IDraw> callback, float[] boundsMin, float[] boundsMax, int axis, IDraw[] children, BinaryNode[] nodes)
            {
                boundsMin[axis] = min;
                boundsMax[axis] = max;

                Vector3 localMin = new Vector3(), localMax = new Vector3();

                localMin.X = boundsMin[0];
                localMin.Y = boundsMin[1];
                localMin.Z = boundsMin[2];

                localMax.X = boundsMax[0];
                localMax.Y = boundsMax[1];
                localMax.Z = boundsMax[2];

                switch (cull.IntersectWorldBox(ref localMin, ref localMax))
                {
                case ContainmentType.Contains:
                    return(Query(callback, children, nodes));

                case ContainmentType.Intersects:
                    if (left == 0)
                    {
                        uint child = firstChild;
                        child <<= ChildCountShift;

                        for (ushort i = 0; i < childCount; i++)
                        {
                            if (!callback(children[child++]))
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        if (!nodes[left].Query(cull, callback, boundsMin, boundsMax, axis == 2 ? 0 : axis + 1, children, nodes))
                        {
                            return(false);
                        }

                        boundsMin[0] = localMin.X;
                        boundsMin[1] = localMin.Y;
                        boundsMin[2] = localMin.Z;

                        boundsMax[0] = localMax.X;
                        boundsMax[1] = localMax.Y;
                        boundsMax[2] = localMax.Z;

                        if (!nodes[right].Query(cull, callback, boundsMin, boundsMax, axis == 2 ? 0 : axis + 1, children, nodes))
                        {
                            return(false);
                        }

                        boundsMin[0] = localMin.X;
                        boundsMin[1] = localMin.Y;
                        boundsMin[2] = localMin.Z;

                        boundsMax[0] = localMax.X;
                        boundsMax[1] = localMax.Y;
                        boundsMax[2] = localMax.Z;
                    }
                    break;
                }
                return(true);
            }