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

[usdAbc] fixed reading indexed attributes #864

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions pxr/usd/plugin/usdAbc/alembicReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ TF_DEFINE_PRIVATE_TOKENS(
_tokens,
(transform)
((xformOpTransform, "xformOp:transform"))
((indicesSuffix, ":indices"))
((valuesSuffix, ":vals"))
);

TF_DEFINE_ENV_SETTING(
Expand Down Expand Up @@ -2156,18 +2158,36 @@ _PrimReaderContext::AddOutOfSchemaProperty(
// Get the converter and add the property.
const bool isOutOfSchema = true;
const UsdAbc_AlembicType alembicType(*header);
const SdfValueTypeName usdTypeName =
SdfValueTypeName usdTypeName =
_context.GetSchema().GetConversions().FindConverter(alembicType);

if (usdTypeName) {
_PrimReaderContext::Property &prop =
(TfGetEnvSetting(USD_ABC_WRITE_UV_AS_ST_TEXCOORD2FARRAY) &&
name == UsdAbcPropertyNames->uvIndices)?
(_AddProperty(UsdAbcPropertyNames->stIndices,
usdTypeName, header->getMetaData(),
sampleTimes, isOutOfSchema)) :
(_AddProperty(TfToken(name),
usdTypeName, header->getMetaData(),
sampleTimes, isOutOfSchema));
TfToken propName(name);
if (TfGetEnvSetting(USD_ABC_WRITE_UV_AS_ST_TEXCOORD2FARRAY) &&
name == UsdAbcPropertyNames->uvIndices) {
propName = UsdAbcPropertyNames->stIndices;
}
else if (TfStringEndsWith(name, _tokens->indicesSuffix)){
// If the property is indexed and we're adding the indices here
// then we want to make sure they are added as an IntArray
// as that's the only supported type for index arrays.
usdTypeName = SdfValueTypeNames->IntArray;
}
else if (TfStringEndsWith(name, _tokens->valuesSuffix)) {
// If the property is indexed and we're adding the values
// it might have a ":vals" suffix. We need to remove it
// to be compatible.
propName = TfToken(name.substr(0, name.size() - _tokens->valuesSuffix.size()));
spiffmon marked this conversation as resolved.
Show resolved Hide resolved
}

_PrimReaderContext::Property &prop = _AddProperty(
propName,
usdTypeName,
header->getMetaData(),
sampleTimes,
isOutOfSchema
);

prop.converter = std::bind(
_context.GetSchema().GetConversions().GetToUsdConverter(
alembicType, prop.typeName),
Expand Down
1 change: 1 addition & 0 deletions pxr/usd/plugin/usdAbc/alembicUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ UsdAbc_AlembicConversions::UsdAbc_AlembicConversions()
// Other conversions.
data.AddConverter<int, int8_t>();
data.AddConverter<int, int16_t>();
data.AddConverter<int, uint32_t>();
data.AddConverter<unsigned int, uint16_t>();
data.AddConverter<TfToken, std::string>();
data.AddConverter<GfMatrix4d, float32_t, 16>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def Mesh "Cube"
uchar xform:ops.timeSamples = {
0: 48,
}
custom matrix4d xform:vals
matrix4d xform:vals.timeSamples = {
custom matrix4d xform
matrix4d xform.timeSamples = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's independent of this change, but this change in output hilites a problem we should probaly catch and fix: if alembic allows arbitrary properties to be indexed, we can't support that, since USD only allows indexing of primvars. So if we find anything other than an arbGeom property that's indexed, we should flatten it on the Alembic side?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this points to two more problems:

  • in this case "vals" shouldn't be removed as there are no indices
  • the xform attribute isn't really used in this prim

0: ( (1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1) ),
}
}
Expand Down