public void Branch_AddBrushes_HaveInOrderIndices() { const int brushUserID1 = 10; const int brushUserID2 = 11; const int brushUserID3 = 12; const int branchUserID = 13; var brush1 = CSGTreeBrush.Create(userID: brushUserID1); var brush2 = CSGTreeBrush.Create(userID: brushUserID2); var brush3 = CSGTreeBrush.Create(userID: brushUserID3); var branch = CSGTreeBranch.Create(branchUserID); var result1 = branch.Add(brush1); var result2 = branch.Add(brush2); var result3 = branch.Add(brush3); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(brush3); CompactHierarchyManager.ClearDirty(branch); var index1 = branch.IndexOf(brush1); var index2 = branch.IndexOf(brush2); var index3 = branch.IndexOf(brush3); Assert.AreEqual(0, index1); Assert.AreEqual(1, index2); Assert.AreEqual(2, index3); Assert.IsTrue(result1); Assert.IsTrue(result2); Assert.IsTrue(result3); Assert.IsFalse(branch.Dirty); Assert.IsFalse(brush1.Tree.Valid); Assert.IsFalse(brush2.Tree.Valid); Assert.IsFalse(brush3.Tree.Valid); Assert.AreEqual(3, branch.Count); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush1.Parent); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush2.Parent); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush3.Parent); TestUtility.ExpectValidBrushWithUserID(ref brush1, brushUserID1); TestUtility.ExpectValidBrushWithUserID(ref brush2, brushUserID2); TestUtility.ExpectValidBrushWithUserID(ref brush3, brushUserID3); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); }
public void BranchWithBranch_DestroyBranch_BranchIsEmpty() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2, new CSGTreeNode[] { branch1 }); CompactHierarchyManager.ClearDirty(branch1); CompactHierarchyManager.ClearDirty(branch2); var result = branch1.Destroy(); Assert.IsTrue(result); TestUtility.ExpectInvalidBranch(ref branch1); Assert.IsTrue(branch2.Dirty); Assert.IsFalse(branch1.Valid); Assert.IsFalse(branch2.Parent.Valid); Assert.IsFalse(branch2.Tree.Valid); Assert.AreEqual(0, branch2.Count); }
public void TreeWithChildBranch_Clear_TreeIsEmpty() { const int branchUserID = 10; const int treeUserID = 11; var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID, new CSGTreeNode[] { branch }); CompactHierarchyManager.ClearDirty(branch); CompactHierarchyManager.ClearDirty(tree); tree.Clear(); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.IsTrue(branch.Dirty); Assert.IsTrue(tree.Dirty); Assert.IsFalse(branch.Parent.Valid); Assert.IsFalse(branch.Tree.Valid); Assert.AreEqual(0, branch.Count); Assert.AreEqual(0, tree.Count); }
public void BranchWithBrush_DestroyBrush_BranchIsEmpty() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush }); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); var result = brush.Destroy(); Assert.IsTrue(result); TestUtility.ExpectInvalidBrush(ref brush); Assert.IsTrue(branch.Dirty); Assert.IsFalse(brush.Valid); Assert.IsFalse(branch.Parent.Valid); Assert.IsFalse(branch.Tree.Valid); Assert.AreEqual(0, branch.Count); }
public void Tree_SetChildrenWithTree_DoesNotContainTree() { const int treeUserID1 = 10; const int treeUserID2 = 11; var tree1 = CSGTree.Create(treeUserID1); var tree2 = CSGTree.Create(treeUserID2); CompactHierarchyManager.ClearDirty(tree1); CompactHierarchyManager.ClearDirty(tree2); tree2.InsertRange(0, new CSGTreeNode[] { tree1 }); LogAssert.Expect(LogType.Error, new Regex("Cannot add a tree as a child")); TestUtility.ExpectValidTreeWithUserID(ref tree1, treeUserID1); TestUtility.ExpectValidTreeWithUserID(ref tree2, treeUserID2); Assert.IsFalse(tree1.Dirty); Assert.IsFalse(tree2.Dirty); Assert.AreEqual(0, tree1.Count); Assert.AreEqual(0, tree2.Count); }
public void DestroyBranch_Multiple() { const int branchUserID0 = 10; const int branchUserID1 = 11; const int branchUserID2 = 12; var branch0 = CSGTreeBranch.Create(branchUserID0); var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); CompactHierarchyManager.ClearDirty(branch0); CompactHierarchyManager.ClearDirty(branch1); CompactHierarchyManager.ClearDirty(branch2); var result = DestroyNodes(new CSGTreeNode[] { branch0, branch1, branch2 }); TestUtility.ExpectInvalidBranch(ref branch0); TestUtility.ExpectInvalidBranch(ref branch1); TestUtility.ExpectInvalidBranch(ref branch2); Assert.IsTrue(result); }
public void Branch_SetChildrenWithTree_DoesNotContainTree() { const int treeUserID = 10; const int branchUserID = 11; var tree = CSGTree.Create(treeUserID); var branch = CSGTreeBranch.Create(branchUserID); CompactHierarchyManager.ClearDirty(branch); CompactHierarchyManager.ClearDirty(tree); branch.InsertRange(0, new CSGTreeNode[] { tree }); LogAssert.Expect(LogType.Error, new Regex("Cannot add a tree as a child")); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.IsFalse(branch.Dirty); Assert.IsFalse(tree.Dirty); Assert.AreEqual(0, tree.Count); Assert.AreEqual(0, branch.Count); }
public void DestroyTree_Multiple() { const int treeUserID0 = 10; const int treeUserID1 = 11; const int treeUserID2 = 12; var tree0 = CSGTree.Create(treeUserID0); var tree1 = CSGTree.Create(treeUserID1); var tree2 = CSGTree.Create(treeUserID2); CompactHierarchyManager.ClearDirty(tree0); CompactHierarchyManager.ClearDirty(tree1); CompactHierarchyManager.ClearDirty(tree2); var result = DestroyNodes(new CSGTreeNode[] { tree0, tree1, tree2 }); Assert.IsTrue(result); TestUtility.ExpectInvalidTree(ref tree0); TestUtility.ExpectInvalidTree(ref tree1); TestUtility.ExpectInvalidTree(ref tree2); }
public void Branch_SetChildrenWithBrush_ContainsBrush() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); branch.InsertRange(0, new CSGTreeNode[] { brush }); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.IsTrue(brush.Dirty); Assert.IsTrue(branch.Dirty); Assert.IsFalse(brush.Tree.Valid); Assert.AreEqual(1, branch.Count); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush.Parent); }
public void TreeWithAChild_InsertRangeWithBrushesAtStart_TreeContainsBrushesInOrder() { const int brushUserID1 = 10; const int brushUserID2 = 11; const int brushUserID3 = 12; const int treeUserID = 13; var brush1 = CSGTreeBrush.Create(userID: brushUserID1, dummyBrushMeshInstance); var brush2 = CSGTreeBrush.Create(userID: brushUserID2, dummyBrushMeshInstance); var brush3 = CSGTreeBrush.Create(userID: brushUserID3, dummyBrushMeshInstance); var tree = CSGTree.Create(treeUserID, new CSGTreeNode[] { brush3 }); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(brush3); CompactHierarchyManager.ClearDirty(tree); var result = tree.InsertRange(0, new CSGTreeNode[] { brush1, brush2 }); Assert.IsTrue(result); Assert.IsTrue(tree.Dirty); Assert.IsTrue(brush1.Dirty); Assert.IsTrue(brush2.Dirty); Assert.IsFalse(brush3.Dirty); Assert.AreEqual(3, tree.Count); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush1.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush1.Tree); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush2.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush2.Tree); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush3.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush3.Tree); Assert.AreEqual((CSGTreeNode)brush1, (CSGTreeNode)tree[0]); Assert.AreEqual((CSGTreeNode)brush2, (CSGTreeNode)tree[1]); Assert.AreEqual((CSGTreeNode)brush3, (CSGTreeNode)tree[2]); TestUtility.ExpectValidBrushWithUserID(ref brush1, brushUserID1); TestUtility.ExpectValidBrushWithUserID(ref brush2, brushUserID2); TestUtility.ExpectValidBrushWithUserID(ref brush3, brushUserID3); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); }
public void Brush_SetCSGType_GetCSGTypeIsSame() { var brush1 = CSGTreeBrush.Create(); var brush2 = CSGTreeBrush.Create(); var brush3 = CSGTreeBrush.Create(); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(brush3); brush1.Operation = CSGOperationType.Additive; brush2.Operation = CSGOperationType.Subtractive; brush3.Operation = CSGOperationType.Intersecting; Assert.AreEqual(CSGOperationType.Additive, brush1.Operation); Assert.AreEqual(CSGOperationType.Subtractive, brush2.Operation); Assert.AreEqual(CSGOperationType.Intersecting, brush3.Operation); Assert.IsFalse(brush1.Dirty); Assert.IsTrue(brush2.Dirty); Assert.IsTrue(brush3.Dirty); }
public void Tree_IndexOfNonChildBrush_IsMinusOne() { const int brushUserID1 = 10; const int brushUserID2 = 11; const int brushUserID3 = 12; const int treeUserID = 13; var brush1 = CSGTreeBrush.Create(userID: brushUserID1); var brush2 = CSGTreeBrush.Create(userID: brushUserID2); var brush3 = CSGTreeBrush.Create(userID: brushUserID3); var tree = CSGTree.Create(treeUserID); tree.Add(brush1); tree.Add(brush2); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(tree); var index = tree.IndexOf(brush3); Assert.AreEqual(-1, index); }
public void BranchWithSingleChild_RemoveLastNode_IsEmptyBranch() { const int branchUserID = 10; const int brushUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush }); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); var result = branch.RemoveAt(0); Assert.IsTrue(result); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); Assert.IsTrue(brush.Dirty); Assert.IsTrue(branch.Dirty); Assert.IsFalse(brush.Parent.Valid); Assert.IsFalse(brush.Tree.Valid); Assert.AreEqual(0, branch.Count); }
public void Branch_InsertTree_ReturnsFalse() { const int branchUserID = 10; const int treeUserID = 11; var tree = CSGTree.Create(treeUserID); var branch = CSGTreeBranch.Create(branchUserID); CompactHierarchyManager.ClearDirty(tree); CompactHierarchyManager.ClearDirty(branch); var result = branch.Insert(0, tree); LogAssert.Expect(LogType.Error, new Regex("Cannot add a tree as a child")); Assert.IsFalse(result); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.IsFalse(tree.Dirty); Assert.IsFalse(branch.Dirty); Assert.AreEqual(0, branch.Count); }
public void TreeWithBranch_DestroyBranch_TreeIsEmpty() { const int branchUserID = 10; const int treeUserID = 11; var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); tree.InsertRange(0, new CSGTreeNode[] { branch }); Assume.That(tree.Count, Is.EqualTo(1)); Assume.That((CSGTreeNode)branch.Parent, Is.EqualTo((CSGTreeNode)tree)); CompactHierarchyManager.ClearDirty(branch); CompactHierarchyManager.ClearDirty(tree); var result = branch.Destroy(); Assert.IsTrue(result); TestUtility.ExpectInvalidBranch(ref branch); Assert.IsTrue(tree.Dirty); Assert.IsFalse(branch.Valid); Assert.AreEqual(0, tree.Count); }
public void Branch_InsertBrush_ContainsBrush() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID, dummyBrushMeshInstance); var branch = CSGTreeBranch.Create(branchUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); var result = branch.Insert(0, brush); Assert.IsTrue(result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.IsTrue(brush.Dirty); Assert.IsTrue(branch.Dirty); Assert.IsFalse(brush.Tree.Valid); Assert.AreEqual(1, branch.Count); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush.Parent); }
public void Tree_SetChildrenWithBranch_ContainsBranch() { const int branchUserID = 10; const int treeUserID = 11; var branch = CSGTreeBranch.Create(branchUserID); var tree = CSGTree.Create(treeUserID); CompactHierarchyManager.ClearDirty(branch); CompactHierarchyManager.ClearDirty(tree); tree.InsertRange(0, new CSGTreeNode[] { branch }); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.IsTrue(branch.Dirty); Assert.IsTrue(tree.Dirty); Assert.AreEqual(0, branch.Count); Assert.AreEqual(1, tree.Count); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)branch.Tree); }
public void BranchWithThreeChildren_RemoveWithNegativeIndex_ReturnsFalse() { const int branchUserID = 10; const int brushUserID1 = 11; const int brushUserID2 = 12; const int brushUserID3 = 12; var brush1 = CSGTreeBrush.Create(userID: brushUserID1); var brush2 = CSGTreeBrush.Create(userID: brushUserID2); var brush3 = CSGTreeBrush.Create(userID: brushUserID3); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush1, brush2, brush3 }); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(brush3); CompactHierarchyManager.ClearDirty(branch); var result = branch.RemoveAt(-1); LogAssert.Expect(LogType.Error, new Regex("must be between")); Assert.IsFalse(result); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); TestUtility.ExpectValidBrushWithUserID(ref brush1, brushUserID1); TestUtility.ExpectValidBrushWithUserID(ref brush2, brushUserID2); TestUtility.ExpectValidBrushWithUserID(ref brush3, brushUserID3); Assert.IsFalse(brush1.Dirty); Assert.IsFalse(brush2.Dirty); Assert.IsFalse(brush3.Dirty); Assert.IsFalse(branch.Dirty); Assert.IsFalse(brush1.Tree.Valid); Assert.IsFalse(brush2.Tree.Valid); Assert.IsFalse(brush3.Tree.Valid); Assert.AreEqual(3, branch.Count); Assert.AreEqual((CSGTreeNode)brush1, (CSGTreeNode)branch[0]); Assert.AreEqual((CSGTreeNode)brush2, (CSGTreeNode)branch[1]); Assert.AreEqual((CSGTreeNode)brush3, (CSGTreeNode)branch[2]); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush1.Parent); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush2.Parent); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush3.Parent); }
public void Tree_RemoveUnknownBrush_ReturnsFalse() { const int brushUserID = 10; const int treeUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var tree = CSGTree.Create(treeUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(tree); var result = tree.Remove(brush); Assert.IsFalse(result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); Assert.IsFalse(TestUtility.IsInTree(tree, brush)); Assert.IsFalse(tree.Dirty); Assert.IsFalse(brush.Dirty); Assert.IsFalse(brush.Parent.Valid); Assert.IsFalse(brush.Tree.Valid); Assert.AreEqual(0, TestUtility.CountOfBrushesInTree(tree)); Assert.AreEqual(0, tree.Count); }
public void TreeWithNoChildren_InsertRangeWithTree_TreeStaysEmpty() { const int treeUserID1 = 13; const int treeUserID2 = 14; var tree1 = CSGTree.Create(treeUserID1); var tree2 = CSGTree.Create(treeUserID2); CompactHierarchyManager.ClearDirty(tree1); CompactHierarchyManager.ClearDirty(tree2); var result = tree1.InsertRange(0, new CSGTreeNode[] { tree2 }); LogAssert.Expect(LogType.Error, new Regex("Cannot add a tree as a child")); Assert.IsFalse(result); TestUtility.ExpectValidTreeWithUserID(ref tree1, treeUserID1); TestUtility.ExpectValidTreeWithUserID(ref tree2, treeUserID2); Assert.IsFalse(tree1.Dirty); Assert.IsFalse(tree2.Dirty); Assert.AreEqual(0, tree1.Count); Assert.AreEqual(0, tree2.Count); }
public void Branch_RemoveUnknownBrush_ReturnsFalse() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var branch = CSGTreeBranch.Create(branchUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); var result = branch.Remove(brush); Assert.IsFalse(result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); Assert.IsFalse(brush.Dirty); Assert.IsFalse(branch.Dirty); Assert.IsFalse(brush.Parent.Valid); Assert.IsFalse(brush.Tree.Valid); Assert.IsFalse(branch.Parent.Valid); Assert.IsFalse(branch.Tree.Valid); Assert.AreEqual(0, branch.Count); }
public void Tree_AddBrush_ContainsBrush() { const int brushUserID = 10; const int treeUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID); var tree = CSGTree.Create(treeUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(tree); var result = tree.Add(brush); Assert.IsTrue(result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidTreeWithUserID(ref tree, treeUserID); Assert.IsTrue(tree.Dirty); Assert.IsTrue(brush.Dirty); Assert.IsTrue(TestUtility.IsInTree(tree, brush)); Assert.AreEqual(1, tree.Count); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush.Parent); Assert.AreEqual((CSGTreeNode)tree, (CSGTreeNode)brush.Tree); }
public void Tree_AddTree_ReturnsFalse() { const int treeUserID1 = 10; const int treeUserID2 = 11; var tree1 = CSGTree.Create(treeUserID1); var tree2 = CSGTree.Create(treeUserID2); CompactHierarchyManager.ClearDirty(tree1); CompactHierarchyManager.ClearDirty(tree2); var result = tree1.Add(tree2); LogAssert.Expect(LogType.Error, "Cannot add a tree as a child"); Assert.IsFalse(result); TestUtility.ExpectValidTreeWithUserID(ref tree1, treeUserID1); TestUtility.ExpectValidTreeWithUserID(ref tree2, treeUserID2); Assert.IsFalse(tree1.Dirty); Assert.IsFalse(tree2.Dirty); Assert.AreEqual(0, tree1.Count); Assert.AreEqual(0, tree2.Count); }
public void BranchWithChildBrushes_RemoveMiddleBrush_OtherBrushesRemain() { const int brushUserID1 = 10; const int brushUserID2 = 11; const int brushUserID3 = 12; const int branchUserID = 13; var brush1 = CSGTreeBrush.Create(userID: brushUserID1); var brush2 = CSGTreeBrush.Create(userID: brushUserID2); var brush3 = CSGTreeBrush.Create(userID: brushUserID3); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush1, brush2, brush3 }); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(brush3); CompactHierarchyManager.ClearDirty(branch); var result = branch.Remove(brush2); Assert.IsTrue(result); TestUtility.ExpectValidBrushWithUserID(ref brush1, brushUserID1); TestUtility.ExpectValidBrushWithUserID(ref brush2, brushUserID2); TestUtility.ExpectValidBrushWithUserID(ref brush3, brushUserID3); Assert.IsFalse(brush1.Dirty); Assert.IsTrue(brush2.Dirty); Assert.IsFalse(brush3.Dirty); Assert.IsTrue(branch.Dirty); Assert.IsFalse(brush1.Tree.Valid); Assert.IsFalse(brush3.Tree.Valid); Assert.IsFalse(brush2.Parent.Valid); Assert.IsFalse(brush2.Tree.Valid); Assert.IsFalse(branch.Parent.Valid); Assert.IsFalse(branch.Tree.Valid); Assert.AreEqual(2, branch.Count); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush1.Parent); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush3.Parent); Assert.AreEqual((CSGTreeNode)brush1, (CSGTreeNode)branch[0]); Assert.AreEqual((CSGTreeNode)brush3, (CSGTreeNode)branch[1]); }
public void Tree_InsertChildBrushOfOtherBranch_MovesBrushToBranch() { const int brushUserID = 10; const int treeUserID1 = 11; const int treeUserID2 = 12; const int branchUserID2 = 14; var brush = CSGTreeBrush.Create(userID: brushUserID, dummyBrushMeshInstance); var branch2 = CSGTreeBranch.Create(branchUserID2); var tree2 = CSGTree.Create(treeUserID2, new CSGTreeNode[] { branch2 }); var tree1 = CSGTree.Create(treeUserID1, new CSGTreeNode[] { brush }); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch2); CompactHierarchyManager.ClearDirty(tree1); CompactHierarchyManager.ClearDirty(tree2); var result = branch2.Insert(0, brush); Assert.IsTrue(result); Assert.IsTrue(brush.Dirty); Assert.IsTrue(branch2.Dirty); Assert.IsTrue(tree1.Dirty); Assert.IsTrue(tree2.Dirty); Assert.IsFalse(TestUtility.IsInTree(tree1, brush)); Assert.IsTrue(TestUtility.IsInTree(tree2, brush)); Assert.AreEqual(0, TestUtility.CountOfBrushesInTree(tree1)); Assert.AreEqual(1, TestUtility.CountOfBrushesInTree(tree2)); Assert.AreEqual(0, tree1.Count); Assert.AreEqual(1, branch2.Count); Assert.AreEqual((CSGTreeNode)branch2, (CSGTreeNode)brush.Parent); Assert.AreEqual((CSGTreeNode)tree2, (CSGTreeNode)brush.Tree); Assert.AreEqual((CSGTreeNode)tree2, (CSGTreeNode)branch2.Tree); Assert.AreEqual((CSGTreeNode)tree2, (CSGTreeNode)branch2.Parent); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); TestUtility.ExpectValidTreeWithUserID(ref tree1, treeUserID1); TestUtility.ExpectValidTreeWithUserID(ref tree2, treeUserID2); }
public void Branch_InsertBrushAtZero_HasBrushInFront() { const int brushUserID1 = 10; const int brushUserID2 = 11; const int brushUserID3 = 12; const int branchUserID = 13; var brush1 = CSGTreeBrush.Create(userID: brushUserID1, dummyBrushMeshInstance); var brush2 = CSGTreeBrush.Create(userID: brushUserID2, dummyBrushMeshInstance); var brush3 = CSGTreeBrush.Create(userID: brushUserID3, dummyBrushMeshInstance); var branch = CSGTreeBranch.Create(branchUserID, new CSGTreeNode[] { brush1, brush2 }); CompactHierarchyManager.ClearDirty(brush1); CompactHierarchyManager.ClearDirty(brush2); CompactHierarchyManager.ClearDirty(brush3); CompactHierarchyManager.ClearDirty(branch); var result = branch.Insert(0, brush3); Assert.IsTrue(result); TestUtility.ExpectValidBrushWithUserID(ref brush1, brushUserID1); TestUtility.ExpectValidBrushWithUserID(ref brush2, brushUserID2); TestUtility.ExpectValidBrushWithUserID(ref brush3, brushUserID3); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.IsTrue(branch.Dirty); Assert.IsFalse(brush1.Dirty); Assert.IsFalse(brush2.Dirty); Assert.IsTrue(brush3.Dirty); Assert.IsFalse(brush1.Tree.Valid); Assert.IsFalse(brush2.Tree.Valid); Assert.IsFalse(brush3.Tree.Valid); Assert.AreEqual(3, branch.Count); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush1.Parent); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush2.Parent); Assert.AreEqual((CSGTreeNode)branch, (CSGTreeNode)brush3.Parent); Assert.AreEqual((CSGTreeNode)brush3, (CSGTreeNode)branch[0]); Assert.AreEqual((CSGTreeNode)brush1, (CSGTreeNode)branch[1]); Assert.AreEqual((CSGTreeNode)brush2, (CSGTreeNode)branch[2]); }
public void Branch_InsertBrushNegativeIndex_ReturnsFalse() { const int brushUserID = 10; const int branchUserID = 11; var brush = CSGTreeBrush.Create(userID: brushUserID, dummyBrushMeshInstance); var branch = CSGTreeBranch.Create(branchUserID); CompactHierarchyManager.ClearDirty(brush); CompactHierarchyManager.ClearDirty(branch); var result = branch.Insert(-1, brush); LogAssert.Expect(LogType.Error, new Regex("index is invalid")); Assert.IsFalse(result); TestUtility.ExpectValidBrushWithUserID(ref brush, brushUserID); TestUtility.ExpectValidBranchWithUserID(ref branch, branchUserID); Assert.IsFalse(brush.Dirty); Assert.IsFalse(branch.Dirty); Assert.IsFalse(brush.Parent.Valid); Assert.IsFalse(brush.Tree.Valid); Assert.AreEqual(0, branch.Count); }
public static void UpdateModels() { // Update the tree meshes Profiler.BeginSample("Flush"); try { if (!CompactHierarchyManager.Flush(s_FinishMeshUpdates)) { ChiselGeneratedComponentManager.DelayedUVGeneration(); return; // Nothing to update .. } } finally { Profiler.EndSample(); } { Profiler.BeginSample("PostUpdateModels"); PostUpdateModels?.Invoke(); Profiler.EndSample(); } }
public void CompactHierarchyManager_RecycleID_EverythingWorksFine() { var oldNodeID = CompactHierarchyManager.CreateBranch(); var oldCompactNodeID = CompactHierarchyManager.GetCompactNodeID(oldNodeID); CompactHierarchyManager.CheckConsistency(); CompactHierarchyManager.DestroyNode(oldNodeID); var newNodeID = CompactHierarchyManager.CreateBranch(); var newCompactNodeID = CompactHierarchyManager.GetCompactNodeID(newNodeID); Assume.That(newNodeID.value, Is.EqualTo(oldNodeID.value)); Assume.That(newNodeID.generation, Is.EqualTo(oldNodeID.generation + 1)); Assume.That(newCompactNodeID.value, Is.EqualTo(oldCompactNodeID.value)); Assume.That(newCompactNodeID.generation, Is.EqualTo(oldCompactNodeID.generation + 1)); Assert.AreEqual((true, true, false, false), (CompactHierarchyManager.IsValidNodeID(newNodeID), CompactHierarchyManager.IsValidCompactNodeID(newCompactNodeID), CompactHierarchyManager.IsValidNodeID(oldNodeID), CompactHierarchyManager.IsValidCompactNodeID(oldCompactNodeID))); CompactHierarchyManager.CheckConsistency(); }
public void Branch_SetChildrenWithBranch_ContainsBranch() { const int branchUserID1 = 10; const int branchUserID2 = 11; var branch1 = CSGTreeBranch.Create(branchUserID1); var branch2 = CSGTreeBranch.Create(branchUserID2); CompactHierarchyManager.ClearDirty(branch1); CompactHierarchyManager.ClearDirty(branch2); branch2.InsertRange(0, new CSGTreeNode[] { branch1 }); TestUtility.ExpectValidBranchWithUserID(ref branch1, branchUserID1); TestUtility.ExpectValidBranchWithUserID(ref branch2, branchUserID2); Assert.IsTrue(branch1.Dirty); Assert.IsTrue(branch2.Dirty); Assert.IsFalse(branch1.Tree.Valid); Assert.IsFalse(branch2.Parent.Valid); Assert.IsFalse(branch2.Tree.Valid); Assert.AreEqual(0, branch1.Count); Assert.AreEqual(1, branch2.Count); Assert.AreEqual((CSGTreeNode)branch2, (CSGTreeNode)branch1.Parent); }