Exemplo n.º 1
0
        /// <summary>Generates a branch on the native side and returns a <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/> struct that contains a reference to it.</summary>
        /// <param name="userID">A unique id to help identify this particular branch. For instance, this could be an InstanceID to a [UnityEngine.Object](https://docs.unity3d.com/ScriptReference/Object.html)</param>
        /// <param name="children">The child nodes that are children of this branch. A branch may not have duplicate children, contain itself or contain a <see cref="RealtimeCSG.Foundation.CSGTree"/>.</param>
        /// <returns>A new <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>. May be an invalid node if it failed to create it.</returns>
        public static CSGTreeBranch Create(Int32 userID = 0, CSGOperationType operation = CSGOperationType.Additive, params CSGTreeNode[] children)
        {
            int branchNodeID;

            if (!GenerateBranch(userID, out branchNodeID))
            {
                return new CSGTreeBranch()
                       {
                           branchNodeID = 0
                       }
            }
            ;
            if (children != null && children.Length > 0)
            {
                if (operation != CSGOperationType.Additive)
                {
                    SetBranchOperationType(userID, operation);
                }
                if (!CSGTreeNode.SetChildNodes(branchNodeID, children))
                {
                    CSGTreeNode.DestroyNode(branchNodeID);
                    return(new CSGTreeBranch()
                    {
                        branchNodeID = 0
                    });
                }
            }
            return(new CSGTreeBranch()
            {
                branchNodeID = branchNodeID
            });
        }
Exemplo n.º 2
0
        /// <summary>Generates a branch on the native side and returns a <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/> struct that contains a reference to it.</summary>
        /// <param name="userID">A unique id to help identify this particular branch. For instance, this could be an InstanceID to a [UnityEngine.Object](https://docs.unity3d.com/ScriptReference/Object.html)</param>
        /// <param name="children">The child nodes that are children of this branch. A branch may not have duplicate children, contain itself or contain a <see cref="RealtimeCSG.Foundation.CSGTree"/>.</param>
        /// <returns>A new <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>. May be an invalid node if it failed to create it.</returns>
        public static CSGTreeBranch Create(Int32 userID, params CSGTreeNode[] children)
        {
            int branchNodeID;

            if (!GenerateBranch(userID, out branchNodeID))
            {
                return new CSGTreeBranch()
                       {
                           branchNodeID = 0
                       }
            }
            ;
            if (children != null && children.Length > 0)
            {
                if (!CSGTreeNode.SetChildNodes(branchNodeID, children))
                {
                    CSGTreeNode.DestroyNode(branchNodeID);
                    return(new CSGTreeBranch()
                    {
                        branchNodeID = 0
                    });
                }
            }
            return(new CSGTreeBranch()
            {
                branchNodeID = branchNodeID
            });
        }
Exemplo n.º 3
0
        /// <summary>Generates a tree on the native side and returns a <see cref="RealtimeCSG.Foundation.CSGTree"/> struct that contains a reference to it.</summary>
        /// <param name="userID">A unique id to help identify this particular tree. For instance, this could be an InstanceID to a [UnityEngine.Object](https://docs.unity3d.com/ScriptReference/Object.html).</param>
        /// <param name="children">The child nodes that are children of this tree. A tree may not have duplicate children, contain itself or contain a <see cref="RealtimeCSG.Foundation.CSGTree"/>.</param>
        /// <returns>A new <see cref="RealtimeCSG.Foundation.CSGTree"/>. May be an invalid node if it failed to create it.</returns>
        public static CSGTree Create(Int32 userID, params CSGTreeNode[] children)
        {
            int treeNodeID;

            if (!GenerateTree(userID, out treeNodeID))
            {
                return new CSGTree()
                       {
                           treeNodeID = 0
                       }
            }
            ;
            if (children != null && children.Length > 0)
            {
                if (!CSGTreeNode.InsertChildNodeRange(treeNodeID, 0, children))
                {
                    CSGTreeNode.DestroyNode(treeNodeID);
                    return(new CSGTree()
                    {
                        treeNodeID = 0
                    });
                }
            }
            return(new CSGTree()
            {
                treeNodeID = treeNodeID
            });
        }
Exemplo n.º 4
0
 /// <summary>Adds the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s of the specified array to the end of the  <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 /// <param name="array">The array whose <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s should be added to the end of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>. The array itself cannot be null.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool AddRange(CSGTreeNode[] array)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     return(CSGTreeNode.InsertChildNodeRange(branchNodeID, Count, array));
 }
Exemplo n.º 5
0
 /// <summary>Destroy this <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>. Sets the state to invalid.</summary>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool Destroy()
 {
     if (!CSGTreeNode.DestroyNode(treeNodeID))
     {
         return(false);
     }
     treeNodeID = 0; return(true);
 }
Exemplo n.º 6
0
 /// <summary>Inserts the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s of an array into the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> at the specified index.</summary>
 /// <param name="index">The zero-based index at which the new <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s should be inserted.</param>
 /// <param name="array">The array whose <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s should be inserted into the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>. The array itself cannot be null.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool InsertRange(int index, CSGTreeNode[] array)
 {
     if (array == null)
     {
         throw new ArgumentNullException("array");
     }
     return(CSGTreeNode.InsertChildNodeRange(branchNodeID, index, array));
 }
Exemplo n.º 7
0
        private static CSGTreeNode[] GetAllTreeNodes()
        {
            var nodeCount      = GetNodeCount();
            var allTreeNodeIDs = new CSGTreeNode[nodeCount];

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

            GCHandle allNodeIDsHandle = GCHandle.Alloc(allTreeNodeIDs, GCHandleType.Pinned);
            IntPtr   allNodeIDsPtr    = allNodeIDsHandle.AddrOfPinnedObject();

            GetAllTreeNodes(nodeCount, allNodeIDsPtr);
            allNodeIDsHandle.Free();
            return(allTreeNodeIDs);
        }
Exemplo n.º 8
0
        internal static CSGTreeNode[] GetChildNodes(Int32 nodeID)
        {
            var childCount = GetChildNodeCount(nodeID);
            var children   = new CSGTreeNode[childCount];

            if (childCount == 0)
            {
                return(children);
            }

            GCHandle childrenHandle = GCHandle.Alloc(children, GCHandleType.Pinned);
            IntPtr   childrenPtr    = childrenHandle.AddrOfPinnedObject();

            GetChildNodes(nodeID, childCount, childrenPtr, 0);
            childrenHandle.Free();
            return(children);
        }
Exemplo n.º 9
0
 /// <summary>Removes all children from the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 public void Clear()
 {
     CSGTreeNode.ClearChildNodes(branchNodeID);
 }
Exemplo n.º 10
0
 public static bool      ClearDirty(CSGTreeNode node)
 {
     return(ClearDirty(node.NodeID));
 }
Exemplo n.º 11
0
 /// <summary>Destroy this <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>. Sets the state to invalid.</summary>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool     Destroy()
 {
     return(CSGTreeNode.DestroyNode(nodeID));
 }
Exemplo n.º 12
0
 /// <summary>Force set the dirty flag of the <see cref="RealtimeCSG.Foundation.CSGTreeBrush"/>.</summary>
 public void SetDirty()
 {
     CSGTreeNode.SetDirty(nodeID);
 }
Exemplo n.º 13
0
 /// <summary>Copies the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/> to a new array.</summary>
 /// <returns>An array containing the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>s of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</returns>
 public         CSGTreeNode[]    ChildrenToArray()
 {
     return(CSGTreeNode.GetChildNodes(nodeID));
 }
Exemplo n.º 14
0
 /// <summary>Gets child at the specified index.</summary>
 /// <param name="index">The zero-based index of the child to get.</param>
 /// <returns>The element at the specified index.</returns>
 public         CSGTreeNode this[int index] {
     get { return(new CSGTreeNode {
             nodeID = CSGTreeNode.GetChildNodeAtIndex(nodeID, index)
         }); }
 }
Exemplo n.º 15
0
 /// <summary>Copies the immediate children of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/> to an Array, starting at a particular Array index.</summary>
 /// <param name="array">The one-dimensional Array that is the destination of the elements copied from <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>. The Array must have zero-based indexing.</param>
 /// <param name="arrayIndex">The zero-based index in array at which copying begins.</param>
 /// <returns>The number of children copied into <paramref name="array"/>.</returns>
 public int      CopyChildrenTo(CSGTreeNode[] array, int arrayIndex)
 {
     return(CSGTreeNode.CopyTo(branchNodeID, array, arrayIndex));
 }
Exemplo n.º 16
0
 /// <summary>Force set the dirty flag of the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>.</summary>
 public void SetDirty()
 {
     CSGTreeNode.SetDirty(branchNodeID);
 }
Exemplo n.º 17
0
 /// <summary>Determines the index of a specific child in the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 /// <param name="item">The <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> to locate in the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</param>
 /// <returns>The index of <paramref name="item"/> if found in the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>; otherwise, –1.</returns>
 public int  IndexOf(CSGTreeNode item)
 {
     return(CSGTreeNode.IndexOfChildNode(branchNodeID, item.nodeID));
 }
Exemplo n.º 18
0
 /// <summary>Determines whether the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/> contains a specific value.</summary>
 /// <param name="item">The Object to locate in the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</param>
 /// <returns><b>true</b> if item is found in the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>; otherwise, <b>false</b>.</returns>
 public bool Contains(CSGTreeNode item)
 {
     return(CSGTreeNode.IndexOfChildNode(branchNodeID, item.nodeID) != -1);
 }
Exemplo n.º 19
0
 /// <summary>Adds a <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> to the end of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 /// <param name="item">The <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> to be added to the end of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool Add(CSGTreeNode item)
 {
     return(CSGTreeNode.AddChildNode(branchNodeID, item.nodeID));
 }
Exemplo n.º 20
0
 /// <summary>Inserts an element into the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> at the specified index.</summary>
 /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
 /// <param name="item">The <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> to insert.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool Insert(int index, CSGTreeNode item)
 {
     return(CSGTreeNode.InsertChildNode(branchNodeID, index, item.nodeID));
 }
Exemplo n.º 21
0
 /// <summary>Removes a range of children from the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 /// <param name="index">The zero-based starting index of the range of children to remove.</param>
 /// <param name="count">The number of children to remove.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool RemoveRange(int index, int count)
 {
     return(CSGTreeNode.RemoveChildNodeRange(branchNodeID, index, count));
 }
Exemplo n.º 22
0
 /// <summary>Removes the child at the specified index of the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 /// <param name="index">The zero-based index of the child to remove.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool RemoveAt(int index)
 {
     return(CSGTreeNode.RemoveChildNodeAt(branchNodeID, index));
 }
Exemplo n.º 23
0
 /// <summary>Removes a specific <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> from the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary>
 /// <param name="item">The <see cref="RealtimeCSG.Foundation.CSGTreeNode"/> to remove from the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</param>
 /// <returns><b>true</b> on success, <b>false</b> on failure</returns>
 public bool Remove(CSGTreeNode item)
 {
     return(CSGTreeNode.RemoveChildNode(branchNodeID, item.nodeID));
 }