8000 Fix inverted shear matrix multiple #1140 by christophe-lunarg · Pull Request #1182 · g-truc/glm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix inverted shear matrix multiple #1140 #1182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions glm/ext/matrix_transform.inl
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ namespace glm
);

mat<4, 4, T, Q> Result;
Result[0] = Shear[0] * m[0][0] + Shear[1] * m[0][1] + Shear[2] * m[0][2] + Shear[3] * m[0][3];
Result[1] = Shear[0] * m[1][0] + Shear[1] * m[1][1] + Shear[2] * m[1][2] + Shear[3] * m[1][3];
Result[2] = Shear[0] * m[2][0] + Shear[1] * m[2][1] + Shear[2] * m[2][2] + Shear[3] * m[2][3];
Result[3] = Shear[0] * m[3][0] + Shear[1] * m[3][1] + Shear[2] * m[3][2] + Shear[3] * m[3][3];
Result[0] = m[0] * Shear[0][0] + m[1] * Shear[0][1] + m[2] * Shear[0][2] + m[3] * Shear[0][3];
Result[1] = m[0] * Shear[1][0] + m[1] * Shear[1][1] + m[2] * Shear[1][2] + m[3] * Shear[1][3];
Result[2] = m[0] * Shear[2][0] + m[1] * Shear[2][1] + m[2] * Shear[2][2] + m[3] * Shear[2][3];
Result[3] = m[0] * Shear[3][0] + m[1] * Shear[3][1] + m[2] * Shear[3][2] + m[3] * Shear[3][3];
return Result;
}

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ target_link_libraries(main PRIVATE glm::glm)
#### Fixes:
- Fixed C++ language auto detection build, disable C++98 warnings with Clang #1235, #1231
- Fixed `GTX_color_space` missing <glm/ext/scalar_constants.hpp> include #1233 #1238
- Fixed `EXT_matrix_transform` `shear` implementation #1140 #1182

### [GLM 1.0.0](https://github.com/g-truc/glm/releases/tag/1.0.0) - 2024-01-24
#### Features:
Expand Down
41 changes: 25 additions & 16 deletions test/core/core_func_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,14 @@ static int test_shearing()
glm::vec4(1, 1, 1, 0),
glm::vec4(1, 1, 0, 1));
glm::mat4x4 const B4x4 = glm::shear(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const C4x4 = glm::shear_slow(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const expected(
glm::vec4(0, 0, 1, 1),
glm::vec4(2, 1, 1, 0),
glm::vec4(3, 1, 1, 0),
glm::vec4(3, 1, 0, 1));
glm::vec4(0, 1, 3, 2),
glm::vec4(1, 1, 1, 0),
glm::vec4(1, 1, 0, 1));
Error += all(equal(B4x4, expected, epsilon<float>())) ? 0 : 1;
Error += all(equal(C4x4, expected, epsilon<float>())) ? 0 : 1;
}

{
Expand All @@ -299,12 +301,14 @@ static int test_shearing()
glm::vec4(1, 1, 1, 0),
glm::vec4(1, 0, 0, 0));
glm::mat4x4 const B4x4 = glm::shear(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const C4x4 = glm::shear_slow(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const expected(
glm::vec4(0, 1, 1, 0),
glm::vec4(1, 2, 1, 0),
glm::vec4(2, 2, 2, 0),
glm::vec4(1, 0, 1, 0));
glm::vec4(1, 1, 2, 0),
glm::vec4(0, 1, 2, 0),
glm::vec4(1, 2, 2, 0),
glm::vec4(1, 0, 0, 0));
Error += all(equal(B4x4, expected, epsilon<float>())) ? 0 : 1;
Error += all(equal(C4x4, expected, epsilon<float>())) ? 0 : 1;
}

{
Expand All @@ -314,12 +318,14 @@ static int test_shearing()
glm::vec2 const l_z(4, 5);
glm::mat4x4 const A4x4(1);
glm::mat4x4 const B4x4 = glm::shear(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const C4x4 = glm::shear_slow(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const expected(
glm::vec4(1, 3, 4, 0),
glm::vec4(1, 1, 5, 0),
glm::vec4(2, 1, 1, 0),
glm::vec4(-9, -8, -9, 1));
Error += all(equal(B4x4, expected, epsilon<float>())) ? 0 : 1;
Error += all(equal(C4x4, expected, epsilon<float>())) ? 0 : 1;
}

{
Expand All @@ -333,12 +339,14 @@ static int test_shearing()
glm::vec4(4, -8, 0, 0),
glm::vec4(7, 1, -2, 0));
glm::mat4x4 const B4x4 = glm::shear(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const C4x4 = glm::shear_slow(A4x4, center, l_x, l_y, l_z);
glm::mat4x4 const expected(
glm::vec4(1, -6, -1, 0),
glm::vec4(7, 12, 23, 0),
glm::vec4(-4, 4, -24, 0),
glm::vec4(4, 20, 31, 0));
glm::vec4(22, -24, 4, 0),
glm::vec4(20, -36, 2, 0),
glm::vec4(1, -2, 3, 0),
glm::vec4(-26, 39, -19, 0));
Error += all(equal(B4x4, expected, epsilon<float>())) ? 0 : 1;
Error += all(equal(C4x4, expected, epsilon<float>())) ? 0 : 1;
}

return Error;
Expand Down Expand Up @@ -392,19 +400,20 @@ static int test_inverse_perf(std::size_t Count, std::size_t Instance, char const
int main()
{
int Error = 0;

Error += test_matrixCompMult();
Error += test_outerProduct();
Error += test_transpose();
Error += test_determinant();
Error += test_inverse();
Error += test_inverse_simd();
Error += test_shearing();
Error += test_inverse_simd();
Error += test_shearing();

# ifdef NDEBUG
#ifdef NDEBUG
std::size_t const Samples = 1000;
# else
#else
std::size_t const Samples = 1;
# endif//NDEBUG
#endif//NDEBUG

for(std::size_t i = 0; i < 1; ++i)
{
Expand Down
0