25 #ifndef OPENSUBDIV3_FAR_PATCH_PARAM_H 26 #define OPENSUBDIV3_FAR_PATCH_PARAM_H 28 #include "../version.h" 30 #include "../far/types.h" 33 namespace OPENSUBDIV_VERSION {
168 void Set(
Index faceid,
short u,
short v,
169 unsigned short depth,
bool nonquad,
170 unsigned short boundary,
unsigned short transition,
171 bool regular =
false);
181 unsigned short GetU()
const {
return (
unsigned short)unpack(
field1,10,22); }
185 unsigned short GetV()
const {
return (
unsigned short)unpack(
field1,10,12); }
208 template <
typename REAL>
209 void Normalize( REAL & u, REAL & v )
const;
210 template <
typename REAL>
219 template <
typename REAL>
221 template <
typename REAL>
234 unsigned int pack(
unsigned int value,
int width,
int offset)
const {
235 return (
unsigned int)((value & ((1<<width)-1)) << offset);
238 unsigned int unpack(
unsigned int value,
int width,
int offset)
const {
239 return (
unsigned int)((value >> offset) & ((1<<width)-1));
250 unsigned short depth,
bool nonquad,
251 unsigned short boundary,
unsigned short transition,
253 field0 = pack(faceid, 28, 0) |
254 pack(transition, 4, 28);
256 field1 = pack(u, 10, 22) |
258 pack(boundary, 5, 7) |
259 pack(regular, 1, 5) |
260 pack(nonquad, 1, 4) |
269 template <
typename REAL>
275 u = u * fracInv - (REAL)
GetU();
276 v = v * fracInv - (REAL)
GetV();
279 template <
typename REAL>
285 u = (u + (REAL)
GetU()) * frac;
286 v = (v + (REAL)
GetV()) * frac;
295 template <
typename REAL>
303 u = (REAL)(depthFactor -
GetU()) - (u * fracInv);
304 v = (REAL)(depthFactor -
GetV()) - (v * fracInv);
310 template <
typename REAL>
318 u = ((REAL)(depthFactor -
GetU()) - u) * frac;
319 v = ((REAL)(depthFactor -
GetV()) - v) * frac;
328 using namespace OPENSUBDIV_VERSION;
float GetParamFraction() const
Returns the fraction of unit parametric space covered by this face.
bool NonQuadRoot() const
True if the parent base face is a non-quad.
std::vector< PatchParam > PatchParamTable
void Set(Index faceid, short u, short v, unsigned short depth, bool nonquad, unsigned short boundary, unsigned short transition, bool regular=false)
Sets the values of the bit fields.
bool IsRegular() const
Returns whether the patch is regular.
void Clear()
Resets everything to 0.
Vtr::ConstArray< PatchParam > ConstPatchParamArray
void NormalizeTriangle(REAL &u, REAL &v) const
unsigned short GetDepth() const
Returns the level of subdivision of the patch.
unsigned short GetV() const
Returns the log2 value of the v parameter at the first corner of the patch.
unsigned short GetBoundary() const
Returns the boundary edge encoding for the patch.
void UnnormalizeTriangle(REAL &u, REAL &v) const
unsigned short GetU() const
Returns the log2 value of the u parameter at the first corner of the patch.
Vtr::Array< PatchParam > PatchParamArray
unsigned short GetTransition() const
Returns the transition edge encoding for the patch.
void Normalize(REAL &u, REAL &v) const
A (u,v) pair in the fraction of parametric space covered by this face is mapped into a normalized par...
void Unnormalize(REAL &u, REAL &v) const
A (u,v) pair in a normalized parametric space is mapped back into the fraction of parametric space co...
Index GetFaceId() const
Returns the faceid.
bool IsTriangleRotated() const
Returns if a triangular patch is parametrically rotated 180 degrees.