| 599 | } |
| 600 | |
| 601 | void HnMesh::UpdateConstantPrimvars(pxr::HdSceneDelegate& SceneDelegate, |
| 602 | pxr::HdRenderParam* RenderParam, |
| 603 | pxr::HdDirtyBits& DirtyBits, |
| 604 | const pxr::TfToken& ReprToken) |
| 605 | { |
| 606 | VERIFY_EXPR(m_StagingVertexData); |
| 607 | const pxr::SdfPath& Id = GetId(); |
| 608 | |
| 609 | pxr::HdPrimvarDescriptorVector ConstantPrims = GetPrimvarDescriptors(&SceneDelegate, pxr::HdInterpolationConstant); |
| 610 | for (const pxr::HdPrimvarDescriptor& PrimDesc : ConstantPrims) |
| 611 | { |
| 612 | if (!pxr::HdChangeTracker::IsPrimvarDirty(DirtyBits, Id, PrimDesc.name)) |
| 613 | continue; |
| 614 | |
| 615 | pxr::VtValue PrimValue = GetPrimvar(&SceneDelegate, PrimDesc.name); |
| 616 | if (PrimValue.IsEmpty()) |
| 617 | continue; |
| 618 | |
| 619 | auto Source = std::make_shared<pxr::HdVtBufferSource>( |
| 620 | PrimDesc.name, |
| 621 | PrimValue, |
| 622 | 1, // values per element |
| 623 | false // whether doubles are supported or must be converted to floats |
| 624 | ); |
| 625 | if (Source->GetNumElements() == 0) |
| 626 | continue; |
| 627 | |
| 628 | const pxr::HdType ElementType = Source->GetTupleType().type; |
| 629 | if (PrimDesc.name == pxr::HdTokens->displayColor) |
| 630 | { |
| 631 | entt::registry& Registry = static_cast<HnRenderDelegate*>(SceneDelegate.GetRenderIndex().GetRenderDelegate())->GetEcsRegistry(); |
| 632 | float4& DisplayColor = Registry.get<Components::DisplayColor>(m_Entity).Val; |
| 633 | |
| 634 | if (ElementType == pxr::HdTypeFloatVec3) |
| 635 | { |
| 636 | memcpy(DisplayColor.Data(), Source->GetData(), sizeof(float3)); |
| 637 | } |
| 638 | else |
| 639 | { |
| 640 | LOG_WARNING_MESSAGE("Unexpected type of ", PrimDesc.name, " primvar: ", ElementType); |
| 641 | } |
| 642 | } |
| 643 | else if (PrimDesc.name == pxr::HdTokens->displayOpacity) |
| 644 | { |
| 645 | entt::registry& Registry = static_cast<HnRenderDelegate*>(SceneDelegate.GetRenderIndex().GetRenderDelegate())->GetEcsRegistry(); |
| 646 | float& Opacity = Registry.get<Components::DisplayColor>(m_Entity).Val.w; |
| 647 | |
| 648 | if (ElementType == pxr::HdTypeFloat) |
| 649 | { |
| 650 | memcpy(&Opacity, Source->GetData(), sizeof(float)); |
| 651 | } |
| 652 | else |
| 653 | { |
| 654 | LOG_WARNING_MESSAGE("Unexpected type of ", PrimDesc.name, " primvar: ", ElementType); |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | } |
nothing calls this directly
no test coverage detected