Skip to content

Commit 9980e76

Browse files
committed
[BUG] Behavior on EPIC_spine_02 : controls are rotating in wrong axis when moving IK Fixes #510
1 parent f7f8fe1 commit 9980e76

1 file changed

Lines changed: 34 additions & 32 deletions

File tree

release/scripts/mgear/core/primitive.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -273,41 +273,43 @@ def add2DChain(
273273

274274
# moving rotation value to joint orient
275275
for i, jnt in enumerate(chain):
276-
if i == 0:
277-
jnt.setAttr("jointOrient", jnt.getAttr("rotate"))
278-
jnt.setAttr("rotate", 0, 0, 0)
279-
elif i == len(chain) - 1:
280-
jnt.setAttr("jointOrient", 0, 0, 0)
281-
jnt.setAttr("rotate", 0, 0, 0)
282-
else:
283-
# This will fail if chain is not always oriented the same
284-
# way (like X chain)
285-
v0 = positions[i] - positions[i - 1]
286-
v1 = positions[i + 1] - positions[i]
287-
angle = datatypes.degrees(v0.angle(v1))
288-
jnt.setAttr("rotate", 0, 0, 0)
289-
jnt.setAttr("jointOrient", 0, 0, angle)
276+
pm.makeIdentity(jnt, apply=True, t=0, r=1, s=0, n=0, pn=1)
277+
278+
# if i == 0:
279+
# jnt.setAttr("jointOrient", jnt.getAttr("rotate"))
280+
# jnt.setAttr("rotate", 0, 0, 0)
281+
# elif i == len(chain) - 1:
282+
# jnt.setAttr("jointOrient", 0, 0, 0)
283+
# jnt.setAttr("rotate", 0, 0, 0)
284+
# else:
285+
# # This will fail if chain is not always oriented the same
286+
# # way (like X chain)
287+
# v0 = positions[i] - positions[i - 1]
288+
# v1 = positions[i + 1] - positions[i]
289+
# angle = datatypes.degrees(v0.angle(v1))
290+
# jnt.setAttr("rotate", 0, 0, 0)
291+
# jnt.setAttr("jointOrient", 0, 0, angle)
290292

291293
# check if we have to negate Z angle by comparing the guide
292294
# position and the resulting position.
293-
if i >= 1:
294-
# round the position values to 6 decimals precission
295-
# TODO: test with less precision and new check after apply
296-
# Ik solver
297-
if [round(elem, 4) for elem in transform.getTranslation(jnt)] != [
298-
round(elem, 4) for elem in positions[i]
299-
]:
300-
301-
jp = jnt.getParent()
302-
303-
# Aviod intermediate e.g. `transform3` groups that can appear
304-
# between joints due to basic moving around.
305-
while jp.type() == "transform":
306-
jp = jp.getParent()
307-
308-
jp.setAttr(
309-
"jointOrient", 0, 0, jp.attr("jointOrient").get()[2] * -1
310-
)
295+
# if i >= 1:
296+
# # round the position values to 6 decimals precission
297+
# # TODO: test with less precision and new check after apply
298+
# # Ik solver
299+
# if [round(elem, 4) for elem in transform.getTranslation(jnt)] != [
300+
# round(elem, 4) for elem in positions[i]
301+
# ]:
302+
303+
# jp = jnt.getParent()
304+
305+
# # Aviod intermediate e.g. `transform3` groups that can appear
306+
# # between joints due to basic moving around.
307+
# while jp.type() == "transform":
308+
# jp = jp.getParent()
309+
310+
# jp.setAttr(
311+
# "jointOrient", 0, 0, jp.attr("jointOrient").get()[2] * -1
312+
# )
311313

312314
jnt.setAttr("radius", 1.5)
313315

0 commit comments

Comments
 (0)