mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +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
|
|
@ -1,6 +1,7 @@
|
|||
#include "Transform.hpp"
|
||||
|
||||
#include "data/dv_util.hpp"
|
||||
#include "maths/util.hpp"
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
|
|
@ -31,3 +32,28 @@ void Transform::deserialize(const dv::value& root) {
|
|||
dv::get_vec(root, "size", size);
|
||||
dv::get_mat(root, "rot", rot);
|
||||
}
|
||||
|
||||
bool Transform::checkValue(const glm::vec3& vector) {
|
||||
if (util::is_nan_or_inf(vector)) {
|
||||
#ifndef NDEBUG
|
||||
throw std::invalid_argument(
|
||||
"invalid vector: " + std::to_string(vector.x) + ", " +
|
||||
std::to_string(vector.y) + ", " + std::to_string(vector.z)
|
||||
);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Transform::checkValue(const glm::mat3& matrix) {
|
||||
if (util::is_nan_or_inf(matrix)) {
|
||||
#ifndef NDEBUG
|
||||
throw std::invalid_argument("invalid matrix (contains nan or inf)");
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue