Exemplo n.º 1
0
        public void RemoveObject(ulong id)
        {
            System.Diagnostics.Debug.Assert(id != CLUSTERED_OBJECT_ID_UNITIALIZED, "Unitialized object in cluster!");

            MyObjectData objectData;

            if (m_objectsData.TryGetValue(id, out objectData))
            {
                MyCluster cluster = objectData.Cluster;

                if (cluster != null)
                {
                    RemoveObjectFromCluster(objectData, false);

                    if (cluster.Objects.Count == 0)
                    {
                        RemoveCluster(cluster);
                    }
                }

                if (objectData.StaticId != MyDynamicAABBTreeD.NullNode)
                {
                    m_staticTree.RemoveProxy(objectData.StaticId);
                    objectData.StaticId = MyDynamicAABBTreeD.NullNode;
                }

                m_objectsData.Remove(id);
            }
            else
            {
                System.Diagnostics.Debug.Fail("Removed object is not in cluster");
            }
        }
        public static void Remove(MyEntity entity)
        {
            if (entity.GamePruningProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                m_aabbTree.RemoveProxy(entity.GamePruningProxyId);
                entity.GamePruningProxyId = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }

            if (entity.TargetPruningProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                m_targetsTree.RemoveProxy(entity.TargetPruningProxyId);
                entity.TargetPruningProxyId = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }

            if (entity.SensablePruningProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                m_sensableTree.RemoveProxy(entity.SensablePruningProxyId);
                entity.SensablePruningProxyId = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }

            var voxelMap = entity as MyVoxelMap;

            if (voxelMap != null && voxelMap.VoxelMapPruningProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                m_voxelMapsTree.RemoveProxy(voxelMap.VoxelMapPruningProxyId);
                voxelMap.VoxelMapPruningProxyId = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }
        }
Exemplo n.º 3
0
 public static void RemoveBroadcaster(MyRadioBroadcaster broadcaster)
 {
     if (broadcaster.RadioProxyID != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
     {
         m_aabbTree.RemoveProxy(broadcaster.RadioProxyID);
         broadcaster.RadioProxyID = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
     }
 }
Exemplo n.º 4
0
 public static void RemovePlaceArea(MyPlaceArea area)
 {
     if (area.PlaceAreaProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
     {
         m_aabbTree.RemoveProxy(area.PlaceAreaProxyId);
         area.PlaceAreaProxyId = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
     }
 }
Exemplo n.º 5
0
 public void RemoveShield(DefenseShields shield)
 {
     if (shield.DtreeProxyId == -1)
     {
         return;
     }
     _aabbTree.RemoveProxy(shield.DtreeProxyId);
     shield.DtreeProxyId = -1;
 }
Exemplo n.º 6
0
            internal bool OnRemovedFromScene(MyClipmapCellProxy cellProxy)
            {
                if (!IsUsed())
                {
                    return(false);
                }

                bool     shouldMarkDirty = false;
                Vector3D translation     = cellProxy.Translation;
                int      divideIndex;

                if (TryGetDivideIndex(ref translation, out divideIndex))
                {
                    MyMergedLodMeshId mergedLodMeshId = MyMeshes.GetMergedLodMesh(m_mergedLodMeshProxies[divideIndex].MeshId, 0);
                    LodMeshId         lodMeshId       = MyMeshes.GetLodMesh(cellProxy.MeshId, 0);

                    bool unmergedMesh = mergedLodMeshId.UnmergeLodMesh(lodMeshId);
                    if (unmergedMesh)
                    {
                        InvalidateAllMergedMeshesInLod();
                    }

                    TryCancelMergeJob(divideIndex, cellProxy.MeshId);
                    bool startedJob = TryStartMergeJob(divideIndex, 1000);

                    shouldMarkDirty = unmergedMesh && !startedJob;
                    if (shouldMarkDirty)
                    {
                        m_dirtyProxyIndices.Add(divideIndex);
                    }

                    m_trackedActors[divideIndex].Remove(cellProxy.Actor);
                }

                int proxyId;

                if (m_cellProxyToAabbProxy.TryGetValue(cellProxy, out proxyId))
                {
                    m_boundingBoxes.RemoveProxy(m_cellProxyToAabbProxy[cellProxy]);
                    m_cellProxyToAabbProxy.Remove(cellProxy);
                }

                return(shouldMarkDirty);
            }
Exemplo n.º 7
0
 private void RemoveFromTree(ProceduralObject t)
 {
     if (t.m_proxyID == -1)
     {
         return;
     }
     m_tree.RemoveProxy(t.m_proxyID);
     t.m_proxyID  = -1;
     t.OnMoved   -= ObjectMoved;
     t.OnRemoved -= RemoveFromTree;
 }
Exemplo n.º 8
0
        public void Remove(T obj)
        {
            int index;

            if (indexes.TryGetValue(obj, out index))
            {
                tree.RemoveProxy(index);
                indexes.Remove(obj);
                boxes.Remove(index);
            }
        }
Exemplo n.º 9
0
        private void RemoveCluster(MyCluster cluster)
        {
            m_clusterTree.RemoveProxy(cluster.ClusterId);
            m_clusters.Remove(cluster);
            m_userObjects.Remove(cluster.UserData);

            if (OnClusterRemoved != null)
            {
                OnClusterRemoved(cluster.UserData);
            }
        }
Exemplo n.º 10
0
 public void RemoveChildEntity(MyEntity child)
 {
     if (MyFakes.ENABLE_PLANET_HIERARCHY)
     {
         if (child.Parent == this)
         {
             MyHierarchyComponentBase childHierarchy = child.Components.Get <MyHierarchyComponentBase>();
             m_sectors.RemoveProxy((int)childHierarchy.ChildId);
             Hierarchy.RemoveChild(child, true);
         }
     }
 }
Exemplo n.º 11
0
        public void Remove(AABBEntity entity)
        {
            int proxyId = GetProxyIdForEntity(entity);

            Log.Trace("Remove entity " + proxyId, "Remove");

            if (proxyId != PROXY_ID_UNITIALIZED)
            {
                MathTree.RemoveProxy(proxyId);
                SetProxyIdForEntity(entity, PROXY_ID_UNITIALIZED);
            }

            Log.Trace("Finished Remove entity " + proxyId, "Remove");
        }
Exemplo n.º 12
0
        public static void Remove(MyEntity entity)
        {
            var voxelMap = entity as MyVoxelBase;

            if (voxelMap != null && voxelMap.VoxelMapPruningProxyId != MyVRageConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                m_voxelMapsTree.RemoveProxy(voxelMap.VoxelMapPruningProxyId);
                voxelMap.VoxelMapPruningProxyId = MyVRageConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }

            if (entity.TopMostPruningProxyId != MyVRageConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                if (entity.StaticForPruningStructure)
                {
                    m_staticObjectsTree.RemoveProxy(entity.TopMostPruningProxyId);
                }
                else
                {
                    m_dynamicObjectsTree.RemoveProxy(entity.TopMostPruningProxyId);
                }

                entity.TopMostPruningProxyId = MyVRageConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }
        }
        public void ProcessDirtyCells(Dictionary <MyEntity, MyEntityTracker> trackedEntities)
        {
            m_dirtyCells.ApplyAdditions();

            if (m_dirtyCells.Count == 0)
            {
                return;
            }
            ProfilerShort.Begin("Find false possitive dirty cells");
            foreach (var cell in m_dirtyCells)
            {
                foreach (var tracker in trackedEntities.Values)
                {
                    var scaledBoundingVolume = tracker.BoundingVolume;
                    scaledBoundingVolume.Radius *= SCALE;
                    if (scaledBoundingVolume.Contains(cell.BoundingVolume) != ContainmentType.Disjoint)
                    {
                        m_dirtyCells.Remove(cell);
                        break;
                    }
                }
            }
            m_dirtyCells.ApplyRemovals();

            ProfilerShort.BeginNextBlock("Remove stuff");
            foreach (var cell in m_dirtyCells)
            {
                cell.GetAll(m_tempObjectSeedList);

                foreach (var objectSeed in m_tempObjectSeedList)
                {
                    if (objectSeed.Generated)
                    {
                        CloseObjectSeed(objectSeed);
                    }
                }
                m_tempObjectSeedList.Clear();
            }

            ProfilerShort.BeginNextBlock("Remove dirty cells");
            foreach (var cell in m_dirtyCells)
            {
                m_cells.Remove(cell.CellId);
                m_cellsTree.RemoveProxy(cell.proxyId);
            }
            m_dirtyCells.Clear();
            ProfilerShort.End();
        }
Exemplo n.º 14
0
        public static void Remove(MyEntity entity)
        {
            var voxelMap = entity as MyVoxelBase;

            if (voxelMap != null && voxelMap.VoxelMapPruningProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                m_voxelMapsTree.RemoveProxy(voxelMap.VoxelMapPruningProxyId);
                voxelMap.VoxelMapPruningProxyId = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }

            if (entity.TopMostPruningProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                m_topMostEntitiesTree.RemoveProxy(entity.TopMostPruningProxyId);
                entity.TopMostPruningProxyId = MyConstants.PRUNING_PROXY_ID_UNITIALIZED;
            }
        }
Exemplo n.º 15
0
        internal static int UpdateBvh(MyDynamicAABBTreeD bvh, LightId lid, bool enabled, int proxy, ref BoundingBoxD aabb)
        {
            if (enabled && proxy == -1)
            {
                return(bvh.AddProxy(ref aabb, lid, 0));
            }
            else if (enabled && proxy != -1)
            {
                bvh.MoveProxy(proxy, ref aabb, Vector3.Zero);
                return(proxy);
            }
            else
            {
                bvh.RemoveProxy(proxy);
            }

            return(-1);
        }
Exemplo n.º 16
0
        internal static void Remove(uint GID, LightId light)
        {
            IdIndex.Remove(GID);

            if (Pointlights[light.Index].BvhProxyId != -1)
            {
                PointlightsBvh.RemoveProxy(Pointlights[light.Index].BvhProxyId);
            }

            if (Spotlights[light.Index].BvhProxyId != -1)
            {
                SpotlightsBvh.RemoveProxy(Spotlights[light.Index].BvhProxyId);
            }

            DirtyPointlights.Remove(light);
            DirtySpotlights.Remove(light);
            Lights.Free(light.Index);
        }
Exemplo n.º 17
0
        public int RevealGroup(ConcealGroup group)
        {
            if (!group.IsConcealed)
            {
                Log.Warn($"Attempted to reveal a group that wasn't concealed: {group.GridNames}");
                Log.Warn(new StackTrace());
                return(0);
            }

            var count = group.Grids.Count;

            Log.Debug($"Revealing grids: {group.GridNames}");
            group.Grids.ForEach(RevealEntity);
            ConcealedGroups.Remove(group);
            _concealedAabbTree.RemoveProxy(group.ProxyId);
            group.UpdatePostReveal();
            return(count);
        }
        /// <summary>
        /// Unloads all cells that have been marked to be unloaded. It will remove all objects inside the sphere from
        /// the world. It will not unload cells that are still in the tracking volume of a tracked entity.
        /// </summary>
        /// <param name="trackedEntities">List of tracked entities</param>
        public void UnloadCells(Dictionary <MyEntity, MyEntityTracker> trackedEntities)
        {
            m_toUnloadCells.ApplyAdditions();
            if (m_toUnloadCells.Count == 0)
            {
                return;
            }

            List <MyObjectSeed> cellObjects = new List <MyObjectSeed>();

            foreach (MyProceduralCell cell in m_toUnloadCells)
            {
                foreach (MyEntityTracker tracker in trackedEntities.Values)
                {
                    BoundingSphereD boundingVolume = tracker.BoundingVolume;
                    if (boundingVolume.Contains(cell.BoundingVolume) != ContainmentType.Disjoint)
                    {
                        m_toUnloadCells.Remove(cell);
                        break;
                    }
                }
            }
            m_toUnloadCells.ApplyRemovals();
            foreach (var cell in m_toUnloadCells)
            {
                cell.GetAll(cellObjects);

                foreach (MyObjectSeed obj in cellObjects)
                {
                    if (obj.Params.Generated)
                    {
                        CloseObject(obj);
                    }
                }
                cellObjects.Clear();
            }
            foreach (MyProceduralCell cell in m_toUnloadCells)
            {
                m_cells.Remove(cell.CellId);
                m_cellsTree.RemoveProxy(cell.proxyId);
            }
            m_toUnloadCells.Clear();
        }
Exemplo n.º 19
0
        private static void Remove(uint GID, LightId id)
        {
            m_idIndex.Remove(GID);

            if (m_pointlights[id.Index].BvhProxyId != -1)
            {
                PointlightsBvh.RemoveProxy(m_pointlights[id.Index].BvhProxyId);
            }

            if (m_spotlights[id.Index].BvhProxyId != -1)
            {
                SpotlightsBvh.RemoveProxy(m_spotlights[id.Index].BvhProxyId);
            }
            MyFlareRenderer.Remove(id.FlareId);
            m_dirtyPointlights.Remove(id);
            m_dirtySpotlights.Remove(id);
            m_ignoredShadowEntities.Remove(id);
            m_lights.Free(id.Index);
        }
Exemplo n.º 20
0
        public int RevealGroup(ConcealGroup group)
        {
            if (!group.IsConcealed)
            {
                Log.Warn($"Attempted to reveal a group that wasn't concealed: {group.GridNames}");
                Log.Warn(new StackTrace());
                return(0);
            }

            var count = group.Grids.Count;

            Log.Debug($"Revealing grids: {group.GridNames}");
            group.Reveal();

            /*foreach (var entity in group.Grids)
             *  entity.GetStorage().SetValue(Id, "False");*/

            ConcealedGroups.Remove(group);
            _concealedAabbTree.RemoveProxy(group.ProxyId);
            group.UpdatePostReveal();
            return(count);
        }
        /// <summary>
        /// Unloads all marked cells, except those, that are also marked to be loaded, due
        /// to overlapping bounds when marking.
        /// </summary>
        public void UnloadCells()
        {
            List <Vector3I> unloadCells = new List <Vector3I>();

            foreach (var cell in m_loadedCells)
            {
                if (m_toLoadCells.Contains(cell.Key))
                {
                    continue;
                }
                unloadCells.Add(cell.Key);
            }

            foreach (var cellid in unloadCells)
            {
                var cell = m_loadedCells[cellid];

                List <MyObjectSeed> seeds = new List <MyObjectSeed>();

                cell.GetAll(seeds);

                foreach (var seed in seeds)
                {
                    if (seed.Params.Generated)
                    {
                        CloseObject(seed);
                    }
                }
                seeds.Clear();

                m_loadedCells.Remove(cellid);
                m_cellsTree.RemoveProxy(cell.proxyId);
            }

            return;
        }
Exemplo n.º 22
0
 override protected void RemoveRoot(IMyReplicable replicable)
 {
     m_roots.Remove(replicable);
     m_rootsAABB.RemoveProxy(m_proxies[replicable]);
 }
Exemplo n.º 23
0
        internal static int UpdateBvh(MyDynamicAABBTreeD bvh, LightId lid, bool enabled, int proxy, ref BoundingBoxD aabb)
        {
            if(enabled && proxy == -1)
            {
                return bvh.AddProxy(ref aabb, lid, 0);
            }
            else if(enabled && proxy != -1)
            {
                bvh.MoveProxy(proxy, ref aabb, Vector3.Zero);
                return proxy;
            }
            else
            {
                bvh.RemoveProxy(proxy);
            }

            return -1;
        }
Exemplo n.º 24
0
        private void ProcessDirtyCells()
        {
            foreach (var cell in m_dirtyCellsToAdd)
            {
                m_dirtyCells.Add(cell);
            }
            m_dirtyCellsToAdd.Clear();

            if (m_dirtyCells.Count == 0)
            {
                return;
            }
            ProfilerShort.Begin("Find false possitive dirty cells");
            foreach (var cell in m_dirtyCells)
            {
                foreach (var tracker in m_trackedEntities.Values)
                {
                    if (tracker.BoundingVolume.Contains(cell.BoundingVolume) != ContainmentType.Disjoint)
                    {
                        m_dirtyCellsToRemove.Add(cell);
                        break;
                    }
                }
            }

            ProfilerShort.BeginNextBlock("Remove false possitive dirty cells");
            foreach (var cell in m_dirtyCellsToRemove)
            {
                m_dirtyCells.Remove(cell);
            }
            m_dirtyCellsToRemove.Clear();

            ProfilerShort.BeginNextBlock("Remove stuff");
            foreach (var cell in m_dirtyCells)
            {
                cell.GetAll(m_tempObjectSeedList);

                foreach (var objectSeed in m_tempObjectSeedList)
                {
                    switch (objectSeed.Type)
                    {
                    case MyObjectSeedType.Asteroid:
                    case MyObjectSeedType.AsteroidCluster:
                        var bbox = objectSeed.BoundingVolume;
                        MyGamePruningStructure.GetAllVoxelMapsInBox(ref bbox, m_tmpVoxelMapsList);

                        String storageName = string.Format("Asteroid_{0}_{1}_{2}_{3}_{4}", cell.CellId.X, cell.CellId.Y, cell.CellId.Z, objectSeed.Index, objectSeed.Seed);

                        foreach (var voxelMap in m_tmpVoxelMapsList)
                        {
                            if (voxelMap.StorageName == storageName)
                            {
                                if (!voxelMap.Save)     // for now
                                {
                                    m_asteroidCount--;
                                    voxelMap.Close();
                                }
                                break;
                            }
                        }
                        m_asteroidSeedCount--;
                        m_tmpVoxelMapsList.Clear();
                        break;

                    case MyObjectSeedType.EncounterAlone:
                    case MyObjectSeedType.EncounterSingle:
                    case MyObjectSeedType.EncounterMulti:
                        if (MyEncounterGenerator.RemoveEncounter(objectSeed.BoundingVolume, objectSeed.Seed))
                        {
                            m_encounterCount--;
                        }
                        m_encounterSeedCount--;
                        break;

                    default:
                        throw new InvalidBranchException();
                        break;
                    }
                }
            }
            m_tempObjectSeedList.Clear();

            ProfilerShort.BeginNextBlock("Remove dirty cells");
            foreach (var cell in m_dirtyCells)
            {
                m_cells.Remove(cell.CellId);
                m_cellsTree.RemoveProxy(cell.proxyId);
            }
            m_dirtyCells.Clear();
            ProfilerShort.End();
        }