Octo
Octo

Reputation: 563

How to use glm::isnan()

I can't get glm::isnan() to compile in my Visual C++ project.

#include <glm/glm.hpp>

glm::vec3 my_vector = ... ;

bool b = glm::isnan(my_vector);

The last line causes the following compilation error:

error C2440: 'initializing' : cannot convert from 'glm::detail::tvec3' to 'bool'

According to documentation it returs true or false.

Upvotes: 1

Views: 2061

Answers (1)

Joakim Thor&#233;n
Joakim Thor&#233;n

Reputation: 1281

The GLM 0.9.9 documentation for glm::isnan can be found at https://glm.g-truc.net/0.9.9/api/a00662.html. It says that the return type is vec<L, bool, Q>, so you can use glm::all like so:

bool b = glm::all(glm::isnan(my_vector));

to check if all components of my_vector are NaN.

Upvotes: 2

Related Questions