8#ifndef OPENSUBDIV3_FAR_PATCH_PARAM_H
9#define OPENSUBDIV3_FAR_PATCH_PARAM_H
11#include "../version.h"
16namespace OPENSUBDIV_VERSION {
151 void Set(
Index faceid,
short u,
short v,
152 unsigned short depth,
bool nonquad,
153 unsigned short boundary,
unsigned short transition,
154 bool regular =
false);
164 unsigned short GetU()
const {
return (
unsigned short)unpack(
field1,10,22); }
168 unsigned short GetV()
const {
return (
unsigned short)unpack(
field1,10,12); }
191 template <
typename REAL>
192 void Normalize( REAL & u, REAL & v )
const;
193 template <
typename REAL>
202 template <
typename REAL>
204 template <
typename REAL>
217 unsigned int pack(
unsigned int value,
int width,
int offset)
const {
218 return (
unsigned int)((value & ((1<<width)-1)) << offset);
221 unsigned int unpack(
unsigned int value,
int width,
int offset)
const {
222 return (
unsigned int)((value >> offset) & ((1<<width)-1));
233 unsigned short depth,
bool nonquad,
234 unsigned short boundary,
unsigned short transition,
236 field0 = pack(faceid, 28, 0) |
237 pack(transition, 4, 28);
239 field1 = pack(u, 10, 22) |
241 pack(boundary, 5, 7) |
242 pack(regular, 1, 5) |
243 pack(nonquad, 1, 4) |
252template <
typename REAL>
258 u = u * fracInv - (REAL)
GetU();
259 v = v * fracInv - (REAL)
GetV();
262template <
typename REAL>
268 u = (u + (REAL)
GetU()) * frac;
269 v = (v + (REAL)
GetV()) * frac;
278template <
typename REAL>
286 u = (REAL)(depthFactor -
GetU()) - (u * fracInv);
287 v = (REAL)(depthFactor -
GetV()) - (v * fracInv);
293template <
typename REAL>
301 u = ((REAL)(depthFactor -
GetU()) - u) * frac;
302 v = ((REAL)(depthFactor -
GetV()) - v) * frac;
311using namespace OPENSUBDIV_VERSION;
Vtr::ConstArray< PatchParam > ConstPatchParamArray
std::vector< PatchParam > PatchParamTable
Vtr::Array< PatchParam > PatchParamArray
bool IsTriangleRotated() const
Returns if a triangular patch is parametrically rotated 180 degrees.
bool IsRegular() const
Returns whether the patch is regular.
void NormalizeTriangle(REAL &u, REAL &v) const
unsigned short GetBoundary() const
Returns the boundary edge encoding for the patch.
unsigned short GetTransition() const
Returns the transition edge encoding for the patch.
float GetParamFraction() const
Returns the fraction of unit parametric space covered by this face.
unsigned short GetU() const
Returns the log2 value of the u parameter at the first corner of the patch.
Index GetFaceId() const
Returns the faceid.
unsigned short GetDepth() const
Returns the level of subdivision of the patch.
bool NonQuadRoot() const
True if the parent base face is a non-quad.
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.
void Clear()
Resets everything to 0.
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...
void UnnormalizeTriangle(REAL &u, REAL &v) const
unsigned short GetV() const
Returns the log2 value of the v parameter at the first corner of 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...