Page 1 of 1

Vector3 weird assignment..

Posted: Mon May 09, 2011 1:19 pm
by syedhs
Someone should fix this:-

Code: Select all

Vector3 test;
test = true;
It compiles in Visual 2005 without even a warning..

Re: Vector3 weird assignment..

Posted: Fri May 13, 2011 12:32 pm
by so0os
that's explicit consturctors.

it goes like this

Code: Select all

Vector3 << float << int << bool

Re: Vector3 weird assignment..

Posted: Fri May 13, 2011 7:45 pm
by syedhs
Yeah but that can potentially introduce tricky bug to one's app - mine is one of them :mrgreen: For an example:-

Code: Select all

bool mHasPosition;
Vector3 mPosition;
...
mPosition = true; // it should be mHasPosition = true;
And btw, what is the use of statement Vector3 v = 1? It was probably done to ease some assignments, but I think it doesn't look right.

Re: Vector3 weird assignment..

Posted: Fri May 13, 2011 10:07 pm
by so0os
I guess you're right, there's no need for explicit constructor from a single float. Probably no one uses it anyways.

Re: Vector3 weird assignment..

Posted: Fri May 13, 2011 10:28 pm
by Klaim

Code: Select all

inline explicit Vector3( const Real scaler )
inline Vector3& operator = ( const Real fScaler )
So the idea is to provide a way to build a scaling vector in one line, i guess. Is it widely used in the Ogre code?


Anyway, the operator= version is dangerous, while the constructor seems useful. Only the operator should be removed?