diff --git a/opensubdiv/far/patchTable.h b/opensubdiv/far/patchTable.h index 3ec2e3f8..e865d7d3 100644 --- a/opensubdiv/far/patchTable.h +++ b/opensubdiv/far/patchTable.h @@ -160,22 +160,6 @@ public: /// \brief Returns the number of local vertex points. int GetNumLocalPoints() const; - /// \brief Updates local point vertex values. - /// - /// @param src Buffer with primvar data for the base and refined - /// vertex values - /// - /// @param dst Destination buffer for the computed local point - /// vertex values - /// - /// - template void - ComputeLocalPointValues(T const *src, T *dst) const; - - template void - ComputeLocalPointValues(T const *srcBase, int numBase, - T const *srcRefined, T *dst) const; - /// \brief Returns the stencil table to compute local point vertex values StencilTable const *GetLocalPointStencilTable() const; @@ -187,24 +171,24 @@ public: /// vertex values template bool IsLocalPointStencilPrecision() const; - /// \brief Returns the number of local varying points. - int GetNumLocalPointsVarying() const; - - /// \brief Updates local point varying values. + /// \brief Updates local point vertex values. /// /// @param src Buffer with primvar data for the base and refined - /// varying values + /// vertex values /// /// @param dst Destination buffer for the computed local point - /// varying values + /// vertex values /// + /// For more flexibility computing local vertex points, retrieval of + /// the local point stencil table and use of its public methods is + /// recommended or often required. /// template void - ComputeLocalPointValuesVarying(T const *src, T *dst) const; + ComputeLocalPointValues(T const *src, T *dst) const; - template void - ComputeLocalPointValuesVarying(T const *srcBase, int numBase, - T const *srcRefined, T *dst) const; + + /// \brief Returns the number of local varying points. + int GetNumLocalPointsVarying() const; /// \brief Returns the stencil table to compute local point varying values StencilTable const *GetLocalPointVaryingStencilTable() const; @@ -217,26 +201,24 @@ public: /// varying values template bool IsLocalPointVaryingStencilPrecision() const; - /// \brief Returns the number of local face-varying points for \p channel - int GetNumLocalPointsFaceVarying(int channel = 0) const; - - /// \brief Updates local point face-varying values. + /// \brief Updates local point varying values. /// /// @param src Buffer with primvar data for the base and refined - /// face-varying values + /// varying values /// /// @param dst Destination buffer for the computed local point - /// face-varying values - /// - /// @param channel face-varying channel + /// varying values /// + /// For more flexibility computing local varying points, retrieval of + /// the local point varying stencil table and use of its public methods + /// is recommended or often required. /// template void - ComputeLocalPointValuesFaceVarying(T const *src, T *dst, int channel = 0) const; + ComputeLocalPointValuesVarying(T const *src, T *dst) const; - template void - ComputeLocalPointValuesFaceVarying(T const *srcBase, int numBase, - T const *srcRefined, T *dst, int channel = 0) const; + + /// \brief Returns the number of local face-varying points for \p channel + int GetNumLocalPointsFaceVarying(int channel = 0) const; /// \brief Returns the stencil table to compute local point face-varying values StencilTable const *GetLocalPointFaceVaryingStencilTable(int channel = 0) const; @@ -248,6 +230,23 @@ public: /// \brief Tests the precision of the stencil table to compute local point /// face-varying values template bool IsLocalPointFaceVaryingStencilPrecision() const; + + /// \brief Updates local point face-varying values. + /// + /// @param src Buffer with primvar data for the base and refined + /// face-varying values + /// + /// @param dst Destination buffer for the computed local point + /// face-varying values + /// + /// @param channel face-varying channel + /// + /// For more flexibility computing local face-varying points, retrieval + /// of the local point face-varying stencil table and use of its public + /// methods is recommended or often required. + /// + template void + ComputeLocalPointValuesFaceVarying(T const *src, T *dst, int channel = 0) const; //@} @@ -737,18 +736,18 @@ PatchTable::IsLocalPointFaceVaryingStencilPrecision() const { // inline StencilTable const * PatchTable::GetLocalPointStencilTable() const { - assert(!_vertexPrecisionIsDouble); + assert(IsLocalPointStencilPrecision()); return static_cast(_localPointStencils.Get()); } inline StencilTable const * PatchTable::GetLocalPointVaryingStencilTable() const { - assert(!_varyingPrecisionIsDouble); + assert(IsLocalPointVaryingStencilPrecision()); return static_cast( _localPointVaryingStencils.Get()); } inline StencilTable const * PatchTable::GetLocalPointFaceVaryingStencilTable(int channel) const { - assert(!_faceVaryingPrecisionIsDouble); + assert(IsLocalPointFaceVaryingStencilPrecision()); if (channel >= 0 && channel < (int)_localPointFaceVaryingStencils.size()) { return static_cast( _localPointFaceVaryingStencils[channel].Get()); @@ -785,81 +784,28 @@ PatchTable::GetLocalPointFaceVaryingStencilTable(int channel) const { template inline void PatchTable::ComputeLocalPointValues(T const *src, T *dst) const { + assert(IsLocalPointStencilPrecision()); if (_localPointStencils.IsSet()) { - if (_vertexPrecisionIsDouble) { - _localPointStencils.Get()->UpdateValues(src, dst); - } else { - _localPointStencils.Get()->UpdateValues(src, dst); - } - } -} -template -inline void -PatchTable::ComputeLocalPointValues(T const *srcBase, int numBase, - T const *srcRefined, T *dst) const { - if (_localPointStencils.IsSet()) { - if (_vertexPrecisionIsDouble) { - _localPointStencils.Get()->UpdateValues( - srcBase, numBase, srcRefined, dst); - } else { - _localPointStencils.Get()->UpdateValues( - srcBase, numBase, srcRefined, dst); - } + _localPointStencils.Get()->UpdateValues(src, dst); } } template inline void PatchTable::ComputeLocalPointValuesVarying(T const *src, T *dst) const { + assert(IsLocalPointVaryingStencilPrecision()); if (_localPointVaryingStencils.IsSet()) { - if (_varyingPrecisionIsDouble) { - _localPointVaryingStencils.Get()->UpdateValues(src, dst); - } else { - _localPointVaryingStencils.Get()->UpdateValues(src, dst); - } - } -} -template -inline void -PatchTable::ComputeLocalPointValuesVarying(T const *srcBase, int numBase, - T const *srcRefined, T *dst) const { - if (_localPointVaryingStencils.IsSet()) { - if (_varyingPrecisionIsDouble) { - _localPointVaryingStencils.Get()->UpdateValues( - srcBase, numBase, srcRefined, dst); - } else { - _localPointVaryingStencils.Get()->UpdateValues( - srcBase, numBase, srcRefined, dst); - } + _localPointVaryingStencils.Get()->UpdateValues(src, dst); } } template inline void PatchTable::ComputeLocalPointValuesFaceVarying(T const *src, T *dst, int channel) const { + assert(IsLocalPointFaceVaryingStencilPrecision()); if (channel >= 0 && channel < (int)_localPointFaceVaryingStencils.size()) { if (_localPointFaceVaryingStencils[channel].IsSet()) { - if (_faceVaryingPrecisionIsDouble) { - _localPointFaceVaryingStencils[channel].Get()->UpdateValues(src, dst); - } else { - _localPointFaceVaryingStencils[channel].Get()->UpdateValues(src, dst); - } - } - } -} -template -inline void -PatchTable::ComputeLocalPointValuesFaceVarying(T const *srcBase, int numBase, - T const *srcRefined, T *dst, int channel) const { - if (channel >= 0 && channel < (int)_localPointFaceVaryingStencils.size()) { - if (_localPointFaceVaryingStencils[channel].IsSet()) { - if (_faceVaryingPrecisionIsDouble) { - _localPointFaceVaryingStencils[channel].Get()->UpdateValues( - srcBase, numBase, srcRefined, dst); - } else { - _localPointFaceVaryingStencils[channel].Get()->UpdateValues( - srcBase, numBase, srcRefined, dst); - } + _localPointFaceVaryingStencils[channel].Get()->UpdateValues(src, dst); } } } diff --git a/tutorials/far/tutorial_6/far_tutorial_6.cpp b/tutorials/far/tutorial_6/far_tutorial_6.cpp index 21a14b11..42817864 100644 --- a/tutorials/far/tutorial_6/far_tutorial_6.cpp +++ b/tutorials/far/tutorial_6/far_tutorial_6.cpp @@ -182,7 +182,10 @@ int main(int, char **) { } // Evaluate local points from interpolated vertex primvars. - patchTable->ComputeLocalPointValues(&verts[0], &verts[nRefinerVertices]); + if (nLocalPoints) { + patchTable->GetLocalPointStencilTable()->UpdateValues( + &verts[0], &verts[nRefinerVertices]); + } // Create a Far::PatchMap to help locating patches in the table Far::PatchMap patchmap(*patchTable); diff --git a/tutorials/far/tutorial_9/far_tutorial_9.cpp b/tutorials/far/tutorial_9/far_tutorial_9.cpp index 17e7b3b7..1b92fd9b 100644 --- a/tutorials/far/tutorial_9/far_tutorial_9.cpp +++ b/tutorials/far/tutorial_9/far_tutorial_9.cpp @@ -86,10 +86,10 @@ namespace { // Clear() and AddWithWeight() required for interpolation: void Clear( void * =0 ) { p[0] = p[1] = p[2] = 0.0f; } - void AddWithWeight(Pos const & src, double weight) { - p[0] += (float)weight * src.p[0]; - p[1] += (float)weight * src.p[1]; - p[2] += (float)weight * src.p[2]; + void AddWithWeight(Pos const & src, float weight) { + p[0] += weight * src.p[0]; + p[1] += weight * src.p[1]; + p[2] += weight * src.p[2]; } float p[3]; @@ -376,8 +376,9 @@ PatchGroup::PatchGroup(Far::PatchTableFactory::Options patchOptions, } } if (nLocalPoints) { - patchTable->ComputeLocalPointValues(&basePositions[0], nBaseVertices, - &localPositions[0], &localPositions[nRefinedVertices]); + patchTable->GetLocalPointStencilTable()->UpdateValues( + &basePositions[0], nBaseVertices, &localPositions[0], + &localPositions[nRefinedVertices]); } delete localRefiner;