mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-25 17:21:14 +00:00
Fix FarStencilTablesFactory: replace limit tangents table
The new table accomodates verts with valence up to 20. Dr. DeRose provided me with a python script to generate the tables, but wants to investigate a closed-form alternative to pre-computed tables. Also: our logic is incorrect - it is missing adjacent face-points in the interpolation (apparently this has been incorrect since day 1). Further fixes coming next year... fixes #246
This commit is contained in:
parent
35a4d45cf2
commit
69ebcb8cc3
@ -40,32 +40,32 @@ namespace OPENSUBDIV_VERSION {
|
||||
class FarStencil {
|
||||
public:
|
||||
|
||||
/// Returns the size of the stencil (number of control vertices)
|
||||
/// \brief Returns the size of the stencil (number of control vertices)
|
||||
int GetSize() const {
|
||||
return *_size;
|
||||
}
|
||||
|
||||
/// Returns the control vertices indices
|
||||
/// \brief Returns the control vertices indices
|
||||
int const * GetVertexIndices() const {
|
||||
return _indices;
|
||||
}
|
||||
|
||||
/// Returns the interpolation weights
|
||||
/// \brief Returns the interpolation weights
|
||||
float const * GetValueWeights() const {
|
||||
return _point;
|
||||
}
|
||||
|
||||
/// Returns U derivative interpolation weights
|
||||
/// \brief Returns U derivative interpolation weights
|
||||
float const * GetUDerivWeights() const {
|
||||
return _uderiv;
|
||||
}
|
||||
|
||||
/// Returns V derivative interpolation weights
|
||||
/// \brief Returns V derivative interpolation weights
|
||||
float const * GetVDerivWeights() const {
|
||||
return _vderiv;
|
||||
}
|
||||
|
||||
/// Increment to the next stencil in the array
|
||||
/// \brief Increment to the next stencil in the array
|
||||
/// Note : there is no array boundary check !
|
||||
void Increment() {
|
||||
int stride = *_size;
|
||||
|
@ -120,6 +120,10 @@ public:
|
||||
float const * v,
|
||||
int reflevel );
|
||||
|
||||
/// \brief Returns the maximum valence of a vertex allowed in the coarse
|
||||
/// mesh topology. Higher valences will generate incorrect limit tangents.
|
||||
int GetMaxValenceSupported();
|
||||
|
||||
private:
|
||||
|
||||
friend class FarVertexStencil;
|
||||
@ -1515,30 +1519,87 @@ template <class T> void
|
||||
FarStencilTablesFactory<T>::Patch::_GetTangentLimitStencils( HbrHalfedge<T> * e,
|
||||
float * uderiv,
|
||||
float * vderiv ) {
|
||||
static float creaseK[][12] = {
|
||||
{ .000000f, .000000f, .000000f, .000000f, .000000f, .000000f,
|
||||
.000000f, .000000f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ .000000f, .000000f, .000000f, .000000f, .000000f, .000000f,
|
||||
.000000f, .000000f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ 1.000000f, -.500000f, -.500000f, .000000f, .000000f, .000000f,
|
||||
.000000f, .000000f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ 1.000000f, .000000f, .000000f, -1.00000f, .000000f, .000000f,
|
||||
.000000f, .000000f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ 1.000000f, .500000f, .500000f, -1.00000f, -1.00000f, .000000f,
|
||||
.000000f, .000000f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ .707107f, .500000f, .500000f, -.500000f, -.707107f, -.500000f,
|
||||
.000000f, .000000f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ .743496f, .601501f, .601501f, -.371748f, -.601501f, -.601501f,
|
||||
-.371748f, .000000f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ .788675f, .683013f, .683013f, -.288675f, -.500000f, -.577350f,
|
||||
-.500000f, -.288675f, .000000f, .000000f, .000000f, .000000f },
|
||||
{ .835813f, .753042f, .753042f, -.231921f, -.417907f, -.521121f,
|
||||
-.521121f, -.417907f, -.231921f, .000000f, .000000f, .000000f },
|
||||
{ .882683f, .815493f, .815493f, -.191342f, -.353553f, -.461940f,
|
||||
-.500000f, -.461940f, -.353553f, -.191342f, .000000f, .000000f },
|
||||
{ .928486f, .872491f, .872491f, -.161230f, -.303013f, -.408248f,
|
||||
-.464243f, -.464243f, -.408248f, -.303013f, -.161230f, .000000f }
|
||||
};
|
||||
|
||||
// Boundary vertex tangent stencil table generated using the python script:
|
||||
// opensubdiv/tools/tangentStencils/tangentStencils.py
|
||||
|
||||
#define FAR_LIMITTANGENT_MAXVALENCE 20
|
||||
|
||||
static float creaseK[][40] =
|
||||
{ { -0.662085, -0.082761, 0.662085, -0.248282, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.165521, 0.165521, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.430450, 0.385279, -0.430450, -0.430450, 0.475622, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, -0.107613, -0.215225, -0.107613, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ -0.263966, -0.557805, 0.263966, 0.373304, 0.263966, -0.530084, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.065992, 0.159318, 0.159318, 0.065992, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.173071, 0.574415, -0.173071, -0.280034, -0.280034, -0.173071, 0.611831, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, -0.043268, -0.113276, -0.140017, -0.113276, -0.043268, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.110310, 0.858370, -0.110310, -0.191063, -0.220620, -0.191063, -0.110310, 0.266369, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, -0.027578, -0.075343, -0.102921, -0.102921, -0.075343, -0.027578, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.059499, -0.108652, -0.059499, -0.107213, -0.133693, -0.133693, -0.107213, -0.059499, 0.950367, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, -0.014875, -0.041678, -0.060226, -0.066846, -0.060226, -0.041678, -0.014875, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ -0.069034, -0.643889, 0.069034, 0.127558, 0.166663, 0.180394, 0.166663, 0.127558, 0.069034, -0.647432,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.017258, 0.049148, 0.073555, 0.086764, 0.086764, 0.073555, 0.049148, 0.017258, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.054360, 0.565883, -0.054360, -0.102164, -0.137645, -0.156524, -0.156524, -0.137645, -0.102164, -0.054360,
|
||||
0.731835, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, -0.013590, -0.039131, -0.059952, -0.073542, -0.078262, -0.073542, -0.059952, -0.039131, -0.013590,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ -0.044000, -0.755024, 0.044000, 0.083693, 0.115193, 0.135418, 0.142386, 0.135418, 0.115193, 0.083693,
|
||||
0.044000, -0.549465, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.011000, 0.031923, 0.049721, 0.062653, 0.069451, 0.069451, 0.062653, 0.049721, 0.031923,
|
||||
0.011000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.010145, -0.497027, -0.010145, -0.019467, -0.027213, -0.032754, -0.035642, -0.035642, -0.032754, -0.027213,
|
||||
-0.019467, -0.010145, 0.862545, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, -0.002536, -0.007403, -0.011670, -0.014992, -0.017099, -0.017821, -0.017099, -0.014992, -0.011670,
|
||||
-0.007403, -0.002536, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ -0.029547, -0.419056, 0.029547, 0.057081, 0.080725, 0.098867, 0.110272, 0.114162, 0.110272, 0.098867,
|
||||
0.080725, 0.057081, 0.029547, -0.852117, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.007387, 0.021657, 0.034451, 0.044898, 0.052285, 0.056109, 0.056109, 0.052285, 0.044898,
|
||||
0.034451, 0.021657, 0.007387, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.022520, 0.197157, -0.022520, -0.043731, -0.062400, -0.077443, -0.087986, -0.093415, -0.093415, -0.087986,
|
||||
-0.077443, -0.062400, -0.043731, -0.022520, 0.942807, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, -0.005630, -0.016563, -0.026533, -0.034961, -0.041357, -0.045350, -0.046707, -0.045350, -0.041357,
|
||||
-0.034961, -0.026533, -0.016563, -0.005630, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ -0.022403, -0.513093, 0.022403, 0.043683, 0.062773, 0.078714, 0.090709, 0.098155, 0.100680, 0.098155,
|
||||
0.090709, 0.078714, 0.062773, 0.043683, 0.022403, -0.804837, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.005601, 0.016522, 0.026614, 0.035372, 0.042356, 0.047216, 0.049709, 0.049709, 0.047216,
|
||||
0.042356, 0.035372, 0.026614, 0.016522, 0.005601, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ -0.019877, -0.743782, 0.019877, 0.038885, 0.056194, 0.071047, 0.082795, 0.090924, 0.095079, 0.095079,
|
||||
0.090924, 0.082795, 0.071047, 0.056194, 0.038885, 0.019877, -0.600744, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.004969, 0.014691, 0.023770, 0.031810, 0.038460, 0.043430, 0.046501, 0.047540, 0.046501,
|
||||
0.043430, 0.038460, 0.031810, 0.023770, 0.014691, 0.004969, 0.000000, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.015725, 0.289165, -0.015725, -0.030845, -0.044780, -0.056994, -0.067018, -0.074466, -0.079053, -0.080602,
|
||||
-0.079053, -0.074466, -0.067018, -0.056994, -0.044780, -0.030845, -0.015725, 0.922656, 0.000000, 0.000000,
|
||||
0.000000, -0.003931, -0.011642, -0.018906, -0.025444, -0.031003, -0.035371, -0.038380, -0.039914, -0.039914,
|
||||
-0.038380, -0.035371, -0.031003, -0.025444, -0.018906, -0.011642, -0.003931, 0.000000, 0.000000, 0.000000, },
|
||||
{ 0.015399, 0.556833, -0.015399, -0.030273, -0.044117, -0.056458, -0.066877, -0.075018, -0.080605, -0.083446,
|
||||
-0.083446, -0.080605, -0.075018, -0.066877, -0.056458, -0.044117, -0.030273, -0.015399, 0.784351, 0.000000,
|
||||
0.000000, -0.003850, -0.011418, -0.018598, -0.025144, -0.030834, -0.035474, -0.038906, -0.041013, -0.041723,
|
||||
-0.041013, -0.038906, -0.035474, -0.030834, -0.025144, -0.018598, -0.011418, -0.003850, 0.000000, 0.000000, },
|
||||
{ -0.006900, -0.951532, 0.006900, 0.013591, 0.019869, 0.025543, 0.030441, 0.034414, 0.037341, 0.039134,
|
||||
0.039737, 0.039134, 0.037341, 0.034414, 0.030441, 0.025543, 0.019869, 0.013591, 0.006900, 0.277130,
|
||||
0.000000, 0.001725, 0.005123, 0.008365, 0.011353, 0.013996, 0.016214, 0.017939, 0.019119, 0.019718,
|
||||
0.019718, 0.019119, 0.017939, 0.016214, 0.013996, 0.011353, 0.008365, 0.005123, 0.001725, 0.000000, },
|
||||
{ 0.010264, 0.154214, -0.010264, -0.020248, -0.029680, -0.038302, -0.045879, -0.052205, -0.057107, -0.060451,
|
||||
-0.062146, -0.062146, -0.060451, -0.057107, -0.052205, -0.045879, -0.038302, -0.029680, -0.020248, -0.010264,
|
||||
0.964364, -0.002566, -0.007628, -0.012482, -0.016995, -0.021045, -0.024521, -0.027328, -0.029389, -0.030649,
|
||||
-0.031073, -0.030649, -0.029389, -0.027328, -0.024521, -0.021045, -0.016995, -0.012482, -0.007628, -0.002566,
|
||||
},
|
||||
};
|
||||
|
||||
HbrVertex<T> * v = e->GetOrgVertex();
|
||||
|
||||
@ -1664,7 +1725,7 @@ FarStencilTablesFactory<T>::Patch::_GetTangentLimitStencils( HbrHalfedge<T> * e,
|
||||
|
||||
// creaseK table has 11 entries : max valence is 10
|
||||
// XXXX error should be reported
|
||||
if (n >= 11) {
|
||||
if (n >= FAR_LIMITTANGENT_MAXVALENCE) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1711,6 +1772,12 @@ FarStencilTablesFactory<T>::Patch::_GetTangentLimitStencils( HbrHalfedge<T> * e,
|
||||
_ScaleTangentStencil(e->GetFace(), GetStencilSize(), uderiv, vderiv);
|
||||
}
|
||||
|
||||
template <class T> int
|
||||
FarStencilTablesFactory<T>::GetMaxValenceSupported() {
|
||||
return FAR_LIMITTANGENT_MAXVALENCE;
|
||||
}
|
||||
|
||||
|
||||
} // end namespace OPENSUBDIV_VERSION
|
||||
using namespace OPENSUBDIV_VERSION;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user