public void Init(IMyEnvironmentOwner owner, ref MyEnvironmentSectorParameters parameters)
        {
            // Copy parameters in
            SectorCenter = parameters.Center;

            Bounds = parameters.Bounds;

            m_dataRange = parameters.DataRange;

            m_environment = (MyProceduralEnvironmentDefinition)parameters.Environment;

            EnvironmentDefinition = parameters.Environment;

            m_owner = owner;

            m_provider = parameters.Provider;

            // Compute appropriate render origin.
            Vector3D center = parameters.Center;

            owner.ProjectPointToSurface(ref center);

            if (!Engine.Platform.Game.IsDedicated)
            {
                m_render = new MyInstancedRenderSector(string.Format("{0}:Sector({1:X})", owner, parameters.SectorId), MatrixD.CreateTranslation(center));
            }

            SectorId = parameters.SectorId;

            BoundingBoxD worldBounds = BoundingBoxD.CreateInvalid();

            for (int i = 0; i < 8; ++i)
            {
                worldBounds.Include(Bounds[i]);
            }

            // Entity stuff
            PositionComp.SetPosition(parameters.Center);
            PositionComp.WorldAABB = worldBounds;

            // Add missing stuff
            AddDebugRenderComponent(new MyDebugRenderComponentEnvironmentSector(this));
            GameLogic = new MyNullGameLogicComponent();
            Save      = false;

            IsClosed = false;
        }
        private void EnsurePhysicsSector(int x, int y, int face)
        {
            MyEnvironmentSector sector;

            long key = Entities.Planet.MyPlanetSectorId.MakeSectorId(x, y, face);

            if (!PhysicsSectors.TryGetValue(key, out sector))
            {
                MyPlanetEnvironmentClipmapProxy proxy;
                if (Proxies.TryGetValue(key, out proxy))
                {
                    sector = proxy.EnvironmentSector;
                    sector.EnablePhysics(true);
                }
                else if (HeldSectors.TryGetValue(key, out sector)) ;
                else
                {
                    sector = EnvironmentDefinition.CreateSector();

                    MyEnvironmentSectorParameters parms = new MyEnvironmentSectorParameters();

                    var leafSize = m_clipmaps[face].LeafSize;
                    var leafSizeHalf = m_clipmaps[face].LeafSize / 2;
                    int leafCountHalf = 1 << m_clipmaps[face].Depth - 1;

                    Matrix wmf = m_clipmaps[face].WorldMatrix;

                    parms.SurfaceBasisX = new Vector3(leafSizeHalf, 0, 0);
                    Vector3.RotateAndScale(ref parms.SurfaceBasisX, ref wmf, out parms.SurfaceBasisX);

                    parms.SurfaceBasisY = new Vector3(0, leafSizeHalf, 0);
                    Vector3.RotateAndScale(ref parms.SurfaceBasisY, ref wmf, out parms.SurfaceBasisY);

                    parms.Environment = EnvironmentDefinition;
                    parms.Center = Vector3D.Transform(new Vector3D((x - leafCountHalf + .5) * leafSize, (y - leafCountHalf + .5) * leafSize, 0),
                        m_clipmaps[face].WorldMatrix);

                    parms.DataRange = new BoundingBox2I(new Vector2I(x, y), new Vector2I(x, y));

                    parms.Provider = Providers[face];
                    parms.EntityId = Entities.Planet.MyPlanetSectorId.MakeSectorEntityId(x, y, 0, face, Planet.EntityId);
                    parms.SectorId = Entities.Planet.MyPlanetSectorId.MakeSectorId(x, y, face);

                    parms.Bounds = GetBoundingShape(ref parms.Center, ref parms.SurfaceBasisX,
                        ref parms.SurfaceBasisY);

                    sector.Init(this, ref parms);

                    sector.EnablePhysics(true);

                    Planet.AddChildEntity((MyEntity)sector);
                }

                PhysicsSectors.Add(key, sector);
            }

            m_sectorsWithPhysics.AddOrEnsureOnComplement(sector);
        }