void CreateThreadMode() { if (m_CellArray == null || m_CellArray.Length <= 0 || m_BoundsArray == null || m_BoundsArray.Length <= 0 || m_CellsResult == null || m_CellsResult.Length <= 0) { Debug.LogError("数据不足"); return; } int itemCount = Mathf.CeilToInt(((float)m_CellArray.Length) / ((float)PVSBakerThread.MaxThreadCount)); int idx = 0; m_CpuThreadRuning = true; while (idx < m_CellArray.Length) { int cnt = System.Math.Min(itemCount, (m_CellArray.Length - idx)); var thread = new PVSBakerThread(m_CellArray, m_CellsResult, m_BoundsArray, idx, idx + cnt - 1, m_TargetCamInfo, m_IsCamOri); if (m_BakerThreads == null) { m_BakerThreads = new List <PVSBakerThread> (); } m_BakerThreads.Add(thread); thread.Start(); idx += itemCount; } }
void DrawSelCellLines() { if (m_SelCellResult < 0 || m_CellsResult == null || m_CellsResult.Length <= 0 || m_SelCellResult >= m_CellsResult.Length) { return; } if (m_BakerMode == PVSSceneBakerMode.CameraRTComputeMode || m_BakerMode == PVSSceneBakerMode.CameraRTCpuMode) { return; } var cell = m_CellsResult[m_SelCellResult]; if (cell == null) { return; } Vector3 right = m_TargetCamInfo.right; Vector3 up = m_TargetCamInfo.up; Vector3 lookAt = m_TargetCamInfo.lookAt; Handles.color = Color.blue; if (m_IsCamOri) { var width = m_TargetCamInfo.CameraWidth; var height = m_TargetCamInfo.CameraHeight; float perX = PVSBakerThread.GetPerX(width); float perY = PVSBakerThread.GetPerY(height); Vector3 halfV = (right * width / 2.0f + up * height / 2.0f); Vector3 minVec = cell.position - halfV; float stepY = 0; while (stepY <= height) { Vector3 yy = stepY * up; float stepX = 0; while (stepX <= width) { Vector3 startPt = minVec + stepX * right + yy + lookAt * m_TargetCamInfo.near; Ray ray = new Ray(startPt, lookAt); Handles.DrawLine(startPt, startPt + lookAt * (m_TargetCamInfo.far - m_TargetCamInfo.near)); stepX += perX; } stepY += perY; } } else { var width = m_TargetCamInfo.farWidth; var height = m_TargetCamInfo.farHeight; float perX = PVSBakerThread.GetPerX(width); float perY = PVSBakerThread.GetPerY(height); Vector3 halfV = (right * width / 2.0f + up * height / 2.0f); Vector3 minVec = cell.position - halfV; float d = m_TargetCamInfo.far; float stepY = 0; while (stepY < height) { Vector3 yy = stepY * up; float stepX = 0; while (stepX < width) { Vector3 endPt = minVec + stepX * right + yy + lookAt * d; Vector3 dir = (endPt - m_TargetCamInfo.position).normalized; Ray ray = new Ray(m_TargetCamInfo.position, dir); Handles.DrawLine(ray.origin, ray.origin + dir * m_TargetCamInfo.far); stepX += perX; } stepY += perY; } } }