Cleanup: autopep8 in object_fracture_cell
This commit is contained in:
parent
d1b824f3c2
commit
848d1dd82c
|
@ -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")
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue