예제 #1
0
 private void AddEdge(OptimizeEdge a_Edge)
 {
     if (!this.m_OverusedInternalEdges.HasEdge(a_Edge))
     {
         if (this.m_RedundantInternalEdges.HasEdge(a_Edge))
         {
             this.m_RedundantInternalEdges.RemoveEdge(a_Edge);
             this.m_OverusedInternalEdges.AddEdge(a_Edge);
         }
         else if (!this.m_RedundantExternalEdges.HasEdge(a_Edge))
         {
             this.m_RedundantExternalEdges.AddEdge(a_Edge);
         }
         else
         {
             OptimizeEdge edge = this.m_RedundantExternalEdges[a_Edge];
             this.m_RedundantExternalEdges.RemoveEdge(a_Edge);
             edge.triangle2Index = a_Edge.triangle1Index;
             this.m_RedundantInternalEdges.AddEdge(edge);
         }
     }
 }
예제 #2
0
        private static bool AreEdgesParallelOrIsAtLeastOneAPoint(DecalsMesh a_DecalsMesh, OptimizeEdge a_Edge1, OptimizeEdge a_Edge2)
        {
            bool    flag    = false;
            Vector3 vector5 = a_DecalsMesh.Vertices[a_Edge1.vertex2Index] - a_DecalsMesh.Vertices[a_Edge1.vertex1Index];
            Vector3 vector6 = a_DecalsMesh.Vertices[a_Edge2.vertex2Index] - a_DecalsMesh.Vertices[a_Edge2.vertex1Index];

            vector5.Normalize();
            vector6.Normalize();
            if (Vector3Extension.Approximately(vector5, Vector3.zero, s_CurrentMaximumAbsoluteError, s_CurrentMaximumRelativeError) || Vector3Extension.Approximately(vector6, Vector3.zero, s_CurrentMaximumAbsoluteError, s_CurrentMaximumRelativeError))
            {
                flag = true;
            }
            else if (MathfExtension.Approximately(Mathf.Abs(Vector3.Dot(vector5, vector6)), 1f, s_CurrentMaximumAbsoluteError, s_CurrentMaximumRelativeError))
            {
                flag = true;
            }
            return(flag);
        }
예제 #3
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();
        }
예제 #4
0
 public OptimizeEdge this[OptimizeEdge a_OptimizeEdge]
 {
     get =>
     this.m_EdgeDictionary[a_OptimizeEdge];
예제 #5
0
 public void RemoveEdge(OptimizeEdge a_OptimizeEdge)
 {
     this.m_EdgeDictionary.Remove(a_OptimizeEdge);
 }
예제 #6
0
 public bool HasEdge(OptimizeEdge a_OptimizeEdge) =>
 this.m_EdgeDictionary.ContainsKey(a_OptimizeEdge);
예제 #7
0
 public void AddEdge(OptimizeEdge a_OptimizeEdge)
 {
     this.m_EdgeDictionary.Add(a_OptimizeEdge, a_OptimizeEdge);
 }