Skip to content
Snippets Groups Projects
Commit 846e736a authored by Campbell Barton's avatar Campbell Barton
Browse files

add support for using non mesh objects as point sources (mainly for curves but...

add support for using non mesh objects as point sources (mainly for curves but meta's and surfaces also work)
remove face/edge point sources. not really that useful in most cases and clogged up UI.
parent b55a9289
No related branches found
No related tags found
No related merge requests found
......@@ -161,7 +161,7 @@ def main(context, **kw):
class FractureCell(Operator):
bl_idname = "object.add_fracture_cell_objects"
bl_label = "Cell Fracture Helper Objects"
bl_label = "Cell Fracture Mesh"
bl_options = {'PRESET'}
# -------------------------------------------------------------------------
......@@ -169,11 +169,7 @@ class FractureCell(Operator):
source = EnumProperty(
name="Source",
items=(('VERT_OWN', "Own Verts", "Use own vertices"),
('EDGE_OWN', "Own Edges", "Use own edges"),
('FACE_OWN', "Own Faces", "Use own faces"),
('VERT_CHILD', "Child Verts", "Use own vertices"),
('EDGE_CHILD', "Child Edges", "Use own edges"),
('FACE_CHILD', "Child Faces", "Use own faces"),
('PARTICLE', "Particles", ("All particle systems of the "
"source object")),
('PENCIL', "Grease Pencil", "This objects grease pencil"),
......
......@@ -35,8 +35,8 @@ def _points_from_object(obj, source):
_source_all = {
'PARTICLE', 'PENCIL',
'VERT_OWN', 'EDGE_OWN', 'FACE_OWN',
'VERT_CHILD', 'EDGE_CHILD', 'FACE_CHILD'}
'VERT_OWN', 'VERT_CHILD',
}
print(source - _source_all)
print(source)
......@@ -59,41 +59,32 @@ def _points_from_object(obj, source):
return co / tot
def points_from_verts(obj):
"""Takes points from _any_ object with geometry"""
if obj.type == 'MESH':
mesh = obj.data
matrix = obj.matrix_world.copy()
points.extend([matrix * v.co for v in mesh.vertices])
else:
try:
mesh = ob.to_mesh(scene=bpy.context.scene,
apply_modifiers=True,
settings='PREVIEW')
except:
mesh = None
def points_from_edges(obj):
if obj.type == 'MESH':
mesh = obj.data
matrix = obj.matrix_world.copy()
points.extend([matrix * edge_center(mesh, e) for e in mesh.edges])
def points_from_faces(obj):
if obj.type == 'MESH':
mesh = obj.data
matrix = obj.matrix_world.copy()
points.extend([matrix * poly_center(mesh, p) for p in mesh.polygons])
if mesh is not None:
matrix = obj.matrix_world.copy()
points.extend([matrix * v.co for v in mesh.vertices])
bpy.data.meshes.remove(mesh)
# geom own
if 'VERT_OWN' in source:
points_from_verts(obj)
if 'EDGE_OWN' in source:
points_from_edges(obj)
if 'FACE_OWN' in source:
points_from_faces(obj)
# geom children
if 'VERT_CHILD' in source:
for obj_child in obj.children:
points_from_verts(obj_child)
if 'EDGE_CHILD' in source:
for obj_child in obj.children:
points_from_edges(obj_child)
if 'FACE_CHILD' in source:
for obj_child in obj.children:
points_from_faces(obj_child)
# geom particles
if 'PARTICLE' in source:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment