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); }
public void AsyncBuild() { if (!IsBuildFinished() && m_event != null) { // already start building return; } if (m_event == null) { m_event = new ManualResetEvent(false); } m_event.Reset(); PrepareForBuild(); ThreadPool.InitInstance(); ThreadPool.QueueUserWorkItem(arg => ((MeshTreeBase)arg).BuildStart(), this); }
/// <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); }