Skip to content
Snippets Groups Projects
Commit c1ecaec1 authored by Florian Meyer's avatar Florian Meyer
Browse files

-better poll

-cleanup and generalizations
parent 6201262b
Branches
Tags
No related merge requests found
...@@ -101,17 +101,27 @@ def binom(n, m): ...@@ -101,17 +101,27 @@ def binom(n, m):
def getDerivative(verts, t, nth): def getDerivative(verts, t, nth):
order = len(verts) - 1 - nth order = len(verts) - 1 - nth
QVerts = [] QVerts = []
for i in range(nth):
if QVerts: if nth:
verts = QVerts for i in range(nth):
derivVerts = [] if QVerts:
for i in range(len(verts)-1): verts = QVerts
derivVerts.append(verts[i+1] - verts[i]) derivVerts = []
QVerts = derivVerts for i in range(len(verts)-1):
point = mathutils.Vector((0, 0, 0)) derivVerts.append(verts[i+1] - verts[i])
QVerts = derivVerts
else:
QVerts = verts
if len(verts[0]) == 3:
point = mathutils.Vector((0, 0, 0))
if len(verts[0]) == 2:
point = mathutils.Vector((0, 0))
for i, vert in enumerate(QVerts): for i, vert in enumerate(QVerts):
point += binom(order, i) * math.pow(t, i) * math.pow(1-t, order-i) * vert point += binom(order, i) * math.pow(t, i) * math.pow(1-t, order-i) * vert
deriv = point deriv = point
return deriv return deriv
# get curvature from first, second derivative # get curvature from first, second derivative
...@@ -232,7 +242,6 @@ def main(context, obj, options): ...@@ -232,7 +242,6 @@ def main(context, obj, options):
# get vec3 list to simplify # get vec3 list to simplify
if spline.type == 'BEZIER': # get bezierverts if spline.type == 'BEZIER': # get bezierverts
splineVerts = spline.bezier_points.values()
splineVerts = [splineVert.co.copy() splineVerts = [splineVert.co.copy()
for splineVert in spline.bezier_points.values()] for splineVert in spline.bezier_points.values()]
...@@ -400,14 +409,21 @@ class GRAPH_OT_simplify(bpy.types.Operator): ...@@ -400,14 +409,21 @@ class GRAPH_OT_simplify(bpy.types.Operator):
box.prop(props, 'dis_error', expand=True) box.prop(props, 'dis_error', expand=True)
col = layout.column() col = layout.column()
## Check for curve ## Check for animdata
def poll(self, context): def poll(self, context):
objs = context.selected_objects obj = context.active_object
return (objs) fcurves = False
if obj:
animdata = obj.animation_data
if animdata:
act = animdata.action
if act:
fcurves = act.fcurves
return (obj and fcurves)
## execute ## execute
def execute(self, context): def execute(self, context):
print("------START------") #print("------START------")
options = [ options = [
self.properties.mode, #0 self.properties.mode, #0
...@@ -425,7 +441,7 @@ class GRAPH_OT_simplify(bpy.types.Operator): ...@@ -425,7 +441,7 @@ class GRAPH_OT_simplify(bpy.types.Operator):
fcurves_simplify(context, obj, options, self.fcurves) fcurves_simplify(context, obj, options, self.fcurves)
print("-------END-------") #print("-------END-------")
return {'FINISHED'} return {'FINISHED'}
########################### ###########################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment