diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-07-07 04:22:37 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-07-07 04:25:26 +0300 |
commit | f1176bd276e7009b394b76840943abb698de9c35 (patch) | |
tree | 3cf1e16415d469ae3c5505e05354c2aab9025ebc /object_fracture_cell/__init__.py | |
parent | 3f68f8442a531ebf234ac6d01fb35a4a5a0c2213 (diff) |
object_fracture_cell: Update add-on for 2.8x
Note, there is a remaining TODO:
We should be able to initialize rigit-body data so the mass can be set.
Diffstat (limited to 'object_fracture_cell/__init__.py')
-rw-r--r-- | object_fracture_cell/__init__.py | 75 |
1 files changed, 25 insertions, 50 deletions
diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py index e1fcb41f..fd8f0c4d 100644 --- a/object_fracture_cell/__init__.py +++ b/object_fracture_cell/__init__.py @@ -19,14 +19,15 @@ bl_info = { "name": "Cell Fracture", "author": "ideasman42, phymec, Sergey Sharybin", - "version": (0, 1), - "blender": (2, 70, 0), - "location": "Edit panel of Tools tab, in Object mode, 3D View tools", + "version": (0, 2), + "blender": (2, 80, 0), + "location": "Viewport Object Menu -> Quick Effects", "description": "Fractured Object, Bomb, Projectile, Recorder", "warning": "", "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/" "Scripts/Object/CellFracture", - "category": "Object"} + "category": "Object", +} #if "bpy" in locals(): @@ -57,9 +58,7 @@ def main_object(context, obj, level, **kw): recursion_clamp = kw_copy.pop("recursion_clamp") recursion_chance = kw_copy.pop("recursion_chance") recursion_chance_select = kw_copy.pop("recursion_chance_select") - use_layer_next = kw_copy.pop("use_layer_next") - use_layer_index = kw_copy.pop("use_layer_index") - group_name = kw_copy.pop("group_name") + collection_name = kw_copy.pop("collection_name") use_island_split = kw_copy.pop("use_island_split") use_debug_bool = kw_copy.pop("use_debug_bool") use_interior_vgroup = kw_copy.pop("use_interior_vgroup") @@ -150,24 +149,11 @@ def main_object(context, obj, level, **kw): #-------------- # Scene Options - # layer - layers_new = None - if use_layer_index != 0: - layers_new = [False] * 20 - layers_new[use_layer_index - 1] = True - elif use_layer_next: - layers_new = [False] * 20 - layers_new[(obj.layers[:].index(True) + 1) % 20] = True - - if layers_new is not None: - for obj_cell in objects: - obj_cell.layers = layers_new - # group - if group_name: - group = bpy.data.collections.get(group_name) + if collection_name: + group = bpy.data.collections.get(collection_name) if group is None: - group = bpy.data.collections.new(group_name) + group = bpy.data.collections.new(collection_name) group_objects = group.objects[:] for obj_cell in objects: if obj_cell not in group_objects: @@ -201,9 +187,12 @@ def main(context, **kw): for obj_cell in objects: obj_cell.select_set(True) + # FIXME(campbell): we should be able to initialize rigid-body data. if mass_mode == 'UNIFORM': for obj_cell in objects: - obj_cell.game.mass = mass + rb = obj_cell.rigid_body + if rb is not None: + rb.mass = mass elif mass_mode == 'VOLUME': from mathutils import Vector def _get_volume(obj_cell): @@ -237,7 +226,9 @@ def main(context, **kw): if obj_volume_tot > 0.0: mass_fac = mass / obj_volume_tot for i, obj_cell in enumerate(objects): - obj_cell.game.mass = obj_volume_ls[i] * mass_fac + rb = obj_cell.rigid_body + if rb is not None: + rb.mass = obj_volume_ls[i] * mass_fac else: assert(0) @@ -259,7 +250,7 @@ class FractureCell(Operator): "source object")), ('PARTICLE_CHILD', "Child Particles", ("All particle systems of the " "child objects")), - ('PENCIL', "Grease Pencil", "This object's grease pencil"), + ('PENCIL', "Annotations", "Use points from visible annotation"), ), options={'ENUM_FLAG'}, default={'PARTICLE_OWN'}, @@ -420,22 +411,9 @@ class FractureCell(Operator): # .. different from object options in that this controls how the objects # are setup in the scene. - use_layer_index: IntProperty( - name="Layer Index", - description="Layer to add the objects into or 0 for existing", - default=0, - min=0, max=20, - ) - - use_layer_next: BoolProperty( - name="Next Layer", - description="At the object into the next layer (layer index overrides)", - default=True, - ) - - group_name: StringProperty( - name="Group", - description="Create objects int a group " + collection_name: StringProperty( + name="Collection", + description="Create objects in a collection " "(use existing or create new)", ) @@ -534,9 +512,7 @@ class FractureCell(Operator): col = box.column() col.label(text="Scene") rowsub = col.row(align=True) - rowsub.prop(self, "use_layer_index") - rowsub.prop(self, "use_layer_next") - rowsub.prop(self, "group_name") + rowsub.prop(self, "collection_name") box = layout.box() col = box.column() @@ -549,19 +525,18 @@ class FractureCell(Operator): def menu_func(self, context): layout = self.layout - layout.label(text="Cell Fracture:") - layout.operator("object.add_fracture_cell_objects", - text="Cell Fracture") + layout.separator() + layout.operator("object.add_fracture_cell_objects", text="Cell Fracture") def register(): bpy.utils.register_class(FractureCell) - bpy.types.VIEW3D_PT_tools_object.append(menu_func) + bpy.types.VIEW3D_MT_object_quick_effects.append(menu_func) def unregister(): bpy.utils.unregister_class(FractureCell) - bpy.types.VIEW3D_PT_tools_object.remove(menu_func) + bpy.types.VIEW3D_MT_object_quick_effects.remove(menu_func) if __name__ == "__main__": |