OpenSubdiv
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1//
2// Copyright 2015 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://opensubdiv.org/license.
6//
7
8#ifndef OPENSUBDIV3_OSD_TYPES_H
9#define OPENSUBDIV3_OSD_TYPES_H
10
11#include "../version.h"
12#include "../far/patchTable.h"
13
14#include <algorithm>
15
16namespace OpenSubdiv {
17namespace OPENSUBDIV_VERSION {
18
19namespace Osd {
20
25struct PatchCoord {
26 // 5-ints struct.
27
36 PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg) :
37 handle(handleArg), s(sArg), t(tArg) { }
38
39 PatchCoord() : s(0), t(0) {
42 handle.vertIndex = 0;
43 }
44
46 float s, t;
47};
48
49struct PatchArray {
50 // 4-ints struct.
52 int numPatches_in, int indexBase_in, int primitiveIdBase_in) :
53 regDesc(desc_in), desc(desc_in),
54 numPatches(numPatches_in), indexBase(indexBase_in),
55 stride(desc_in.GetNumControlVertices()),
56 primitiveIdBase(primitiveIdBase_in) {}
57
59 int numPatches_in, int indexBase_in, int primitiveIdBase_in) :
60 regDesc(regDesc_in), desc(irregDesc_in),
61 numPatches(numPatches_in), indexBase(indexBase_in),
62 stride(std::max(regDesc_in.GetNumControlVertices(),
63 irregDesc_in.GetNumControlVertices())),
64 primitiveIdBase(primitiveIdBase_in) {}
65
67 return desc;
68 }
70 return regDesc;
71 }
73 return desc;
74 }
75
76 int GetPatchType() const {
77 return desc.GetType();
78 }
79 int GetPatchTypeRegular() const {
80 return regDesc.GetType();
81 }
83 return desc.GetType();
84 }
85
86 int GetNumPatches() const {
87 return numPatches;
88 }
89 int GetIndexBase() const {
90 return indexBase;
91 }
92 int GetStride() const {
93 return stride;
94 }
95 int GetPrimitiveIdBase() const {
96 return primitiveIdBase;
97 }
98
99 // Separate regular and irregular patch descriptors for cases where the
100 // array is mixed -- both will be equal if only a single type specified
103
105 int indexBase; // an offset within the index buffer
106 int stride; // stride in buffer between patches
107 int primitiveIdBase; // an offset within the patch param buffer
108};
109
111 // int3 struct.
113};
114
115typedef std::vector<PatchArray> PatchArrayVector;
116typedef std::vector<PatchParam> PatchParamVector;
117
118} // end namespace Osd
119
120} // end namespace OPENSUBDIV_VERSION
121using namespace OPENSUBDIV_VERSION;
122
123} // end namespace OpenSubdiv
124
125
126#endif // OPENSUBDIV3_OSD_TYPES_H
std::vector< PatchParam > PatchParamVector
Definition types.h:116
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
Type GetType() const
Returns the type of the patch.
Handle that can be used as unique patch identifier within PatchTable.
Definition patchTable.h:43
Coordinates set on a patch table.
Definition types.h:25
Far::PatchTable::PatchHandle handle
patch handle
Definition types.h:45
PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg)
Constructor.
Definition types.h:36
float t
parametric location on patch
Definition types.h:46
Far::PatchDescriptor const & GetDescriptorIrregular() const
Definition types.h:72
Far::PatchDescriptor const & GetDescriptorRegular() const
Definition types.h:69
PatchArray(Far::PatchDescriptor desc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition types.h:51
Far::PatchDescriptor const & GetDescriptor() const
Definition types.h:66
PatchArray(Far::PatchDescriptor regDesc_in, Far::PatchDescriptor irregDesc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition types.h:58