Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
 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();
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
		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();
		}