Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
//
// Copyright 2015 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef OPENSUBDIV3_OSD_TYPES_H
#define OPENSUBDIV3_OSD_TYPES_H
#include "../version.h"
#include "../far/patchTable.h"
#include <algorithm>
namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
namespace Osd {
struct PatchCoord {
// 5-ints struct.
PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg) :
handle(handleArg), s(sArg), t(tArg) { }
PatchCoord() : s(0), t(0) {
handle.arrayIndex = 0;
handle.patchIndex = 0;
handle.vertIndex = 0;
}
Far::PatchTable::PatchHandle handle;
float s, t;
};
struct PatchArray {
// 4-ints struct.
PatchArray(Far::PatchDescriptor desc_in,
int numPatches_in, int indexBase_in, int primitiveIdBase_in) :
regDesc(desc_in), desc(desc_in),
numPatches(numPatches_in), indexBase(indexBase_in),
stride(desc_in.GetNumControlVertices()),
primitiveIdBase(primitiveIdBase_in) {}
PatchArray(Far::PatchDescriptor regDesc_in, Far::PatchDescriptor irregDesc_in,
int numPatches_in, int indexBase_in, int primitiveIdBase_in) :
regDesc(regDesc_in), desc(irregDesc_in),
numPatches(numPatches_in), indexBase(indexBase_in),
stride(std::max(regDesc_in.GetNumControlVertices(),
irregDesc_in.GetNumControlVertices())),
primitiveIdBase(primitiveIdBase_in) {}
Far::PatchDescriptor const &GetDescriptor() const {
return desc;
}
Far::PatchDescriptor const &GetDescriptorRegular() const {
return regDesc;
}
Far::PatchDescriptor const &GetDescriptorIrregular() const {
return desc;
}
int GetPatchType() const {
return desc.GetType();
}
int GetPatchTypeRegular() const {
return regDesc.GetType();
}
int GetPatchTypeIrregular() const {
return desc.GetType();
}
int GetNumPatches() const {
return numPatches;
}
int GetIndexBase() const {
return indexBase;
}
int GetStride() const {
return stride;
}
int GetPrimitiveIdBase() const {
return primitiveIdBase;
}
// Separate regular and irregular patch descriptors for cases where the
// array is mixed -- both will be equal if only a single type specified
Far::PatchDescriptor regDesc;
Far::PatchDescriptor desc;
int numPatches;
int indexBase; // an offset within the index buffer
int stride; // stride in buffer between patches
int primitiveIdBase; // an offset within the patch param buffer
};
struct PatchParam : public Far::PatchParam {
// int3 struct.
float sharpness;
};
typedef std::vector<PatchArray> PatchArrayVector;
typedef std::vector<PatchParam> PatchParamVector;
} // end namespace Osd
} // end namespace OPENSUBDIV_VERSION
using namespace OPENSUBDIV_VERSION;
} // end namespace OpenSubdiv
#endif // OPENSUBDIV3_OSD_TYPES_H
patchTable.h
OpenSubdiv
Definition limits.h:32
OpenSubdiv::OPENSUBDIV_VERSION
Definition limits.h:33
OpenSubdiv::OPENSUBDIV_VERSION::Osd
Definition bufferDescriptor.h:34
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParamVector
std::vector< PatchParam > PatchParamVector
Definition types.h:133
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArrayVector
std::vector< PatchArray > PatchArrayVector
Definition types.h:132
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchDescriptor
Describes the type of a patch.
Definition patchDescriptor.h:44
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchParam
Patch parameterization.
Definition patchParam.h:152
OpenSubdiv::OPENSUBDIV_VERSION::Far::PatchTable::PatchHandle
Handle that can be used as unique patch identifier within PatchTable.
Definition patchTable.h:60
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::handle
Far::PatchTable::PatchHandle handle
patch handle
Definition types.h:62
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::PatchCoord
PatchCoord()
Definition types.h:56
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::s
float s
Definition types.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::PatchCoord
PatchCoord(Far::PatchTable::PatchHandle handleArg, float sArg, float tArg)
Constructor.
Definition types.h:53
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchCoord::t
float t
parametric location on patch
Definition types.h:63
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::regDesc
Far::PatchDescriptor regDesc
Definition types.h:118
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::stride
int stride
Definition types.h:123
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPrimitiveIdBase
int GetPrimitiveIdBase() const
Definition types.h:112
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptorIrregular
Far::PatchDescriptor const & GetDescriptorIrregular() const
Definition types.h:89
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchTypeIrregular
int GetPatchTypeIrregular() const
Definition types.h:99
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::primitiveIdBase
int primitiveIdBase
Definition types.h:124
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptorRegular
Far::PatchDescriptor const & GetDescriptorRegular() const
Definition types.h:86
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::indexBase
int indexBase
Definition types.h:122
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::numPatches
int numPatches
Definition types.h:121
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchTypeRegular
int GetPatchTypeRegular() const
Definition types.h:96
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::PatchArray
PatchArray(Far::PatchDescriptor desc_in, int numPatches_in, int indexBase_in, int primitiveIdBase_in)
Definition types.h:68
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetStride
int GetStride() const
Definition types.h:109
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetDescriptor
Far::PatchDescriptor const & GetDescriptor() const
Definition types.h:83
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::desc
Far::PatchDescriptor desc
Definition types.h:119
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetIndexBase
int GetIndexBase() const
Definition types.h:106
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:75
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetNumPatches
int GetNumPatches() const
Definition types.h:103
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchArray::GetPatchType
int GetPatchType() const
Definition types.h:93
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam
Definition types.h:127
OpenSubdiv::OPENSUBDIV_VERSION::Osd::PatchParam::sharpness
float sharpness
Definition types.h:129