| 445 | } |
| 446 | |
| 447 | static std::shared_ptr<pxr::HdBufferSource> CreateBufferSource(const pxr::TfToken& Name, const pxr::VtValue& Data, size_t ExpectedNumElements, const pxr::SdfPath& MeshId) |
| 448 | { |
| 449 | auto BufferSource = std::make_shared<pxr::HdVtBufferSource>( |
| 450 | Name, |
| 451 | Data, |
| 452 | 1, // values per element |
| 453 | false // whether doubles are supported or must be converted to floats |
| 454 | ); |
| 455 | |
| 456 | if (BufferSource->GetNumElements() == 0) |
| 457 | return nullptr; |
| 458 | |
| 459 | // Verify primvar length - it is alright to have more data than we index into. |
| 460 | if (BufferSource->GetNumElements() < ExpectedNumElements) |
| 461 | { |
| 462 | LOG_WARNING_MESSAGE("Primvar '", Name, "' in mesh ", MeshId, " has only ", BufferSource->GetNumElements(), |
| 463 | " elements, while its topology expects at least ", ExpectedNumElements, |
| 464 | " elements. Skipping primvar."); |
| 465 | return nullptr; |
| 466 | } |
| 467 | else if (BufferSource->GetNumElements() > ExpectedNumElements) |
| 468 | { |
| 469 | // If the primvar has more data than needed, we issue a warning, |
| 470 | // but don't skip the primvar update. Truncate the buffer to |
| 471 | // the expected length. |
| 472 | LOG_WARNING_MESSAGE("Primvar '", Name, "' in mesh ", MeshId, " has ", BufferSource->GetNumElements(), |
| 473 | " elements, while its topology expects ", ExpectedNumElements, |
| 474 | " elements. Truncating."); |
| 475 | BufferSource->Truncate(ExpectedNumElements); |
| 476 | } |
| 477 | |
| 478 | return BufferSource; |
| 479 | } |
| 480 | |
| 481 | static HnRenderPass::SupportedVertexInputsSetType GetSupportedPrimvars( |
| 482 | const pxr::HdRenderIndex& RenderIndex, |
no test coverage detected