Пример #1
0
        public void TestBuildNodesParents()
        {
            var root = GetTestTree();

            var testList1 = new List <SceneGraphNode>
            {
                GetNode(root, "Level1_0"),
                GetNode(root, "Level3_0"),
                GetNode(root, "Level3_1"),
                GetNode(root, "Level1_3"),
            };
            var solidList = SceneGraphTools.BuildNodesParents(testList1);

            Assert.IsTrue(solidList != null && solidList.Count == 2);
            Assert.IsTrue(solidList.Contains(GetNode(root, "Level1_0")));
            Assert.IsTrue(solidList.Contains(GetNode(root, "Level1_3")));
        }
Пример #2
0
        /// <inheritdoc />
        public override void OnSelectionChanged(List <SceneGraphNode> newSelection)
        {
            // End current action
            EndTransforming();

            // Prepare collections
            _selection.Clear();
            _selectionParents.Clear();
            int count = newSelection.Count;

            if (_selection.Capacity < count)
            {
                _selection.Capacity        = Mathf.NextPowerOfTwo(count);
                _selectionParents.Capacity = Mathf.NextPowerOfTwo(count);
            }

            // Cache selected objects
            _selection.AddRange(newSelection);

            // Build selected objects parents list.
            // Note: because selection may contain objects and their children we have to split them and get only parents.
            // Later during transformation we apply translation/scale/rotation only on them (children inherit transformations)
            SceneGraphTools.BuildNodesParents(_selection, _selectionParents);
        }