/// <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 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 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>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>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)); }