mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 12:31:51 +00:00
add transform vectors/matrices nan/inf check
This commit is contained in:
parent
35498e1c0f
commit
f1d85000e4
3 changed files with 54 additions and 0 deletions
|
|
@ -162,4 +162,19 @@ namespace util {
|
|||
|
||||
return a + glm::ivec3(glm::round(glm::vec3(vec) * t));
|
||||
}
|
||||
|
||||
template <int n, typename T = float>
|
||||
bool is_nan_or_inf(const glm::vec<n, T>& vector) {
|
||||
return glm::any(glm::isnan(vector)) || glm::any(glm::isinf(vector));
|
||||
}
|
||||
|
||||
template <int n, typename T = float>
|
||||
bool is_nan_or_inf(const glm::mat<n, n, T>& matrix) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (is_nan_or_inf(matrix[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue