|
16 | 16 | #include "fvpUtils.h"
|
17 | 17 |
|
18 | 18 | #include <pxr/imaging/hd/instanceIndicesSchema.h>
|
| 19 | +#include <pxr/imaging/hd/materialBindingsSchema.h> |
19 | 20 | #include <pxr/imaging/hd/selectionSchema.h>
|
20 | 21 |
|
| 22 | +PXR_NAMESPACE_USING_DIRECTIVE |
| 23 | + |
21 | 24 | namespace FVP_NS_DEF {
|
22 | 25 |
|
23 | 26 | #ifdef CODE_COVERAGE_WORKAROUND
|
@@ -56,4 +59,53 @@ PXR_NS::HdDataSourceBaseHandle createSelectionDataSource(const Fvp::PrimSelectio
|
56 | 59 | return PXR_NS::HdDataSourceBase::Cast(selectionBuilder.Build());
|
57 | 60 | }
|
58 | 61 |
|
| 62 | +Fvp::PrimSelection ConvertHydraToFvpSelection(const SdfPath& primPath, const HdSelectionSchema& selectionSchema) { |
| 63 | + Fvp::PrimSelection primSelection; |
| 64 | + primSelection.primPath = primPath; |
| 65 | + |
| 66 | + auto nestedInstanceIndicesSchema = |
| 67 | +#if HD_API_VERSION < 66 |
| 68 | + const_cast<HdSelectionSchema&>(selectionSchema).GetNestedInstanceIndices(); |
| 69 | +#else |
| 70 | + selectionSchema.GetNestedInstanceIndices(); |
| 71 | +#endif |
| 72 | + for (size_t iNestedInstanceIndices = 0; iNestedInstanceIndices < nestedInstanceIndicesSchema.GetNumElements(); iNestedInstanceIndices++) { |
| 73 | + HdInstanceIndicesSchema instanceIndicesSchema = nestedInstanceIndicesSchema.GetElement(iNestedInstanceIndices); |
| 74 | + auto instanceIndices = instanceIndicesSchema.GetInstanceIndices()->GetTypedValue(0); |
| 75 | + primSelection.nestedInstanceIndices.push_back( |
| 76 | + { |
| 77 | + instanceIndicesSchema.GetInstancer()->GetTypedValue(0), |
| 78 | + instanceIndicesSchema.GetPrototypeIndex()->GetTypedValue(0), |
| 79 | + std::vector<int>(instanceIndices.begin(), instanceIndices.end()) |
| 80 | + } |
| 81 | + ); |
| 82 | + } |
| 83 | + |
| 84 | + return primSelection; |
| 85 | +} |
| 86 | + |
| 87 | +SdfPath GetMaterialPath(const PXR_NS::HdContainerDataSourceHandle& primDataSource) |
| 88 | +{ |
| 89 | + if (!primDataSource) { |
| 90 | + return {}; |
| 91 | + } |
| 92 | + |
| 93 | + HdMaterialBindingsSchema materialBindingsSchema = HdMaterialBindingsSchema::GetFromParent(primDataSource); |
| 94 | + if (!materialBindingsSchema.IsDefined()) { |
| 95 | + return {}; |
| 96 | + } |
| 97 | + |
| 98 | + HdMaterialBindingSchema materialBindingSchema = materialBindingsSchema.GetMaterialBinding(); |
| 99 | + if (!materialBindingSchema) { |
| 100 | + return {}; |
| 101 | + } |
| 102 | + |
| 103 | + HdPathDataSourceHandle bindingPathDataSource = materialBindingSchema.GetPath(); |
| 104 | + if (!bindingPathDataSource) { |
| 105 | + return {}; |
| 106 | + } |
| 107 | + |
| 108 | + return bindingPathDataSource->GetTypedValue(0); |
| 109 | +} |
| 110 | + |
59 | 111 | } // namespace FVP_NS_DEF
|
0 commit comments