24 #ifndef PXR_IMAGING_HD_ST_MESH_H 25 #define PXR_IMAGING_HD_ST_MESH_H 28 #include "pxr/imaging/hdSt/api.h" 29 #include "pxr/imaging/hd/version.h" 30 #include "pxr/imaging/hd/changeTracker.h" 31 #include "pxr/imaging/hd/drawingCoord.h" 32 #include "pxr/imaging/hd/mesh.h" 33 #include "pxr/imaging/hd/perfLog.h" 35 #include "pxr/usd/sdf/path.h" 40 PXR_NAMESPACE_OPEN_SCOPE
46 using Hd_VertexAdjacencySharedPtr = std::shared_ptr<class Hd_VertexAdjacency>;
47 using HdBufferSourceSharedPtr = std::shared_ptr<class HdBufferSource>;
48 using HdSt_MeshTopologySharedPtr = std::shared_ptr<class HdSt_MeshTopology>;
50 using HdStResourceRegistrySharedPtr =
51 std::shared_ptr<class HdStResourceRegistry>;
58 HF_MALLOC_TAG_NEW(
"new HdStMesh");
73 HdDirtyBits *dirtyBits,
74 TfToken const &reprToken)
override;
84 HdMeshTopologySharedPtr
GetTopology()
const override;
100 HdDirtyBits *dirtyBitsState);
102 HdBufferArrayRangeSharedPtr
103 _GetSharedPrimvarRange(uint64_t primvarId,
104 HdBufferSpecVector
const &updatedOrAddedSpecs,
105 HdBufferSpecVector
const &removedSpecs,
106 HdBufferArrayRangeSharedPtr
const &curRange,
107 bool * isFirstInstance,
108 HdStResourceRegistrySharedPtr
const &resourceRegistry)
const;
111 const SdfPath &materialId)
const;
114 const HdSt_MeshTopologySharedPtr &topology)
const;
116 bool _MaterialHasLimitSurface(
const HdRenderIndex &renderIndex,
117 const SdfPath &materialId)
const;
122 bool _UseSmoothNormals(HdSt_MeshTopologySharedPtr
const& topology)
const;
128 HdStDrawItem *drawItem,
129 HdDirtyBits *dirtyBits,
131 const HdReprSharedPtr &repr,
133 bool requireSmoothNormals,
134 bool requireFlatNormals,
135 int geomSubsetDescIndex);
139 HdStDrawItem *drawItem,
145 bool updateMaterialNetworkShader,
146 bool updateGeometricShader);
153 HdStDrawItem *drawItem,
154 HdDirtyBits *dirtyBits,
156 const HdReprSharedPtr &repr,
158 int geomSubsetDescIndex);
162 HdStDrawItem *drawItem,
164 const HdReprSharedPtr &repr,
165 const HdGeomSubsets &geomSubsets,
166 size_t oldNumGeomSubsets);
168 void _CreateTopologyRangeForGeomSubset(
169 HdStResourceRegistrySharedPtr resourceRegistry,
174 HdBufferSourceSharedPtr indicesSource,
175 HdBufferSourceSharedPtr fvarIndicesSource,
176 HdBufferSourceSharedPtr geomSubsetFaceIndicesHelperSource,
177 const VtIntArray &faceIndices,
181 const HdReprSharedPtr &repr,
183 HdStDrawItem *drawItem,
184 int geomSubsetDescIndex,
185 HdDirtyBits *dirtyBits,
187 HdSt_MeshTopologySharedPtr topology);
189 void _PopulateAdjacency(
190 HdStResourceRegistrySharedPtr
const &resourceRegistry);
194 const HdReprSharedPtr &repr,
196 HdStDrawItem *drawItem,
197 int geomSubsetDescIndex,
198 HdDirtyBits *dirtyBits,
199 bool requireSmoothNormals);
203 const HdReprSharedPtr &repr,
205 HdStDrawItem *drawItem,
206 int geomSubsetDescIndex,
207 HdDirtyBits *dirtyBits);
211 const HdReprSharedPtr &repr,
213 HdStDrawItem *drawItem,
214 int geomSubsetDescIndex,
215 HdDirtyBits *dirtyBits,
216 bool requireFlatNormals);
225 class _FvarTopologyTracker
228 const TopologyToPrimvarVector & GetTopologyToPrimvarVector()
const {
233 void AddOrUpdateTopology(
const TfToken &primvar,
234 const VtIntArray &topology) {
235 for (
size_t i = 0; i < _topologies.size(); ++i) {
237 if (_topologies[i].first == topology) {
239 if (std::find(_topologies[i].second.begin(),
240 _topologies[i].second.end(),
241 primvar) == _topologies[i].second.end()) {
243 RemovePrimvar(primvar);
244 _topologies[i].second.push_back(primvar);
251 RemovePrimvar(primvar);
252 _topologies.push_back(
253 std::pair<VtIntArray, std::vector<TfToken>>(
254 topology, {primvar}));
258 void RemovePrimvar(
const TfToken &primvar) {
259 for (
size_t i = 0; i < _topologies.size(); ++i) {
260 _topologies[i].second.erase(std::find(
261 _topologies[i].second.begin(),
262 _topologies[i].second.end(),
263 primvar), _topologies[i].second.end());
270 void RemoveUnusedTopologies() {
271 _topologies.erase(std::remove_if(
272 _topologies.begin(), _topologies.end(), NoPrimvars),
278 int GetChannelFromPrimvar(
const TfToken &primvar)
const {
279 for (
size_t i = 0; i < _topologies.size(); ++i) {
280 if (std::find(_topologies[i].second.begin(),
281 _topologies[i].second.end(),
283 _topologies[i].second.end()) {
291 std::vector<VtIntArray> GetFvarTopologies()
const {
292 std::vector<VtIntArray> fvarTopologies;
293 for (
const auto& it : _topologies) {
294 fvarTopologies.push_back(it.first);
296 return fvarTopologies;
299 size_t GetNumTopologies()
const {
300 return _topologies.size();
306 static bool NoPrimvars(
const std::pair<VtIntArray, std::vector<TfToken>>
308 return topology.second.empty();
311 TopologyToPrimvarVector _topologies;
316 HullTopology = HdDrawingCoord::CustomSlotsBegin,
324 enum DirtyBits : HdDirtyBits {
325 DirtySmoothNormals = HdChangeTracker::CustomBitsBegin,
326 DirtyFlatNormals = (DirtySmoothNormals << 1),
327 DirtyIndices = (DirtyFlatNormals << 1),
328 DirtyHullIndices = (DirtyIndices << 1),
329 DirtyPointsIndices = (DirtyHullIndices << 1)
332 HdSt_MeshTopologySharedPtr _topology;
333 Hd_VertexAdjacencySharedPtr _vertexAdjacency;
335 HdTopology::ID _topologyId;
336 HdTopology::ID _vertexPrimvarId;
337 HdDirtyBits _customDirtyBitsInUse;
339 HdType _pointsDataType;
340 HdInterpolation _sceneNormalsInterpolation;
341 HdCullStyle _cullStyle;
342 bool _hasMirroredTransform : 1;
343 bool _doubleSided : 1;
344 bool _flatShadingEnabled : 1;
345 bool _displacementEnabled : 1;
346 bool _limitNormals : 1;
347 bool _sceneNormals : 1;
348 bool _hasVaryingTopology : 1;
350 bool _displayOpacity : 1;
351 bool _occludedSelectionShowsThrough : 1;
352 bool _pointsShadingEnabled : 1;
354 std::unique_ptr<_FvarTopologyTracker> _fvarTopologyTracker;
358 PXR_NAMESPACE_CLOSE_SCOPE
360 #endif // PXR_IMAGING_HD_ST_MESH_H The Hydra render index is a flattened representation of the client scene graph, which may be composed...
HDST_API HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override
This callback from Rprim gives the prim an opportunity to set additional dirty bits based on those al...
Descriptor to configure the drawItem(s) for a repr.
Tracks changes from the HdSceneDelegate, providing invalidation cues to the render engine.
HDST_API void _InitRepr(TfToken const &reprToken, HdDirtyBits *dirtyBits) override
Initialize the given representation of this Rprim.
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Token for efficient comparison, assignment, and hashing of known strings.
Adapter class providing data exchange with the client scene graph.
A path value used to locate objects in layers or scenegraphs.
A subdivision surface or poly-mesh object.
A draw item is a light-weight representation of an HdRprim's resources and material to be used for re...
HDST_API HdMeshTopologySharedPtr GetTopology() const override
Topology (member) getter.
Hydra Schema for a subdivision surface or poly-mesh object.
Topology data for meshes.
HDST_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the set of dirty bits that should be added to the change tracker for this prim,...
HDST_API void Finalize(HdRenderParam *renderParam) override
Finalizes object resources.
HDST_API void Sync(HdSceneDelegate *delegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits, TfToken const &reprToken) override
Pull invalidated scene data and prepare/update the renderable representation.
static HDST_API bool IsEnabledPackedNormals()
Returns whether packed (10_10_10 bits) normals to be used.