Export arbitrary time samples - #4675
Conversation
…> guide type It was causing a coding error when -frameSample was used.
- UsdMayaWriteUtil::GetTimeSamples now takes an optional userTimeSamples vector, merged with the samples computed from frameRange subframeOffsets and stride, always included even when frameRange is empty. Duplicates are removed before merging, to avoid evaluating/writing the same frame twice. - Only validate stride when frameRange is actually used, since it has no effect otherwise. - Add a new timeSample token support to UsdMayaJobExportArgs, mirroring the frameSample token. - Add -timeSample/-ts flag to MayaUSDExportCommand. - On the MPxFileTranslator path, the timeSample option is gated by the animation option, matching the frameRange option's behaviour.
70df798 to
b9ae245
Compare
b9ae245 to
97fab8a
Compare
|
Hey @jufrantz! I discussed it with some folks on the team, there was some debate about whether instead we should improve frame range to support multiple ranges and individual frames ex: [1-10, 15, 18, 20-45], but it's true that individual frames would still get affected by the frameSample offset. So this new parameter would still be a benefit. However, we're wondering if "timeSample" is the clearest name for the parameter. Thanks! |
|
Hi @scottrenaud, Thanks for your feedback! Yes, definitely, supporting multiple frame ranges would be more interesting, and it would cover our use case. Having frameSample apply to those extra frames wouldn't be a problem for us either. That said, I'm not sure how to add this cleanly while keeping back-compatibility with the current command syntaxes ( For the single-frame parameter, the range specification differs between the command arguments and the options dict/options-string formats:
Rather than
Let me know what you think. Happy to go with Julien |
There was a problem hiding this comment.
Pull request overview
Adds explicit arbitrary time-sample support to Maya USD export paths.
Changes:
- Adds
-timeSample/-tsand dictionary-option handling. - Merges, sorts, and deduplicates explicit and generated samples.
- Adds documentation and integration tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/lib/usd/translators/testUsdExportExplicitTimeSamples.py |
Tests explicit sample export paths. |
test/lib/usd/translators/CMakeLists.txt |
Registers the new tests. |
lib/mayaUsd/utils/util.cpp |
Parses multi-use double flags. |
lib/mayaUsd/fileio/utils/writeUtil.h |
Extends the time-sampling API. |
lib/mayaUsd/fileio/utils/writeUtil.cpp |
Merges explicit samples. |
lib/mayaUsd/fileio/jobs/jobArgs.h |
Declares the new option token. |
lib/mayaUsd/fileio/jobs/jobArgs.cpp |
Handles dictionary-based samples. |
lib/mayaUsd/commands/Readme.md |
Documents the new flag. |
lib/mayaUsd/commands/baseExportCommand.h |
Defines flag names. |
lib/mayaUsd/commands/baseExportCommand.cpp |
Parses and applies the flag. |
Suppressed comments (1)
test/lib/usd/translators/testUsdExportExplicitTimeSamples.py:75
- This second dictionary union also requires Python 3.9 and prevents the file-translator tests from running under the supported Python 3.7 configuration (doc/build.md:16). Use
copy()plusupdate()here as well.
exportOptions = kwargs | dict(
mergeTransformAndShape=True,
chaser=f'[{_FrameLoggingChaser.name}]'
)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| exportOptions = kwargs | dict( | ||
| mergeTransformAndShape=True, | ||
| chaser=_FrameLoggingChaser.name | ||
| ) |
There was a problem hiding this comment.
@seando-adsk is this a valid concern? Are we still supporting Python 3.7 ?
There was a problem hiding this comment.
@AramAzhari-adsk just in case, I made this code 3.7 compatible (e029305)
There was a problem hiding this comment.
No, we have dropped py 3.7 and 3.9. The min we need to support is 3.10 for Maya 2024.
| static std::vector<double> GetTimeSamples( | ||
| const GfInterval& frameRange, | ||
| const std::set<double>& subframeOffsets, | ||
| const double stride = 1.0); | ||
| const GfInterval& frameRange, | ||
| const std::set<double>& subframeOffsets, | ||
| const double stride = 1.0, | ||
| const std::vector<double>& userTimeSamples = std::vector<double> {}); |
|
I see there's some activity, just wanted to reply and say "extraFrame" and "extraTime" sounds good to me as a label switch @jufrantz! |
This PR adds a new
-timeSample/-tsflag toMayaUSDExportCommand(and the dictionary option on the MPxFileTranslator path), letting users export an explicit, arbitrary list of absolute time samples, regardless of-frameRange/-frameStride/-frameSample.We need this in some specific export workflows. It mirrors a capability available in Maya's
AbcExportplugin, which lets users repeat-frameRangewith single-point frameRanges to export isolated samples.Included Changes
UsdMayaWriteUtil::GetTimeSamplesnow takes an optionaluserTimeSamplesvector, merged with the samples computed fromframeRange,subframeOffsetsandstride, always included even whenframeRangeis empty. Duplicates are removed before merging, to avoid evaluating/writing the same frame twice.stridewhenframeRangeis actually used, since it has no effect otherwise.timeSampletoken support toUsdMayaJobExportArgs, mirroring theframeSampletoken.-timeSample/-tsflag toMayaUSDExportCommand.MPxFileTranslatorpath, thetimeSampleoption is gated by theanimationoption, matching theframeRangeoption's behaviour.UsdMayaUtil::GetDictionaryFromArgDatabaseto handlevector<double>guide type. It was already causing a coding error when-frameSamplewas used.-timeSampleflag inlib/mayaUsd/commands/Readme.md.