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

non uniform cell shape, currently only xyz scale.

parent 1b0bdd04
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@ from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
EnumProperty)
from bpy.types import Operator
......@@ -192,6 +193,14 @@ class FractureCell(Operator):
default=0.0,
)
cell_scale = FloatVectorProperty(
name="Scale",
description="Scale Cell Shape",
size=3,
min=0.0, max=1.0,
default=(1.0, 1.0, 1.0),
)
# -------------------------------------------------------------------------
# Recursion
......@@ -330,6 +339,7 @@ class FractureCell(Operator):
rowsub.prop(self, "source_limit")
rowsub.prop(self, "source_noise")
rowsub = col.row()
rowsub.prop(self, "cell_scale")
box = layout.box()
col = box.column()
......
......@@ -21,7 +21,9 @@
# Script copyright (C) Blender Foundation 2012
def points_as_bmesh_cells(verts, points,
def points_as_bmesh_cells(verts,
points,
points_scale=None,
margin_bounds=0.05,
margin_cell=0.0):
from math import sqrt
......@@ -29,6 +31,14 @@ def points_as_bmesh_cells(verts, points,
from mathutils import Vector
cells = []
'''
if points_scale:
points_scale = (1.0 / points_scale[0],
1.0 / points_scale[1],
1.0 / points_scale[2],
)
'''
points_sorted_current = [p for p in points]
plane_indices = []
......@@ -65,6 +75,20 @@ def points_as_bmesh_cells(verts, points,
for j in range(1, len(points)):
normal = points_sorted_current[j] - point_cell_current
nlength = normal.length
if points_scale is not None:
normal_alt = normal.copy()
normal_alt.x *= points_scale[0]
normal_alt.y *= points_scale[1]
normal_alt.z *= points_scale[2]
# rotate plane to new distance
# should always be positive!! - but abs incase
scalar = normal_alt.normalized().dot(normal.normalized())
# assert(scalar >= 0.0)
nlength *= scalar
normal = normal_alt
if nlength > distance_max:
break
......
......@@ -125,6 +125,7 @@ def cell_fracture_objects(scene, obj,
margin=0.0,
material_index=0,
use_debug_redraw=False,
cell_scale=(1.0, 1.0, 1.0),
):
from . import fracture_cell_calc
......@@ -136,7 +137,7 @@ def cell_fracture_objects(scene, obj,
if not points:
# print using fallback
points = _points_from_object(obj, source | {'VERT_OWN'})
points = _points_from_object(obj, {'VERT_OWN'})
if not points:
print("no points found")
......@@ -187,7 +188,9 @@ def cell_fracture_objects(scene, 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,
cells = fracture_cell_calc.points_as_bmesh_cells(verts,
points,
cell_scale,
margin_cell=margin)
# some hacks here :S
......
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