42 HF_MALLOC_TAG_NEW(
"new HdStMesh");
57 HdDirtyBits *dirtyBits,
58 TfToken const &reprToken)
override;
84 HdDirtyBits *dirtyBitsState);
86 HdBufferArrayRangeSharedPtr
87 _GetSharedPrimvarRange(uint64_t primvarId,
88 HdBufferSpecVector
const &updatedOrAddedSpecs,
89 HdBufferSpecVector
const &removedSpecs,
90 HdBufferArrayRangeSharedPtr
const &curRange,
91 bool * isFirstInstance,
92 HdStResourceRegistrySharedPtr
const &resourceRegistry)
const;
95 const SdfPath &materialId)
const;
98 const HdSt_MeshTopologySharedPtr &topology)
const;
100 bool _MaterialHasLimitSurface(
const HdRenderIndex &renderIndex,
101 const SdfPath &materialId)
const;
106 bool _UseSmoothNormals(HdSt_MeshTopologySharedPtr
const& topology)
const;
112 HdStDrawItem *drawItem,
113 HdDirtyBits *dirtyBits,
115 const HdReprSharedPtr &repr,
117 bool requireSmoothNormals,
118 bool requireFlatNormals,
119 int geomSubsetDescIndex);
123 HdStDrawItem *drawItem,
129 bool updateMaterialNetworkShader,
130 bool updateGeometricShader);
137 HdStDrawItem *drawItem,
138 HdDirtyBits *dirtyBits,
140 const HdReprSharedPtr &repr,
142 int geomSubsetDescIndex);
146 HdStDrawItem *drawItem,
148 const HdReprSharedPtr &repr,
149 const HdGeomSubsets &geomSubsets,
150 size_t oldNumGeomSubsets);
152 void _CreateTopologyRangeForGeomSubset(
153 HdStResourceRegistrySharedPtr resourceRegistry,
156 HdStDrawItem *drawItem,
158 HdBufferSourceSharedPtr indicesSource,
159 HdBufferSourceSharedPtr fvarIndicesSource,
160 HdBufferSourceSharedPtr geomSubsetFaceIndicesHelperSource,
161 const VtIntArray &faceIndices,
165 const HdReprSharedPtr &repr,
167 HdStDrawItem *drawItem,
168 int geomSubsetDescIndex,
169 HdDirtyBits *dirtyBits,
171 HdSt_MeshTopologySharedPtr topology);
173 void _PopulateAdjacency(
174 HdStResourceRegistrySharedPtr
const &resourceRegistry);
178 const HdReprSharedPtr &repr,
180 HdStDrawItem *drawItem,
181 int geomSubsetDescIndex,
182 HdDirtyBits *dirtyBits,
183 bool requireSmoothNormals);
187 const HdReprSharedPtr &repr,
189 HdStDrawItem *drawItem,
190 int geomSubsetDescIndex,
191 HdDirtyBits *dirtyBits);
195 const HdReprSharedPtr &repr,
197 HdStDrawItem *drawItem,
198 int geomSubsetDescIndex,
199 HdDirtyBits *dirtyBits,
200 bool requireFlatNormals);
209 class _FvarTopologyTracker
212 const TopologyToPrimvarVector & GetTopologyToPrimvarVector()
const {
217 void AddOrUpdateTopology(
const TfToken &primvar,
218 const VtIntArray &topology) {
219 for (
size_t i = 0; i < _topologies.size(); ++i) {
221 if (_topologies[i].first == topology) {
223 if (std::find(_topologies[i].second.begin(),
224 _topologies[i].second.end(),
225 primvar) == _topologies[i].second.end()) {
227 RemovePrimvar(primvar);
228 _topologies[i].second.push_back(primvar);
235 RemovePrimvar(primvar);
236 _topologies.push_back(
237 std::pair<VtIntArray, std::vector<TfToken>>(
238 topology, {primvar}));
242 void RemovePrimvar(
const TfToken &primvar) {
243 for (
size_t i = 0; i < _topologies.size(); ++i) {
244 _topologies[i].second.erase(std::find(
245 _topologies[i].second.begin(),
246 _topologies[i].second.end(),
247 primvar), _topologies[i].second.end());
254 void RemoveUnusedTopologies() {
255 _topologies.erase(std::remove_if(
256 _topologies.begin(), _topologies.end(), NoPrimvars),
262 int GetChannelFromPrimvar(
const TfToken &primvar)
const {
263 for (
size_t i = 0; i < _topologies.size(); ++i) {
264 if (std::find(_topologies[i].second.begin(),
265 _topologies[i].second.end(),
267 _topologies[i].second.end()) {
275 std::vector<VtIntArray> GetFvarTopologies()
const {
276 std::vector<VtIntArray> fvarTopologies;
277 for (
const auto& it : _topologies) {
278 fvarTopologies.push_back(it.first);
280 return fvarTopologies;
283 size_t GetNumTopologies()
const {
284 return _topologies.size();
290 static bool NoPrimvars(
const std::pair<VtIntArray, std::vector<TfToken>>
292 return topology.second.empty();
295 TopologyToPrimvarVector _topologies;
300 HullTopology = HdDrawingCoord::CustomSlotsBegin,
308 enum DirtyBits : HdDirtyBits {
309 DirtySmoothNormals = HdChangeTracker::CustomBitsBegin,
310 DirtyFlatNormals = (DirtySmoothNormals << 1),
311 DirtyIndices = (DirtyFlatNormals << 1),
312 DirtyHullIndices = (DirtyIndices << 1),
313 DirtyPointsIndices = (DirtyHullIndices << 1)
316 HdSt_MeshTopologySharedPtr _topology;
317 HdSt_VertexAdjacencyBuilderSharedPtr _vertexAdjacencyBuilder;
319 HdTopology::ID _topologyId;
320 HdTopology::ID _vertexPrimvarId;
321 HdDirtyBits _customDirtyBitsInUse;
323 HdType _pointsDataType;
324 HdInterpolation _sceneNormalsInterpolation;
325 HdCullStyle _cullStyle;
326 bool _hasMirroredTransform : 1;
327 bool _doubleSided : 1;
328 bool _flatShadingEnabled : 1;
329 bool _displacementEnabled : 1;
330 bool _limitNormals : 1;
331 bool _sceneNormalsFromPrimvars : 1;
332 bool _sceneNormalsFromInstancer : 1;
333 bool _hasVaryingTopology : 1;
335 bool _displayOpacityFromPrimvars : 1;
336 bool _displayOpacityFromInstancer : 1;
337 bool _displayInOverlay : 1;
338 bool _occludedSelectionShowsThrough : 1;
339 bool _pointsShadingEnabled : 1;
341 std::unique_ptr<_FvarTopologyTracker> _fvarTopologyTracker;