From 832437932350f1d94c7d64afa5016539ea150cfb Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Tue, 3 Jul 2012 16:27:48 +0000 Subject: [PATCH] option to draw as fracture runs --- object_fracture_voroni/__init__.py | 17 ++++++++++++++++- object_fracture_voroni/fracture_cell_setup.py | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/object_fracture_voroni/__init__.py b/object_fracture_voroni/__init__.py index 5122abefc..3a6e507a2 100644 --- a/object_fracture_voroni/__init__.py +++ b/object_fracture_voroni/__init__.py @@ -60,9 +60,14 @@ def main_object(scene, obj, level, **kw): from . import fracture_cell_setup + if kw_copy["use_debug_redraw"]: + obj_draw_type_prev = obj.draw_type + obj.draw_type = 'WIRE' + objects = fracture_cell_setup.cell_fracture_objects(scene, obj, **kw_copy) objects = fracture_cell_setup.cell_fracture_boolean(scene, obj, objects, - use_island_split=use_island_split) + use_island_split=use_island_split, + use_debug_redraw=kw_copy["use_debug_redraw"]) # todo, split islands. @@ -129,6 +134,9 @@ def main_object(scene, obj, level, **kw): for obj_cell in objects: group.objects.link(obj_cell) + if kw_copy["use_debug_redraw"]: + obj.draw_type = obj_draw_type_prev + # testing only! # obj.hide = True return objects @@ -292,6 +300,12 @@ class FractureCell(Operator): description="Create mesh data showing the points used for fracture", default=False, ) + + use_debug_redraw = BoolProperty( + name="Show Progress Realtime", + description="Redraw as fracture is done", + default=True, + ) def execute(self, context): keywords = self.as_keywords() # ignore=("blah",) @@ -358,6 +372,7 @@ class FractureCell(Operator): col = box.column() col.label("Debug") rowsub = col.row(align=True) + rowsub.prop(self, "use_debug_redraw") rowsub.prop(self, "use_debug_points") #def menu_func(self, context): diff --git a/object_fracture_voroni/fracture_cell_setup.py b/object_fracture_voroni/fracture_cell_setup.py index ee821716b..c2661a10a 100644 --- a/object_fracture_voroni/fracture_cell_setup.py +++ b/object_fracture_voroni/fracture_cell_setup.py @@ -23,6 +23,14 @@ import bpy import bmesh + +def _redraw_yasiamevil(): + _redraw_yasiamevil.opr(**_redraw_yasiamevil.arg) +_redraw_yasiamevil.opr = bpy.ops.wm.redraw_timer +_redraw_yasiamevil.arg = dict(type='DRAW_WIN_SWAP', iterations=1) + + + def _points_from_object(obj, source): _source_all = { @@ -125,6 +133,7 @@ def cell_fracture_objects(scene, obj, use_debug_points=False, margin=0.0, material_index=0, + use_debug_redraw=False, ): from . import fracture_cell_calc @@ -189,7 +198,7 @@ def cell_fracture_objects(scene, obj, cells = fracture_cell_calc.points_as_bmesh_cells(verts, points, margin_cell=margin) - + # some hacks here :S cell_name = obj.name + "_cell" @@ -270,6 +279,10 @@ def cell_fracture_objects(scene, obj, objects.append(obj_cell) + if use_debug_redraw: + scene.update() + _redraw_yasiamevil() + scene.update() @@ -287,6 +300,7 @@ def cell_fracture_boolean(scene, obj, objects, apply=True, clean=True, use_island_split=False, + use_debug_redraw=False, ): objects_boolean = [] @@ -334,6 +348,9 @@ def cell_fracture_boolean(scene, obj, objects, if obj_cell is not None: objects_boolean.append(obj_cell) + + if use_debug_redraw: + _redraw_yasiamevil() if use_island_split: # this is ugly and Im not proud of this - campbell -- GitLab