From 93226d0188184b45d2554572cca2f64f23cf5e8e Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Sat, 7 Jul 2012 09:46:56 +0000 Subject: [PATCH] support for using other objects particles as input --- object_fracture_cell/__init__.py | 8 +++++--- object_fracture_cell/fracture_cell_setup.py | 21 +++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py index c1a713335..0076742e9 100644 --- a/object_fracture_cell/__init__.py +++ b/object_fracture_cell/__init__.py @@ -183,12 +183,14 @@ class FractureCell(Operator): name="Source", items=(('VERT_OWN', "Own Verts", "Use own vertices"), ('VERT_CHILD', "Child Verts", "Use own vertices"), - ('PARTICLE', "Particles", ("All particle systems of the " - "source object")), + ('PARTICLE_OWN', "Own Particles", ("All particle systems of the " + "source object")), + ('PARTICLE_CHILD', "Child Particles", ("All particle systems of the " + "child objects")), ('PENCIL', "Grease Pencil", "This objects grease pencil"), ), options={'ENUM_FLAG'}, - default={'PARTICLE', 'VERT_OWN'} # 'VERT_OWN', 'EDGE_OWN', 'FACE_OWN' + default={'PARTICLE_OWN', 'VERT_OWN'}, ) source_limit = IntProperty( diff --git a/object_fracture_cell/fracture_cell_setup.py b/object_fracture_cell/fracture_cell_setup.py index 9a6ccbbfe..c2237f68b 100644 --- a/object_fracture_cell/fracture_cell_setup.py +++ b/object_fracture_cell/fracture_cell_setup.py @@ -34,7 +34,8 @@ _redraw_yasiamevil.arg = dict(type='DRAW_WIN_SWAP', iterations=1) def _points_from_object(obj, source): _source_all = { - 'PARTICLE', 'PENCIL', + 'PARTICLE_OWN', 'PARTICLE_CHILD', + 'PENCIL', 'VERT_OWN', 'VERT_CHILD', } @@ -77,6 +78,12 @@ def _points_from_object(obj, source): points.extend([matrix * v.co for v in mesh.vertices]) bpy.data.meshes.remove(mesh) + def points_from_particles(obj): + points.extend([p.location.copy() + for psys in obj.particle_systems + for p in psys.particles]) + + # geom own if 'VERT_OWN' in source: points_from_verts(obj) @@ -87,10 +94,12 @@ def _points_from_object(obj, source): points_from_verts(obj_child) # geom particles - if 'PARTICLE' in source: - points.extend([p.location.copy() - for psys in obj.particle_systems - for p in psys.particles]) + if 'PARTICLE_OWN' in source: + points_from_verts(obj) + + if 'PARTICLE_CHILD' in source: + for obj_child in obj.children: + points_from_particles(obj_child) # grease pencil def get_points(stroke): @@ -115,7 +124,7 @@ def _points_from_object(obj, source): def cell_fracture_objects(scene, obj, - source={'PARTICLE'}, + source={'PARTICLE_OWN'}, source_limit=0, source_noise=0.0, clean=True, -- GitLab