Bases: BlenderInstancePlugin
, OptionalPyblishPluginMixin
Camera must have a keyframe at frame 0.
Unreal shifts the first keyframe to frame 0. Forcing the camera to have a keyframe at frame 0 will ensure that the animation will be the same in Unreal and Blender.
Source code in client/ayon_blender/plugins/publish/validate_camera_zero_keyframe.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 | class ValidateCameraZeroKeyframe(
plugin.BlenderInstancePlugin,
OptionalPyblishPluginMixin
):
"""Camera must have a keyframe at frame 0.
Unreal shifts the first keyframe to frame 0. Forcing the camera to have
a keyframe at frame 0 will ensure that the animation will be the same
in Unreal and Blender.
"""
order = ValidateContentsOrder
hosts = ["blender"]
families = ["camera"]
label = "Zero Keyframe"
actions = [ayon_blender.api.action.SelectInvalidAction]
@staticmethod
def get_invalid(instance) -> List:
invalid = []
for obj in instance:
if isinstance(obj, bpy.types.Object) and obj.type == "CAMERA":
if obj.animation_data and obj.animation_data.action:
action = obj.animation_data.action
frames_set = set()
for fcu in action.fcurves:
for kp in fcu.keyframe_points:
frames_set.add(kp.co[0])
frames = list(frames_set)
frames.sort()
if frames[0] != 0.0:
invalid.append(obj)
return invalid
def process(self, instance):
if not self.is_active(instance.data):
return
invalid = self.get_invalid(instance)
if invalid:
names = ", ".join(obj.name for obj in invalid)
raise PublishValidationError(
f"Camera must have a keyframe at frame 0: {names}"
)
|