defining custom vex functions - unexpected identifiers

   5483   4   2
User Avatar
Member
41 posts
Joined: 1月 2007
Offline
Hey all -

I'm trying to get out of crazy, incomprehensible VOPsop if-then blocks, and get to writing some actual VEX code. I've been working with the new pointWrangler, and am making good progress.

However, I'm trying to define a function and I'm getting errors. I've followed the instructions in the VEX manual, and this is my function:

void populatePoints(float i) {
//null null null
}

However, I get the error:

Syntax error, unexpected identifier, expecting ‘(’

Hopefully this is an easy mistake. Thanks!
User Avatar
Member
4536 posts
Joined: 2月 2012
Offline
Unfortunately you can not define functions inside the Snippet VOP/SOP and even inside the Inline VOP.

You will have to create a new VEX Builder Type. Or you can use a separate file to define your functions and include them. You can also use the #define directive to define simple functions like this:

#define noise0(PP) (2.0*noise(PP)-1.0)


I have been asking for this feature for a long time, and without it, these operators are greatly limited in what you can do with them.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
41 posts
Joined: 1月 2007
Offline
Interesting! Definitely feels lacking without them. That define directive should work for this instance, but if I had a more complicated function I wanted to define in a separate file, how would I link to it in the wrangler?
User Avatar
Member
4536 posts
Joined: 2月 2012
Offline
You can't do it using the Wrangle SOPs as the parameter is not promoted. But if you use a Snippet VOP, then there is a parameter that allows you to include files.

The problem with using extra files on disk is portability though. You can save the file inside Extra Files of a digital asset, but you still can't include this file as you should because this functionality is currently broken (Bug ID #54180).

So this forces people to create new operators to run relatively complex VEX code to solve specific problems that doesn't make sense to have as separate operators.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
41 posts
Joined: 1月 2007
Offline
Ugh! Well, that's a bit disappointing. But I definitely get what's going on now, and am glad that it wasn't something more stupid.

Thanks!!
  • Quick Links