/// <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 }); }
/// <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 }); }
/// <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 }); }
/// <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)); }
/// <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); }
/// <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)); }
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); }
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); }
/// <summary>Removes all children from the <see cref="RealtimeCSG.Foundation.CSGTreeBranch"/>.</summary> public void Clear() { CSGTreeNode.ClearChildNodes(branchNodeID); }
public static bool ClearDirty(CSGTreeNode node) { return(ClearDirty(node.NodeID)); }
/// <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)); }
/// <summary>Force set the dirty flag of the <see cref="RealtimeCSG.Foundation.CSGTreeBrush"/>.</summary> public void SetDirty() { CSGTreeNode.SetDirty(nodeID); }
/// <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)); }
/// <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) }); } }
/// <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)); }
/// <summary>Force set the dirty flag of the <see cref="RealtimeCSG.Foundation.CSGTreeNode"/>.</summary> public void SetDirty() { CSGTreeNode.SetDirty(branchNodeID); }
/// <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)); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }