Vector3 weird assignment..

Minor issues with the Ogre API that can be trivial to fix
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Vector3 weird assignment..

Post by syedhs »

Someone should fix this:-

Code: Select all

Vector3 test;
test = true;
It compiles in Visual 2005 without even a warning..
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
so0os
Bugbear
Posts: 833
Joined: Thu Apr 15, 2010 7:42 am
Location: Poznan, Poland
x 33

Re: Vector3 weird assignment..

Post by so0os »

that's explicit consturctors.

it goes like this

Code: Select all

Vector3 << float << int << bool
Sos Sosowski :)
http://www.sos.gd
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Vector3 weird assignment..

Post 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.
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me
User avatar
so0os
Bugbear
Posts: 833
Joined: Thu Apr 15, 2010 7:42 am
Location: Poznan, Poland
x 33

Re: Vector3 weird assignment..

Post by so0os »

I guess you're right, there's no need for explicit constructor from a single float. Probably no one uses it anyways.
Sos Sosowski :)
http://www.sos.gd
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56

Re: Vector3 weird assignment..

Post 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?