[Bf-extensions-cvs] [1857eaff] master: object_fracture_cell: update for 2.8 T61901 f7c91d3382ea

meta-androcto noreply at git.blender.org
Sun Jun 30 05:24:05 CEST 2019


Commit: 1857eaff3077a0d44b2f50570d7ad12e48c76d05
Author: meta-androcto
Date:   Sun Jun 30 13:23:36 2019 +1000
Branches: master
https://developer.blender.org/rBAC1857eaff3077a0d44b2f50570d7ad12e48c76d05

object_fracture_cell: update for 2.8 T61901 f7c91d3382ea

===================================================================

M	object_fracture_cell/__init__.py
D	object_fracture_cell/fracture_cell_calc.py
D	object_fracture_cell/fracture_cell_setup.py
A	object_fracture_cell/operator.py
A	object_fracture_cell/process/cell_calc.py
A	object_fracture_cell/process/cell_functions.py
A	object_fracture_cell/process/cell_main.py
A	object_fracture_cell/process/crack_functions.py
A	object_fracture_cell/process/material_functions.py
A	object_fracture_cell/process/materials/materials1.blend
A	object_fracture_cell/utilities.py
D	object_fracture_crack/__init__.py
D	object_fracture_crack/crack_it.py
D	object_fracture_crack/materials/materials1.blend
D	object_fracture_crack/operator.py

===================================================================

diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py
index e1fcb41f..9fd3e6d3 100644
--- a/object_fracture_cell/__init__.py
+++ b/object_fracture_cell/__init__.py
@@ -18,20 +18,23 @@
 
 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",
-    "description": "Fractured Object, Bomb, Projectile, Recorder",
+    "author": "ideasman42, phymec, Sergey Sharybin, Nobuyuki Hirakata",
+    "version": (1, 0),
+    "blender": (2, 80, 0),
+    "location": "View3D > Sidebar > Transform tab",
+    "description": "Fractured Object, or Cracked Surface",
     "warning": "",
     "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
                 "Scripts/Object/CellFracture",
     "category": "Object"}
 
 
-#if "bpy" in locals():
-#    import importlib
-#    importlib.reload(fracture_cell_setup)
+if "bpy" in locals():
+    import importlib
+    importlib.reload(operator)
+
+else:
+    from . import operator
 
 import bpy
 from bpy.props import (
@@ -41,244 +44,114 @@ from bpy.props import (
         FloatProperty,
         FloatVectorProperty,
         EnumProperty,
+        BoolVectorProperty,
+        PointerProperty,
         )
 
-from bpy.types import Operator
-
-def main_object(context, obj, level, **kw):
-    import random
-
-    # pull out some args
-    kw_copy = kw.copy()
-    use_recenter = kw_copy.pop("use_recenter")
-    use_remove_original = kw_copy.pop("use_remove_original")
-    recursion = kw_copy.pop("recursion")
-    recursion_source_limit = kw_copy.pop("recursion_source_limit")
-    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")
-    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")
-    use_sharp_edges = kw_copy.pop("use_sharp_edges")
-    use_sharp_edges_apply = kw_copy.pop("use_sharp_edges_apply")
-
-    collection = context.collection
-
-    if level != 0:
-        kw_copy["source_limit"] = recursion_source_limit
-
-    from . import fracture_cell_setup
-
-    # not essential but selection is visual distraction.
-    obj.select_set(False)
-
-    if kw_copy["use_debug_redraw"]:
-        obj_display_type_prev = obj.display_type
-        obj.display_type = 'WIRE'
-
-    objects = fracture_cell_setup.cell_fracture_objects(context, obj, **kw_copy)
-    objects = fracture_cell_setup.cell_fracture_boolean(context, obj, objects,
-                                                        use_island_split=use_island_split,
-                                                        use_interior_hide=(use_interior_vgroup or use_sharp_edges),
-                                                        use_debug_bool=use_debug_bool,
-                                                        use_debug_redraw=kw_copy["use_debug_redraw"],
-                                                        level=level,
-                                                        )
-
-    # must apply after boolean.
-    if use_recenter:
-        bpy.ops.object.origin_set({"selected_editable_objects": objects},
-                                  type='ORIGIN_GEOMETRY', center='MEDIAN')
-
-    if level == 0:
-        for level_sub in range(1, recursion + 1):
-
-            objects_recurse_input = [(i, o) for i, o in enumerate(objects)]
-
-            if recursion_chance != 1.0:
-                from mathutils import Vector
-                if recursion_chance_select == 'RANDOM':
-                    random.shuffle(objects_recurse_input)
-                elif recursion_chance_select in {'SIZE_MIN', 'SIZE_MAX'}:
-                    objects_recurse_input.sort(key=lambda ob_pair:
-                        (Vector(ob_pair[1].bound_box[0]) -
-                         Vector(ob_pair[1].bound_box[6])).length_squared)
-                    if recursion_chance_select == 'SIZE_MAX':
-                        objects_recurse_input.reverse()
-                elif recursion_chance_select in {'CURSOR_MIN', 'CURSOR_MAX'}:
-                    c = scene.cursor.location.copy()
-                    objects_recurse_input.sort(key=lambda ob_pair:
-                        (ob_pair[1].location - c).length_squared)
-                    if recursion_chance_select == 'CURSOR_MAX':
-                        objects_recurse_input.reverse()
-
-                objects_recurse_input[int(recursion_chance * len(objects_recurse_input)):] = []
-                objects_recurse_input.sort()
-
-            # reverse index values so we can remove from original list.
-            objects_recurse_input.reverse()
-
-            objects_recursive = []
-            for i, obj_cell in objects_recurse_input:
-                assert(objects[i] is obj_cell)
-                objects_recursive += main_object(context, obj_cell, level_sub, **kw)
-                if use_remove_original:
-                    collection.objects.unlink(obj_cell)
-                    del objects[i]
-                if recursion_clamp and len(objects) + len(objects_recursive) >= recursion_clamp:
-                    break
-            objects.extend(objects_recursive)
-
-            if recursion_clamp and len(objects) > recursion_clamp:
-                break
-
-    #--------------
-    # Level Options
-    if level == 0:
-        # import pdb; pdb.set_trace()
-        if use_interior_vgroup or use_sharp_edges:
-            fracture_cell_setup.cell_fracture_interior_handle(objects,
-                                                              use_interior_vgroup=use_interior_vgroup,
-                                                              use_sharp_edges=use_sharp_edges,
-                                                              use_sharp_edges_apply=use_sharp_edges_apply,
-                                                              )
-
-    #--------------
-    # 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 group is None:
-            group = bpy.data.collections.new(group_name)
-        group_objects = group.objects[:]
-        for obj_cell in objects:
-            if obj_cell not in group_objects:
-                group.objects.link(obj_cell)
-
-    if kw_copy["use_debug_redraw"]:
-        obj.display_type = obj_display_type_prev
-
-    # testing only!
-    # obj.hide = True
-    return objects
-
-
-def main(context, **kw):
-    import time
-    t = time.time()
-    objects_context = context.selected_editable_objects
-
-    kw_copy = kw.copy()
-
-    # mass
-    mass_mode = kw_copy.pop("mass_mode")
-    mass = kw_copy.pop("mass")
-
-    objects = []
-    for obj in objects_context:
-        if obj.type == 'MESH':
-            objects += main_object(context, obj, 0, **kw_copy)
-
-    bpy.ops.object.select_all(action='DESELECT')
-    for obj_cell in objects:
-        obj_cell.select_set(True)
-
-    if mass_mode == 'UNIFORM':
-        for obj_cell in objects:
-            obj_cell.game.mass = mass
-    elif mass_mode == 'VOLUME':
-        from mathutils import Vector
-        def _get_volume(obj_cell):
-            def _getObjectBBMinMax():
-                min_co = Vector((1000000.0, 1000000.0, 1000000.0))
-                max_co = -min_co
-                matrix = obj_cell.matrix_world
-                for i in range(0, 8):
-                    bb_vec = obj_cell.matrix_world * Vector(obj_cell.bound_box[i])
-                    min_co[0] = min(bb_vec[0], min_co[0])
-                    min_co[1] = min(bb_vec[1], min_co[1])
-                    min_co[2] = min(bb_vec[2], min_co[2])
-                    max_co[0] = max(bb_vec[0], max_co[0])
-                    max_co[1] = max(bb_vec[1], max_co[1])
-                    max_co[2] = max(bb_vec[2], max_co[2])
-                return (min_co, max_co)
-
-            def _getObjectVolume():
-                min_co, max_co = _getObjectBBMinMax()
-                x = max_co[0] - min_co[0]
-                y = max_co[1] - min_co[1]
-                z = max_co[2] - min_co[2]
-                volume = x * y * z
-                return volume
-
-            return _getObjectVolume()
-
-
-        obj_volume_ls = [_get_volume(obj_cell) for obj_cell in objects]
-        obj_volume_tot = sum(obj_volume_ls)
-        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
-    else:
-        assert(0)
-
-    print("Done! %d objects in %.4f sec" % (len(objects), time.time() - t))
-
-
-class FractureCell(Operator):
-    bl_idname = "object.add_fracture_cell_objects"
-    bl_label = "Cell fracture selected mesh objects"
-    bl_options = {'PRESET'}
-
+from bpy.types import (
+        Panel,
+        PropertyGroup,
+        )        
+
+
+class FRACTURE_PT_Menu(Panel):
+    bl_idname = 'FRACTURE_PT_Menu'
+    bl_label = "Fracture Cell"
+    bl_space_type = "VIEW_3D"
+    bl_region_type = "UI"
+    bl_category = "Transform"
+    bl_context = 'objectmode'
+    bl_options = {"DEFAULT_CLOSED"}
+    
+    def draw(self, context):
+        # Show pop-upped menu when the button is hit.
+        layout = self.layout
+        #layout.label(text="Cell Fracture:")
+        layout.operator(operator.FRACTURE_OT_Cell.bl_idname,
+                    text="1. Cell Fracture")       
+        layout.operator(operator.FRACTURE_OT_Crack.bl_idname,
+             

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list