internal void AddInstanceLod(InstancingId id, int index, MyRenderableProxy[][] newProxies, ulong[][] newSortingKeys, BoundingBoxD aabb, Vector3D position)
        {
            ProfilerShort.Begin("AddInstanceLod");

            if (!SetDelta(id, index, -0.1f, (float)(MyEnvironment.CameraPosition - position).LengthSquared()))
            {
                MyInstanceLodId key = new MyInstanceLodId {
                    Id = id, InstanceIndex = index
                };

                MySingleInstance instance = MySingleInstance.Allocate();

                Array.Resize(ref instance.Lods, newProxies.Length);
                instance.Position = position;

                for (int lodIndex = 0; lodIndex < newProxies.Length; ++lodIndex)
                {
                    MyUtils.Init(ref instance.Lods[lodIndex]);
                    MySingleInstanceLod lod = instance.Lods[lodIndex];

                    if (lod.RenderableProxies != null && lod.RenderableProxies.Length == newProxies[lodIndex].Length)
                    {
                        Array.Copy(newProxies[lodIndex], lod.RenderableProxies, lod.RenderableProxies.Length);
                    }
                    else
                    {
                        lod.RenderableProxies = newProxies[lodIndex];
                    }

                    lod.SortingKeys = newSortingKeys[lodIndex];

                    if (lodIndex < newProxies.Length - 1)
                    {
                        int lodTransitionProxiesCount = newProxies[lodIndex].Length + newProxies[lodIndex + 1].Length;

                        Array.Resize(ref lod.RenderableProxiesForLodTransition, lodTransitionProxiesCount);
                        Array.Copy(newProxies[lodIndex], lod.RenderableProxiesForLodTransition, newProxies[lodIndex].Length);
                        Array.Copy(newProxies[lodIndex + 1], 0, lod.RenderableProxiesForLodTransition, newProxies[lodIndex].Length, newProxies[lodIndex + 1].Length);

                        int sortingKeysLength = newSortingKeys[lodIndex].Length + newSortingKeys[lodIndex + 1].Length;
                        Array.Resize(ref lod.SortingKeysForLodTransition, sortingKeysLength);
                        Array.Copy(newSortingKeys[lodIndex], lod.SortingKeysForLodTransition, newSortingKeys.Length);
                        Array.Copy(newSortingKeys[lodIndex + 1], 0, lod.SortingKeysForLodTransition, newSortingKeys.Length, newSortingKeys[lodIndex + 1].Length);
                    }
                }

                instance.CurrentLod = 0;

                instance.CullProxy = MyObjectPoolManager.Allocate <MyCullProxy>();

                instance.BtreeProxy = MyScene.DynamicRenderablesDBVH.AddProxy(ref aabb, instance.CullProxy, 0);
                m_instances.Add(key, instance);

                instance.IsDirty = true;
            }
            ProfilerShort.End();
        }