private void InitializeSortedNeighboringInternalVertices(DecalsMesh a_DecalsMesh, int a_VertexIndex) { this.m_SortedNeighboringVerticesInitialized = true; this.m_UnusedNeighboringTriangles.AddRange(this.m_NeighboringTriangles); int num = this.m_UnusedNeighboringTriangles[this.m_UnusedNeighboringTriangles.Count - 1]; int num2 = this.InnerTriangleIndexOfVertexIndex(a_DecalsMesh, num, a_VertexIndex); num2 = this.SuccessorInnerTriangleVertexIndex(num2); this.m_SortedNeighboringVertices.Add(a_DecalsMesh.Triangles[num + num2]); this.m_SortedNeighboringVertices.Add(a_DecalsMesh.Triangles[num + this.SuccessorInnerTriangleVertexIndex(num2)]); this.m_UnusedNeighboringTriangles.RemoveAt(this.m_UnusedNeighboringTriangles.Count - 1); while (true) { if (this.m_UnusedNeighboringTriangles.Count <= 1) { break; } bool flag = false; int num3 = this.m_SortedNeighboringVertices[this.m_SortedNeighboringVertices.Count - 1]; int index = 0; while (true) { if (index < this.m_UnusedNeighboringTriangles.Count) { int num5 = this.m_UnusedNeighboringTriangles[index]; int num6 = this.InnerTriangleIndexOfVertexIndex(a_DecalsMesh, num5, a_VertexIndex); num6 = this.SuccessorInnerTriangleVertexIndex(num6); int num7 = a_DecalsMesh.Triangles[num5 + num6]; if (num7 != num3) { index++; continue; } int item = a_DecalsMesh.Triangles[num5 + this.SuccessorInnerTriangleVertexIndex(num6)]; this.m_SortedNeighboringVertices.Add(item); this.m_UnusedNeighboringTriangles.RemoveAt(index); flag = true; } if (!flag) { this.m_SortedNeighboringVerticesInitialized = false; } break; } } if (this.m_SortedNeighboringVerticesInitialized) { int num10 = this.m_UnusedNeighboringTriangles[0]; int num11 = this.InnerTriangleIndexOfVertexIndex(a_DecalsMesh, num10, a_VertexIndex); num11 = this.SuccessorInnerTriangleVertexIndex(num11); if (this.m_SortedNeighboringVertices[this.m_SortedNeighboringVertices.Count - 1] != a_DecalsMesh.Triangles[num10 + num11]) { throw new InvalidOperationException("The last triangle doesn't match the previous ones."); } if (this.m_SortedNeighboringVertices[0] != a_DecalsMesh.Triangles[num10 + this.SuccessorInnerTriangleVertexIndex(num11)]) { throw new InvalidOperationException("The last triangle doesn't match to the first one."); } } }
public void MinimizeActiveProjectorOfDecalsMesh(DecalsMesh a_DecalsMesh, float a_MaximumAbsoluteError, float a_MaximumRelativeError) { if (a_DecalsMesh == null) { throw new ArgumentNullException("Decals mesh argument is not allowed to be null."); } if (a_DecalsMesh.ActiveDecalProjector == null) { throw new ArgumentNullException("Active decal projector of decals mesh is not allowed to be null."); } if (a_MaximumAbsoluteError < 0f) { throw new ArgumentOutOfRangeException("The maximum absolute error has to be greater than zero."); } if ((a_MaximumRelativeError < 0f) || (a_MaximumRelativeError > 1f)) { throw new ArgumentOutOfRangeException("The maximum relative error has to be within [0.0f, 1.0f]."); } this.ClearAll(); s_CurrentMaximumAbsoluteError = a_MaximumAbsoluteError; s_CurrentMaximumRelativeError = a_MaximumRelativeError; this.ComputePotentialObsoleteVertices(a_DecalsMesh); this.ComputeObsoleteInternalVertices(a_DecalsMesh); this.ComputeObsoleteExternalVertices(a_DecalsMesh); this.RemoveObsoleteVertices(a_DecalsMesh); this.ClearAll(); }
private void ComputeNeighbors(DecalsMesh a_DecalsMesh, int a_VertexIndex) { this.ClearNeighbors(); for (int i = a_DecalsMesh.ActiveDecalProjector.DecalsMeshLowerTriangleIndex; i < a_DecalsMesh.Triangles.Count; i += 3) { this.AddNeighborTriangleIfNeeded(a_DecalsMesh, a_VertexIndex, i); } }
private void ComputeNeighbors(DecalsMesh a_DecalsMesh, int a_VertexIndex, List <OptimizeEdge> a_RedundantInternalEdges) { this.ClearNeighbors(); foreach (OptimizeEdge edge in a_RedundantInternalEdges) { this.AddNeighborTriangleIfNeeded(a_DecalsMesh, a_VertexIndex, edge.triangle1Index); this.AddNeighborTriangleIfNeeded(a_DecalsMesh, a_VertexIndex, edge.triangle2Index); } }
private void AddTriangleNormal(DecalsMesh a_DecalsMesh, int a_TriangleIndex) { if (!this.m_TriangleNormals.HasTriangleNormal(a_TriangleIndex)) { int num = a_DecalsMesh.Triangles[a_TriangleIndex]; int num2 = a_DecalsMesh.Triangles[a_TriangleIndex + 1]; int num3 = a_DecalsMesh.Triangles[a_TriangleIndex + 2]; Vector3 vector4 = GeometryUtilities.TriangleNormal(a_DecalsMesh.Vertices[num], a_DecalsMesh.Vertices[num2], a_DecalsMesh.Vertices[num3]); this.m_TriangleNormals.AddTriangleNormal(a_TriangleIndex, vector4); } }
private void ComputeObsoleteExternalVertices(DecalsMesh a_DecalsMesh) { for (int i = this.m_ObsoleteExternalVertexIndices.Count - 1; i >= 0; i--) { int num2 = this.m_ObsoleteExternalVertexIndices[i]; if (!this.m_ObsoleteVertexFinder.IsExternalVertexObsolete(a_DecalsMesh, num2)) { this.m_ObsoleteExternalVertexIndices.RemoveAt(i); } } }
private void ComputeObsoleteInternalVertices(DecalsMesh a_DecalsMesh) { List <OptimizeEdge> list = this.m_RedundantInternalEdges.OptimizedEdgeList(); for (int i = this.m_ObsoleteInternalVertexIndices.Count - 1; i >= 0; i--) { int num2 = this.m_ObsoleteInternalVertexIndices[i]; if (!this.m_ObsoleteVertexFinder.IsInternalVertexObsolete(a_DecalsMesh, num2, list)) { this.m_ObsoleteInternalVertexIndices.RemoveAt(i); } } }
private void AddNewTriangles(DecalsMesh a_DecalsMesh) { while (true) { bool flag; while (true) { if (this.m_SortedNeighboringVertices.Count >= 3) { flag = false; for (int i = 0; i < this.m_SortedNeighboringVertices.Count; i++) { int num2 = i; int index = i + 1; int num4 = i + 2; if (index >= this.m_SortedNeighboringVertices.Count) { index -= this.m_SortedNeighboringVertices.Count; num4 -= this.m_SortedNeighboringVertices.Count; } else if (num4 >= this.m_SortedNeighboringVertices.Count) { num4 -= this.m_SortedNeighboringVertices.Count; } int item = this.m_SortedNeighboringVertices[num2]; int num6 = this.m_SortedNeighboringVertices[index]; int num7 = this.m_SortedNeighboringVertices[num4]; Vector3 rhs = GeometryUtilities.TriangleNormal(a_DecalsMesh.Vertices[item], a_DecalsMesh.Vertices[num6], a_DecalsMesh.Vertices[num7]); if (Vector3.Dot(this.m_ReferenceTriangleNormal, rhs) >= 0f) { a_DecalsMesh.Triangles.Add(item); a_DecalsMesh.Triangles.Add(num6); a_DecalsMesh.Triangles.Add(num7); this.m_SortedNeighboringVertices.RemoveAt(index); flag = true; break; } } } else { return; } break; } if (!flag) { return; } } }
private void AddNeighborTriangleIfNeeded(DecalsMesh a_DecalsMesh, int a_VertexIndex, int a_TriangleIndex) { int num = a_DecalsMesh.Triangles[a_TriangleIndex]; int num2 = a_DecalsMesh.Triangles[a_TriangleIndex + 1]; int num3 = a_DecalsMesh.Triangles[a_TriangleIndex + 2]; int item = 0; int num5 = 0; bool flag = true; if (a_VertexIndex == num) { item = num2; num5 = num3; } else if (a_VertexIndex == num2) { item = num; num5 = num3; } else if (a_VertexIndex != num3) { flag = false; } else { item = num; num5 = num2; } if (flag && !this.m_NeighboringTriangles.Contains(a_TriangleIndex)) { this.m_NeighboringTriangles.Add(a_TriangleIndex); if (!this.m_NeighboringVertexIndices.Contains(item)) { float num6 = Vector3.Distance(a_DecalsMesh.Vertices[a_VertexIndex], a_DecalsMesh.Vertices[item]); this.m_NeighboringVertexIndices.Add(item); this.m_NeighboringVertexDistances.Add(num6); } if (!this.m_NeighboringVertexIndices.Contains(num5)) { float num7 = Vector3.Distance(a_DecalsMesh.Vertices[a_VertexIndex], a_DecalsMesh.Vertices[num5]); this.m_NeighboringVertexIndices.Add(num5); this.m_NeighboringVertexDistances.Add(num7); } this.AddTriangleNormal(a_DecalsMesh, a_TriangleIndex); } }
internal void RemoveObsoleteInternalVertex(DecalsMesh a_DecalsMesh, int a_VertexIndex, List <OptimizeEdge> a_RedundantInternalEdges, out bool a_SuccessfulRemoval) { this.InitializeNeighboringTriangles(a_DecalsMesh, a_VertexIndex); this.InitializeSortedNeighboringInternalVertices(a_DecalsMesh, a_VertexIndex); if (!this.m_SortedNeighboringVerticesInitialized) { a_SuccessfulRemoval = false; } else { this.RemoveUnneededTriangles(a_DecalsMesh); this.AddNewTriangles(a_DecalsMesh); a_DecalsMesh.ActiveDecalProjector.DecalsMeshUpperTriangleIndex = a_DecalsMesh.Triangles.Count - 1; a_SuccessfulRemoval = true; } this.Clear(); }
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); }
public void MinimizeActiveProjectorOfDecalsMesh(DecalsMesh a_DecalsMesh) { if (a_DecalsMesh == null) { throw new ArgumentNullException("Decals mesh argument is not allowed to be null."); } float meshMinimizerMaximumAbsoluteError = a_DecalsMesh.Decals.MeshMinimizerMaximumAbsoluteError; float meshMinimizerMaximumRelativeError = a_DecalsMesh.Decals.MeshMinimizerMaximumRelativeError; try { this.MinimizeActiveProjectorOfDecalsMesh(a_DecalsMesh, meshMinimizerMaximumAbsoluteError, meshMinimizerMaximumRelativeError); } catch { throw; } }
private int InnerTriangleIndexOfVertexIndex(DecalsMesh a_DecalsMesh, int a_TriangleIndex, int a_VertexIndex) { int num; if (a_DecalsMesh.Triangles[a_TriangleIndex] == a_VertexIndex) { num = 0; } else if (a_DecalsMesh.Triangles[a_TriangleIndex + 1] == a_VertexIndex) { num = 1; } else { if (a_DecalsMesh.Triangles[a_TriangleIndex + 2] != a_VertexIndex) { throw new InvalidOperationException("The vertex index argument is not in the provided triangle."); } num = 2; } return(num); }
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; }
private void RemoveUnneededTriangles(DecalsMesh a_DecalsMesh) { this.m_NeighboringTriangles.Sort(); int num = this.m_NeighboringTriangles.Count - 1; while (num >= 0) { int num2 = this.m_NeighboringTriangles[num]; int num3 = 1; while (true) { if ((num <= 0) || ((num2 - 3) != this.m_NeighboringTriangles[num - 1])) { a_DecalsMesh.RemoveTrianglesAt(num2, num3); num--; break; } num2 -= 3; num3++; num--; } } }
private bool AreVertexPropertiesIdentical(DecalsMesh a_DecalsMesh, int a_VertexIndex1, int a_VertexIndex2) { Decals decals = a_DecalsMesh.Decals; bool flag = Vector3Extension.Approximately(a_DecalsMesh.Vertices[a_VertexIndex1], a_DecalsMesh.Vertices[a_VertexIndex2], DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); if (flag && (decals.CurrentNormalsMode == NormalsMode.Target)) { flag = Vector3Extension.Approximately(a_DecalsMesh.Normals[a_VertexIndex1], a_DecalsMesh.Normals[a_VertexIndex2], DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); } if (flag && (decals.CurrentTangentsMode == TangentsMode.Target)) { Vector4 vector6 = a_DecalsMesh.Tangents[a_VertexIndex2]; flag = Vector3Extension.Approximately(a_DecalsMesh.Tangents[a_VertexIndex1], (Vector3)vector6, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); } if (flag && ((decals.CurrentUVMode == UVMode.TargetUV) || (decals.CurrentUVMode == UVMode.TargetUV2))) { flag = Vector2Extension.Approximately(a_DecalsMesh.UVs[a_VertexIndex1], a_DecalsMesh.UVs[a_VertexIndex2], DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); } if (flag && ((decals.CurrentUV2Mode == UV2Mode.TargetUV) || (decals.CurrentUV2Mode == UV2Mode.TargetUV2))) { flag = Vector2Extension.Approximately(a_DecalsMesh.UV2s[a_VertexIndex1], a_DecalsMesh.UV2s[a_VertexIndex2], DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); } return(flag); }
private void InitializeNeighboringTriangles(DecalsMesh a_DecalsMesh, int a_VertexIndex) { bool flag = false; for (int i = a_DecalsMesh.ActiveDecalProjector.DecalsMeshLowerTriangleIndex; i < a_DecalsMesh.Triangles.Count; i += 3) { int num2 = a_DecalsMesh.Triangles[i]; int num3 = a_DecalsMesh.Triangles[i + 1]; int num4 = a_DecalsMesh.Triangles[i + 2]; if ((num2 == a_VertexIndex) || ((num3 == a_VertexIndex) || (num4 == a_VertexIndex))) { this.m_NeighboringTriangles.Add(i); if (!flag) { Vector3 vector = a_DecalsMesh.Vertices[num2]; this.m_ReferenceTriangleNormal = GeometryUtilities.TriangleNormal(vector, a_DecalsMesh.Vertices[num3], a_DecalsMesh.Vertices[num4]); if (!Vector3Extension.Approximately(this.m_ReferenceTriangleNormal, Vector3.zero, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError)) { flag = true; } } } } }
public bool IsInternalVertexObsolete(DecalsMesh a_DecalsMesh, int a_VertexIndex, List <OptimizeEdge> a_RedundantInternalEdges) { this.ClearAll(); this.ComputeNeighbors(a_DecalsMesh, a_VertexIndex, a_RedundantInternalEdges); return(this.IsVertexObsolete(a_DecalsMesh, a_VertexIndex)); }
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(); }
private bool AreWeightedVertexPropertiesApproximatelyVertexProperties(DecalsMesh a_DecalsMesh, int a_VertexIndex) { bool flag = true; Decals decals = a_DecalsMesh.Decals; if (flag) { Vector3 vector = a_DecalsMesh.Vertices[a_VertexIndex]; Vector3 zero = Vector3.zero; int num = 0; while (true) { if (num >= this.m_NeighboringVertexIndices.Count) { flag = flag && Vector3Extension.Approximately(vector, zero, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); break; } int num2 = this.m_NeighboringVertexIndices[num]; float num3 = this.m_NeighboringVertexWeight[num]; Vector3 vector3 = a_DecalsMesh.Vertices[num2]; zero += num3 * vector3; num++; } } if (flag && (decals.CurrentNormalsMode == NormalsMode.Target)) { Vector3 vector4 = a_DecalsMesh.Normals[a_VertexIndex]; Vector3 zero = Vector3.zero; int num4 = 0; while (true) { if (num4 >= this.m_NeighboringVertexIndices.Count) { flag = flag && Vector3Extension.Approximately(vector4, zero, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); break; } int num5 = this.m_NeighboringVertexIndices[num4]; float num6 = this.m_NeighboringVertexWeight[num4]; Vector3 vector6 = a_DecalsMesh.Normals[num5]; (zero + (num6 * vector6)).Normalize(); num4++; } } if (flag && (decals.CurrentTangentsMode == TangentsMode.Target)) { Vector4 vector7 = a_DecalsMesh.Tangents[a_VertexIndex]; Vector4 zero = Vector3.zero; int num7 = 0; while (true) { if (num7 >= this.m_NeighboringVertexIndices.Count) { flag = flag && Vector4Extension.Approximately(vector7, zero, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); break; } int num8 = this.m_NeighboringVertexIndices[num7]; float num9 = this.m_NeighboringVertexWeight[num7]; Vector4 vector9 = a_DecalsMesh.Tangents[num8]; (zero + (num9 * vector9)).Normalize(); num7++; } } if (flag && ((decals.CurrentUVMode == UVMode.TargetUV) || (decals.CurrentUVMode == UVMode.TargetUV2))) { Vector2 vector10 = a_DecalsMesh.UVs[a_VertexIndex]; Vector2 zero = Vector3.zero; int num10 = 0; while (true) { if (num10 >= this.m_NeighboringVertexIndices.Count) { flag = flag && Vector2Extension.Approximately(vector10, zero, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); break; } int num11 = this.m_NeighboringVertexIndices[num10]; float num12 = this.m_NeighboringVertexWeight[num10]; Vector2 vector12 = a_DecalsMesh.UVs[num11]; zero += num12 * vector12; num10++; } } if (flag && ((decals.CurrentUV2Mode == UV2Mode.TargetUV) || (decals.CurrentUV2Mode == UV2Mode.TargetUV2))) { Vector2 vector13 = a_DecalsMesh.UV2s[a_VertexIndex]; Vector2 zero = Vector3.zero; int num13 = 0; while (true) { if (num13 >= this.m_NeighboringVertexIndices.Count) { flag = flag && Vector2Extension.Approximately(vector13, zero, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError); break; } int num14 = this.m_NeighboringVertexIndices[num13]; float num15 = this.m_NeighboringVertexWeight[num13]; Vector2 vector15 = a_DecalsMesh.UV2s[num14]; zero += num15 * vector15; num13++; } } return(true); }
private bool IsVertexObsolete(DecalsMesh a_DecalsMesh, int a_VertexIndex) { bool flag = false; if (this.m_NeighboringTriangles.Count <= 0) { return(flag); } else { flag = true; bool flag2 = false; Vector3 zero = Vector3.zero; foreach (int num in this.m_NeighboringTriangles) { zero = this.m_TriangleNormals[num]; if (zero != Vector3.zero) { flag2 = true; break; } } if (flag2) { foreach (int num2 in this.m_NeighboringTriangles) { Vector3 rhs = this.m_TriangleNormals[num2]; if ((rhs != Vector3.zero) && !MathfExtension.Approximately(Vector3.Dot(zero, rhs), 1f, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError)) { flag = false; break; } } } if (!flag) { return(flag); } else { float num4 = 0f; int num5 = 0; while (true) { if (num5 >= this.m_NeighboringVertexIndices.Count) { float num7 = 0f; if (!MathfExtension.Approximately(num4, 0f, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError)) { num7 = 1f / num4; } for (int i = 0; i < this.m_NeighboringVertexIndices.Count; i++) { float num9 = this.m_NeighboringVertexDistances[i]; if (!MathfExtension.Approximately(num9, 0f, DecalsMeshMinimizer.s_CurrentMaximumAbsoluteError, DecalsMeshMinimizer.s_CurrentMaximumRelativeError)) { float item = 1f - (num9 / num7); this.m_NeighboringVertexWeight.Add(item); } else { this.m_NeighboringVertexWeight.Add(0f); int num10 = this.m_NeighboringVertexIndices[i]; flag = this.AreVertexPropertiesIdentical(a_DecalsMesh, a_VertexIndex, num10); if (!flag) { break; } } } break; } float num6 = this.m_NeighboringVertexDistances[num5]; num4 += num6; num5++; } } } if (flag) { flag = this.AreWeightedVertexPropertiesApproximatelyVertexProperties(a_DecalsMesh, a_VertexIndex); } return(flag); }
public bool IsExternalVertexObsolete(DecalsMesh a_DecalsMesh, int a_VertexIndex) { this.ClearAll(); this.ComputeNeighbors(a_DecalsMesh, a_VertexIndex); return(this.IsVertexObsolete(a_DecalsMesh, a_VertexIndex)); }
private void InitializeSortedNeighboringExternalVertices(DecalsMesh a_DecalsMesh, int a_VertexIndex) { this.m_SortedNeighboringVerticesInitialized = true; this.m_UnusedNeighboringTriangles.AddRange(this.m_NeighboringTriangles); if (this.m_UnusedNeighboringTriangles.Count > 0) { int num = this.m_UnusedNeighboringTriangles[this.m_UnusedNeighboringTriangles.Count - 1]; int num2 = this.InnerTriangleIndexOfVertexIndex(a_DecalsMesh, num, a_VertexIndex); num2 = this.SuccessorInnerTriangleVertexIndex(num2); this.m_SortedNeighboringVertices.Add(a_DecalsMesh.Triangles[num + num2]); this.m_SortedNeighboringVertices.Add(a_DecalsMesh.Triangles[num + this.SuccessorInnerTriangleVertexIndex(num2)]); this.m_UnusedNeighboringTriangles.RemoveAt(this.m_UnusedNeighboringTriangles.Count - 1); } else { this.m_SortedNeighboringVerticesInitialized = false; return; } while (true) { while (true) { if (this.m_UnusedNeighboringTriangles.Count != 0) { bool flag = false; int num3 = this.m_SortedNeighboringVertices[0]; int num4 = this.m_SortedNeighboringVertices[this.m_SortedNeighboringVertices.Count - 1]; int index = 0; while (true) { if (index < this.m_UnusedNeighboringTriangles.Count) { int num6 = this.m_UnusedNeighboringTriangles[index]; int num7 = this.InnerTriangleIndexOfVertexIndex(a_DecalsMesh, num6, a_VertexIndex); num7 = this.SuccessorInnerTriangleVertexIndex(num7); if (a_DecalsMesh.Triangles[num6 + num7] == num4) { int item = a_DecalsMesh.Triangles[num6 + this.SuccessorInnerTriangleVertexIndex(num7)]; this.m_SortedNeighboringVertices.Add(item); this.m_UnusedNeighboringTriangles.RemoveAt(index); flag = true; } else { int num10 = num7; int num8 = a_DecalsMesh.Triangles[num6 + this.SuccessorInnerTriangleVertexIndex(num7)]; if (num8 != num3) { index++; continue; } int item = a_DecalsMesh.Triangles[num6 + num10]; this.m_SortedNeighboringVertices.Insert(0, item); this.m_UnusedNeighboringTriangles.RemoveAt(index); flag = true; } } if (flag) { continue; } else { this.m_SortedNeighboringVerticesInitialized = false; } break; } } return; } } }