Exemple #1
0
 public bool sharesVerts(MB_Triangle obj)
 {
     if (vs[0] == obj.vs[0] ||
         vs[0] == obj.vs[1] ||
         vs[0] == obj.vs[2])
     {
         if (submeshIdx != obj.submeshIdx)
         {
             return(true);
         }
     }
     if (vs[1] == obj.vs[0] ||
         vs[1] == obj.vs[1] ||
         vs[1] == obj.vs[2])
     {
         if (submeshIdx != obj.submeshIdx)
         {
             return(true);
         }
     }
     if (vs[2] == obj.vs[0] ||
         vs[2] == obj.vs[1] ||
         vs[2] == obj.vs[2])
     {
         if (submeshIdx != obj.submeshIdx)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
        public static int doSubmeshesShareVertsOrTris(Mesh m, ref MeshAnalysisResult mar)
        {
            MB_Triangle consider = new MB_Triangle();
            MB_Triangle other    = new MB_Triangle();

            //cache all triangles
            int[][] tris = new int[m.subMeshCount][];
            for (int i = 0; i < m.subMeshCount; i++)
            {
                tris[i] = m.GetTriangles(i);
            }
            bool sharesVerts = false;
            bool sharesTris  = false;

            for (int i = 0; i < m.subMeshCount; i++)
            {
                int[] smA = tris[i];
                for (int j = i + 1; j < m.subMeshCount; j++)
                {
                    int[] smB = tris[j];
                    for (int k = 0; k < smA.Length; k += 3)
                    {
                        consider.Initialize(smA, k, i);
                        for (int l = 0; l < smB.Length; l += 3)
                        {
                            other.Initialize(smB, l, j);
                            if (consider.isSame(other))
                            {
                                sharesTris = true;
                                break;
                            }
                            if (consider.sharesVerts(other))
                            {
                                sharesVerts = true;
                                break;
                            }
                        }
                    }
                }
            }
            if (sharesTris)
            {
                mar.hasOverlappingSubmeshVerts = true;
                mar.hasOverlappingSubmeshTris  = true;
                return(2);
            }
            else if (sharesVerts)
            {
                mar.hasOverlappingSubmeshVerts = true;
                mar.hasOverlappingSubmeshTris  = false;
                return(1);
            }
            else
            {
                mar.hasOverlappingSubmeshTris  = false;
                mar.hasOverlappingSubmeshVerts = false;
                return(0);
            }
        }
Exemple #3
0
        public bool isSame(object obj)
        {
            MB_Triangle tobj = (MB_Triangle)obj;

            if (vs[0] == tobj.vs[0] &&
                vs[1] == tobj.vs[1] &&
                vs[2] == tobj.vs[2] &&
                submeshIdx != tobj.submeshIdx)
            {
                return(true);
            }
            return(false);
        }
Exemple #4
0
    public static int doSubmeshesShareVertsOrTris(Mesh m)
    {
        List <MB_Triangle> tlist = new List <MB_Triangle>();
        bool sharesVerts         = false;
        bool sharesTris          = false;

        for (int i = 0; i < m.subMeshCount; i++)
        {
            int[] sm = m.GetTriangles(i);
            for (int j = 0; j < sm.Length; j += 3)
            {
                MB_Triangle consider = new MB_Triangle(sm, j, i);
                for (int k = 0; k < tlist.Count; k++)
                {
                    if (consider.isSame(tlist[k]))
                    {
                        sharesTris = true;
                    }
                    if (consider.sharesVerts(tlist[k]))
                    {
                        sharesVerts = true;
                    }
                }
                tlist.Add(consider);
            }
        }
        if (sharesTris)
        {
            return(2);
        }
        if (sharesVerts)
        {
            return(1);
        }
        return(0);
    }
Exemple #5
0
	public static int doSubmeshesShareVertsOrTris(Mesh m, ref MeshAnalysisResult mar){
		MB_Triangle consider = new MB_Triangle();
		MB_Triangle other = new MB_Triangle();
		//cache all triangles
		int[][] tris = new int[m.subMeshCount][];
		for (int i = 0; i < m.subMeshCount; i++){
			tris[i] = m.GetTriangles(i);
		}
		bool sharesVerts = false;
		bool sharesTris = false;
		for (int i = 0; i < m.subMeshCount; i++){
			int[] smA = tris[i];
			for (int j = i+1; j < m.subMeshCount; j++){
				int[] smB = tris[j];
				for (int k = 0; k < smA.Length; k+=3){
					consider.Initialize(smA,k,i);
					for (int l = 0; l < smB.Length; l+=3){
						other.Initialize(smB,l,j);
						if (consider.isSame(other)){
							sharesTris = true;
							break;
						}
						if (consider.sharesVerts(other)){
							sharesVerts = true;
							break;
						}					
					}
				}
			}
		}
		if (sharesTris){
				mar.hasOverlappingSubmeshVerts = true;
				mar.hasOverlappingSubmeshTris = true;
				return 2;
		} else if (sharesVerts){
				mar.hasOverlappingSubmeshVerts = true;
				mar.hasOverlappingSubmeshTris = false;
				return 1;
		} else {
				mar.hasOverlappingSubmeshTris = false;
				mar.hasOverlappingSubmeshVerts = false;
				return 0;
		}
	}	
Exemple #6
0
		public bool sharesVerts(MB_Triangle obj){
			if (vs[0] == obj.vs[0] ||
				vs[0] == obj.vs[1] ||
				vs[0] == obj.vs[2]){
				if (submeshIdx != obj.submeshIdx) return true;	
			}
			if (vs[1] == obj.vs[0] ||
				vs[1] == obj.vs[1] ||
				vs[1] == obj.vs[2]){
				if (submeshIdx != obj.submeshIdx) return true;
			}	
			if (vs[2] == obj.vs[0] ||
				vs[2] == obj.vs[1] ||
				vs[2] == obj.vs[2]){
				if (submeshIdx != obj.submeshIdx) return true;	
			}
			return false;			
		}
	public static int doSubmeshesShareVertsOrTris(Mesh m){
		List<MB_Triangle> tlist = new List<MB_Triangle>();
		bool sharesVerts = false;
		bool sharesTris = false;
		for (int i = 0; i < m.subMeshCount; i++){
			int[] sm = m.GetTriangles(i);
			for (int j = 0; j < sm.Length; j+=3){
				MB_Triangle consider = new MB_Triangle(sm,j,i);
				for (int k = 0; k < tlist.Count; k++){
					if (consider.isSame(tlist[k])) sharesTris = true;
					if (consider.sharesVerts(tlist[k])){
						sharesVerts = true;
					}
				}
				tlist.Add(consider);
			}
		}
		if (sharesTris) return 2;
		if (sharesVerts) return 1;
		return 0;
	}