检查是否设置了glm::vec3
Check if glm::vec3 has be set
如果我将一个值声明为 glm::vec3 myVector;
,我是否可以检查
通过
安全地 它是空的
if (!myVector) {
setVector(myVector);
}
或者有没有办法将 glm::vec3
值设置为 null 而不必将每个单独的值都设置为 null
当您将向量声明为
glm::vec3 myVector;
它没有被初始化,你需要声明为:
glm::vec3 myVector(0.0);
正确初始化为 0。
顺便说一句:
if (!myVector) { //It is always false, because, it is a reference to a local variable, not a pointer.
If there is a single scalar parameter to a vector constructor, it is
used to initialize all components of the constructed vector to that
scalar’s value.
如果我将一个值声明为 glm::vec3 myVector;
,我是否可以检查
通过
if (!myVector) {
setVector(myVector);
}
或者有没有办法将 glm::vec3
值设置为 null 而不必将每个单独的值都设置为 null
当您将向量声明为
glm::vec3 myVector;
它没有被初始化,你需要声明为:
glm::vec3 myVector(0.0);
正确初始化为 0。
顺便说一句:
if (!myVector) { //It is always false, because, it is a reference to a local variable, not a pointer.
If there is a single scalar parameter to a vector constructor, it is used to initialize all components of the constructed vector to that scalar’s value.