IEnumerator EditorUpdate() { yield return(null); for (int i = 0; i < links.Length; i++) { DiagramMaterialLink link = links[i]; if (link.diagram != null) { int rowIndex = 0, rowCount = 0; link.AllocateTextures(); link.InitBuffers(ref buffers); link.currentDirection = CubemapFace.PositiveX; yield return(null); float previousTime = 0f; while (!link.FillRows(buffers, ref rowIndex, rowCount)) { float now = Time.realtimeSinceStartup; float deltaTime = now - previousTime; previousTime = now; if (rowCount <= 0) { // We took a break or just started. rowCount = 1; } else if (deltaTime < 0.05f) { // We can speed up. rowCount *= 2; } else if (deltaTime > 0.1f) { // Emergency stop. rowCount = 0; } else if (deltaTime > 0.05f) { // Slow down. rowCount /= 2; } yield return(null); } link.PostProcess(buffers); link.ApplyTextures(buffers); link.AssignTexturesToMaterials(); } yield return(null); } }
IEnumerator FillTexturesThreaded() { threadShouldBeWorking = new AutoResetEvent(false); thread = new Thread(FillTextures); thread.IsBackground = true; thread.Start(); for (int i = 0; i < links.Length; i++) { currentLink = links[i]; currentLink.AllocateTextures(); if (currentLink.diagram.isCubemap) { for (CubemapFace d = CubemapFace.PositiveX; d <= CubemapFace.NegativeZ; d++) { currentLink.currentDirection = d; threadFinished = false; threadShouldBeWorking.Set(); while (!threadFinished) { yield return(null); } currentLink.AssignCubemapFaces(buffers); } } else { threadFinished = false; threadShouldBeWorking.Set(); while (!threadFinished) { yield return(null); } } currentLink.ApplyTextures(buffers); currentLink.AssignTexturesToMaterials(); } currentLink = null; threadShouldBeWorking.Set(); FinishGenerating(); }
private IEnumerator FillTexturesThreaded() { threadShouldBeWorking = new AutoResetEvent(false); thread = new Thread(FillTextures); thread.IsBackground = true; thread.Start(); for (int i = 0; i < links.Length; i++) { currentLink = links[i]; currentLink.AllocateTextures(); threadFinished = false; threadShouldBeWorking.Set(); while (!threadFinished) { yield return(null); } currentLink.ApplyTextures(buffers); currentLink.AssignTexturesToMaterials(); } currentLink = null; threadShouldBeWorking.Set(); FinishGenerating(); }
void FillTexturesImmediately() { for (int i = 0; i < links.Length; i++) { DiagramMaterialLink link = links[i]; link.AllocateTextures(); if (link.diagram.isCubemap) { for (CubemapFace d = CubemapFace.PositiveX; d <= CubemapFace.NegativeZ; d++) { link.currentDirection = d; link.Process(ref buffers); link.AssignCubemapFaces(buffers); } } else { link.Process(ref buffers); } link.ApplyTextures(buffers); link.AssignTexturesToMaterials(); } FinishGenerating(); }
private IEnumerator FillTexturesThreaded () { threadShouldBeWorking = new AutoResetEvent(false); thread = new Thread(FillTextures); thread.IsBackground = true; thread.Start(); for (int i = 0; i < links.Length; i++) { currentLink = links[i]; currentLink.AllocateTextures(); threadFinished = false; threadShouldBeWorking.Set(); while (!threadFinished) { yield return null; } currentLink.ApplyTextures(buffers); currentLink.AssignTexturesToMaterials(); } currentLink = null; threadShouldBeWorking.Set(); FinishGenerating(); }