Revision: 18541
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18541
Author:   theeth
Date:     2009-01-16 21:24:31 +0100 (Fri, 16 Jan 2009)

Log Message:
-----------
Command Gesture - Polygonize

New command option to turn continuous strokes into polylines.

Modified Paths:
--------------
    branches/etch-a-ton/source/blender/src/editarmature_sketch.c

Modified: branches/etch-a-ton/source/blender/src/editarmature_sketch.c
===================================================================
--- branches/etch-a-ton/source/blender/src/editarmature_sketch.c        
2009-01-16 18:04:01 UTC (rev 18540)
+++ branches/etch-a-ton/source/blender/src/editarmature_sketch.c        
2009-01-16 20:24:31 UTC (rev 18541)
@@ -957,6 +957,52 @@
        }
 }
 
+void sk_polygonizeStroke(SK_Stroke *stk, int start, int end)
+{
+       int offset;
+       int i;
+       
+       /* find first exact points outside of range */
+       for (;start > 0; start--)
+       {
+               if (stk->points[start].type == PT_EXACT)
+               {
+                       break;
+               }
+       }
+       
+       for (;end < stk->nb_points - 1; end++)
+       {
+               if (stk->points[end].type == PT_EXACT)
+               {
+                       break;
+               }
+       }
+       
+       offset = start + 1;
+       
+       for (i = start + 1; i < end; i++)
+       {
+               if (stk->points[i].type == PT_EXACT)
+               {
+                       if (offset != i)
+                       {
+                               memcpy(stk->points + offset, stk->points + i, 
sizeof(SK_Point));
+                       }
+
+                       offset++;
+               }
+       }
+       
+       /* some points were removes, move end of array */
+       if (offset < end)
+       {
+               int size = stk->nb_points - end;
+               memmove(stk->points + offset, stk->points + end, size * 
sizeof(SK_Point));
+               stk->nb_points = offset + size;
+       }
+}
+
 void sk_flattenStroke(SK_Stroke *stk, int start, int end)
 {
        float normal[3], distance[3];
@@ -2509,7 +2555,7 @@
        SK_Intersection *isect;
        int command;
        
-       command = pupmenu("Action %t|Flatten %x1|Cut Out %x2");
+       command = pupmenu("Action %t|Flatten %x1|Cut Out %x2|Polygonize %x3");
        if(command < 1) return;
 
        for (isect = gest->intersections.first; isect; isect = isect->next)
@@ -2528,6 +2574,9 @@
                                case 2:
                                        sk_cutoutStroke(isect->stroke, 
isect->after, i2->before, isect->p, i2->p);
                                        break;
+                               case 3:
+                                       sk_polygonizeStroke(isect->stroke, 
isect->before, i2->after);
+                                       break;
                        }
 
                        isect = i2;


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to