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
13 changes: 13 additions & 0 deletions client/ayon_blender/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ 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"]
for item in include_handles_settings["per_task_type"]:
if task_type in item["task_type"]:
include_handles = item["include_handles"]
break
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
30 changes: 30 additions & 0 deletions server/settings/include_handles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from ayon_server.settings import (
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
BaseSettingsModel,
SettingsField,
task_types_enum,
)


class IncludeByTaskTypeModel(BaseSettingsModel):
task_type: list[str] = SettingsField(
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
default_factory=list,
title="Task types",
enum_resolver=task_types_enum
)
include_handles: bool = SettingsField(True, title="Include handles")


class IncludeHandlesModel(BaseSettingsModel):
include_handles_default: bool = SettingsField(
True, title="Include handles by default"
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
)
per_task_type: list[IncludeByTaskTypeModel] = SettingsField(
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
default_factory=list,
title="Include/exclude handles by task type"
)


DEFAULT_INCLUDE_HANDLES = {
"include_handles_default": False,
"per_task_type": []
}
7 changes: 6 additions & 1 deletion server/settings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SettingsField,
TemplateWorkfileBaseOptions,
)

from .include_handles import IncludeHandlesModel, DEFAULT_INCLUDE_HANDLES
from .imageio import BlenderImageIOModel
from .publish_plugins import (
PublishPluginsModel,
Expand Down Expand Up @@ -37,6 +37,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 +65,7 @@ class BlenderSettings(BaseSettingsModel):
},
"set_frames_startup": True,
"set_resolution_startup": True,
"include_handles": DEFAULT_INCLUDE_HANDLES,
"RenderSettings": DEFAULT_RENDER_SETTINGS,
"publish": DEFAULT_BLENDER_PUBLISH_SETTINGS,
"workfile_builder": {
Expand Down