From b80a6bb251ac479337e110dc6308b52f655d322d Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 28 Apr 2011 11:17:42 +0100 Subject: [PATCH] Fixed build errors --- glm/gtx/noise.inl | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/glm/gtx/noise.inl b/glm/gtx/noise.inl index 92e7d83d..cc61e9e4 100644 --- a/glm/gtx/noise.inl +++ b/glm/gtx/noise.inl @@ -17,18 +17,46 @@ namespace glm { + template + GLM_FUNC_QUALIFIER T permute(T const & x) + { + return mod(((x * T(34)) + T(1)) * x, T(289)); + } + template class vecType> GLM_FUNC_QUALIFIER vecType permute(vecType const & x) { return mod(((x * T(34)) + T(1)) * x, T(289)); } + template + GLM_FUNC_QUALIFIER T taylorInvSqrt(T const & r) + { + return T(1.79284291400159) - T(0.85373472095314) * r; + } + template class vecType> GLM_FUNC_QUALIFIER vecType taylorInvSqrt(vecType const & r) { return T(1.79284291400159) - T(0.85373472095314) * r; } + template class vecType> + GLM_FUNC_QUALIFIER vecType fade(vecType const & t) + { + return t * t * t * (t * (t * T(6) - T(15)) + T(10)); + } + + template + GLM_FUNC_QUALIFIER detail::tvec4 grad4(T const & j, detail::tvec4 const & ip) + { + detail::tvec3 pXYZ = floor(fract(detail::tvec3(j) * detail::tvec3(ip)) * T(7)) * ip[2] - T(1); + T pW = T(1.5) - dot(abs(pXYZ), detail::tvec3(1)); + detail::tvec4 s = detail::tvec4(lessThan(detail::tvec4(pXYZ, pW), detail::tvec4(0.0))); + pXYZ = pXYZ + (detail::tvec3(s) * T(2) - T(1)) * s.w; + return detail::tvec4(pXYZ, pW); + } + namespace gtx{ namespace noise { @@ -627,8 +655,8 @@ namespace noise detail::tvec4 x_ = floor(j * ns.z); detail::tvec4 y_ = floor(j - T(7) * x_); // mod(j,N) - detail::tvec4 x = x_ * ns.x + ns; - detail::tvec4 y = y_ * ns.x + ns; + detail::tvec4 x = x_ * ns.x + ns.y; + detail::tvec4 y = y_ * ns.x + ns.y; detail::tvec4 h = T(1) - abs(x) - abs(y); detail::tvec4 b0 = detail::tvec4(x.x, x.y, y.x, y.y); @@ -683,7 +711,7 @@ namespace noise -0.447213595499958); // -1 + 4 * G4 // (sqrt(5) - 1)/4 = F4, used once below - T const F4(0.309016994374947451); + T const F4 = T(0.309016994374947451); // First corner detail::tvec4 i = floor(v + dot(v, vec4(F4))); @@ -702,10 +730,10 @@ namespace noise // i0.y += dot(isYZ.xy, vec2(1.0)); i0.y += isYZ.x + isYZ.y; //i0.zw += 1.0 - detail::tvec2(isYZ.x, isYZ.y); - i0.z += 1.0 - detail::tvec2(isYZ.x, isYZ.y); - i0.w += 1.0 - detail::tvec2(isYZ.x, isYZ.y); + i0.z += T(1) - isYZ.x; + i0.w += T(1) - isYZ.y; i0.z += isYZ.z; - i0.w += 1.0 - isYZ.z; + i0.w += T(1) - isYZ.z; // i0 now contains the unique values 0,1,2,3 in each channel detail::tvec4 i3 = clamp(i0, 0.0, 1.0);