示例#1
0
 public void AsyncStart(MeshTreeBase tree)
 {
     if (m_event == null)
     {
         m_event = new ManualResetEvent(false);
     }
     m_event.Reset();
     m_tree = tree;
     ThreadPool.QueueUserWorkItem(s_searchCallback, this);
 }
示例#2
0
 /// <summary>
 ///     Cast a ray against a mesh tree object.
 ///     The return value indicates whether the raycast hit or not.
 ///     After this function is called, you can access "isHit", "hitPosition" and "hitNormal" properties.
 /// </summary>
 /// <param name="tree">A MeshTree object.</param>
 /// <param name="origin">The origin point of the ray in the local space of the mesh object.</param>
 /// <param name="direction">The direction of the ray in the local space of the mesh object.</param>
 /// <param name="distance">The length of the ray.</param>
 /// <param name="cullBackFace">If set to <c>true</c> cull back face.</param>
 public bool Raycast(MeshTreeBase tree, Vector3 origin, Vector3 direction, float distance, bool cullBackFace)
 {
     this.origin = origin;
     distance   *= direction.magnitude;
     direction.Normalize();
     this.direction = direction;
     m_distance     = distance;
     hitDistance    = distance;
     m_cullBackFace = cullBackFace;
     tree.Raycast(this);
     return(isHit);
 }
示例#3
0
 /// <summary>
 ///     Cast a ray against a mesh tree object in a background thread.
 ///     You can wait for the raycast to be done by calling Wait() function.
 ///     Also, you can check if the raycast is done or not by calling IsDone() function.
 ///     Please be noted that "isHit", "hitPosition" and "hitNormal" properties are invalid until the raycast is done
 /// </summary>
 /// <param name="tree">A MeshTree object.</param>
 /// <param name="origin">The origin point of the ray in the local space of the mesh object.</param>
 /// <param name="direction">The direction of the ray in the local space of the mesh object.</param>
 /// <param name="distance">The length of the ray.</param>
 /// <param name="cullBackFace">If set to <c>true</c> cull back face.</param>
 public void AsyncRaycast(MeshTreeBase tree, Vector3 origin, Vector3 direction, float distance, bool cullBackFace)
 {
     if (m_event == null)
     {
         m_event = new ManualResetEvent(false);
     }
     m_event.Reset();
     m_tree    = tree;
     distance *= direction.magnitude;
     direction.Normalize();
     this.origin    = origin;
     this.direction = direction;
     m_distance     = distance;
     hitDistance    = distance;
     m_cullBackFace = cullBackFace;
     ThreadPool.QueueUserWorkItem(s_raycastCallback, this);
 }
示例#4
0
 private void Search()
 {
     try
     {
         m_tree.Search(this);
         m_tree = null;
     }
     catch (Exception e)
     {
         Debug.LogException(e);
         m_event.Set();
         throw e;
     }
     finally
     {
         m_event.Set();
     }
 }
示例#5
0
 private void Raycast()
 {
     try
     {
         m_tree.Raycast(this);
         m_tree = null;
     }
     catch (Exception e)
     {
         if (Debug.isDebugBuild || Application.isEditor)
         {
             Debug.LogException(e);
         }
         throw e;
     }
     finally
     {
         m_event.Set();
     }
 }