Loading...
Searching...
No Matches
basisCurves.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HD_ST_BASIS_CURVES_H
8#define PXR_IMAGING_HD_ST_BASIS_CURVES_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hd/version.h"
13#include "pxr/imaging/hd/basisCurves.h"
14#include "pxr/imaging/hd/drawingCoord.h"
15#include "pxr/imaging/hd/enums.h"
16#include "pxr/imaging/hd/perfLog.h"
17
18#include "pxr/usd/sdf/path.h"
19#include "pxr/base/vt/array.h"
20
21#include <memory>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
25class HdStDrawItem;
26using HdSt_BasisCurvesTopologySharedPtr =
27 std::shared_ptr<class HdSt_BasisCurvesTopology>;
28
54class HdStBasisCurves final: public HdBasisCurves
55{
56public:
57 HF_MALLOC_TAG_NEW("new HdStBasisCurves");
58
59 HDST_API
60 HdStBasisCurves(SdfPath const& id);
61
62 HDST_API
63 ~HdStBasisCurves() override;
64
65 HDST_API
66 void UpdateRenderTag(HdSceneDelegate *delegate,
67 HdRenderParam *renderParam) override;
68
69 HDST_API
70 void Sync(HdSceneDelegate *delegate,
71 HdRenderParam *renderParam,
72 HdDirtyBits *dirtyBits,
73 TfToken const &reprToken) override;
74
75 HDST_API
76 void Finalize(HdRenderParam *renderParam) override;
77
78 HDST_API
79 HdDirtyBits GetInitialDirtyBitsMask() const override;
80
81 HDST_API
82 TfTokenVector const & GetBuiltinPrimvarNames() const override;
83
84protected:
85 HDST_API
86 void _InitRepr(TfToken const &reprToken, HdDirtyBits *dirtyBits) override;
87
88 HDST_API
89 HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;
90
91 void _UpdateRepr(HdSceneDelegate *sceneDelegate,
92 HdRenderParam *renderParam,
93 TfToken const &reprToken,
94 HdDirtyBits *dirtyBitsState);
95
96 void _PopulateTopology(HdSceneDelegate *sceneDelegate,
97 HdRenderParam *renderParam,
98 HdStDrawItem *drawItem,
99 HdDirtyBits *dirtyBits,
100 const HdBasisCurvesReprDesc &desc);
101
102 void _PopulateVertexPrimvars(HdSceneDelegate *sceneDelegate,
103 HdRenderParam *renderParam,
104 HdStDrawItem *drawItem,
105 HdDirtyBits *dirtyBits);
106
107 void _PopulateVaryingPrimvars(HdSceneDelegate *sceneDelegate,
108 HdRenderParam *renderParam,
109 HdStDrawItem *drawItem,
110 HdDirtyBits *dirtyBits);
111
112 void _PopulateElementPrimvars(HdSceneDelegate *sceneDelegate,
113 HdRenderParam *renderParam,
114 HdStDrawItem *drawItem,
115 HdDirtyBits *dirtyBits);
116
117private:
118 enum DrawingCoord {
119 HullTopology = HdDrawingCoord::CustomSlotsBegin,
120 PointsTopology,
121 InstancePrimvar // has to be at the very end
122 };
123
124 enum DirtyBits : HdDirtyBits {
125 DirtyIndices = HdChangeTracker::CustomBitsBegin,
126 DirtyHullIndices = (DirtyIndices << 1),
127 DirtyPointsIndices = (DirtyHullIndices << 1)
128 };
129
130 // When processing primvars, these will get set to if we determine that
131 // we should do cubic basis interpolation on the normals and widths.
132 // NOTE: I worry that it may be possible for these to get out of sync.
133 // The right long term fix is likely to maintain proper separation between
134 // varying and vertex primvars throughout the HdSt rendering pipeline.
135 bool _basisWidthInterpolation = false;
136 bool _basisNormalInterpolation = false;
137
138 bool _SupportsRefinement(int refineLevel);
139 bool _SupportsUserWidths(HdStDrawItem* drawItem);
140 bool _SupportsUserNormals(HdStDrawItem* drawItem);
141
142 void _UpdateDrawItem(HdSceneDelegate *sceneDelegate,
143 HdRenderParam *renderParam,
144 HdStDrawItem *drawItem,
145 HdDirtyBits *dirtyBits,
146 const HdBasisCurvesReprDesc &desc);
147
148 void _UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate,
149 HdRenderParam *renderParam,
150 HdStDrawItem *drawItem,
151 const HdBasisCurvesReprDesc &desc);
152
153 void _UpdateShadersForAllReprs(HdSceneDelegate *sceneDelegate,
154 HdRenderParam *renderParam,
155 bool updateMaterialNetworkShader,
156 bool updateGeometricShader);
157
158 void _UpdateMaterialTagsForAllReprs(HdSceneDelegate *sceneDelegate,
159 HdRenderParam *renderParam);
160
161 HdSt_BasisCurvesTopologySharedPtr _topology;
162 HdTopology::ID _topologyId;
163 HdDirtyBits _customDirtyBitsInUse;
164 int _refineLevel; // XXX: could be moved into HdBasisCurveTopology.
165 bool _displayOpacity : 1;
166 bool _displayInOverlay : 1;
167 bool _occludedSelectionShowsThrough : 1;
168 bool _pointsShadingEnabled : 1;
169};
170
171
172PXR_NAMESPACE_CLOSE_SCOPE
173
174#endif // PXR_IMAGING_HD_ST_BASIS_CURVES_H
Hydra Schema for a collection of curves using a particular basis.
Definition: basisCurves.h:52
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
Adapter class providing data exchange with the client scene graph.
A collection of curves using a particular basis.
Definition: basisCurves.h:55
HDST_API void Sync(HdSceneDelegate *delegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits, TfToken const &reprToken) override
Pull invalidated scene data and prepare/update the renderable representation.
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...
HDST_API void _InitRepr(TfToken const &reprToken, HdDirtyBits *dirtyBits) override
Initialize the given representation of this Rprim.
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 TfTokenVector const & GetBuiltinPrimvarNames() const override
Returns the names of built-in primvars, i.e.
HDST_API void Finalize(HdRenderParam *renderParam) override
Finalizes object resources.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Descriptor to configure a drawItem for a repr.
Definition: basisCurves.h:31
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440