Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2022-04-26 12:04:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2022-04-26 12:07:44 +0300
commit848d1dd82c906f15acc3e9c6db99e43e125c7e14 (patch)
tree64340b8a96468620711cbd2f0d2590f060061147
parentd1b824f3c2a7a7b3e37e70f336e5a1580028c63e (diff)
Cleanup: autopep8 in object_fracture_cell
-rw-r--r--object_fracture_cell/__init__.py21
-rw-r--r--object_fracture_cell/fracture_cell_calc.py14
-rw-r--r--object_fracture_cell/fracture_cell_setup.py79
3 files changed, 58 insertions, 56 deletions
diff --git a/object_fracture_cell/__init__.py b/object_fracture_cell/__init__.py
index 68d887a5..e9f70a44 100644
--- a/object_fracture_cell/__init__.py
+++ b/object_fracture_cell/__init__.py
@@ -13,9 +13,9 @@ bl_info = {
}
-#if "bpy" in locals():
-# import importlib
-# importlib.reload(fracture_cell_setup)
+# if "bpy" in locals():
+# import importlib
+# importlib.reload(fracture_cell_setup)
import bpy
from bpy.props import (
@@ -29,6 +29,7 @@ from bpy.props import (
from bpy.types import Operator
+
def main_object(context, collection, obj, level, **kw):
import random
@@ -79,7 +80,7 @@ def main_object(context, collection, obj, level, **kw):
center='MEDIAN',
)
- #----------
+ # ----------
# Recursion
if level == 0:
for level_sub in range(1, recursion + 1):
@@ -99,8 +100,7 @@ def main_object(context, collection, obj, level, **kw):
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)
+ 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()
@@ -124,7 +124,7 @@ def main_object(context, collection, obj, level, **kw):
if recursion_clamp and len(objects) > recursion_clamp:
break
- #--------------
+ # --------------
# Level Options
if level == 0:
# import pdb; pdb.set_trace()
@@ -182,6 +182,7 @@ def main(context, **kw):
rb.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))
@@ -207,7 +208,6 @@ def main(context, **kw):
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:
@@ -387,7 +387,6 @@ class FractureCell(Operator):
default=1.0,
)
-
# -------------------------------------------------------------------------
# Object Options
@@ -444,7 +443,6 @@ class FractureCell(Operator):
return {'FINISHED'}
-
def invoke(self, context, event):
# print(self.recursion_chance_select)
wm = context.window_manager
@@ -492,7 +490,6 @@ class FractureCell(Operator):
rowsub.prop(self, "margin")
rowsub.prop(self, "use_island_split")
-
box = layout.box()
col = box.column()
col.label(text="Physics")
@@ -500,14 +497,12 @@ class FractureCell(Operator):
rowsub.prop(self, "mass_mode")
rowsub.prop(self, "mass")
-
box = layout.box()
col = box.column()
col.label(text="Object")
rowsub = col.row(align=True)
rowsub.prop(self, "use_recenter")
-
box = layout.box()
col = box.column()
col.label(text="Scene")
diff --git a/object_fracture_cell/fracture_cell_calc.py b/object_fracture_cell/fracture_cell_calc.py
index 98bba36d..c609f299 100644
--- a/object_fracture_cell/fracture_cell_calc.py
+++ b/object_fracture_cell/fracture_cell_calc.py
@@ -5,11 +5,13 @@
# Script copyright (C) Blender Foundation 2012
-def points_as_bmesh_cells(verts,
- points,
- points_scale=None,
- margin_bounds=0.05,
- margin_cell=0.0):
+def points_as_bmesh_cells(
+ verts,
+ points,
+ points_scale=None,
+ margin_bounds=0.05,
+ margin_cell=0.0,
+):
from math import sqrt
import mathutils
from mathutils import Vector
@@ -42,7 +44,7 @@ def points_as_bmesh_cells(verts,
Vector((0.0, -1.0, 0.0, +ymin)),
Vector((0.0, 0.0, +1.0, -zmax)),
Vector((0.0, 0.0, -1.0, +zmin)),
- ]
+ ]
for i, point_cell_current in enumerate(points):
planes = [None] * len(convexPlanes)
diff --git a/object_fracture_cell/fracture_cell_setup.py b/object_fracture_cell/fracture_cell_setup.py
index 3720a171..aa03a808 100644
--- a/object_fracture_cell/fracture_cell_setup.py
+++ b/object_fracture_cell/fracture_cell_setup.py
@@ -10,6 +10,8 @@ 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)
@@ -20,7 +22,7 @@ def _points_from_object(depsgraph, scene, obj, source):
'PARTICLE_OWN', 'PARTICLE_CHILD',
'PENCIL',
'VERT_OWN', 'VERT_CHILD',
- }
+ }
# print(source - _source_all)
# print(source)
@@ -98,29 +100,28 @@ def _points_from_object(depsgraph, scene, obj, source):
# Used to be from object in 2.7x, now from scene.
gp = scene.grease_pencil
if gp:
- points.extend([p for spline in get_splines(gp)
- for p in spline])
+ points.extend([p for spline in get_splines(gp) for p in spline])
print("Found %d points" % len(points))
return points
-def cell_fracture_objects(context, collection, obj,
- source={'PARTICLE_OWN'},
- source_limit=0,
- source_noise=0.0,
- clean=True,
- # operator options
- use_smooth_faces=False,
- use_data_match=False,
- use_debug_points=False,
- margin=0.0,
- material_index=0,
- use_debug_redraw=False,
- cell_scale=(1.0, 1.0, 1.0),
- ):
-
+def cell_fracture_objects(
+ context, collection, obj,
+ source={'PARTICLE_OWN'},
+ source_limit=0,
+ source_noise=0.0,
+ clean=True,
+ # operator options
+ use_smooth_faces=False,
+ use_data_match=False,
+ use_debug_points=False,
+ margin=0.0,
+ material_index=0,
+ use_debug_redraw=False,
+ cell_scale=(1.0, 1.0, 1.0),
+):
from . import fracture_cell_calc
depsgraph = context.evaluated_depsgraph_get()
scene = context.scene
@@ -182,10 +183,12 @@ def cell_fracture_objects(context, collection, obj,
matrix = obj.matrix_world.copy()
verts = [matrix @ v.co for v in mesh.vertices]
- cells = fracture_cell_calc.points_as_bmesh_cells(verts,
- points,
- cell_scale,
- margin_cell=margin)
+ cells = fracture_cell_calc.points_as_bmesh_cells(
+ verts,
+ points,
+ cell_scale,
+ margin_cell=margin,
+ )
# some hacks here :S
cell_name = obj.name + "_cell"
@@ -203,6 +206,7 @@ def cell_fracture_objects(context, collection, obj,
# WORKAROUND FOR CONVEX HULL BUG/LIMIT
# XXX small noise
import random
+
def R():
return (random.random() - 0.5) * 0.001
# XXX small noise
@@ -241,7 +245,6 @@ def cell_fracture_objects(context, collection, obj,
for bm_face in bm.faces:
bm_face.material_index = material_index
-
# ---------------------------------------------------------------------
# MESH
mesh_dst = bpy.data.meshes.new(name=cell_name)
@@ -290,15 +293,16 @@ def cell_fracture_objects(context, collection, obj,
return objects
-def cell_fracture_boolean(context, collection, obj, objects,
- use_debug_bool=False,
- clean=True,
- use_island_split=False,
- use_interior_hide=False,
- use_debug_redraw=False,
- level=0,
- remove_doubles=True
- ):
+def cell_fracture_boolean(
+ context, collection, obj, objects,
+ use_debug_bool=False,
+ clean=True,
+ use_island_split=False,
+ use_interior_hide=False,
+ use_debug_redraw=False,
+ level=0,
+ remove_doubles=True
+):
objects_boolean = []
scene = context.scene
@@ -393,11 +397,12 @@ def cell_fracture_boolean(context, collection, obj, objects,
return objects_boolean
-def cell_fracture_interior_handle(objects,
- use_interior_vgroup=False,
- use_sharp_edges=False,
- use_sharp_edges_apply=False,
- ):
+def cell_fracture_interior_handle(
+ objects,
+ use_interior_vgroup=False,
+ use_sharp_edges=False,
+ use_sharp_edges_apply=False,
+):
"""Run after doing _all_ booleans"""
assert(use_interior_vgroup or use_sharp_edges or use_sharp_edges_apply)