All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
smoothNormals.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_SMOOTH_NORMALS_H
25 #define PXR_IMAGING_HD_SMOOTH_NORMALS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/bufferSource.h"
31 #include "pxr/imaging/hd/computation.h"
32 #include "pxr/imaging/hd/types.h"
33 
34 #include "pxr/base/gf/vec3d.h"
35 #include "pxr/base/gf/vec3f.h"
36 #include "pxr/base/tf/token.h"
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 class Hd_VertexAdjacency;
42 
50 class Hd_SmoothNormals final {
51 public:
55  HD_API
56  static VtArray<GfVec3f> ComputeSmoothNormals(
57  Hd_VertexAdjacency const * adjacency,
58  int numPoints,
59  GfVec3f const * pointsPtr);
60  HD_API
61  static VtArray<GfVec3d> ComputeSmoothNormals(
62  Hd_VertexAdjacency const * adjacency,
63  int numPoints,
64  GfVec3d const * pointsPtr);
65  HD_API
66  static VtArray<HdVec4f_2_10_10_10_REV> ComputeSmoothNormalsPacked(
67  Hd_VertexAdjacency const * adjacency,
68  int numPoints,
69  GfVec3f const * pointsPtr);
70  HD_API
71  static VtArray<HdVec4f_2_10_10_10_REV> ComputeSmoothNormalsPacked(
72  Hd_VertexAdjacency const * adjacency,
73  int numPoints,
74  GfVec3d const * pointsPtr);
75 
76 private:
77  Hd_SmoothNormals() = delete;
78  ~Hd_SmoothNormals() = delete;
79 };
80 
85 class Hd_SmoothNormalsComputation : public HdComputedBufferSource {
86 public:
87  HD_API
88  Hd_SmoothNormalsComputation(Hd_VertexAdjacency const *adjacency,
89  HdBufferSourceSharedPtr const &points,
90  TfToken const &dstName,
91  HdBufferSourceSharedPtr const &adjacencyBuilder,
92  bool packed);
93 
95  HD_API
96  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
97  HD_API
98  virtual bool Resolve() override;
99  HD_API
100  virtual TfToken const &GetName() const override;
101 
102 protected:
103  HD_API
104  virtual bool _CheckValid() const override;
105 
106 private:
107  Hd_VertexAdjacency const *_adjacency;
108  HdBufferSourceSharedPtr _points;
109  TfToken _dstName;
110  HdBufferSourceSharedPtr _adjacencyBuilder;
111  bool _packed;
112 };
113 
114 PXR_NAMESPACE_CLOSE_SCOPE
115 
116 #endif // PXR_IMAGING_HD_SMOOTH_NORMALS_H
virtual HD_API TfToken const & GetName() const override
Return the name of this buffer source.
virtual void GetBufferSpecs(HdBufferSpecVector *specs) const =0
Add the buffer spec for this buffer source into given bufferspec vector.
Basic type for a vector of 3 float components.
Definition: vec3f.h:63
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
virtual bool _CheckValid() const =0
Checks the validity of the source buffer.
Basic type for a vector of 3 double components.
Definition: vec3d.h:63
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
virtual bool Resolve()=0
Prepare the access of GetData().
A abstract base class for cpu computation followed by buffer transfer to the GPU. ...
Definition: bufferSource.h:213