From b09f395cd27346c67f8f9c9c212ab41ac67ee2f4 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sun, 20 Nov 2016 23:39:22 +0100 Subject: [PATCH] Optimized GTX_matrix_interpolation axisAngle function --- glm/gtx/color_space.inl | 4 ++-- glm/gtx/matrix_interpolation.inl | 14 +++++++------- readme.md | 6 ++++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/glm/gtx/color_space.inl b/glm/gtx/color_space.inl index 43f66415..11e0ac83 100644 --- a/glm/gtx/color_space.inl +++ b/glm/gtx/color_space.inl @@ -14,8 +14,8 @@ namespace glm rgbColor = tvec3(hsv.z); else { - T sector = floor(hsv.x / T(60)); - T frac = (hsv.x / T(60)) - sector; + T sector = floor(hsv.x * (T(1) / T(60))); + T frac = (hsv.x * (T(1) / T(60))) - sector; // factorial part of h T o = hsv.z * (T(1) - hsv.y); T p = hsv.z * (T(1) - hsv.y * frac); diff --git a/glm/gtx/matrix_interpolation.inl b/glm/gtx/matrix_interpolation.inl index 8645f967..12c1a5b5 100644 --- a/glm/gtx/matrix_interpolation.inl +++ b/glm/gtx/matrix_interpolation.inl @@ -25,12 +25,12 @@ namespace glm return; } angle = static_cast(3.1415926535897932384626433832795); - T xx = (mat[0][0] + (T)1.0) / (T)2.0; - T yy = (mat[1][1] + (T)1.0) / (T)2.0; - T zz = (mat[2][2] + (T)1.0) / (T)2.0; - T xy = (mat[1][0] + mat[0][1]) / (T)4.0; - T xz = (mat[2][0] + mat[0][2]) / (T)4.0; - T yz = (mat[2][1] + mat[1][2]) / (T)4.0; + T xx = (mat[0][0] + (T)1.0) * (T)0.5; + T yy = (mat[1][1] + (T)1.0) * (T)0.5; + T zz = (mat[2][2] + (T)1.0) * (T)0.5; + T xy = (mat[1][0] + mat[0][1]) * (T)0.25; + T xz = (mat[2][0] + mat[0][2]) * (T)0.25; + T yz = (mat[2][1] + mat[1][2]) * (T)0.25; if((xx > yy) && (xx > zz)) { if (xx < epsilon) { @@ -72,7 +72,7 @@ namespace glm T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1])); if (glm::abs(s) < T(0.001)) s = (T)1.0; - angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) / (T)2.0); + angle = acos((mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) * (T)0.5); axis.x = (mat[1][2] - mat[2][1]) / s; axis.y = (mat[2][0] - mat[0][2]) / s; axis.z = (mat[0][1] - mat[1][0]) / s; diff --git a/readme.md b/readme.md index 6c4a47e4..a177f01b 100644 --- a/readme.md +++ b/readme.md @@ -60,10 +60,12 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate) - Added [GLM_ENABLE_EXPERIMENTAL](manual.md#section7_4) to enable experimental features. #### Improvements: -- Added lowp variant of GTC_colorspace convertLinearToSRGB #419 +- Added lowp variant of GTC_color_space convertLinearToSRGB #419 - Replaced the manual by a markdown version #458 - Optimized GTC_packing implementation -- Optimized noise functions +- Optimized GTC_noise functions +- Optimized GTC_color_space HSV to RGB conversions +- Optimized GTX_matrix_interpolation axisAngle function - Added FAQ 12: Windows headers cause build errors... #557 #### Fixes: