Skip to content

Commit b84c895

Browse files
committed
Add target offset to cast ik handle definition.
1 parent 030648b commit b84c895

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,12 @@ Cast ids are stored as integers to make it faster to serialize and deserialize.
562562
<td>False</td>
563563
<td>False</td>
564564
</tr>
565+
<tr>
566+
<td>Target Offset (to)</td>
567+
<td>Vector 3 (v3)</td>
568+
<td>False</td>
569+
<td>False</td>
570+
</tr>
565571
<tr>
566572
<td>Pole Vector Bone Hash (pv)</td>
567573
<td>Integer 64 (l)</td>

libraries/python/cast.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,17 @@ def SetTargetBone(self, hash):
11501150
"""Sets the bone that acts as a target for the chain."""
11511151
self.CreateProperty("tb", "l").values = [hash]
11521152

1153+
def TargetOffset(self):
1154+
"""An offset to apply to the target."""
1155+
to = self.properties.get("to")
1156+
if to is not None:
1157+
return to.values
1158+
return None
1159+
1160+
def SetTargetOffset(self, offset):
1161+
"""Sets an offset to apply to the target."""
1162+
self.CreateProperty("to", "3v").values = list(offset)
1163+
11531164
def PoleVectorBone(self):
11541165
"""The bone that acts as a pole vector for this chain."""
11551166
pv = self.properties.get("pv")

plugins/blender/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
bl_info = {
1010
"name": "Cast Support",
1111
"author": "DTZxPorter",
12-
"version": (1, 9, 5),
12+
"version": (1, 9, 6),
1313
"blender": (3, 6, 0),
1414
"location": "File > Import",
1515
"description": "Import & Export Cast",

plugins/blender/import_cast.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,16 @@ def importSkeletonIKNode(self, skeleton, poses):
511511
ik.chain_count = 0
512512
ik.use_tail = True
513513

514+
# Blender ik requires a pole vector bone to orient properly.
515+
poleVectorBone = handle.PoleVectorBone()
516+
517+
if not poleVectorBone:
518+
self.report({"WARNING"},
519+
"Skipped ik \"%s\" setup due to blender requiring a pole vector bone." % ik.name)
520+
521+
startBone.constraints.remove(ik)
522+
continue
523+
514524
bone = startBone
515525

516526
while True:
@@ -535,8 +545,6 @@ def importSkeletonIKNode(self, skeleton, poses):
535545
if handle.UseTargetRotation():
536546
ik.use_rotation = True
537547

538-
poleVectorBone = handle.PoleVectorBone()
539-
540548
if poleVectorBone is not None:
541549
poleVector = poses[poleVectorBone.Name()]
542550

@@ -548,7 +556,7 @@ def importSkeletonIKNode(self, skeleton, poses):
548556
if poleBone is not None:
549557
# Warn until we figure out how to emulate this effectively.
550558
self.report({"WARNING"},
551-
"Unable to setup %s fully due to blender not supporting pole (twist) bones." % ik.name)
559+
"Unable to setup \"%s\" fully due to blender not supporting pole (twist) bones." % ik.name)
552560

553561

554562
def importSkeletonNode(name, skeleton, collection):

plugins/maya/castplugin.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
}
5555

5656
# Shared version number
57-
version = "1.95"
57+
version = "1.96"
5858

5959
# Time unit to framerate map
6060
framerateMap = {
@@ -1696,7 +1696,9 @@ def importSkeletonIKNode(skeleton, handles, paths, indexes, jointTransform):
16961696
"%s.rotateX" % paths[indexes[poleBone.Hash()]],
16971697
"%s.twist" % ikHandle.fullPathName())
16981698

1699-
cmds.setAttr("%s.translate" % ikHandle.fullPathName(), 0, 0, 0)
1699+
targetOffset = handle.TargetOffset() or (0, 0, 0)
1700+
1701+
cmds.setAttr("%s.translate" % ikHandle.fullPathName(), *targetOffset)
17001702
cmds.setAttr("%s.rotate" % ikHandle.fullPathName(), 0, 0, 0)
17011703

17021704

0 commit comments

Comments
 (0)