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 HDST_BASIS_CURVES_H
25 #define HDST_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 <boost/shared_ptr.hpp>
39 
40 PXR_NAMESPACE_OPEN_SCOPE
41 
42 class HdStDrawItem;
43 typedef boost::shared_ptr<class HdResourceRegistry> HdResourceRegistrySharedPtr;
44 typedef boost::shared_ptr<class HdSt_BasisCurvesTopology>
45  HdSt_BasisCurvesTopologySharedPtr;
46 
72 class HdStBasisCurves final: public HdBasisCurves {
73 public:
74  HF_MALLOC_TAG_NEW("new HdStBasisCurves");
75 
76  HDST_API
77  HdStBasisCurves(SdfPath const& id,
78  SdfPath const& instancerId = SdfPath());
79  HDST_API
80  virtual ~HdStBasisCurves();
81 
82  HDST_API
83  virtual void Sync(HdSceneDelegate *delegate,
84  HdRenderParam *renderParam,
85  HdDirtyBits *dirtyBits,
86  TfToken const &reprToken) override;
87 
88  HDST_API
89  virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
90 
91 protected:
92  HDST_API
93  virtual void _InitRepr(TfToken const &reprToken,
94  HdDirtyBits *dirtyBits) override;
95 
96  HDST_API
97  virtual HdDirtyBits _PropagateDirtyBits(HdDirtyBits bits) const override;
98 
99  void _UpdateRepr(HdSceneDelegate *sceneDelegate,
100  TfToken const &reprToken,
101  HdDirtyBits *dirtyBitsState);
102 
103  void _PopulateTopology(HdSceneDelegate *sceneDelegate,
104  HdStDrawItem *drawItem,
105  HdDirtyBits *dirtyBits,
106  const HdBasisCurvesReprDesc &desc);
107 
108  void _PopulateVertexPrimvars(HdSceneDelegate *sceneDelegate,
109  HdStDrawItem *drawItem,
110  HdDirtyBits *dirtyBits);
111 
112  void _PopulateElementPrimvars(HdSceneDelegate *sceneDelegate,
113  HdStDrawItem *drawItem,
114  HdDirtyBits *dirtyBits);
115 
116 
117 private:
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  const TfToken& _GetMaterialTag(const HdRenderIndex &renderIndex) const;
143 
144  void _UpdateDrawItem(HdSceneDelegate *sceneDelegate,
145  HdStDrawItem *drawItem,
146  HdDirtyBits *dirtyBits,
147  const HdBasisCurvesReprDesc &desc);
148 
149  void _UpdateDrawItemGeometricShader(HdSceneDelegate *sceneDelegate,
150  HdStDrawItem *drawItem,
151  const HdBasisCurvesReprDesc &desc);
152 
153  void _UpdateShadersForAllReprs(HdSceneDelegate *sceneDelegate,
154  bool updateMaterialShader,
155  bool updateGeometricShader);
156 
157 
158  HdSt_BasisCurvesTopologySharedPtr _topology;
159  HdTopology::ID _topologyId;
160  HdDirtyBits _customDirtyBitsInUse;
161  int _refineLevel; // XXX: could be moved into HdBasisCurveTopology.
162 };
163 
164 
165 PXR_NAMESPACE_CLOSE_SCOPE
166 
167 #endif // HDST_BASIS_CURVES_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
The HdRenderParam is an opaque (to core Hydra) handle, to an object that is obtained from the render ...
virtual 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...
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Adapter class providing data exchange with the client scene graph.
Descriptor to configure a drawItem for a repr.
Definition: basisCurves.h:38
A collection of curves using a particular basis.
Definition: basisCurves.h:72
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
virtual 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:53
virtual HDST_API HdDirtyBits GetInitialDirtyBitsMask() const override
Returns the set of dirty bits that should be added to the change tracker for this prim...
virtual HDST_API void Sync(HdSceneDelegate *delegate, HdRenderParam *renderParam, HdDirtyBits *dirtyBits, TfToken const &reprToken) override
Pull invalidated scene data and prepare/update the renderable representation.