diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-30 05:34:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-30 05:34:49 +0300 |
commit | 9b0a3ee9ce7c2edf93d84457420a46703eb9c82f (patch) | |
tree | 6b75a13fd17b0c06ade48eaa5fb42b2f2ea6eb35 /release | |
parent | 3f37f32e177d125646b624e596157858f9ead443 (diff) |
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
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/retopo.py | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/release/scripts/modules/retopo.py b/release/scripts/modules/retopo.py index 7d1c48a3f8f..89d1066da52 100644 --- a/release/scripts/modules/retopo.py +++ b/release/scripts/modules/retopo.py @@ -156,20 +156,20 @@ class Spline: hub.links.append(hub_prev) hub_prev.links.append(hub) hub_prev = hub - - - -def get_points(spline): - points = spline.points - if len(spline.bezier_points): - points = spline.bezier_points +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] - return [point.co.copy().resize3D() for point in points] - - -def get_splines(data): - return [Spline(get_points(spline)) for spline in data.splines] +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] def xsect_spline(sp_a, sp_b, _hubs): from Mathutils import LineIntersect @@ -203,9 +203,8 @@ def xsect_spline(sp_a, sp_b, _hubs): 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 calculate(scene, obj): 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 |