forked from icaven/glm
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added mix implementation for matrices in EXT_matrix_common #842
- Loading branch information
1 parent
96e7eb5
commit 6492c85
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/// @ref ext_matrix_common | ||
/// @file glm/ext/matrix_common.hpp | ||
/// | ||
/// @defgroup ext_matrix_common GLM_EXT_matrix_common | ||
/// @ingroup ext | ||
/// | ||
/// Defines functions for common matrix operations. | ||
/// | ||
/// Include <glm/ext/matrix_common.hpp> to use the features of this extension. | ||
/// | ||
/// @see ext_matrix_common | ||
|
||
#pragma once | ||
|
||
#include "../detail/qualifier.hpp" | ||
#include "../detail/_fixes.hpp" | ||
|
||
#if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) | ||
# pragma message("GLM: GLM_EXT_matrix_transform extension included") | ||
#endif | ||
|
||
namespace glm | ||
{ | ||
/// @addtogroup ext_matrix_common | ||
/// @{ | ||
|
||
template<length_t C, length_t R, typename T, typename U, qualifier Q> | ||
GLM_FUNC_DECL mat<C, R, T, Q> mix(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, mat<C, R, U, Q> const& a); | ||
|
||
template<length_t C, length_t R, typename T, typename U, qualifier Q> | ||
GLM_FUNC_DECL mat<C, R, T, Q> mix(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, U a); | ||
|
||
/// @} | ||
}//namespace glm | ||
|
||
#include "matrix_common.inl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "../matrix.hpp" | ||
|
||
namespace glm | ||
{ | ||
template<length_t C, length_t R, typename T, typename U, qualifier Q> | ||
GLM_FUNC_QUALIFIER mat<C, R, T, Q> mix(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, U a) | ||
{ | ||
return mat<C, R, U, Q>(x) * (static_cast<U>(1) - a) + mat<C, R, U, Q>(y) * a; | ||
} | ||
|
||
template<length_t C, length_t R, typename T, typename U, qualifier Q> | ||
GLM_FUNC_QUALIFIER mat<C, R, T, Q> mix(mat<C, R, T, Q> const& x, mat<C, R, T, Q> const& y, mat<C, R, U, Q> const& a) | ||
{ | ||
return matrixCompMult(mat<C, R, U, Q>(x), static_cast<U>(1) - a) + matrixCompMult(mat<C, R, U, Q>(y), a); | ||
} | ||
}//namespace glm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include <glm/ext/matrix_common.hpp> | ||
#include <glm/ext/matrix_double4x4.hpp> | ||
#include <glm/ext/matrix_float4x4.hpp> | ||
#include <glm/ext/matrix_relational.hpp> | ||
#include <glm/ext/vector_bool4.hpp> | ||
|
||
static int test_mix() | ||
{ | ||
int Error = 0; | ||
|
||
{ | ||
glm::mat4 A(2); | ||
glm::mat4 B(4); | ||
glm::mat4 C = glm::mix(A, B, 0.5f); | ||
glm::bvec4 const D = glm::equal(C, glm::mat4(3), 1); | ||
Error += glm::all(D) ? 0 : 1; | ||
} | ||
|
||
{ | ||
glm::mat4 A(2); | ||
glm::mat4 B(4); | ||
glm::mat4 C = glm::mix(A, B, 0.5); | ||
glm::bvec4 const D = glm::equal(C, glm::mat4(3), 1); | ||
Error += glm::all(D) ? 0 : 1; | ||
} | ||
|
||
{ | ||
glm::dmat4 A(2); | ||
glm::dmat4 B(4); | ||
glm::dmat4 C = glm::mix(A, B, 0.5); | ||
glm::bvec4 const D = glm::equal(C, glm::dmat4(3), 1); | ||
Error += glm::all(D) ? 0 : 1; | ||
} | ||
|
||
{ | ||
glm::dmat4 A(2); | ||
glm::dmat4 B(4); | ||
glm::dmat4 C = glm::mix(A, B, 0.5f); | ||
glm::bvec4 const D = glm::equal(C, glm::dmat4(3), 1); | ||
Error += glm::all(D) ? 0 : 1; | ||
} | ||
|
||
return Error; | ||
} | ||
|
||
int main() | ||
{ | ||
int Error = 0; | ||
|
||
Error += test_mix(); | ||
|
||
return Error; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters