Skip to content

Commit

Permalink
check if the VtValue is empty before doing a UncheckedGet (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpichard authored Jun 11, 2024
1 parent 7673dd3 commit 6e91505
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [usd#1923](https://github.com/Autodesk/arnold-usd/issues/1923) - Fix instance primvar indices
with multiple prototypes
- [usd#1929](https://github.com/Autodesk/arnold-usd/issues/1929) - Ensure subdiv_iterations is not set uselessly during procedural updates
- [usd#1932](https://github.com/Autodesk/arnold-usd/issues/1932) - Fix a crash when the number of elements in a primvar should be equal to the number of points but is not.

## [7.3.2.0] - 2024-05-22

Expand Down
14 changes: 8 additions & 6 deletions libs/render_delegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,16 @@ struct _ConvertValueToArnoldParameter<UsdType, ArnoldType, HdArnoldSampledPrimva
if (samples.count == 0 || samples.values.empty() || !samples.values[0].IsHolding<VtArray<UsdType>>()) {
return;
}

const VtArray<UsdType> *v0 = nullptr;
if (requiredValues) {
for (const auto& value : samples.values) {
const auto& array = value.UncheckedGet<VtArray<UsdType>>();
if (array.size() == *requiredValues) {
v0 = &array;
break;
// Looking for the correct buffer by size.
if (!value.IsEmpty()) {
const auto& array = value.UncheckedGet<VtArray<UsdType>>();
if (array.size() == *requiredValues) {
v0 = &array;
break;
}
}
}
}
Expand Down Expand Up @@ -442,8 +444,8 @@ void HdArnoldMesh::Sync(
} else if (primvar.first == HdTokens->normals) {
if (desc.value.IsEmpty()) {
HdArnoldIndexedSampledPrimvarType sample;
sceneDelegate->SampleIndexedPrimvar(id, primvar.first, &sample);
sample.count = _numberOfPositionKeys;
sceneDelegate->SampleIndexedPrimvar(id, primvar.first, &sample);
_ConvertFaceVaryingPrimvarToBuiltin<GfVec3f, AI_TYPE_VECTOR, HdArnoldSampledPrimvarType>(
GetArnoldNode(), sample, sample.indices.empty() ? VtIntArray{} : sample.indices[0],
str::nlist, str::nidxs, &_vertexCounts, &_vertexCountSum);
Expand Down

0 comments on commit 6e91505

Please sign in to comment.