Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static bool LineIntersection(Vector3 a_Line1Start, Vector3 a_Line1End, Vector3 a_Line2Start, Vector3 a_Line2End, out Vector3 a_IntersectionPoint, out bool a_IsUnique)
        {
            bool flag = false;

            a_IntersectionPoint = Vector3.zero;
            a_IsUnique          = false;
            Vector3 lhs     = a_Line1End - a_Line1Start;
            Vector3 rhs     = a_Line2End - a_Line2Start;
            Vector3 vector3 = a_Line2Start - a_Line1Start;
            Vector3 vector4 = Vector3.Cross(lhs, rhs);

            if (Mathf.Approximately(Vector3.Dot(vector3, vector4), 0f))
            {
                float sqrMagnitude = vector4.sqrMagnitude;
                if (!Mathf.Approximately(sqrMagnitude, 0f))
                {
                    float num5 = Vector3.Dot(Vector3.Cross(vector3, rhs), vector4) / sqrMagnitude;
                    if ((0f <= num5) && (num5 <= 1f))
                    {
                        flag = true;
                        a_IntersectionPoint = a_Line1Start + (num5 * lhs);
                        a_IsUnique          = true;
                    }
                }
                else if (Vector3Extension.Approximately(lhs, Vector3.zero))
                {
                    if (IsPointOnLine(a_Line1Start, a_Line2Start, a_Line2End))
                    {
                        flag                = true;
                        a_IsUnique          = true;
                        a_IntersectionPoint = a_Line1Start;
                    }
                }
                else if (Vector3Extension.Approximately(rhs, Vector3.zero))
                {
                    if (IsPointOnLine(a_Line2Start, a_Line1Start, a_Line1End))
                    {
                        flag                = true;
                        a_IsUnique          = true;
                        a_IntersectionPoint = a_Line2Start;
                    }
                }
                else
                {
                    float num3 = FactorOfPointOnLine(a_Line2Start, a_Line1Start, a_Line1End);
                    float num4 = FactorOfPointOnLine(a_Line2End, a_Line1Start, a_Line1End);
                    if ((0f <= num3) && (num3 <= 1f))
                    {
                        flag = true;
                        a_IntersectionPoint = a_Line2Start;
                    }
                    else if ((0f <= num4) && (num4 <= 1f))
                    {
                        flag = true;
                        a_IntersectionPoint = a_Line2End;
                    }
                    else if (((num3 < 0f) && (num4 > 1f)) || ((num4 < 0f) && (num3 > 1f)))
                    {
                        flag = true;
                        a_IntersectionPoint = a_Line1Start;
                    }
                }
            }
            return(flag);
        }
Ejemplo n.º 5
0
        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);
        }