static void CreateBoneJointIfNeed(
     InsideEdgeLine insideEdge,
     GlyphTriangle first_p_tri,
     GlyphBoneJoint firstJoint,
     List <GlyphBone> newlyCreatedBones,
     List <GlyphBone> glyphBones)
 {
     if (insideEdge != null &&
         insideEdge.inside_joint == null)
     {
         InsideEdgeLine mainEdge = insideEdge;
         EdgeLine       nbEdge   = null;
         if (FindSameCoordEdgeLine(first_p_tri.N0, mainEdge, out nbEdge) ||
             FindSameCoordEdgeLine(first_p_tri.N1, mainEdge, out nbEdge) ||
             FindSameCoordEdgeLine(first_p_tri.N2, mainEdge, out nbEdge))
         {
             //confirm that nbEdge is INSIDE edge
             if (nbEdge.IsInside)
             {
                 GlyphBoneJoint joint = new GlyphBoneJoint((InsideEdgeLine)nbEdge, mainEdge);
                 GlyphBone      bone  = new GlyphBone(mainEdge.inside_joint, firstJoint);
                 newlyCreatedBones.Add(bone);
                 glyphBones.Add(bone);
             }
             else
             {
                 //?
             }
         }
         else
         {
             //?
         }
     }
 }
Esempio n. 2
0
        static bool FindCommonInsideEdges(GlyphTriangle a, GlyphTriangle b, out InsideEdgeLine a_edge, out InsideEdgeLine b_edge)
        {
            //2 contact triangles share GlyphBoneJoint.


            EdgeLine       find_b_edge = b.e0;
            InsideEdgeLine matching_inside_edge_of_a = null;

            if ((matching_inside_edge_of_a = FindCommonInsideEdge(a, find_b_edge)) != null)
            {
                //found
                a_edge = matching_inside_edge_of_a;
                b_edge = (InsideEdgeLine)find_b_edge;
                return(true);
            }
            //--------------
            find_b_edge = b.e1;
            if ((matching_inside_edge_of_a = FindCommonInsideEdge(a, find_b_edge)) != null)
            {
                //found
                a_edge = matching_inside_edge_of_a;
                b_edge = (InsideEdgeLine)find_b_edge;
                return(true);
            }
            find_b_edge = b.e2;
            if ((matching_inside_edge_of_a = FindCommonInsideEdge(a, find_b_edge)) != null)
            {
                //found
                a_edge = matching_inside_edge_of_a;
                b_edge = (InsideEdgeLine)find_b_edge;
                return(true);
            }
            a_edge = b_edge = null;
            return(false);
        }
 static void CreateTipBoneIfNeed(
     InsideEdgeLine insideEdge, GlyphBoneJoint joint,
     List <GlyphBone> newlyCreatedBones, List <GlyphBone> glyphBones)
 {
     if (insideEdge != null &&
         insideEdge.inside_joint != null &&
         insideEdge.inside_joint != joint)
     {
         //create connection
         GlyphBone tipBone = new GlyphBone(insideEdge.inside_joint, joint);
         newlyCreatedBones.Add(tipBone);
         glyphBones.Add(tipBone);
     }
 }
        internal GlyphBoneJoint(
            InsideEdgeLine p_contact_edge,
            InsideEdgeLine q_contact_edge)
        {
            //both p and q is INSIDE, contact edge
            this._p_contact_edge = p_contact_edge;
            this._q_contact_edge = q_contact_edge;
            //this is original x,y
            Vector2 midpos = p_contact_edge.GetMidPoint();

            this._fitX = midpos.X;
            this._fitY = midpos.Y;

#if DEBUG
            if (p_contact_edge.inside_joint != null ||
                q_contact_edge.inside_joint != null)
            {
                throw new System.NotSupportedException();
            }
#endif
            p_contact_edge.inside_joint = this;
            q_contact_edge.inside_joint = this;
        }