public bool FindTriangleCollisionClipMethod(PrimitiveTriangle other, GIM_TRIANGLE_CONTACT contacts)
        {
            float margin = m_margin + other.m_margin;


            int clipped_count;

            //create planes
            // plane v vs U points


            m_contacts1.m_separating_normal = m_plane;

            clipped_count = ClipTriangle(other, clipped_points);

            if (clipped_count == 0)
            {
                return(false);//Reject
            }

            //find most deep interval face1
            m_contacts1.MergePoints(ref m_contacts1.m_separating_normal, margin, clipped_points, clipped_count);
            if (m_contacts1.m_point_count == 0)
            {
                return(false); // too far
            }
            //Normal pointing to this triangle
            m_contacts1.m_separating_normal *= -1.0f;


            //Clip tri1 by tri2 edges
            GIM_TRIANGLE_CONTACT contacts2 = new GIM_TRIANGLE_CONTACT();

            contacts2.m_separating_normal = other.m_plane;

            clipped_count = other.ClipTriangle(this, clipped_points);

            if (clipped_count == 0)
            {
                return(false);//Reject
            }

            //find most deep interval face1
            contacts2.MergePoints(ref contacts2.m_separating_normal, margin, clipped_points, clipped_count);
            if (contacts2.m_point_count == 0)
            {
                return(false); // too far
            }

            ////check most dir for contacts
            if (contacts2.m_penetration_depth < m_contacts1.m_penetration_depth)
            {
                contacts.CopyFrom(contacts2);
            }
            else
            {
                contacts.CopyFrom(m_contacts1);
            }
            return(true);
        }
Beispiel #2
0
 public void PushTriangleContacts(GIM_TRIANGLE_CONTACT tricontact,
                                  int feature1, int feature2)
 {
     for (int i = 0; i < tricontact.m_point_count; i++)
     {
         PushContact(
             ref tricontact.m_points[i],
             ref tricontact.m_separating_normal,
             tricontact.m_penetration_depth, feature1, feature2);
     }
 }
        public void CopyFrom(GIM_TRIANGLE_CONTACT other)
        {
            m_penetration_depth = other.m_penetration_depth;
            m_separating_normal = other.m_separating_normal;
            m_point_count       = other.m_point_count;
            int i = m_point_count;

            while (i-- != 0)
            {
                m_points[i] = other.m_points[i];
            }
        }
 public GIM_TRIANGLE_CONTACT(GIM_TRIANGLE_CONTACT other)
 {
     CopyFrom(other);
 }