All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
triangulate.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_TRIANGULATE_H
25 #define HDST_TRIANGULATE_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/version.h"
29 #include "pxr/imaging/hd/bufferSource.h"
30 
31 #include "pxr/usd/sdf/path.h"
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
35 
36 class HdSt_MeshTopology;
37 
42 
43 // Index triangulation generates a mapping from triangle ID to authored
44 // face index domain, called primitiveParams. The primitive params are stored
45 // alongside topology index buffers, so that the same aggregation locators can
46 // be used for such an additional buffer as well. This change transforms index
47 // buffer from int array to int[3] array or int[4] array at first. Thanks to
48 // the heterogenius non-interleaved buffer aggregation ability in hd,
49 // we'll get this kind of buffer layout:
50 //
51 // ----+--------+--------+------
52 // ... |i0 i1 i2|i3 i4 i5| ... index buffer (for triangles)
53 // ----+--------+--------+------
54 // ... | m0 | m1 | ... primitive param buffer (coarse face index)
55 // ----+--------+--------+------
56 
57 class HdSt_TriangleIndexBuilderComputation : public HdComputedBufferSource {
58 public:
59  HdSt_TriangleIndexBuilderComputation(HdSt_MeshTopology *topology,
60  SdfPath const &id);
61  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
62  virtual bool Resolve() override;
63 
64  virtual bool HasChainedBuffer() const override;
65  virtual HdBufferSourceVector GetChainedBuffers() const override;
66 
67 protected:
68  virtual bool _CheckValid() const override;
69 
70 private:
71  SdfPath const _id;
72  HdSt_MeshTopology *_topology;
73  HdBufferSourceSharedPtr _primitiveParam;
74  HdBufferSourceSharedPtr _trianglesEdgeIndices;
75 };
76 
77 //
78 
83 class HdSt_TriangulateFaceVaryingComputation : public HdComputedBufferSource {
84 public:
85  HdSt_TriangulateFaceVaryingComputation(HdSt_MeshTopology *topolgoy,
86  HdBufferSourceSharedPtr const &source,
87  SdfPath const &id);
88 
89  virtual void GetBufferSpecs(HdBufferSpecVector *specs) const override;
90  virtual bool Resolve() override;
91 
92 protected:
93  virtual bool _CheckValid() const override;
94 
95 private:
96  SdfPath const _id;
97  HdSt_MeshTopology *_topology;
98  HdBufferSourceSharedPtr _source;
99 };
100 
101 
102 PXR_NAMESPACE_CLOSE_SCOPE
103 
104 #endif // HdSt_TRIANGULATE_H
virtual void GetBufferSpecs(HdBufferSpecVector *specs) const =0
Add the buffer spec for this buffer source into given bufferspec vector.
virtual bool _CheckValid() const =0
Checks the validity of the source buffer.
virtual HD_API bool HasChainedBuffer() const
Returns true if this buffer has any chained buffer(s)
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
virtual HD_API HdBufferSourceVector GetChainedBuffers() const
Returns the vector of chained buffers.
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