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

Implemented ReadDoubleVector instead of ReadDoubleArray for crate::CrateDataTypeId::CRATE_DATA_TYPE_DOUBLE_VECTOR #197

Merged
merged 1 commit into from
Oct 24, 2024

Conversation

rdeioris
Copy link
Contributor

This patch addresses the management of the DoubleVector type in crates:

the original approach was to use ReadDoubleArray for crate::CrateDataTypeId::CRATE_DATA_TYPE_DOUBLE_VECTOR but the OpenUSD implementation has a dedicated codepath for it (that does not account for compression or 32bit sizes of older formats)

https://github.com/PixarAnimationStudios/OpenUSD/blob/release/pxr/usd/usd/crateFile.cpp#L1069

 template <class T>
    vector<T> _Read(vector<T> *) {
        auto sz = Read<uint64_t>();
        vector<T> vec(sz);
        ReadContiguous(vec.data(), sz);
        return vec;
    }

This patch adds a ReadDoubleVector that does the same thing as the code above.

In addition to this the patch adds a check for zero-sized array in ReadDoubleArray

This patch allows to load the spinning top asset from OpenUSD and flatten it with all of the TimeSamples (https://github.com/PixarAnimationStudios/OpenUSD/blob/release/extras/usd/tutorials/animatedTop/top.geom.usd)

Note that the top.geom.usd asset has TimeSampled indices, that will be supported in a different pull request i am going to send in few minutes

…ateDataTypeId::CRATE_DATA_TYPE_DOUBLE_VECTOR
@syoyo
Copy link
Collaborator

syoyo commented Oct 24, 2024

Thanks! Let me give some time to review the PR.

@syoyo
Copy link
Collaborator

syoyo commented Oct 24, 2024

Confirmed the issue.

tusdcat top.geom.usd reports the following error:

...
/home/syoyo/work/tinyusdz/src/crate-reader.cc:UnpackValueRep:2314 ValueRep type value = 48
ERR : Failed to read double array data.
Failed to read DoubleVector value

@syoyo syoyo added the bug Something isn't working label Oct 24, 2024
@syoyo syoyo merged commit 0693cae into lighttransport:dev Oct 24, 2024
14 checks passed
@syoyo
Copy link
Collaborator

syoyo commented Oct 24, 2024

And confirmed the PR fixes reading data with CRATE_DATA_TYPE_DOUBLE_VECTOR type.
Good find and thank you for the implementation! Merged! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants