コード例 #1
0
        internal static CSGTreeNode DuplicateInternal(CSGTreeNode node)
        {
            switch (node.Type)
            {
            case CSGNodeType.Brush:
            {
                var srcTreeBrush = (CSGTreeBrush)node;
                return(CSGTreeBrush.Create(srcTreeBrush.UserID, srcTreeBrush.LocalTransformation, srcTreeBrush.BrushMesh, srcTreeBrush.Operation, srcTreeBrush.Flags));
            }

            case CSGNodeType.Tree:
            {
                var srcTree = (CSGTree)node;
                return(CSGTree.Create(srcTree.UserID, DuplicateChildNodesInternal(srcTree)));
            }

            case CSGNodeType.Branch:
            {
                var srcTreeBranch = (CSGTreeBranch)node;
                return(CSGTreeBranch.Create(srcTreeBranch.UserID, srcTreeBranch.Operation, DuplicateChildNodesInternal(srcTreeBranch)));
            }

            default:
                throw new NotImplementedException();
            }
        }
コード例 #2
0
 public Data this[CSGTree treeNode]
 {
     get
     {
         if (!chiselTreeLookup.TryGetValue(treeNode, out int dataIndex))
         {
             dataIndex = chiselTreeData.Count;
             chiselTreeLookup[treeNode] = dataIndex;
             chiselTreeData.Add(new Data());
             chiselTreeData[dataIndex].Initialize();
         }
         return(chiselTreeData[dataIndex]);
     }
 }
コード例 #3
0
        public void Remove(CSGTree tree)
        {
            if (!chiselTreeLookup.TryGetValue(tree, out int dataIndex))
            {
                return;
            }

            var data = chiselTreeData[dataIndex];

            data.Dispose();
            // TODO: remove null entry and fix up indices
            chiselTreeData[dataIndex] = default;
            chiselTreeLookup.Remove(tree);
        }
コード例 #4
0
        internal static CSGTreeNode[] DuplicateChildNodesInternal(CSGTree tree)
        {
            var childCount = tree.Count;

            if (childCount == 0)
            {
                return(new CSGTreeNode[0]);
            }
            var duplicateNodes = new CSGTreeNode[childCount];

            for (int i = 0; i < childCount; i++)
            {
                duplicateNodes[i] = DuplicateInternal(tree[i]);
            }
            return(duplicateNodes);
        }
コード例 #5
0
        private static CSGTree[] GetAllTrees()
        {
            var nodeCount = GetTreeCount();
            var allTrees  = new CSGTree[nodeCount];

            if (nodeCount == 0)
            {
                return(allTrees);
            }

            GCHandle allTreeIDsHandle = GCHandle.Alloc(allTrees, GCHandleType.Pinned);
            IntPtr   allTreeIDsPtr    = allTreeIDsHandle.AddrOfPinnedObject();

            GetAllTrees(nodeCount, allTreeIDsPtr);
            allTreeIDsHandle.Free();
            return(allTrees);
        }