Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divide glm::vec3 by its own member #116

Closed
koonschi opened this issue Sep 17, 2013 · 4 comments
Closed

Divide glm::vec3 by its own member #116

koonschi opened this issue Sep 17, 2013 · 4 comments
Assignees
Labels
Milestone

Comments

@koonschi
Copy link

Hello,
I have come across a strange issue. If you type

glm::vec3 v(1, 2, 3);
v /= v.y;

then v will hold
x = 0.5, y = 1, z = 3

instead of the expected

x = 0.5, y = 1, z = 1.5

This issue is present with all glm::vec types.

Edit: I was just investigating it more, it seems to be the case with all arithmetic operators.

@ghost ghost assigned Groovounet Sep 17, 2013
@Groovounet
Copy link
Member

Hi,

I managed to reproduce this bug on Visual C++ 2013 with GLM 0.9.5 branch... The most strange bug I have ever experienced. Oo

The code executed is:
template <typename T, precision P>
template
GLM_FUNC_QUALIFIER tvec3<T, P> & tvec3<T, P>::operator/=
(
U const & s
)
{
this->x /= static_cast(s);
this->y /= static_cast(s);
this->z /= static_cast(s);
return *this;
}

x and y are modified... z isn't. Oo

What version of GLM and what compiler are you using?

Thanks,
Christophe

@Groovounet
Copy link
Member

So the problem is that the divisor is passed by const reference...

@koonschi
Copy link
Author

It looks like it. I was using version 0.9.4.5 with gcc on linux. I had the problem with mingw on windows, too.
I was assuming that it might be due to that pass by reference ...

@Groovounet
Copy link
Member

This bug has been fixed in GLM 0.9.4 and GLM 0.9.5 branch.

Thanks for contributing,
Christophe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants