WIP: Animation: operators to update the pose library #104673
@ -329,16 +329,15 @@ class POSELIB_OT_update_pose_asset(Operator):
|
||||
def _update_existing_fcurve(action: Action, fcu_existing: FCurve, fcu_to_read: FCurve) -> bool:
|
||||
# Update the exsting FCurve. This assumes that it is a valid
|
||||
# pose asset, i.e. that the FCurve has a single key.
|
||||
kp = fcu_existing.keyframe_points[0]
|
||||
old_value = kp.co.y
|
||||
keyframe = fcu_existing.keyframe_points[0]
|
||||
|
||||
dr.sybren marked this conversation as resolved
|
||||
# Don't bother updating the FCurve if the value was unchanged.
|
||||
fcu_value = fcu_to_read.keyframe_points[0].co.y
|
||||
if abs(old_value - fcu_value) < 0.0001:
|
||||
if keyframe.co.y == fcu_value:
|
||||
return False
|
||||
dr.sybren marked this conversation as resolved
Nathan Vegdahl
commented
Do we expect there to be floating point error involved here? I wouldn't think so, but I could very well be missing something. But if not, I think it makes more sense to just do a straight Do we expect there to be floating point error involved here? I wouldn't think so, but I could very well be missing something.
But if not, I think it makes more sense to just do a straight `==` comparison, rather than having an arbitrary epsilon.
|
||||
|
||||
# Use co_ui to move the handles along with the value.
|
||||
kp.co_ui.y = fcu_value
|
||||
keyframe.co_ui.y = fcu_value
|
||||
fcu_existing.update()
|
||||
return True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
Unimportant nit: it doesn't seem like the
old_value
temporary is necessary.(
fcu_value
, by contrast, I think aids readability, since it's short-handing something that's rather long to read.)Not a big deal either way, though.
It's indeed not really necessary, but to me it makes the
if old_value == fcu_value:
read nicer. That can be resolved by renamingkp
tokeyframe
and it overall being less cryptic.