Edges on polygon outlines not always correct

后端 未结 6 1136
梦毁少年i
梦毁少年i 2020-12-01 08:54

I\'m using the algorithm below to generate quads which are then rendered to make an outline like this

http://img810.imageshack.us/img810/8530/uhohz.p

6条回答
  •  一向
    一向 (楼主)
    2020-12-01 09:15

    You're reversing the orientation between the first segment and the rest. The block where you pull previous values out of the output vector should set the p0 and p1 points and you should calculate p2 and p3 based on the endpoints every time.

    i.e. it should be:

         if(i == 0)
         {
             p0.x = start.x + perpoffset.x - diroffset.x;
             p0.y = start.y + perpoffset.y - diroffset.y;
    
             p1.x = start.x - perpoffset.x - diroffset.x;
             p1.y = start.y - perpoffset.y - diroffset.y;
         }
         else
         {
             temp = (8 * (i - 1));
             p0.x = output[temp + 0];
             p0.y = output[temp + 1];
             p1.x = output[temp + 6];
             p1.y = output[temp + 7];
    
         }
    
         p2.x = end.x + perpoffset.x + diroffset.x;
         p2.y = end.y + perpoffset.y + diroffset.y;
    
         p3.x = end.x - perpoffset.x + diroffset.x;
         p3.y = end.y - perpoffset.y + diroffset.y;
    

提交回复
热议问题