Getting face of mesh when you already have one tri
I currently have a setup where the user can select one tri of a face of a mesh but i want my program to find the other tri and thus have the entire face.
Currently i was trying to compare my current points with the vertices table and find two matching points that both tri's share and the missing one so i could have a whole face but it doesn't seem to work. Here's my code.
Find tri selected(WORKS):
  void Update()
     {
        
         Ray ray = Camera.main.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
 
       
         RaycastHit hit = new RaycastHit();
        
         if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity))
         {
          
             Debug.DrawRay(ray.origin, ray.direction * hit.distance, Color.red);
     
 
             if (Input.GetMouseButtonDown(0))
             {
                int ind = hit.triangleIndex;
                hitTransform = hit.collider.transform;
                Debug.Log("Hit tri index is " + ind * 3);
 
                 SelectFace(hit);
             }
         }
     }
 
     void SelectTriangle(RaycastHit hit)
     {
         int ind = hit.triangleIndex;
         Vector3 point0 = vertices[triangles[ind * 3]];
         Vector3 point1 = vertices[triangles[ind * 3 + 1]];
         Vector3 point2 = vertices[triangles[ind * 3 + 2]];
 
         point0 = hitTransform.TransformPoint(point0);
         point1 = hitTransform.TransformPoint(point1);
         point2 = hitTransform.TransformPoint(point2);
 
        
         Debug.DrawLine(point0, point1, Color.red);
         Debug.DrawLine(point1, point2, Color.red);
         Debug.DrawLine(point0, point2, Color.red);
     }
 
               Select Face(NOT WORKING):
    void SelectFace(RaycastHit hit)
     {
         int ind = hit.triangleIndex;
         Vector3 point0 = vertices[triangles[ind * 3]];
         Vector3 point1 = vertices[triangles[ind * 3 + 1]];
         Vector3 point2 = vertices[triangles[ind * 3 + 2]];
         Vector3 point3 = new Vector3(0,0,0);
         
 
         for(int i = 0; i < triangleCount; i++)
         {
             int pointCount = 0;
             bool point0t = false, point1t = false, point2t = false;
 
             Vector3 V1 = vertices[triangles[i * 3]];
             Vector3 V2 = vertices[triangles[i * 3 + 1]];
             Vector3 V3 = vertices[triangles[i * 3 + 2]]; 
 
             List<Vector3> al = new List<Vector3>();
   
 
             al.Add(V1);
             al.Add(V2);
             al.Add(V3);
 
 
 
             if (al.Contains(point0))
             {
                 pointCount += 1;
                 point0t = true;
 
                 Debug.Log("CONTAINS POINT 0");
             }
 
             if (al.Contains(point1))
             {
                 pointCount += 1;
                 point1t = true;
 
                 Debug.Log("CONTAINS POINT 1");
             }
 
             if (al.Contains(point2))
             {
                 pointCount += 1;
                 point2t = true;
 
                 Debug.Log("CONTAINS POINT 2");
             }
 
             if(pointCount == 2)
             {
                 Debug.Log("MATCH");
 
             }
 
 
             if (point0t == false)
             {
                 point3 = point0;
             }
 
             if (point1t == false)
             {
                 point3 = point1;
             }
 
             if (point2t == false)
             {
                 point3 = point2;
             }
 
           
             // Debug.Log(point3);
         }
         // Debug.Log(point3);
         point0 = hitTransform.TransformPoint(point0);
         point1 = hitTransform.TransformPoint(point1);
         point2 = hitTransform.TransformPoint(point2);
         point3 = hitTransform.TransformPoint(point3);
 
         Debug.DrawLine(point0, point3, Color.red);
         Debug.DrawLine(point1, point3, Color.red);
         Debug.DrawLine(point2, point3, Color.red);
 
         Debug.DrawLine(point0, point1, Color.red);
         Debug.DrawLine(point1, point2, Color.red);
     }
 
               Any help would be appreciated, thanks! :)
               Comment
              
 
               
              Your answer