Implicit cast ?

   12556   3   2
User Avatar
Member
767 posts
Joined: April 2014
Offline
I don't understand this one common error in VEX; Implicit cast from vector to float. By default attributes are floats, if I cast an attribute as a vector, why do I get this error ?
【T】【C】【S】
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
Hi
If you cast a vector to a float in VEX, Houdini will use the first value of the vector and set the float to that:
v@myvec = {1,0,0};
f@myfloat = @myvec;
// myfloat will be set to 1

v@myvec = {0,1,0};
f@myfloat = @myvec;
// myfloat will be set to 0
It only issues a warning, so you can basically ignore this. But if you want to get rid of this warning you should tell VEX what value from the vector you want to use like this:
f@myfloat = @myvec[0];
// myfloat will be set to the first value of the vector myvec

Cheers
Bonsak
Edited by bonsak - July 10, 2016 18:23:52
http://www.racecar.no [www.racecar.no]
User Avatar
Member
767 posts
Joined: April 2014
Offline
Ohh, and to think I was thinking before posting; maybe I tell the attribute that I want to use the first item in the vector array

Big thank you
【T】【C】【S】
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
http://www.racecar.no [www.racecar.no]
  • Quick Links