diff --git a/examples/glBatchViewer/effect.cpp b/examples/glBatchViewer/effect.cpp index 0677f648..9fdd036c 100644 --- a/examples/glBatchViewer/effect.cpp +++ b/examples/glBatchViewer/effect.cpp @@ -184,9 +184,10 @@ MyEffect::BindDrawConfig(MyDrawConfig *config, OpenSubdiv::OsdDrawContext::Patch GLint diffuseColor = config->diffuseColorUniform; if (displayPatchColor) { - GLfloat patchColor[10][4] = { + GLfloat patchColor[11][4] = { { 1.0f, 1.0f, 1.0f, 1.0f }, // NON_PATCH - { 1.0f, 1.0f, 1.0f, 1.0f }, // POLYGON + { 1.0f, 1.0f, 1.0f, 1.0f }, // POINTS + { 1.0f, 1.0f, 1.0f, 1.0f }, // LINES { 1.0f, 1.0f, 1.0f, 1.0f }, // QUADS { 1.0f, 1.0f, 1.0f, 1.0f }, // TRIANGLES { 1.0f, 1.0f, 1.0f, 1.0f }, // LOOP diff --git a/examples/glViewer/viewer.cpp b/examples/glViewer/viewer.cpp index 197f0053..3329f173 100644 --- a/examples/glViewer/viewer.cpp +++ b/examples/glViewer/viewer.cpp @@ -1226,7 +1226,7 @@ display() { */ // patch drawing - int patchCount[10][6][4]; // [Type][Pattern][Rotation] (see far/patchTables.h) + int patchCount[11][6][4]; // [Type][Pattern][Rotation] (see far/patchTables.h) memset(patchCount, 0, sizeof(patchCount)); // primitive counting diff --git a/opensubdiv/far/multiMeshFactory.h b/opensubdiv/far/multiMeshFactory.h index f517435f..dcdfeec6 100644 --- a/opensubdiv/far/multiMeshFactory.h +++ b/opensubdiv/far/multiMeshFactory.h @@ -178,7 +178,7 @@ FarMultiMeshFactory::Create(std::vector const *> const &meshes) result->_vertexEditTables = spliceVertexEditTables(result, meshes); // count total num vertices, numptex faces - int numVertices = 0, numPtexFaces; + int numVertices = 0, numPtexFaces = 0; for (size_t i = 0; i < meshes.size(); ++i) { numVertices += meshes[i]->GetNumVertices(); numPtexFaces += meshes[i]->GetNumPtexFaces(); @@ -640,7 +640,7 @@ FarMultiMeshFactory::splicePatchTables(FarMeshVector const &meshes) { if (not parray) continue; copyWithPtexFaceOffset(std::back_inserter(result->_paramTable), - result->_paramTable, + ptables->_paramTable, parray->GetPatchIndex(), parray->GetNumPatches(), ptexFaceOffset); diff --git a/opensubdiv/far/patchTables.h b/opensubdiv/far/patchTables.h index 07f096bb..cd9d8c76 100644 --- a/opensubdiv/far/patchTables.h +++ b/opensubdiv/far/patchTables.h @@ -86,7 +86,8 @@ public: enum Type { NON_PATCH = 0, // undefined - POLYGONS, // general polygon mesh + POINTS, // points (useful for cage drawing) + LINES, // lines (useful for cage drawing) QUADS, // bilinear quads-only patches TRIANGLES, // bilinear triangles-only mesh @@ -341,6 +342,31 @@ public: serialIndex; // Serialized Index of the patch }; + + /// Constructor + /// + /// @param patchArrays Vector of descriptors and ranges for arrays of patches + /// + /// @param indices Indices of the control vertices of the patches + /// + /// @param vertexValences Vertex valance table + /// + /// @param quadOffsets Quad offset table + /// + /// @param ptexCoords Ptex coordinate table + /// + /// @param fvarData Face varying data table + /// + /// @param maxValence Highest vertex valence allowed in the mesh + /// + FarPatchTables(PatchArrayVector const & patchArrays, + PTable const & patches, + VertexValenceTable const * vertexValences, + QuadOffsetTable const * quadOffsets, + PatchParamTable const * patchParams, + FVarDataTable const * fvarData, + int maxValence); + /// Get the table of patch control vertices PTable const & GetPatchTable() const { return _patches; } @@ -442,6 +468,30 @@ private: int _maxValence; }; +// Constructor +inline +FarPatchTables::FarPatchTables(PatchArrayVector const & patchArrays, + PTable const & patches, + VertexValenceTable const * vertexValences, + QuadOffsetTable const * quadOffsets, + PatchParamTable const * patchParams, + FVarDataTable const * fvarData, + int maxValence) : + _patchArrays(patchArrays), + _patches(patches), + _maxValence(maxValence) { + + // copy other tables if exist + if (vertexValences) + _vertexValenceTable = *vertexValences; + if (quadOffsets) + _quadOffsetTable = *quadOffsets; + if (patchParams) + _paramTable = *patchParams; + if (fvarData) + _fvarTable = *fvarData; +} + inline bool FarPatchTables::IsFeatureAdaptive() const { return ((not _vertexValenceTable.empty()) and (not _quadOffsetTable.empty())); @@ -458,6 +508,8 @@ FarPatchTables::Descriptor::GetNumControlVertices( FarPatchTables::Type type ) { case BOUNDARY : return FarPatchTables::GetBoundaryPatchRingsize(); case CORNER : return FarPatchTables::GetCornerPatchRingsize(); case TRIANGLES : return 3; + case LINES : return 2; + case POINTS : return 1; default : return -1; } }