/////////////////////////////////////////

        public MeshRayTestOptimized(Vector3F[] vertices, int[] indices)
        {
            this.vertices = vertices;
            this.indices  = indices;

            if (vertices.Length != 0 && indices.Length != 0)
            {
                var bounds = Bounds.Cleared;
                foreach (var vertex in vertices)
                {
                    bounds.Add(vertex);
                }

                var initSettings = new OctreeContainer.InitSettings();
                initSettings.InitialOctreeBounds       = bounds;
                initSettings.OctreeBoundsRebuildExpand = Vector3.Zero;
                initSettings.MinNodeSize = bounds.GetSize() / 50;
                octreeContainer          = new OctreeContainer(initSettings);

                for (int nTriangle = 0; nTriangle < indices.Length / 3; nTriangle++)
                {
                    var vertex0 = vertices[indices[nTriangle * 3 + 0]];
                    var vertex1 = vertices[indices[nTriangle * 3 + 1]];
                    var vertex2 = vertices[indices[nTriangle * 3 + 2]];

                    var triangleBounds = new Bounds(vertex0);
                    triangleBounds.Add(vertex1);
                    triangleBounds.Add(vertex2);

                    octreeContainer.AddObject(triangleBounds, 1);
                }
            }
        }
        /////////////////////////////////////////

        internal void ObjectsInSpace_ObjectUpdate(Component_ObjectInSpace obj)
        {
            if (octree != null)
            {
                if (obj.sceneOctreeIndex == -1)
                {
                    //add object to the scene graph
                    obj.sceneOctreeIndex = octree.AddObject(obj.SpaceBounds.CalculatedBoundingBox, 0);                      // obj.sceneOctreeGroup );

                    //add to sceneGraphObjects
                    while (octreeObjects.Count <= obj.sceneOctreeIndex)
                    {
                        octreeObjects.Add(null);
                    }
                    octreeObjects[obj.sceneOctreeIndex] = obj;
                }
                else
                {
                    //update
                    octree.UpdateObject(obj.sceneOctreeIndex, obj.SpaceBounds.CalculatedBoundingBox, 0);                      // obj.sceneOctreeGroup );
                }
            }
        }