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
8da041a3
Commit
8da041a3
authored
13 years ago
by
Nathan Vegdahl
Browse files
Options
Downloads
Patches
Plain Diff
Rigify: fixed broken ik/fk snapping (api changes).
parent
940b6cd3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rigify/generate.py
+2
-2
2 additions, 2 deletions
rigify/generate.py
rigify/rig_ui_template.py
+5
-35
5 additions, 35 deletions
rigify/rig_ui_template.py
rigify/utils.py
+11
-4
11 additions, 4 deletions
rigify/utils.py
with
18 additions
and
41 deletions
rigify/generate.py
+
2
−
2
View file @
8da041a3
...
@@ -25,7 +25,7 @@ from rigify.utils import MetarigError, new_bone, get_rig_type
...
@@ -25,7 +25,7 @@ from rigify.utils import MetarigError, new_bone, get_rig_type
from
rigify.utils
import
ORG_PREFIX
,
MCH_PREFIX
,
DEF_PREFIX
,
WGT_PREFIX
,
ROOT_NAME
,
make_original_name
from
rigify.utils
import
ORG_PREFIX
,
MCH_PREFIX
,
DEF_PREFIX
,
WGT_PREFIX
,
ROOT_NAME
,
make_original_name
from
rigify.utils
import
RIG_DIR
from
rigify.utils
import
RIG_DIR
from
rigify.utils
import
create_root_widget
from
rigify.utils
import
create_root_widget
from
rigify.utils
import
random_
string
from
rigify.utils
import
random_
id
from
rigify.rig_ui_template
import
UI_SLIDERS
,
layers_ui
,
UI_REGISTER
from
rigify.rig_ui_template
import
UI_SLIDERS
,
layers_ui
,
UI_REGISTER
from
rigify
import
rigs
from
rigify
import
rigs
...
@@ -55,7 +55,7 @@ def generate_rig(context, metarig):
...
@@ -55,7 +55,7 @@ def generate_rig(context, metarig):
# Random string with time appended so that
# Random string with time appended so that
# different rigs don't collide id's
# different rigs don't collide id's
rig_id
=
random_
string
(
8
)
+
str
(
hex
(
int
(
time
.
time
())))[
2
:][
-
8
:].
rjust
(
8
,
'
0
'
)
rig_id
=
random_
id
(
16
)
# Initial configuration
# Initial configuration
mode_orig
=
context
.
mode
mode_orig
=
context
.
mode
...
...
This diff is collapsed.
Click to expand it.
rigify/rig_ui_template.py
+
5
−
35
View file @
8da041a3
...
@@ -49,42 +49,12 @@ def get_pose_matrix_in_other_space(mat, pose_bone):
...
@@ -49,42 +49,12 @@ def get_pose_matrix_in_other_space(mat, pose_bone):
# Get matrix in bone
'
s current transform space
# Get matrix in bone
'
s current transform space
smat = rest_inv * (par_rest * (par_inv * mat))
smat = rest_inv * (par_rest * (par_inv * mat))
# Compensate for non-inherited rotation/scale
if not pose_bone.bone.use_inherit_rotation:
loc = mat.to_translation()
loc -= (par_mat*(par_rest.inverted() * rest)).to_translation()
loc *= rest.inverted().to_quaternion()
if pose_bone.bone.use_inherit_scale:
t = par_mat.to_scale()
par_scale = Matrix.Scale(t[0], 4, Vector((1,0,0)))
par_scale *= Matrix.Scale(t[1], 4, Vector((0,1,0)))
par_scale *= Matrix.Scale(t[2], 4, Vector((0,0,1)))
else:
par_scale = Matrix()
smat = rest_inv * mat * par_scale.inverted()
smat[3][0] = loc[0]
smat[3][1] = loc[1]
smat[3][2] = loc[2]
elif not pose_bone.bone.use_inherit_scale:
loc = smat.to_translation()
rot = smat.to_quaternion()
scl = mat.to_scale()
smat = Matrix.Scale(scl[0], 4, Vector((1,0,0)))
smat *= Matrix.Scale(scl[1], 4, Vector((0,1,0)))
smat *= Matrix.Scale(scl[2], 4, Vector((0,0,1)))
smat *= Matrix.Rotation(rot.angle, 4, rot.axis)
smat[3][0] = loc[0]
smat[3][1] = loc[1]
smat[3][2] = loc[2]
# Compensate for non-local location
# Compensate for non-local location
if not pose_bone.bone.use_local_location:
#
if not pose_bone.bone.use_local_location:
loc = smat.to_translation() * (par_rest.inverted() * rest).to_quaternion()
#
loc = smat.to_translation() * (par_rest.inverted() * rest).to_quaternion()
smat[3][0] = loc[0]
#
smat[3][0] = loc[0]
smat[3][1] = loc[1]
#
smat[3][1] = loc[1]
smat[3][2] = loc[2]
#
smat[3][2] = loc[2]
return smat
return smat
...
...
This diff is collapsed.
Click to expand it.
rigify/utils.py
+
11
−
4
View file @
8da041a3
...
@@ -18,7 +18,8 @@
...
@@ -18,7 +18,8 @@
import
bpy
import
bpy
import
imp
import
imp
from
random
import
randint
import
random
import
time
from
mathutils
import
Vector
from
mathutils
import
Vector
from
math
import
ceil
,
floor
from
math
import
ceil
,
floor
from
rna_prop_ui
import
rna_idprop_ui_prop_get
from
rna_prop_ui
import
rna_idprop_ui_prop_get
...
@@ -497,10 +498,16 @@ def write_metarig(obj, layers=False, func_name="create_sample"):
...
@@ -497,10 +498,16 @@ def write_metarig(obj, layers=False, func_name="create_sample"):
return
"
\n
"
.
join
(
code
)
return
"
\n
"
.
join
(
code
)
def
random_string
(
length
):
def
random_id
(
length
=
8
):
"""
Generates a random alphanumeric id string.
"""
tlength
=
int
(
length
/
2
)
rlength
=
int
(
length
/
2
)
+
int
(
length
%
2
)
chars
=
[
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
,
'
7
'
,
'
8
'
,
'
9
'
,
'
0
'
,
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
,
'
e
'
,
'
f
'
,
'
g
'
,
'
h
'
,
'
i
'
,
'
j
'
,
'
k
'
,
'
l
'
,
'
m
'
,
'
n
'
,
'
o
'
,
'
p
'
,
'
q
'
,
'
r
'
,
'
s
'
,
'
t
'
,
'
u
'
,
'
v
'
,
'
w
'
,
'
x
'
,
'
y
'
,
'
z
'
]
chars
=
[
'
0
'
,
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
,
'
5
'
,
'
6
'
,
'
7
'
,
'
8
'
,
'
9
'
,
'
0
'
,
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
,
'
e
'
,
'
f
'
,
'
g
'
,
'
h
'
,
'
i
'
,
'
j
'
,
'
k
'
,
'
l
'
,
'
m
'
,
'
n
'
,
'
o
'
,
'
p
'
,
'
q
'
,
'
r
'
,
'
s
'
,
'
t
'
,
'
u
'
,
'
v
'
,
'
w
'
,
'
x
'
,
'
y
'
,
'
z
'
]
text
=
""
text
=
""
for
i
in
range
(
0
,
length
):
for
i
in
range
(
0
,
rlength
):
text
+=
chars
[
randint
(
0
,
35
)]
text
+=
random
.
choice
(
chars
)
text
+=
str
(
hex
(
int
(
time
.
time
())))[
2
:][
-
tlength
:].
rjust
(
tlength
,
'
0
'
)[::
-
1
]
return
text
return
text
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