Improve Alembic plugin to read assets with ArResolver to support other sources except local files #3302
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change(s)
Alembic plugin only accepts assets that are from local paths. In order to fix this, we need to use ArResolver/ArAsset to read/write contents. However, interfaces of Alembic library have limitations that only accept local paths or
std::istreams
. We tried the following solutions in order to fix this:ArResolver
ANDArAsset
and feed isteams into Alembic library. It works except Alembic library only accepts Ogawa format and layered assets are not supported with istreams. It also has performance implications that require all asset data to be in memory.ArResolver
. Instead of reading them into the memory, we get the mapped file path with ArchGetFileName fromArAsset::GetFileUnsafe
. It doesn't work asArchGetFileName
only returns relative path to the current drive. We are not sure if it's a bug or that's the real purpose of that API.ArResolver
. Then we construct astd::filebuf
with the file handle fromArAsset::GetFileUnsafe
. It works and has the same limitations of 1st solution. Also,std::filebuf(FILE *)
is not standard for c++ and compiler specific. This is the solution used in this MR also.ArResolver
. Instead,std::spanbuf
withArAsset::GetBuffer
might be a solution with C++23. We aren't able to verify that it would work but from the docs it sounds like a good fit with the ArAsset API. It has the same limitations as 1st solution to use isteams.Fixes Issue(s)