Esempio n. 1
0
        // public Texture2D texHeight;

        // [HideInInspector] public byte[] treemap;
        // [HideInInspector] public byte[] objectmap;

        public void DisposeTextures()
        {
            TC_Compute.DisposeRenderTexture(ref rtHeight);
            TC_Compute.DisposeTexture(ref texHeight);
            TC_Compute.DisposeTexture(ref texColormap);
            TC_Compute.DisposeTexture(ref texNormalmap);
        }
        public void Capture(int collisionMask, CollisionDirection collisionDirection, int outputId, Vector2 resolution)
        {
            if (TC_Area2D.current.currentTerrainArea == null)
            {
                return;
            }

            bool create = false;

            if (rtCapture == null)
            {
                create = true;
            }
            else if (rtCapture.width != resolution.x || rtCapture.height != resolution.y)
            {
                TC_Compute.DisposeRenderTexture(ref rtCapture);
                create = true;
            }

            if (create)
            {
                rtCapture         = new RenderTexture((int)resolution.x, (int)resolution.y, 16, RenderTextureFormat.Depth, RenderTextureReadWrite.Linear);
                cam.targetTexture = rtCapture;
            }

            // Debug.Log("Capture");
            this.collisionMask = collisionMask;
            terrain            = TC_Area2D.current.currentTerrain;
            // this.collisionDirection = collisionDirection;
            cam.cullingMask = collisionMask;

            SetCamera(collisionDirection, outputId);

            cam.Render();
        }
Esempio n. 3
0
        void DestroyMe()
        {
            TC_Settings settings = TC_Settings.instance;

            if (settings == null)
            {
                return;
            }
            if (settings.imageList == null)
            {
                return;
            }

            int index = settings.imageList.IndexOf(this);

            if (index != -1)
            {
                settings.imageList.RemoveAt(index);
            }

            TC_Compute.DisposeRenderTexture(ref rt);

            #if UNITY_EDITOR
            UnityEditor.Undo.DestroyObjectImmediate(gameObject);
            #else
            Destroy(gameObject);
            #endif
        }
Esempio n. 4
0
        public void SetPreviewTextureAfter()
        {
            if (totalActive == 1)
            {
                TC_Compute.DisposeRenderTexture(ref rtPreview);

                rtDisplay = itemList[firstActive].rtDisplay;
            }
        }
        public void DisposeTextures()
        {
            TC_Compute.DisposeRenderTextures(ref rtSplatmaps);
            TC_Compute.DisposeRenderTexture(ref rtColormap);

            for (int i = 0; i < terrains.Count; i++)
            {
                terrains[i].DisposeTextures();
            }
        }
Esempio n. 6
0
        public void SetPreviewTextureBefore()
        {
            // Debug.Log("no " + maskNodeGroup.itemList.Count + " " + itemList.Count);
            if (totalActive == 0)
            {
                active    = false;
                rtDisplay = null;

                TC_Compute.DisposeRenderTexture(ref rtPreview);
            }
            else if (totalActive != 1)
            {
                TC_Compute.InitPreviewRenderTexture(ref rtPreview, "rtGroupResult");
                rtDisplay = rtPreview;
            }
        }
Esempio n. 7
0
 public void RemoveFromPortalNode()
 {
     if (portalNode == null)
     {
         return;
     }
     if (portalNode.isPortalCount > 0)
     {
         portalNode.isPortalCount--;
         portalNode.usedAsPortalList.Remove(this);
         if (portalNode.isPortalCount == 0)
         {
             TC_Compute.DisposeRenderTexture(ref portalNode.rtPortal);
         }
     }
     else
     {
         portalNode.isPortalCount = 0;
     }
 }
Esempio n. 8
0
 public virtual void DisposeTextures()
 {
     rtDisplay = null;
     TC_Compute.DisposeRenderTexture(ref rtPreview);
 }
Esempio n. 9
0
 public void DisposeRTCapture()
 {
     cam.targetTexture = null;
     TC_Compute.DisposeRenderTexture(ref rtCapture);
 }
Esempio n. 10
0
        public ComputeBuffer ComputeValue(float seedParent)
        {
            TC_Compute compute = TC_Compute.instance;

            if (compute == null)
            {
                Debug.Log("Compute is null");
            }

            ComputeBuffer nodeBuffer  = null;
            ComputeBuffer totalBuffer = null;

            bool inputCurrent;

            if (totalActive > 1)
            {
                InitPreviewRenderTexture(true, name);
            }

            int length = useConstant ? 1 : itemList.Count;

            float seedTotal = seed + seedParent;

            for (int i = 0; i < length; i++)
            {
                TC_Node node = itemList[i] as TC_Node;

                if (node != null)
                {
                    node.Init();

                    if (!node.active)
                    {
                        continue;
                    }

                    if (node.clamp)
                    {
                        // if (node.OutOfBounds()) continue;
                    }

                    inputCurrent = (node.inputKind == InputKind.Current);
                    node.InitPreviewRenderTexture(true, node.name);

                    if (totalBuffer == null && !inputCurrent)
                    {
                        totalBuffer = compute.RunNodeCompute(this, node, seedTotal);
                    }
                    else
                    {
                        if (!inputCurrent)
                        {
                            // Debug.Log(totalBuffer == null);
                            nodeBuffer = compute.RunNodeCompute(this, node, seedTotal, totalBuffer, false);
                        }
                        else
                        {
                            for (int j = 0; j < node.iterations; j++)
                            {
                                totalBuffer = compute.RunNodeCompute(this, node, seedTotal, totalBuffer, true);
                            }
                            // if (preview && totalBuffer != null) { compute.DisposeBuffer(ref totalBuffer); }
                        }

                        // if (preview && nodeBuffer != null) { compute.DisposeBuffer(ref nodeBuffer); }
                    }
                    if (totalBuffer != null && nodeBuffer != null && !inputCurrent)
                    {
                        compute.RunComputeMethod(this, node, totalBuffer, ref nodeBuffer, itemList.Count, i == lastActive ? rtPreview : null);
                    }
                }
                else
                {
                    TC_NodeGroup nodeGroup = itemList[i] as TC_NodeGroup;

                    if (nodeGroup != null)
                    {
                        if (!nodeGroup.active)
                        {
                            continue;
                        }
                        if (totalBuffer == null)
                        {
                            totalBuffer = nodeGroup.ComputeValue(seedTotal);
                        }
                        else
                        {
                            nodeBuffer = nodeGroup.ComputeValue(seedTotal);
                        }

                        if (totalBuffer != null && nodeBuffer != null)
                        {
                            compute.RunComputeMethod(this, nodeGroup, totalBuffer, ref nodeBuffer, itemList.Count, i == lastActive ? rtPreview : null);
                        }
                    }
                }
            }

            if (totalActive == 1)
            {
                TC_Compute.DisposeRenderTexture(ref rtPreview);
                rtDisplay = itemList[firstActive].rtDisplay;
            }

            if (isPortalCount > 0 && totalBuffer != null)
            {
                TC_Compute.instance.MakePortalBuffer(this, totalBuffer);
            }

            return(totalBuffer);
        }
Esempio n. 11
0
 public override void DisposeTextures()
 {
     base.DisposeTextures();
     TC_Compute.DisposeRenderTexture(ref rtColorPreview);
 }