hoknamahn Posted January 24, 2007 Share Posted January 24, 2007 I wonder what the difference between the "old" C style and "new" C++ style of type casting? I've tried to do vector var = (vector)pcfilter... and vcc said that it can't determine which version to use. If I change the code to vector var = vector(pcfilter...)... all is okay. So there is the difference... Quote Link to comment Share on other sites More sharing options...
crunch Posted January 24, 2007 Share Posted January 24, 2007 I wonder what the difference between the "old" C style and "new" C++ style of type casting?... Unlike C++ (but like RenderMan SL), VEX uses the return type as part of the signature. This can create unresolvable type problems Cf = random(noise(P)); This code should generate a warning from vcc since it's impossible to figure out whether the noise() function should return a float, vector or vector4. The C++ style of casting is used to specify the return type explicitly. Cf = random( vector(noise(P)) ); The C style of casting is implemented as a type conversion operation. If you inspect the VEX assembler of the two types of Cf = random( (vector) noise(P)); You'll still get the warning, and you should see that the noise() function generates a floating point value which is then converted to a vector. This is very different than the noise() function generating a vector result by itself. However, since the C++ type-casting style is used for explicit return code specification, it can't really be used for casting one type to another. You have to use the C style. int ival = (int)(s*4.0); A very subtle difference, but a potentially important one. Quote Link to comment Share on other sites More sharing options...
hoknamahn Posted January 24, 2007 Author Share Posted January 24, 2007 Arhhhh... now I see! Thanks crunch Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.