Merge pull request #4664 from quadproduction/348-fix-studio-openpype-template-builder-set-wrong-frame-range-in-created-animation-instance

This commit is contained in:
Ondřej Samohel 2023-04-12 17:34:13 +02:00 committed by GitHub
commit 88a5bd9543
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 91 additions and 10 deletions

View file

@ -32,7 +32,12 @@ from openpype.pipeline import (
load_container,
registered_host,
)
from openpype.pipeline.context_tools import get_current_project_asset
from openpype.pipeline.context_tools import (
get_current_asset_name,
get_current_project_asset,
get_current_project_name,
get_current_task_name
)
self = sys.modules[__name__]
@ -292,15 +297,20 @@ def collect_animation_data(fps=False):
"""
# get scene values as defaults
start = cmds.playbackOptions(query=True, animationStartTime=True)
end = cmds.playbackOptions(query=True, animationEndTime=True)
frame_start = cmds.playbackOptions(query=True, minTime=True)
frame_end = cmds.playbackOptions(query=True, maxTime=True)
handle_start = cmds.playbackOptions(query=True, animationStartTime=True)
handle_end = cmds.playbackOptions(query=True, animationEndTime=True)
handle_start = frame_start - handle_start
handle_end = handle_end - frame_end
# build attributes
data = OrderedDict()
data["frameStart"] = start
data["frameEnd"] = end
data["handleStart"] = 0
data["handleEnd"] = 0
data["frameStart"] = frame_start
data["frameEnd"] = frame_end
data["handleStart"] = handle_start
data["handleEnd"] = handle_end
data["step"] = 1.0
if fps:
@ -2134,9 +2144,13 @@ def get_frame_range():
"""Get the current assets frame range and handles."""
# Set frame start/end
project_name = legacy_io.active_project()
asset_name = legacy_io.Session["AVALON_ASSET"]
project_name = get_current_project_name()
task_name = get_current_task_name()
asset_name = get_current_asset_name()
asset = get_asset_by_name(project_name, asset_name)
settings = get_project_settings(project_name)
include_handles_settings = settings["maya"]["include_handles"]
current_task = asset.get("data").get("tasks").get(task_name)
frame_start = asset["data"].get("frameStart")
frame_end = asset["data"].get("frameEnd")
@ -2148,6 +2162,26 @@ def get_frame_range():
handle_start = asset["data"].get("handleStart") or 0
handle_end = asset["data"].get("handleEnd") or 0
animation_start = frame_start
animation_end = frame_end
include_handles = include_handles_settings["include_handles_default"]
for item in include_handles_settings["per_task_type"]:
if current_task["type"] in item["task_type"]:
include_handles = item["include_handles"]
break
if include_handles:
animation_start -= int(handle_start)
animation_end += int(handle_end)
cmds.playbackOptions(
minTime=frame_start,
maxTime=frame_end,
animationStartTime=animation_start,
animationEndTime=animation_end
)
cmds.currentTime(frame_start)
return {
"frameStart": frame_start,
"frameEnd": frame_end,
@ -2166,7 +2200,6 @@ def reset_frame_range(playback=True, render=True, fps=True):
Defaults to True.
fps (bool, Optional): Whether to set scene FPS. Defaults to True.
"""
if fps:
fps = convert_to_maya_fps(
float(legacy_io.Session.get("AVALON_FPS", 25))

View file

@ -1144,6 +1144,10 @@
}
]
},
"include_handles": {
"include_handles_default": false,
"per_task_type": []
},
"templated_workfile_build": {
"profiles": []
},

View file

@ -151,6 +151,40 @@
}
]
},
{
"type": "dict",
"key": "include_handles",
"collapsible": true,
"label": "Include/Exclude Handles in default playback & render range",
"children": [
{
"key": "include_handles_default",
"label": "Include handles by default",
"type": "boolean"
},
{
"type": "list",
"key": "per_task_type",
"label": "Include/exclude handles by task type",
"use_label_wrap": true,
"object_type": {
"type": "dict",
"children": [
{
"type": "task-types-enum",
"key": "task_type",
"label": "Task types"
},
{
"type": "boolean",
"key": "include_handles",
"label": "Include handles"
}
]
}
}
]
},
{
"type": "schema",
"name": "schema_scriptsmenu"

View file

@ -200,6 +200,16 @@ Most settings to override in the viewport are self explanatory and can be found
These options are set on the camera shape when publishing the review. They correspond to attributes on the Maya camera shape node.
![Extract Playblast Settings](assets/maya-admin_extract_playblast_settings_camera_options.png)
## Include/exclude handles by task type
You can include or exclude handles, globally or by task type.
The "Include handles by default" defines whether by default handles are included. Additionally you can add a per task type override whether you want to include or exclude handles.
For example, in this image you can see that handles are included by default in all task types, except for the 'Lighting' task, where the toggle is disabled.
![Include/exclude handles](assets/maya-admin_exclude_handles.png)
And here you can see that the handles are disabled by default, except in 'Animation' task where it's enabled.
![Custom menu definition](assets/maya-admin_include_handles.png)
## Custom Menu

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB