OpenSubdiv: opensubdiv/osd/types.h Source File

| 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
25 struct 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) {
40 handle.arrayIndex = 0;
41 handle.patchIndex = 0;
42 handle.vertIndex = 0;
43 }
44
45 Far::PatchTable::PatchHandle handle;
46 float s, t;
47};
48
49 struct PatchArray {
50 // 4-ints struct.
51 PatchArray(Far::PatchDescriptor desc_in,
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
58 PatchArray(Far::PatchDescriptor regDesc_in, Far::PatchDescriptor irregDesc_in,
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
66 Far::PatchDescriptor const &GetDescriptor() const {
67 return desc;
68 }
69 Far::PatchDescriptor const &GetDescriptorRegular() const {
70 return regDesc;
71 }
72 Far::PatchDescriptor const &GetDescriptorIrregular() const {
73 return desc;
74 }
75
76 int GetPatchType() const {
77 return desc.GetType();
78 }
79 int GetPatchTypeRegular() const {
80 return regDesc.GetType();
81 }
82 int GetPatchTypeIrregular() const {
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
101 Far::PatchDescriptor regDesc;
102 Far::PatchDescriptor desc;
103
104 int numPatches;
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
110 struct PatchParam : public Far::PatchParam {
111 // int3 struct.
112 float sharpness;
113};
114
115 typedef std::vector<PatchArray> PatchArrayVector;
116 typedef 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
patchTable.h
OpenSubdiv
Definition limits.h:15
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:16
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:17
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParamVector
std::vector< PatchParam > PatchParamVector
Definition types.h:116
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition types.h:115
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor
Describes the type of a patch.
Definition patchDescriptor.h:27
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchParam
Patch parameterization.
Definition patchParam.h:135
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable::PatchHandle
Handle that can be used as unique patch identifier within PatchTable.
Definition patchTable.h:43
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::handle
Far::PatchTable::PatchHandle handle
patch handle
Definition types.h:45
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::PatchCoord
PatchCoord()
Definition types.h:39
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::s
float s
Definition types.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::PatchCoord
PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg)
Constructor.
Definition types.h:36
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::t
float t
parametric location on patch
Definition types.h:46
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::regDesc
Far::PatchDescriptor regDesc
Definition types.h:101
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::stride
int stride
Definition types.h:106
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPrimitiveIdBase
int GetPrimitiveIdBase() const
Definition types.h:95
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptorIrregular
Far::PatchDescriptor const & GetDescriptorIrregular() const
Definition types.h:72
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchTypeIrregular
int GetPatchTypeIrregular() const
Definition types.h:82
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::primitiveIdBase
int primitiveIdBase
Definition types.h:107
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptorRegular
Far::PatchDescriptor const & GetDescriptorRegular() const
Definition types.h:69
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::indexBase
int indexBase
Definition types.h:105
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::numPatches
int numPatches
Definition types.h:104
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchTypeRegular
int GetPatchTypeRegular() const
Definition types.h:79
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::PatchArray
PatchArray(Far::PatchDescriptor desc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition types.h:51
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetStride
int GetStride() const
Definition types.h:92
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptor
Far::PatchDescriptor const & GetDescriptor() const
Definition types.h:66
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::desc
Far::PatchDescriptor desc
Definition types.h:102
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetIndexBase
int GetIndexBase() const
Definition types.h:89
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::PatchArray
PatchArray(Far::PatchDescriptor regDesc_in, Far::PatchDescriptor irregDesc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition types.h:58
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetNumPatches
int GetNumPatches() const
Definition types.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchType
int GetPatchType() const
Definition types.h:76
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam
Definition types.h:110
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam::sharpness
float sharpness
Definition types.h:112