Simple VEX Question

   2869   3   2
User Avatar
Member
156 posts
Joined: July 2005
Offline
(This is a duplicate of a question sent out on the list.)

Hello All,

Still muddling my way through VEX.

As an example… I have an Attribute Wrangle with 3 inputs.

Input 1: some geometry
Input 2: a single animating point
Input 3: another single animating point

If I have the following vex snippet… (the actual function is more complex.)

float test = 1.2;
@P = @P * test;


All points will have their xyz values multiplied by “test”.

But if I have…

float test = distance(@opinput1_P, @opinput2_P);
@P = @P * test;


Only the first point will have it’s xyz values multiplied by “test”.

Any help appreciated.
Floyd Gillis
User Avatar
Member
806 posts
Joined: Oct. 2016
Offline
Moin, Floyd,

currently VEX does not seem to support calculations/autocasts on assignments. Casting a vector from a single float is an overloaded function (“autocasting” from a single value to three) - and that, too, is not supported (yet?).

You can wrap the cast into a function, though: By writing
@P = @P * set(test);
you use the “workaround” of sending your float “test” to a function first that takes care of the casting and returns a vector for the interpreter to use for “@P”.

Marc
---
Out of here. Being called a dick after having supported Houdini users for years is over my paygrade.
I will work for money, but NOT for "you have to provide people with free products" Indie-artists.
Good bye.
https://www.marc-albrecht.de [www.marc-albrecht.de]
User Avatar
Staff
6219 posts
Joined: July 2005
Offline
That should work as written. Possible problems:

@opinput uses `id` attribute if it exists to match pairs of points so it works with particle systems for free. This becomes surprising if you have an `id` attribute that means something else. Under Bindings, erase the default `id` for attributes to match.

There may still be annoying bugs with VEX not refreshing its bindings cache when @opinput is used when nodes re-wire. Adding some white space to your wrangle will force a re-cache. If this does fix it and you can reproduce, please submit a bug as we want to fix these bugs. (For performance, we don't re-scan all the attributes when we re-cook if we think they are the same, but @opinput bindings have confused this in the past)
User Avatar
Member
156 posts
Joined: July 2005
Offline
Thank you Marc & Jeff for your suggestions.

I ended up merging the 2 “animated single points” into the geometry I wanted to manipulate and accessed them with point functions instead…

vector pnt_A = point(0, “P”, 1001);
vector pnt_B = point(0, “P”, 1002);


Then did the distance calculation like so…

vector dist = distance(pnt_A, pnt_B);

Then the following worked fine…

@P = @P * dist;

Again, this was just a simplified segment of a complex hscript expression I was trying to update to VEX.

Damn, VEX is fast! If I'm not careful I'll become a convert.
Edited by fgillis - July 15, 2017 03:54:25
Floyd Gillis
  • Quick Links