Merge pull request #537 from barfowl/bilinear_derivs

Added missing scaling to derivatives of Bilinear patches
This commit is contained in:
Takahito Tejima 2015-05-27 17:12:50 -07:00
commit 2e788a5250

View File

@ -165,30 +165,32 @@ inline void Spline<BASIS_BOX_SPLINE>::GetWeights(
template <> template <>
inline void Spline<BASIS_BILINEAR>::GetPatchWeights(PatchParam::BitField bits, inline void Spline<BASIS_BILINEAR>::GetPatchWeights(PatchParam::BitField bits,
float s, float t, float point[4], float deriv1[4], float deriv2[4]) { float s, float t, float point[4], float derivS[4], float derivT[4]) {
bits.Normalize(s,t); bits.Normalize(s,t);
float os = 1.0f - s, float sC = 1.0f - s,
ot = 1.0f - t; tC = 1.0f - t;
if (point) { if (point) {
point[0] = os*ot; point[0] = sC * tC;
point[1] = s*ot; point[1] = s * tC;
point[2] = s * t; point[2] = s * t;
point[3] = os*t; point[3] = sC * t;
} }
if (deriv1 and deriv2) { if (derivS and derivT) {
deriv1[0] = t-1.0f; float dScale = (float)(1 << bits.GetDepth());
deriv1[1] = ot;
deriv1[2] = t;
deriv1[3] = -t;
deriv2[0] = s-1.0f; derivS[0] = -tC * dScale;
deriv2[1] = -s; derivS[1] = tC * dScale;
deriv2[2] = s; derivS[2] = t * dScale;
deriv2[3] = os; derivS[3] = -t * dScale;
derivT[0] = -sC * dScale;
derivT[1] = -s * dScale;
derivT[2] = s * dScale;
derivT[3] = sC * dScale;
} }
} }