magneto Posted June 1, 2012 Share Posted June 1, 2012 I have a few parameters in one of my VOPs, and I want to combine their tokens like this: $parameter1 + $parameter2 + $parameter3 where it could be: Deform + Surface + Fast = DeformSurfaceFast I know I can do this with a single parameter where I can call it as a function, but I am wondering if it's possible to do with multiple parameters to form a function name that exists? Thanks Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted June 1, 2012 Share Posted June 1, 2012 (edited) So basically you want to change concatenated tokens into function name just like you can in C# with reflection and dynamic method invocation ? In that case, you can't. You still seems to think about VEX like if it was dynamic language. It's not. Stick with thinking about everything in it in like if it was "0-1". For dynamic things you have Python. If you need more than python can give you, you can use inlineCPP in it. If it's still not what you are looking for, you got HDK. End of story. Edited June 2, 2012 by mantragora 1 Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted June 1, 2012 Share Posted June 1, 2012 (edited) Anyway, if you are looking for simple concatination - not dynamic method invocation , for example - your menus returns strings as tokens, you can just concatinate them like any string with string text = $menu1 + $menu2 + $menu3; This will give you "DeformSurfaceFast" and then you can compare this string with if{}else{}whatever{} to call your function based on this. Edited June 2, 2012 by mantragora 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted June 1, 2012 Author Share Posted June 1, 2012 Yes that's what I wanted. I thought it might allow that because just using the variable name actually allows you to call a function using its string token. So thought perhaps it would also allow combining them. Otherwise, I will have to code a large if else statements and call a different function based on the menu choices. Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted June 1, 2012 Share Posted June 1, 2012 Dynamic method invocation is slow. VEX is made to be fast. It was thought as a shading language. You don't have dynamic calls in any other shading languages too. They must throw data from one end to other as fast as they can. All this sugar code is nice, but it is always slow. 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted June 1, 2012 Author Share Posted June 1, 2012 (edited) I also wonder if having if statements before the function call would be slow for VEX? I don't mean inside the function itself but before it's decided which function to call. Say you have 2 parameters, each have 3 options, so have 9 functions. If inside the VOP you have: if ($option1 == 0 && $option2 == 0) function00(); ... if ($option1 == 2 && $option2 == 2) function22(); I wonder if this code is called for each point or only once? I assume only once because options don't change for each iteration. But actual if statements inside VEX is something I avoid. Edited June 1, 2012 by magneto Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted June 1, 2012 Share Posted June 1, 2012 (edited) As long as you don't force for each point yourself, it will call it once for all points. That's what SIMD is for. Edited June 2, 2012 by mantragora 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted June 1, 2012 Author Share Posted June 1, 2012 Great then, no I don't loop each point manually. Quote Link to comment Share on other sites More sharing options...
anim Posted July 9, 2012 Share Posted July 9, 2012 as far as I know functions (as well as all code in VEX) are run once per each point, not once per all points in VEX (SIMD) they can run parallel, but still per each point, therefore you can have different result for each point I never had performance problems with if statements within VEX, on the other hand they can speed up a lot, because it can decide for each point what to compute and what not, so I would not fear to use them 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.