Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
c1ecaec1
Commit
c1ecaec1
authored
14 years ago
by
Florian Meyer
Browse files
Options
Downloads
Patches
Plain Diff
-better poll
-cleanup and generalizations
parent
6201262b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
curve_simplify.py
+30
-14
30 additions, 14 deletions
curve_simplify.py
with
30 additions
and
14 deletions
curve_simplify.py
+
30
−
14
View file @
c1ecaec1
...
...
@@ -101,17 +101,27 @@ def binom(n, m):
def
getDerivative
(
verts
,
t
,
nth
):
order
=
len
(
verts
)
-
1
-
nth
QVerts
=
[]
for
i
in
range
(
nth
):
if
QVerts
:
verts
=
QVerts
derivVerts
=
[]
for
i
in
range
(
len
(
verts
)
-
1
):
derivVerts
.
append
(
verts
[
i
+
1
]
-
verts
[
i
])
QVerts
=
derivVerts
point
=
mathutils
.
Vector
((
0
,
0
,
0
))
if
nth
:
for
i
in
range
(
nth
):
if
QVerts
:
verts
=
QVerts
derivVerts
=
[]
for
i
in
range
(
len
(
verts
)
-
1
):
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
):
point
+=
binom
(
order
,
i
)
*
math
.
pow
(
t
,
i
)
*
math
.
pow
(
1
-
t
,
order
-
i
)
*
vert
deriv
=
point
return
deriv
# get curvature from first, second derivative
...
...
@@ -232,7 +242,6 @@ def main(context, obj, options):
# get vec3 list to simplify
if
spline
.
type
==
'
BEZIER
'
:
# get bezierverts
splineVerts
=
spline
.
bezier_points
.
values
()
splineVerts
=
[
splineVert
.
co
.
copy
()
for
splineVert
in
spline
.
bezier_points
.
values
()]
...
...
@@ -400,14 +409,21 @@ class GRAPH_OT_simplify(bpy.types.Operator):
box
.
prop
(
props
,
'
dis_error
'
,
expand
=
True
)
col
=
layout
.
column
()
## Check for
curve
## Check for
animdata
def
poll
(
self
,
context
):
objs
=
context
.
selected_objects
return
(
objs
)
obj
=
context
.
active_object
fcurves
=
False
if
obj
:
animdata
=
obj
.
animation_data
if
animdata
:
act
=
animdata
.
action
if
act
:
fcurves
=
act
.
fcurves
return
(
obj
and
fcurves
)
## execute
def
execute
(
self
,
context
):
print
(
"
------START------
"
)
#
print("------START------")
options
=
[
self
.
properties
.
mode
,
#0
...
...
@@ -425,7 +441,7 @@ class GRAPH_OT_simplify(bpy.types.Operator):
fcurves_simplify
(
context
,
obj
,
options
,
self
.
fcurves
)
print
(
"
-------END-------
"
)
#
print("-------END-------")
return
{
'
FINISHED
'
}
###########################
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment