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
e6e82736
Commit
e6e82736
authored
13 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
use reverse vector multiply order,
also fix error check and report the message rather then print it.
parent
01dd77b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
animation_add_corrective_shape_key.py
+16
-18
16 additions, 18 deletions
animation_add_corrective_shape_key.py
with
16 additions
and
18 deletions
animation_add_corrective_shape_key.py
+
16
−
18
View file @
e6e82736
...
...
@@ -177,15 +177,15 @@ def func_add_corrective_pose_shape( source, target):
if
epsilon
<
threshold
:
epsilon
=
0.0
dx
[
0
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
[
1
,
0
,
0
]
)]
dx
[
1
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
[
-
1
,
0
,
0
]
)]
dx
[
2
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
[
0
,
1
,
0
]
)]
dx
[
3
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
[
0
,
-
1
,
0
]
)]
dx
[
4
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
[
0
,
0
,
1
]
)]
dx
[
5
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
[
0
,
0
,
-
1
]
)]
dx
[
0
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
(
1
,
0
,
0
)
)]
dx
[
1
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
(
-
1
,
0
,
0
)
)]
dx
[
2
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
(
0
,
1
,
0
)
)]
dx
[
3
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
(
0
,
-
1
,
0
)
)]
dx
[
4
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
(
0
,
0
,
1
)
)]
dx
[
5
]
+=
[
x
[
i
]
+
0.5
*
epsilon
*
mathutils
.
Vector
(
(
0
,
0
,
-
1
)
)]
for
j
in
range
(
0
,
6
):
applyX
(
ob_1
,
mesh_1_key_verts
,
dx
[
j
]
)
applyX
(
ob_1
,
mesh_1_key_verts
,
dx
[
j
])
dx
[
j
]
=
extractMappedX
(
ob_1
,
mesh_1_key_verts
)
# take a step in the direction of the gradient
...
...
@@ -193,13 +193,13 @@ def func_add_corrective_pose_shape( source, target):
epsilon
=
(
targetx
[
i
]
-
mapx
[
i
]).
length
if
epsilon
>=
threshold
:
Gx
=
list
((
dx
[
0
][
i
]
-
dx
[
1
][
i
])
/
epsilon
)
Gy
=
list
((
dx
[
2
][
i
]
-
dx
[
3
][
i
])
/
epsilon
)
Gz
=
list
((
dx
[
4
][
i
]
-
dx
[
5
][
i
])
/
epsilon
)
Gx
=
list
((
dx
[
0
][
i
]
-
dx
[
1
][
i
])
/
epsilon
)
Gy
=
list
((
dx
[
2
][
i
]
-
dx
[
3
][
i
])
/
epsilon
)
Gz
=
list
((
dx
[
4
][
i
]
-
dx
[
5
][
i
])
/
epsilon
)
G
=
mathutils
.
Matrix
((
Gx
,
Gy
,
Gz
))
G
=
flip_matrix_direction
(
G
)
x
[
i
]
+=
(
targetx
[
i
]
-
mapx
[
i
])
*
G
x
[
i
]
+=
G
*
(
targetx
[
i
]
-
mapx
[
i
])
applyX
(
ob_1
,
mesh_1_key_verts
,
x
)
...
...
@@ -224,24 +224,22 @@ class add_corrective_pose_shape(bpy.types.Operator):
return
context
.
active_object
!=
None
def
execute
(
self
,
context
):
if
len
(
context
.
selected_objects
)
>
2
:
print
(
"
Select source and target objects please
"
)
return
{
'
FINISHED
'
}
selection
=
context
.
selected_objects
if
len
(
selection
)
!=
2
:
self
.
report
({
'
ERROR
'
},
"
Select source and target objects
"
)
return
{
'
CANCELLED
'
}
target
=
context
.
active_object
if
context
.
active_object
==
selection
[
0
]:
source
=
selection
[
1
]
else
:
source
=
selection
[
0
]
#~ print(source)
#~ print(target)
func_add_corrective_pose_shape
(
source
,
target
)
return
{
'
FINISHED
'
}
def
func_object_duplicate_flatten_modifiers
(
ob
,
scene
):
mesh
=
ob
.
to_mesh
(
bpy
.
context
.
scene
,
True
,
'
PREVIEW
'
)
name
=
ob
.
name
+
"
_clean
"
...
...
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