Motion transfer setup #1
14
README.md
14
README.md
@ -25,6 +25,20 @@ Not a complete list yet.
|
|||||||
|
|
||||||
- Rotations are always quaternions. Conversion is OK, but if it's labeled "Rotation" it has to be a quaternion.
|
- Rotations are always quaternions. Conversion is OK, but if it's labeled "Rotation" it has to be a quaternion.
|
||||||
- All transforms are in world space, except when there is an explicit choice or conversion node.
|
- All transforms are in world space, except when there is an explicit choice or conversion node.
|
||||||
|
- Nodes should try and produce 'normal' values. So a vector normalisation node should output `(0, 0, 0)` for unnormalizable inputs, and a division by zero should produce `0`. When we have a 'debug mode' for visualising issues in the node tree, then we can output `NaN` instead, and highlight those sockets to help tracing those issues.
|
||||||
|
|
||||||
|
## Optional vs. regular input sockets
|
||||||
|
|
||||||
|
In the code of certain nodes you'll find 'optional' input sockets. Those are for *optional functionality* of the node. If such a socket is unconnected, it will cause certain functionality to be skipped. For example, a "Set Bone" socket will *only* set the bone's rotation if the 'Rotation' socket is connected.
|
||||||
|
|
||||||
|
Note that these are *not* indicative of whether the socket must be connected or not. Regular input sockets can also remain unconnected. The big difference is that regular input sockets will allow users to edit their values when unconnected, whereas 'optional' sockets will not.
|
||||||
|
|
||||||
|
Regular socket
|
||||||
|
: Always has a value. When unconnected, the GUI allows a user to edit the socket value.
|
||||||
|
|
||||||
|
Optional socket
|
||||||
|
: Only has a value when connected. When unconnected, the corresponding functionality is simply skipped.
|
||||||
|
|
||||||
|
|
||||||
## Wishlist
|
## Wishlist
|
||||||
|
|
||||||
|
2
nodes.py
2
nodes.py
@ -572,8 +572,6 @@ class SetControlNode(AbstractPowerShipNode):
|
|||||||
)
|
)
|
||||||
if control_scale is not None:
|
if control_scale is not None:
|
||||||
control_obj.scale = control_scale
|
control_obj.scale = control_scale
|
||||||
case _:
|
|
||||||
return Matrix.Identity(4)
|
|
||||||
|
|
||||||
|
|
||||||
class ToVector(AbstractPowerShipNode):
|
class ToVector(AbstractPowerShipNode):
|
||||||
|
@ -12,7 +12,8 @@ def snap_to_bone(object: bpy.types.Object, depsgraph: bpy.types.Depsgraph) -> No
|
|||||||
ob_pos = object.matrix_world.translation
|
ob_pos = object.matrix_world.translation
|
||||||
|
|
||||||
def distance_sq(bone_pos: Vector) -> float:
|
def distance_sq(bone_pos: Vector) -> float:
|
||||||
return (bone_pos - ob_pos).length_squared
|
# mypy doesn't know `.length_squared` returns a float.
|
||||||
|
return (bone_pos - ob_pos).length_squared # type: ignore
|
||||||
|
|
||||||
closest_bone_pos = min(all_armature_bone_positions(depsgraph), key=distance_sq)
|
closest_bone_pos = min(all_armature_bone_positions(depsgraph), key=distance_sq)
|
||||||
object.matrix_world.translation = closest_bone_pos
|
object.matrix_world.translation = closest_bone_pos
|
||||||
|
Loading…
Reference in New Issue
Block a user