AntoineSfx Posted January 26, 2018 Share Posted January 26, 2018 How do you define a VEX function in a pointwrangle node ? Using this: int[] myfunc( int input, int ptnum) { int result[]; return result; } Houdini complains about a syntax error at myfunc. What is the correct syntax, and where is it documented ? Quote Link to comment Share on other sites More sharing options...
fencer Posted January 26, 2018 Share Posted January 26, 2018 myfunc(int input; int ptnum) Quote Link to comment Share on other sites More sharing options...
coltonmil Posted January 26, 2018 Share Posted January 26, 2018 Hey Antoine, Reference for VEX in general and the syntax for defining functions can be found here: http://www.sidefx.com/docs/houdini/vex/lang Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted January 26, 2018 Author Share Posted January 26, 2018 So this was an error (; instead of ,) but I still can't get this to compile, because of the array type as return type: int [] myfunc(int input; int ptnum) { int result[]; return result; } Quote Link to comment Share on other sites More sharing options...
fencer Posted January 26, 2018 Share Posted January 26, 2018 13 minutes ago, AntoineSfx said: So this was an error (; instead of ,) but I still can't get this to compile, because of the array type as return type: int [] myfunc(int input; int ptnum) { int result[]; return result; } not sure that vex allows return array Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted January 26, 2018 Author Share Posted January 26, 2018 37 minutes ago, fencer said: not sure that vex allows return array actually .. a lot a functions do that. I need a more powerful version of neighbours, hence the question in the first place. Quote Link to comment Share on other sites More sharing options...
Sepu Posted January 27, 2018 Share Posted January 27, 2018 If you are looking for something faster you might want to look at http://www.sidefx.com/docs/houdini/vex/functions/pgfind.html or pcfind Quote Link to comment Share on other sites More sharing options...
julian johnson Posted January 27, 2018 Share Posted January 27, 2018 function int[] test() { int result[] = {1,2,3}; return result; }; i[]@test = test(); I get syntax errors using the 'normal' array syntax in the documentation i.e. a simple int[] test(){}; but if you disambiguate using the 'function' syntax it seems to work.. 2 2 Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted January 27, 2018 Author Share Posted January 27, 2018 (edited) On 27/01/2018 at 8:39 AM, julian johnson said: function int[] test() { int result[] = {1,2,3}; return result; }; i[]@test = test(); I get syntax errors using the 'normal' array syntax in the documentation i.e. a simple int[] test(){}; but if you disambiguate using the 'function' syntax it seems to work.. This solves my problem. May I ask where you have found this ? Is there a BNF for VEX ? Edited January 28, 2018 by AntoineSfx Quote Link to comment Share on other sites More sharing options...
julian johnson Posted January 28, 2018 Share Posted January 28, 2018 I found this in the documentation: http://www.sidefx.com/docs/houdini/vex/arrays.html Not sure what a BNR is :-) Quote Link to comment Share on other sites More sharing options...
AntoineSfx Posted January 28, 2018 Author Share Posted January 28, 2018 (edited) 3 hours ago, julian johnson said: I found this in the documentation: http://www.sidefx.com/docs/houdini/vex/arrays.html Not sure what a BNR is :-) ok. Typo.. I meant BNF, the formal definition of the language (Backus normal form) Also, the use case of the keyword function is for nested functions. So I assume the whole VEX block is really run inside a parallel for loop over prim / points .. Edited January 28, 2018 by AntoineSfx Quote Link to comment Share on other sites More sharing options...
julian johnson Posted January 28, 2018 Share Posted January 28, 2018 // // VEX Code Generated by Houdini 16.5.268 // Date: Sun Jan 28 16:23:25 2018 // File: C:/Users/johnson/untitled // Node: /obj/geo1/attribwrangle2/attribvop1 // #ifndef VOP_OP #define VOP_OP #endif #ifndef VOP_CVEX #define VOP_CVEX #endif #pragma opname attribvop1 #pragma oplabel "Local Vop Code" #pragma opmininputs 1 #pragma opmaxinputs 1 #include <math.h> void _obj_geo1_attribwrangle2_attribvop1_snippet1(int _bound_test[]) { function int[] test() { int result[] = {1,2,3}; return result; }; _bound_test = test(); } cvex obj_geo1_attribwrangle2_attribvop1(export int test[] = {}) { // Code produced by: snippet1 _obj_geo1_attribwrangle2_attribvop1_snippet1(test); } Looks like a nested function when you expand the inner VOP node to VEX... 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.