[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25018] trunk/blender: previous commit for retopo converted the strokes into a curve first, better to use the grease pencil data directly.

Campbell Barton ideasman42 at gmail.com
Mon Nov 30 03:34:50 CET 2009


Revision: 25018
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25018
Author:   campbellbarton
Date:     2009-11-30 03:34:49 +0100 (Mon, 30 Nov 2009)

Log Message:
-----------
previous commit for retopo converted the strokes into a curve first, better to use the grease pencil data directly. renamed coordinates --> co, matching mesh verts

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/retopo.py
    trunk/blender/source/blender/makesrna/intern/rna_gpencil.c

Modified: trunk/blender/release/scripts/modules/retopo.py
===================================================================
--- trunk/blender/release/scripts/modules/retopo.py	2009-11-30 02:28:50 UTC (rev 25017)
+++ trunk/blender/release/scripts/modules/retopo.py	2009-11-30 02:34:49 UTC (rev 25018)
@@ -156,21 +156,21 @@
             hub.links.append(hub_prev)
             hub_prev.links.append(hub)
             hub_prev = hub
-    
 
+def get_points(stroke):
+    from Mathutils import Vector
+    # TODO - why isnt point.co a Vector?
+    return [Vector(tuple(point.co)) for point in stroke.points]
 
-def get_points(spline):
-    points = spline.points
+def get_splines(gp):
+    for l in gp.layers:
+        if l.active: # XXX - should be layers.active
+            break
+    
+    frame = l.active_frame
+    
+    return [Spline(get_points(stroke)) for stroke in frame.strokes]
 
-    if len(spline.bezier_points):
-        points = spline.bezier_points
-
-    return [point.co.copy().resize3D() for point in points]
-
-
-def get_splines(data):
-    return [Spline(get_points(spline)) for spline in data.splines]
-
 def xsect_spline(sp_a, sp_b, _hubs):
     from Mathutils import LineIntersect
     from Mathutils import MidpointVecs
@@ -203,9 +203,8 @@
         pt_a_prev = pt_a
 
 
-def calculate(scene, obj):
-    data = obj.data
-    splines = get_splines(data)
+def calculate(gp):
+    splines = get_splines(gp)
     _hubs = {}
     
     for i, sp in enumerate(splines):
@@ -265,22 +264,21 @@
     
     
 def main():
-    # first convert gpencil
-    # *** evil!
     scene = bpy.context.scene
+    obj = bpy.context.object
     
-    bpy.ops.gpencil.convert(type='PATH')
-        
+    gp = None
     
-    scene = bpy.context.scene
-    obj = bpy.context.object
-    if not obj:
-        raise Exception("no active object")
+    if obj:
+        gp = obj.grease_pencil
     
-    obj_new = calculate(scene, obj)
+    if not gp:
+        gp = scene.grease_pencil
+
+    if not gp:
+        raise Exception("no active grease pencil")
     
-    # obj.selected = False
-    scene.objects.unlink(obj)
+    obj_new = calculate(gp)
     
     scene.objects.active = obj_new
     obj_new.selected = True

Modified: trunk/blender/source/blender/makesrna/intern/rna_gpencil.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_gpencil.c	2009-11-30 02:28:50 UTC (rev 25017)
+++ trunk/blender/source/blender/makesrna/intern/rna_gpencil.c	2009-11-30 02:34:49 UTC (rev 25018)
@@ -77,7 +77,7 @@
 	RNA_def_struct_sdna(srna, "bGPDspoint");
 	RNA_def_struct_ui_text(srna, "Grease Pencil Stroke Point", "Data point for freehand stroke curve.");
 	
-	prop= RNA_def_property(srna, "coordinates", PROP_FLOAT, PROP_NONE);
+	prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_float_sdna(prop, NULL, "x");
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Coordinates", "");





More information about the Bf-blender-cvs mailing list