31 std::memset(
this, 0,
sizeof(
QuadNode));
44 void SetChild(
int quadrant,
int index,
bool isLeaf);
49 typedef OpenSubdiv::Far::PatchTable::PatchHandle
Handle;
55 PatchMap(OpenSubdiv::Far::PatchTable
const &patchTable);
90 return _patchesAreTriangular;
98 const std::vector<QuadNode> &
nodes()
104 void initializeHandles(OpenSubdiv::Far::PatchTable
const &patchTable);
105 void initializeQuadtree(OpenSubdiv::Far::PatchTable
const &patchTable);
107 typedef std::vector<QuadNode> QuadTree;
110 void assignRootNode(QuadNode *node,
int index);
111 QuadNode *assignLeafOrChildNode(QuadNode *node,
bool isLeaf,
int quadrant,
int index);
113 template<
class T>
static int transformUVToQuadQuadrant(T
const &median, T &u, T &
v);
115 static int transformUVToTriQuadrant(T
const &median, T &u, T &
v,
bool &rotated);
118 bool _patchesAreTriangular;
124 std::vector<Handle> _handles;
125 std::vector<QuadNode> _quadtree;
211 if ((faceid < _minPatchFace) || (faceid > _maxPatchFace)) {
215 QuadNode const *node = &_quadtree[faceid - _minPatchFace];
217 if (!node->children[0].isSet) {
224 assert((u >= 0.0) && (u <= 1.0) && (
v >= 0.0) && (
v <= 1.0));
227 bool triRotated =
false;
229 for (
int depth = 0; depth <= _maxDepth; ++depth, median *= 0.5) {
231 int quadrant = _patchesAreTriangular ? transformUVToTriQuadrant(median, u,
v, triRotated) :
232 transformUVToQuadQuadrant(median, u,
v);
235 assert(node->children[quadrant].isSet);
237 if (node->children[quadrant].isLeaf) {
238 return &_handles[node->children[quadrant].index];
241 node = &_quadtree[node->children[quadrant].index];
Handle const * FindPatch(int patchFaceId, double u, double v) const
Returns a handle to the sub-patch of the face at the given (u,v). Note that the patch face ID corresp...