コード例 #1
0
        public override void RecalculateIntersections()
        {
            CSGModelBase csgModel = GetCSGModel();

            if (csgModel != null)
            {
                List <Brush> brushes = GetCSGModel().GetBrushes();

                // Tracked brushes at edit time can be added in any order, so sort them
                IComparer <Brush> comparer = new BrushOrderComparer();
                for (int i = 0; i < brushes.Count; i++)
                {
                    if (brushes[i] == null)
                    {
                        brushes.RemoveAt(i);
                        i--;
                    }
                }

                for (int i = 0; i < brushes.Count; i++)
                {
                    brushes[i].UpdateCachedBrushOrder();
                }

                brushes.Sort(comparer);

                RecalculateIntersections(brushes, true);
            }
        }
コード例 #2
0
        void UpdateTracking()
        {
            CSGModelBase parentCSGModel = GetCSGModel();

            // Make sure the CSG Model knows about this brush. If they duplicated a brush in the hierarchy then this
            // allows us to make sure the CSG Model knows about it
            if (parentCSGModel != null)
            {
                bool newBrush = parentCSGModel.TrackBrush(this);

                if (newBrush)
                {
                    MeshFilter meshFilter = gameObject.AddOrGetComponent <MeshFilter>();

                    meshFilter.sharedMesh = new Mesh();
                    brushCache            = new BrushCache();
                    EnsureWellFormed();
                    RecalculateBrushCache();
                }
                Invalidate(false);
                tracked = true;
            }
            else
            {
                tracked = false;
            }
        }
コード例 #3
0
 /// <summary>
 /// Get the CSG Model that the brush is under
 /// </summary>
 /// <returns>The CSG Model.</returns>
 public CSGModelBase GetCSGModel()
 {
     if (parentCsgModel == null)
     {
         CSGModelBase[] models = transform.GetComponentsInParent <CSGModelBase>(true);
         if (models.Length > 0)
         {
             parentCsgModel = models[0];
         }
     }
     return(parentCsgModel);
 }
コード例 #4
0
        public override void UpdateVisibility()
        {
            // Display brush if the CSG Model says to or if the brush isn't under a CSG Model
            CSGModelBase csgModel  = GetCSGModel();
            bool         isVisible = false;

            if (csgModel == null || csgModel.AreBrushesVisible)
            {
                isVisible = true;
            }
            MeshRenderer meshRenderer = GetComponent <MeshRenderer>();

            if (meshRenderer != null)
            {
                meshRenderer.enabled = isVisible && !CurrentSettings.ShowBrushesAsWireframes;
            }
        }
コード例 #5
0
ファイル: PrimitiveBrush.cs プロジェクト: vrum/SabreCSG
        public override void UpdateVisibility()
        {
            // Display brush if the CSG Model says to or if the brush isn't under a CSG Model
            CSGModelBase csgModel  = GetCSGModel();
            bool         isVisible = false;

            if (csgModel == null || csgModel.AreBrushesVisible)
            {
                isVisible = true;
            }
            MeshRenderer meshRenderer = GetComponent <MeshRenderer>();

            if (meshRenderer != null)
            {
#if UNITY_EDITOR
                meshRenderer.enabled = mode == CSGMode.Volume || isVisible;
#else
                meshRenderer.enabled = isVisible;
#endif
            }
        }