예제 #1
0
        private void RemoveObsoleteVertices(DecalsMesh a_DecalsMesh)
        {
            DecalProjectorBase activeDecalProjector = a_DecalsMesh.ActiveDecalProjector;

            this.m_ObsoleteInternalVertexIndices.Sort();
            List <OptimizeEdge> list = this.m_RedundantInternalEdges.OptimizedEdgeList();

            for (int i = this.m_ObsoleteInternalVertexIndices.Count - 1; i >= 0; i--)
            {
                bool flag;
                int  num2 = this.m_ObsoleteInternalVertexIndices[i];
                this.m_ObsoleteVertexRemover.RemoveObsoleteInternalVertex(a_DecalsMesh, num2, list, out flag);
                if (!flag)
                {
                    this.m_ObsoleteInternalVertexIndices.RemoveAt(i);
                }
            }
            for (int j = this.m_ObsoleteExternalVertexIndices.Count - 1; j >= 0; j--)
            {
                bool flag2;
                int  num4 = this.m_ObsoleteExternalVertexIndices[j];
                this.m_ObsoleteVertexRemover.RemoveObsoleteExternalVertex(a_DecalsMesh, num4, out flag2);
                if (!flag2)
                {
                    this.m_ObsoleteExternalVertexIndices.RemoveAt(j);
                }
            }
            this.m_ObsoleteInternalVertexIndices.AddRange(this.m_ObsoleteExternalVertexIndices);
            this.m_ObsoleteInternalVertexIndices.Sort();
            foreach (int num5 in this.m_ObsoleteInternalVertexIndices)
            {
                this.m_RemovedIndices.AddRemovedIndex(num5);
            }
            a_DecalsMesh.RemoveAndAdjustIndices(activeDecalProjector.DecalsMeshLowerTriangleIndex, this.m_RemovedIndices);
            activeDecalProjector.IsUV1ProjectionCalculated     = false;
            activeDecalProjector.IsUV2ProjectionCalculated     = false;
            activeDecalProjector.IsTangentProjectionCalculated = false;
        }
예제 #2
0
        private void ComputePotentialObsoleteVertices(DecalsMesh a_DecalsMesh)
        {
            DecalProjectorBase activeDecalProjector = a_DecalsMesh.ActiveDecalProjector;

            this.ClearAll();
            for (int i = activeDecalProjector.DecalsMeshLowerTriangleIndex; i <= activeDecalProjector.DecalsMeshUpperTriangleIndex; i += 3)
            {
                int          num2  = a_DecalsMesh.Triangles[i];
                int          num3  = a_DecalsMesh.Triangles[i + 1];
                int          num4  = a_DecalsMesh.Triangles[i + 2];
                OptimizeEdge edge  = new OptimizeEdge(num2, num3, i);
                OptimizeEdge edge2 = new OptimizeEdge(num3, num4, i);
                OptimizeEdge edge3 = new OptimizeEdge(num4, num2, i);
                this.AddEdge(edge);
                this.AddEdge(edge2);
                this.AddEdge(edge3);
            }
            List <OptimizeEdge> list = this.m_RedundantExternalEdges.OptimizedEdgeList();

            foreach (OptimizeEdge edge4 in list)
            {
                if (!this.m_NonInternalVertexIndices.ContainsKey(edge4.vertex1Index))
                {
                    this.m_NonInternalVertexIndices.Add(edge4.vertex1Index, edge4.vertex1Index);
                }
                if (!this.m_NonInternalVertexIndices.ContainsKey(edge4.vertex2Index))
                {
                    this.m_NonInternalVertexIndices.Add(edge4.vertex2Index, edge4.vertex2Index);
                }
            }
            foreach (OptimizeEdge edge5 in this.m_OverusedInternalEdges.OptimizedEdgeList())
            {
                if (!this.m_NonInternalVertexIndices.ContainsKey(edge5.vertex1Index))
                {
                    this.m_NonInternalVertexIndices.Add(edge5.vertex1Index, edge5.vertex1Index);
                }
                if (!this.m_NonInternalVertexIndices.ContainsKey(edge5.vertex2Index))
                {
                    this.m_NonInternalVertexIndices.Add(edge5.vertex2Index, edge5.vertex2Index);
                }
            }
            for (int j = activeDecalProjector.DecalsMeshLowerVertexIndex; j <= activeDecalProjector.DecalsMeshUpperVertexIndex; j++)
            {
                if (!this.m_NonInternalVertexIndices.ContainsKey(j))
                {
                    this.m_ObsoleteInternalVertexIndices.Add(j);
                }
            }
            int num6 = 0;

            while (num6 < list.Count)
            {
                OptimizeEdge edge6 = list[num6];
                int          num7  = num6 + 1;
                while (true)
                {
                    if (num7 >= this.m_RedundantExternalEdges.Count)
                    {
                        num6++;
                        break;
                    }
                    OptimizeEdge edge7 = list[num7];
                    if ((edge6.vertex1Index != edge7.vertex1Index) && (edge6.vertex1Index != edge7.vertex2Index))
                    {
                        if ((((edge6.vertex2Index == edge7.vertex1Index) || (edge6.vertex2Index == edge7.vertex2Index)) && !this.m_ObsoleteExternalVertexIndices.Contains(edge6.vertex2Index)) && AreEdgesParallelOrIsAtLeastOneAPoint(a_DecalsMesh, edge6, edge7))
                        {
                            this.m_ObsoleteExternalVertexIndices.Add(edge6.vertex2Index);
                        }
                    }
                    else if (!this.m_ObsoleteExternalVertexIndices.Contains(edge6.vertex1Index) && AreEdgesParallelOrIsAtLeastOneAPoint(a_DecalsMesh, edge6, edge7))
                    {
                        this.m_ObsoleteExternalVertexIndices.Add(edge6.vertex1Index);
                    }
                    num7++;
                }
            }
            this.ClearTemporaryCollections();
        }