25 #ifndef OPENSUBDIV3_FAR_PATCH_PARAM_H
26 #define OPENSUBDIV3_FAR_PATCH_PARAM_H
28 #include "../version.h"
30 #include "../far/types.h"
32 namespace OpenSubdiv {
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 void Normalize(
float & u,
float & v )
const;
225 unsigned int pack(
unsigned int value,
int width,
int offset)
const {
226 return (
unsigned int)((value & ((1<<width)-1)) << offset);
229 unsigned int unpack(
unsigned int value,
int width,
int offset)
const {
230 return (
unsigned int)((value >> offset) & ((1<<width)-1));
241 unsigned short depth,
bool nonquad,
242 unsigned short boundary,
unsigned short transition,
244 field0 = pack(faceid, 28, 0) |
245 pack(transition, 4, 28);
247 field1 = pack(u, 10, 22) |
249 pack(boundary, 4, 8) |
250 pack(regular, 1, 5) |
251 pack(nonquad, 1, 4) |
258 return 1.0f / float( 1 << (
GetDepth()-1) );
260 return 1.0f / float( 1 <<
GetDepth() );
269 float pu = (float)
GetU()*frac;
270 float pv = (float)
GetV()*frac;
281 float pu = (float)
GetU()*frac;
282 float pv = (float)
GetV()*frac;
291 using namespace OPENSUBDIV_VERSION;
bool IsRegular() const
Returns whether the patch is regular.
float GetParamFraction() const
Returns the fraction of unit parametric space covered by this face.
Index GetFaceId() const
Returns the faceid.
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 NonQuadRoot() const
True if the parent base face is a non-quad.
void Unnormalize(float &u, float &v) const
A (u,v) pair in a normalized parametric space is mapped back into the fraction of parametric space co...
Vtr::ConstArray< PatchParam > ConstPatchParamArray
void Clear()
Resets everything to 0.
unsigned short GetTransition() const
Returns the transition edge encoding for the patch.
unsigned short GetDepth() const
Returns the level of subdivision of the patch.
unsigned short GetU() const
Returns the log2 value of the u parameter at the first corner of the patch.
unsigned short GetBoundary() const
Returns the boundary edge encoding for the patch.
Vtr::Array< PatchParam > PatchParamArray
unsigned short GetV() const
Returns the log2 value of the v parameter at the first corner of the patch.
std::vector< PatchParam > PatchParamTable
void Normalize(float &u, float &v) const
A (u,v) pair in the fraction of parametric space covered by this face is mapped into a normalized par...