public void UnregisterPlanetEnvironment(MyPlanetEnvironmentComponent env) { m_planetEnvironments.Remove(env); foreach (var provider in env.Providers) { m_environmentProviders.Remove(provider); } }
public void Init(IMy2DClipmapManager parent, int x, int y, int lod, ref BoundingBox2D bounds) { m_manager = (MyPlanetEnvironmentComponent)parent; var bounds3D = new BoundingBoxD(new Vector3D(bounds.Min, 0), new Vector3D(bounds.Max, 0)); Lod = lod; Face = m_manager.ActiveFace; var matrix = m_manager.ActiveClipmap.WorldMatrix; bounds3D = bounds3D.Transform(matrix); Coords = new Vector2I(x, y); Id = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); m_manager.RegisterProxy(this); MyEnvironmentSectorParameters sectorParams; matrix.Translation = Vector3D.Zero; sectorParams.SurfaceBasisX = Vector3.Transform(new Vector3(bounds.Width / 2, 0, 0), matrix); sectorParams.SurfaceBasisY = Vector3.Transform(new Vector3(0, bounds.Height / 2, 0), matrix); sectorParams.Center = bounds3D.Center; if (lod > m_manager.MaxLod) { return; } if (!m_manager.TryGetSector(Id, out EnvironmentSector)) { sectorParams.SectorId = Id; sectorParams.EntityId = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); sectorParams.Bounds = m_manager.GetBoundingShape(ref sectorParams.Center, ref sectorParams.SurfaceBasisX, ref sectorParams.SurfaceBasisY);; sectorParams.Environment = m_manager.EnvironmentDefinition; sectorParams.DataRange = new BoundingBox2I(Coords << lod, ((Coords + 1) << lod) - 1); sectorParams.Provider = m_manager.Providers[m_manager.ActiveFace]; EnvironmentSector = m_manager.EnvironmentDefinition.CreateSector(); EnvironmentSector.Init(m_manager, ref sectorParams); m_manager.Planet.AddChildEntity((MyEntity)EnvironmentSector); } m_manager.EnqueueOperation(this, lod); LodSet = lod; EnvironmentSector.OnLodCommit += sector_OnMyLodCommit; }
public void Init(IMy2DClipmapManager parent, int x, int y, int lod, ref BoundingBox2D bounds) { m_manager = (MyPlanetEnvironmentComponent)parent; var bounds3D = new BoundingBoxD(new Vector3D(bounds.Min, 0), new Vector3D(bounds.Max, 0)); Lod = lod; Face = m_manager.ActiveFace; var matrix = m_manager.ActiveClipmap.WorldMatrix; bounds3D = bounds3D.Transform(matrix); Coords = new Vector2I(x, y); Id = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); m_manager.RegisterProxy(this); MyEnvironmentSectorParameters sectorParams; matrix.Translation = Vector3D.Zero; sectorParams.SurfaceBasisX = Vector3.Transform(new Vector3(bounds.Width / 2, 0, 0), matrix); sectorParams.SurfaceBasisY = Vector3.Transform(new Vector3(0, bounds.Height / 2, 0), matrix); sectorParams.Center = bounds3D.Center; if (lod > m_manager.MaxLod) return; if (!m_manager.TryGetSector(Id, out EnvironmentSector)) { sectorParams.SectorId = Id; sectorParams.EntityId = MyPlanetSectorId.MakeSectorId(x, y, m_manager.ActiveFace, lod); sectorParams.Bounds = m_manager.GetBoundingShape(ref sectorParams.Center, ref sectorParams.SurfaceBasisX, ref sectorParams.SurfaceBasisY); ; sectorParams.Environment = m_manager.EnvironmentDefinition; sectorParams.DataRange = new BoundingBox2I(Coords << lod, ((Coords + 1) << lod) - 1); sectorParams.Provider = m_manager.Providers[m_manager.ActiveFace]; EnvironmentSector = m_manager.EnvironmentDefinition.CreateSector(); EnvironmentSector.Init(m_manager, ref sectorParams); m_manager.Planet.AddChildEntity((MyEntity)EnvironmentSector); } m_manager.EnqueueOperation(this, lod); LodSet = lod; EnvironmentSector.OnLodCommit += sector_OnMyLodCommit; }
public void UnregisterPlanetEnvironment(MyPlanetEnvironmentComponent env) { m_planetEnvironments.Remove(env); foreach (var provider in env.Providers) m_environmentProviders.Remove(provider); }