Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement/AY-6116-blender_allow_handles_frame_range #28

Merged
merged 10 commits into from
Sep 6, 2024
21 changes: 20 additions & 1 deletion client/ayon_blender/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from ayon_core.lib import (
Logger,
register_event_callback,
emit_event
emit_event,
filter_profiles
)
from ayon_core.settings import get_project_settings
from ayon_blender import BLENDER_ADDON_ROOT
Expand Down Expand Up @@ -273,6 +274,24 @@ def set_frame_range(entity: dict):
if attrib.get("fps"):
fps = attrib.get("fps")

# Should handles be included, defined by settings
settings = get_project_settings(get_current_project_name())
task_type = entity.get("taskType")
include_handles_settings = settings["blender"]["include_handles"]
include_handles = include_handles_settings["include_handles_default"]
profile = filter_profiles(
include_handles_settings["profiles"],
key_values={
"task_types": task_type,
"task_names": entity["name"]
}
)
if profile:
include_handles = profile["include_handles"]
if include_handles:
frame_start -= int(attrib.get("handleStart", 0))
frame_end += int(attrib.get("handleEnd", 0))

scene.frame_start = frame_start
scene.frame_end = frame_end
scene.render.fps = round(fps)
Expand Down
35 changes: 34 additions & 1 deletion server/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
BaseSettingsModel,
SettingsField,
TemplateWorkfileBaseOptions,
task_types_enum,
)

from .imageio import BlenderImageIOModel
from .publish_plugins import (
PublishPluginsModel,
Expand All @@ -24,6 +24,31 @@ class UnitScaleSettingsModel(BaseSettingsModel):
)


class IncludeHandlesProfilesModel(BaseSettingsModel):
task_types: list[str] = SettingsField(
default_factory=list,
title="Task Types",
description="Filter by task types",
enum_resolver=task_types_enum,
)
task_names: list[str] = SettingsField(
default_factory=list,
title="Task Names",
description="Filter by task names.",
)
include_handles: bool = SettingsField(True, title="Include handles")


class IncludeHandlesModel(BaseSettingsModel):
include_handles_default: bool = SettingsField(
False, title="Include handles by default"
)
profiles: list[IncludeHandlesProfilesModel] = SettingsField(
default_factory=list,
title="Include/exclude handles by profiles"
)


class BlenderSettings(BaseSettingsModel):
unit_scale_settings: UnitScaleSettingsModel = SettingsField(
default_factory=UnitScaleSettingsModel,
Expand All @@ -37,6 +62,10 @@ class BlenderSettings(BaseSettingsModel):
True,
title="Set Start/End Frames and FPS on Startup"
)
include_handles: IncludeHandlesModel = SettingsField(
default_factory=IncludeHandlesModel,
title="Include/Exclude Handles in default playback & render range"
)
imageio: BlenderImageIOModel = SettingsField(
default_factory=BlenderImageIOModel,
title="Color Management (ImageIO)"
Expand All @@ -61,6 +90,10 @@ class BlenderSettings(BaseSettingsModel):
},
"set_frames_startup": True,
"set_resolution_startup": True,
"include_handles": {
"include_handles_default": False,
"profiles": []
},
"RenderSettings": DEFAULT_RENDER_SETTINGS,
"publish": DEFAULT_BLENDER_PUBLISH_SETTINGS,
"workfile_builder": {
Expand Down