/// <summary> /// This is an expensive operation due to EditMesh construction, avoid. /// </summary> /// <param name="mesh"></param> public NormalVectorGenerator(Mesh mesh) { Debug.Assert(!mesh.PrimitiveType.HasFlag(PrimitiveType.Polygon)); _mesh = mesh; lock (_mesh) { _editMesh = new EditMesh(_mesh); } lock (ThreadPoolMutex) { if (_threadPool != null) return; int cpuCount = Environment.ProcessorCount; // One thread is busy rendering, so many extra threads that do not block on IO // (which our computation-heavy jobs don't) easily starve the GUI. Thus, // always reserve 25% and at least one core. int jobCount = Math.Max(1, (cpuCount * 3) / 4); _threadPool = new SmartThreadPool(1000, jobCount, jobCount); } }
/// <summary> /// This is an expensive operation due to EditMesh construction, avoid. /// </summary> /// <param name="mesh"></param> public NormalVectorGenerator(Mesh mesh) { Debug.Assert(!mesh.PrimitiveType.HasFlag(PrimitiveType.Polygon)); _mesh = mesh; lock (_mesh) { _editMesh = new EditMesh(_mesh); } lock (ThreadPoolMutex) { if (_threadPool != null) { return; } int cpuCount = Environment.ProcessorCount; // One thread is busy rendering, so many extra threads that do not block on IO // (which our computation-heavy jobs don't) easily starve the GUI. Thus, // always reserve 25% and at least one core. int jobCount = Math.Max(1, (cpuCount * 3) / 4); _threadPool = new SmartThreadPool(1000, jobCount, jobCount); } }