internal void RemoveCubePartDecal(MyCubePart part, uint decalId)
        {
            List <uint> decals;
            bool        found = m_cubeParts.TryGetValue(part, out decals);

            if (!found || decals == null)
            {
                return;
            }

            int indexToRemove = -1;

            for (int it = 0; it < decals.Count; it++)
            {
                if (decals[it] == decalId)
                {
                    indexToRemove = it;
                    break;
                }
            }

            if (indexToRemove != -1)
            {
                decals.RemoveAt(indexToRemove);
            }
        }
        public void RebuildInstanceParts(RenderFlags renderFlags)
        {
            if (m_tmpInstanceParts == null)
            {
                m_tmpInstanceParts = new Dictionary <ModelId, Tuple <List <MyCubeInstanceMergedData>, MyInstanceInfo> >();
            }
            var list = m_tmpInstanceParts;

            ProfilerShort.Begin("Assert data empty");
            Debug.Assert(InstanceDataCleared(list));
            ProfilerShort.End();

            ProfilerShort.Begin("Add cube parts");
            foreach (var pair in m_cubeParts)
            {
                MyCubePart  part   = pair.Key;
                List <uint> decals = pair.Value;
                AddInstancePart(list, part.Model.UniqueId, ref part.InstanceData, decals,
                                MyInstanceFlagsEnum.ShowLod1 | MyInstanceFlagsEnum.CastShadows | MyInstanceFlagsEnum.EnableColorMask);
            }
            ProfilerShort.End();

            ProfilerShort.Begin("Add edge parts");
            AddEdgeParts(list);
            ProfilerShort.End();

            UpdateRenderInstanceData(list, renderFlags);

            ProfilerShort.Begin("Clear parts");
            ClearInstanceParts(list);
            ProfilerShort.End();
        }
 public void AddCubePart(MyCubePart part)
 {
     if (!m_cubeParts.ContainsKey(part))
     {
         m_cubeParts.Add(part, null);
     }
 }
 public void RemoveCubePart(MyCubePart part)
 {
     var pos = part.InstanceData.Translation;
     var cell = GetCell(pos);
     if (cell.RemoveCubePart(part))
         m_dirtyCells.Add(cell);
 }
示例#5
0
        public void AddCubePart(MyCubePart part)
        {
            Vector3 translation            = part.InstanceData.Translation;
            MyCubeGridRenderCell orAddCell = this.GetOrAddCell(translation, true);

            orAddCell.AddCubePart(part);
            this.m_dirtyCells.Add(orAddCell);
        }
        public void AddCubePart(MyCubePart part)
        {
            var pos = part.InstanceData.Translation;
            var cell = GetCell(pos);

            // We have to add anyway, even when it's already there, bones may have changed
            cell.AddCubePart(part);
            m_dirtyCells.Add(cell);
        }
        public void AddCubePart(MyCubePart part)
        {
            var pos  = part.InstanceData.Translation;
            var cell = GetCell(pos);

            // We have to add anyway, even when it's already there, bones may have changed
            cell.AddCubePart(part);
            m_dirtyCells.Add(cell);
        }
        public void RemoveCubePart(MyCubePart part)
        {
            var pos  = part.InstanceData.Translation;
            var cell = GetCell(pos);

            if (cell.RemoveCubePart(part))
            {
                m_dirtyCells.Add(cell);
            }
        }
示例#9
0
        internal void RemoveCubePartDecal(MyCubePart part, uint decalId)
        {
            ConcurrentDictionary <uint, bool> dictionary;

            if (this.m_cubeParts.TryGetValue(part, out dictionary))
            {
                bool flag;
                dictionary.TryRemove(decalId, out flag);
            }
        }
示例#10
0
        public void RemoveCubePart(MyCubePart part)
        {
            Vector3 translation            = part.InstanceData.Translation;
            MyCubeGridRenderCell orAddCell = this.GetOrAddCell(ref translation, false);

            if ((orAddCell != null) && orAddCell.RemoveCubePart(part))
            {
                this.m_dirtyCells.Add(orAddCell);
            }
        }
示例#11
0
        private void RemoveDecal(Vector3I position, ConcurrentQueue <MyDecalPartIdentity> decals, MyCube cube)
        {
            MyDecalPartIdentity identity;

            decals.TryDequeue(out identity);
            MyDecals.RemoveDecal(identity.DecalId);
            if (identity.CubePartIndex != -1)
            {
                MyCubePart part = cube.Parts[identity.CubePartIndex];
                this.GetOrAddCell((Vector3)position, true).RemoveCubePartDecal(part, identity.DecalId);
            }
        }
        internal void AddCubePartDecal(MyCubePart part, uint decalId)
        {
            List <uint> decals;
            bool        found = m_cubeParts.TryGetValue(part, out decals);

            if (!found)
            {
                decals = new List <uint>();
                m_cubeParts.Add(part, decals);
            }

            if (decals == null)
            {
                // Decals list can be null as well
                decals            = new List <uint>();
                m_cubeParts[part] = decals;
            }

            decals.Add(decalId);
        }
示例#13
0
        public void RebuildInstanceParts(RenderFlags renderFlags)
        {
            Thread currentThread = Thread.CurrentThread;
            Thread updateThread  = MySandboxGame.Static.UpdateThread;
            Dictionary <MyInstanceBucket, Tuple <List <MyCubeInstanceMergedData>, Sandbox.Game.Entities.Cube.MyInstanceInfo> > tmpInstanceParts = m_tmpInstanceParts;

            foreach (KeyValuePair <MyCubePart, ConcurrentDictionary <uint, bool> > pair in this.m_cubeParts)
            {
                MyCubePart key = pair.Key;
                ConcurrentDictionary <uint, bool> decals = pair.Value;
                this.AddInstancePart(tmpInstanceParts, key.Model.UniqueId, key.SkinSubtypeId, ref key.InstanceData, decals, MyInstanceFlagsEnum.CastShadows | MyInstanceFlagsEnum.EnableColorMask | MyInstanceFlagsEnum.ShowLod1, float.MaxValue);
            }
            this.UpdateDirtyEdges();
            this.AddEdgeParts(tmpInstanceParts);
            this.UpdateRenderInstanceData(tmpInstanceParts, renderFlags);
            this.ClearInstanceParts(tmpInstanceParts);
            if (this.m_gridRenderComponent != null)
            {
                this.m_gridRenderComponent.FadeIn = false;
            }
        }
示例#14
0
        public void AddDecal(Vector3I position, MyCubeGrid.MyCubeGridHitInfo gridHitInfo, uint decalId)
        {
            MyCube cube;

            if (this.m_gridRender.CubeGrid.TryGetCube(position, out cube))
            {
                if (gridHitInfo.CubePartIndex != -1)
                {
                    MyCubePart part = cube.Parts[gridHitInfo.CubePartIndex];
                    this.GetOrAddCell(part.InstanceData.Translation, true).AddCubePartDecal(part, decalId);
                }
                ConcurrentQueue <MyDecalPartIdentity> orAdd = this.m_cubeDecals.GetOrAdd(position, x => new ConcurrentQueue <MyDecalPartIdentity>());
                if (orAdd.Count > 30)
                {
                    this.RemoveDecal(position, orAdd, cube);
                }
                MyDecalPartIdentity item = new MyDecalPartIdentity {
                    DecalId       = decalId,
                    CubePartIndex = gridHitInfo.CubePartIndex
                };
                orAdd.Enqueue(item);
            }
        }
示例#15
0
 public void AddCubePart(MyCubePart part)
 {
     this.m_cubeParts.TryAdd(part, null);
 }
 public void AddCubePart(MyCubePart part)
 {
     if (!m_cubeParts.ContainsKey(part))
         m_cubeParts.Add(part, null);
 }
示例#17
0
        public bool RemoveCubePart(MyCubePart part)
        {
            ConcurrentDictionary <uint, bool> dictionary;

            return(this.m_cubeParts.TryRemove(part, out dictionary));
        }
        internal void AddCubePartDecal(MyCubePart part, uint decalId)
        {
            List<uint> decals;
            bool found = m_cubeParts.TryGetValue(part, out decals);
            if (!found)
            {
                decals = new List<uint>();
                m_cubeParts.Add(part, decals);
            }

            if (decals == null)
            {
                // Decals list can be null as well
                decals = new List<uint>();
                m_cubeParts[part] = decals;
            }

            decals.Add(decalId);
        }
 public bool RemoveCubePart(MyCubePart part)
 {
     return(m_cubeParts.Remove(part));
 }
 public bool AddCubePart(MyCubePart part)
 {
     return m_cubeParts.Add(part);
 }
 public bool RemoveCubePart(MyCubePart part)
 {
     return m_cubeParts.Remove(part);
 }
        internal void RemoveCubePartDecal(MyCubePart part, uint decalId)
        {
            List<uint> decals;
            bool found = m_cubeParts.TryGetValue(part, out decals);
            if (!found || decals == null)
                return;

            int indexToRemove = -1;
            for (int it = 0; it < decals.Count; it++)
            {
                if (decals[it] == decalId)
                {
                    indexToRemove = it;
                    break;
                }
            }

            if (indexToRemove != -1)
                decals.RemoveAt(indexToRemove);
        }
示例#23
0
 internal void AddCubePartDecal(MyCubePart part, uint decalId)
 {
     this.m_cubeParts.GetOrAdd(part, x => new ConcurrentDictionary <uint, bool>()).TryAdd(decalId, true);
 }
示例#24
0
 internal ConcurrentDictionary <uint, bool> < AddCubePartDecal > b__24_0(MyCubePart x) =>
示例#25
0
 public bool AddCubePart(MyCubePart part)
 {
     return(m_cubeParts.Add(part));
 }