Example #1
0
        public static OctValue CreateTail(Vector3 value)
        {
            var octValue = new OctValue();

            octValue.Position      = value;
            octValue.PreviousValue = IndexToOctValue.Empty();
            return(octValue);
        }
        public void Execute()
        {
            NodesCount.Value  = 1;
            ValuesCount.Value = 0;
            Nodes[0]          = new OctNode(AABB);

            var rootIndex = new IndexToOctNode(0);
            var root      = rootIndex.GetElement(Nodes);

            for (int i = 0; i < ToInsert.Length; i++)
            {
                var point = ToInsert[i];
                if (root.PointOverlaps(point))
                {
                    IndexToOctValue valueIndex = IndexToOctValue.NewElement(Values, ValuesCount, OctValue.CreateTail(point));
                    InsertPointInNodeOrChildren(rootIndex, valueIndex);
                }
                else
                {
                    Debug.LogError("Cannot insert point outside of octree!");
                }
            }
        }