All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flatNormals.h
1 //
2 // Copyright 2018 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 HD_FLAT_NORMALS_H
25 #define HD_FLAT_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 class HdMeshTopology;
41 
49 class Hd_FlatNormals final {
50 public:
54  HD_API
55  static VtArray<GfVec3f> ComputeFlatNormals(
56  HdMeshTopology const * topology,
57  GfVec3f const * pointsPtr);
58  HD_API
59  static VtArray<GfVec3d> ComputeFlatNormals(
60  HdMeshTopology const * topology,
61  GfVec3d const * pointsPtr);
62  HD_API
63  static VtArray<HdVec4f_2_10_10_10_REV> ComputeFlatNormalsPacked(
64  HdMeshTopology const * topology,
65  GfVec3f const * pointsPtr);
66  HD_API
67  static VtArray<HdVec4f_2_10_10_10_REV> ComputeFlatNormalsPacked(
68  HdMeshTopology const * topology,
69  GfVec3d const * pointsPtr);
70 
71 private:
72  Hd_FlatNormals() = delete;
73  ~Hd_FlatNormals() = delete;
74 };
75 
80 class Hd_FlatNormalsComputation : public HdComputedBufferSource {
81 public:
82  HD_API
83  Hd_FlatNormalsComputation(HdMeshTopology const *topology,
84  HdBufferSourceSharedPtr const &points,
85  TfToken const &dstName,
86  bool packed);
87 
89  HD_API
90  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
91  HD_API
92  virtual bool Resolve() override;
93  HD_API
94  virtual TfToken const &GetName() const override;
95 
96 protected:
97  HD_API
98  virtual bool _CheckValid() const override;
99 
100 private:
101  HdMeshTopology const *_topology;
102  HdBufferSourceSharedPtr const _points;
103  TfToken _dstName;
104  bool _packed;
105 };
106 
107 PXR_NAMESPACE_CLOSE_SCOPE
108 
109 #endif // HD_FLAT_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:89
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
Topology data for meshes.
Definition: meshTopology.h:55
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:210