All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
basisCurves.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_ST_BASIS_CURVES_H
25 #define PXR_IMAGING_HD_ST_BASIS_CURVES_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/basisCurves.h"
31 #include "pxr/imaging/hd/drawingCoord.h"
32 #include "pxr/imaging/hd/enums.h"
33 #include "pxr/imaging/hd/perfLog.h"
34 
35 #include "pxr/usd/sdf/path.h"
36 #include "pxr/base/vt/array.h"
37 
38 #include <memory>
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
42 class HdStDrawItem;
43 using HdSt_BasisCurvesTopologySharedPtr =
44  std::shared_ptr<class HdSt_BasisCurvesTopology>;
45 
71 class HdStBasisCurves final: public HdBasisCurves
72 {
73 public:
74  HF_MALLOC_TAG_NEW("new HdStBasisCurves");
75 
76  HDST_API
77  HdStBasisCurves(SdfPath const& id);
78 
79  HDST_API
80  ~HdStBasisCurves() override;
81 
82  HDST_API
83  void Sync(HdSceneDelegate *delegate,
84  HdRenderParam *renderParam,
85  HdDirtyBits *dirtyBits,
86  TfToken const &reprToken) override;
87 
88  HDST_API
89  void Finalize(HdRenderParam *renderParam) override;
90 
91  HDST_API
92  HdDirtyBits GetInitialDirtyBitsMask() const override;
93 
94 protected:
95  HDST_API
96  void _InitRepr(TfToken const &reprToken, HdDirtyBits *dirtyBits) override;
97 
98  HDST_API
99  HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;
100 
101  void _UpdateRepr(HdSceneDelegate *sceneDelegate,
102  HdRenderParam *renderParam,
103  TfToken const &reprToken,
104  HdDirtyBits *dirtyBitsState);
105 
106  void _PopulateTopology(HdSceneDelegate *sceneDelegate,
107  HdRenderParam *renderParam,
108  HdStDrawItem *drawItem,
109  HdDirtyBits *dirtyBits,
110  const HdBasisCurvesReprDesc &desc);
111 
112  void _PopulateVertexPrimvars(HdSceneDelegate *sceneDelegate,
113  HdRenderParam *renderParam,
114  HdStDrawItem *drawItem,
115  HdDirtyBits *dirtyBits);
116 
117  void _PopulateVaryingPrimvars(HdSceneDelegate *sceneDelegate,
118  HdRenderParam *renderParam,
119  HdStDrawItem *drawItem,
120  HdDirtyBits *dirtyBits);
121 
122  void _PopulateElementPrimvars(HdSceneDelegate *sceneDelegate,
123  HdRenderParam *renderParam,
124  HdStDrawItem *drawItem,
125  HdDirtyBits *dirtyBits);
126 
127 private:
128  enum DrawingCoord {
129  HullTopology = HdDrawingCoord::CustomSlotsBegin,
130  PointsTopology,
131  InstancePrimvar // has to be at the very end
132  };
133 
134  enum DirtyBits : HdDirtyBits {
135  DirtyIndices = HdChangeTracker::CustomBitsBegin,
136  DirtyHullIndices = (DirtyIndices << 1),
137  DirtyPointsIndices = (DirtyHullIndices << 1)
138  };
139 
140  // When processing primvars, these will get set to if we determine that
141  // we should do cubic basis interpolation on the normals and widths.
142  // NOTE: I worry that it may be possible for these to get out of sync.
143  // The right long term fix is likely to maintain proper separation between
144  // varying and vertex primvars throughout the HdSt rendering pipeline.
145  bool _basisWidthInterpolation = false;
146  bool _basisNormalInterpolation = false;
147 
148  bool _SupportsRefinement(int refineLevel);
149  bool _SupportsUserWidths(HdStDrawItem* drawItem);
150  bool _SupportsUserNormals(HdStDrawItem* drawItem);
151 
152  void _UpdateDrawItem(HdSceneDelegate *sceneDelegate,
153  HdRenderParam *renderParam,
154  HdStDrawItem *drawItem,
155  HdDirtyBits *dirtyBits,
156  const HdBasisCurvesReprDesc &desc);
157 
158  void _UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate,
159  HdRenderParam *renderParam,
160  HdStDrawItem *drawItem,
161  const HdBasisCurvesReprDesc &desc);
162 
163  void _UpdateShadersForAllReprs(HdSceneDelegate *sceneDelegate,
164  HdRenderParam *renderParam,
165  bool updateMaterialShader,
166  bool updateGeometricShader);
167 
168 
169  HdSt_BasisCurvesTopologySharedPtr _topology;
170  HdTopology::ID _topologyId;
171  HdDirtyBits _customDirtyBitsInUse;
172  int _refineLevel; // XXX: could be moved into HdBasisCurveTopology.
173  bool _displayOpacity : 1;
174  bool _occludedSelectionShowsThrough : 1;
175 };
176 
177 
178 PXR_NAMESPACE_CLOSE_SCOPE
179 
180 #endif // PXR_IMAGING_HD_ST_BASIS_CURVES_H
HDST_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the set of dirty bits that should be added to the change tracker for this prim...
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.
Definition: token.h:87
Adapter class providing data exchange with the client scene graph.
Descriptor to configure a drawItem for a repr.
Definition: basisCurves.h:46
A collection of curves using a particular basis.
Definition: basisCurves.h:71
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
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.
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.
Hydra Schema for a collection of curves using a particular basis.
Definition: basisCurves.h:66