Vex ignoring an "if" statement (?)

   2882   5   1
User Avatar
Member
53 posts
Joined: March 2018
Offline
Hello,

I recently did this tutorial by Entagma http://www.entagma.com/quicktip-rayleigh-taylor-instability-season-3-is-here/ [www.entagma.com] (It is a thin flip fluid sim that swirls around, and I cached out the points)

Everything is working great, but I want to put a picture behind it on frame one, attribute transfer color to the particles, store the Cd and then remove the image and see what patterns this makes.

I made a vector attribute called Ctrans to store the color and Pswitch to toggle when to fill Ctrans. I then made a point wrangle with this code:

if(@Pswitch==1){
v@Ctrans.x = v@Cd.r;
v@Ctrans.y = v@Cd.g;
v@Ctrans.z = v@Cd.b;
@Pswitch=0;
}

@Cd = @Ctrans;

It acts as if @Pswitch is always 1, even when the geometry spread sheet says it is 0.

Thank you for you time, any tip helps!
User Avatar
Member
1743 posts
Joined: March 2012
Offline
Hi! What version and build number of Houdini are you using? Is Pswitch 0 in the input geometry, or just in the output geometry? If you're using 16.5, does this still happen in 17.0? If it's happening in 17.0, could you submit a bug report?
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
53 posts
Joined: March 2018
Offline
ndickson
Hi! What version and build number of Houdini are you using? Is Pswitch 0 in the input geometry, or just in the output geometry? If you're using 16.5, does this still happen in 17.0? If it's happening in 17.0, could you submit a bug report?

When I created the attribute with “attribute create” in the node above it, it is set to 1. I am using 16.5, I will try it in 17 and submit a bug report if it is still happening. Thank you.
User Avatar
Member
1743 posts
Joined: March 2012
Offline
animationalex
When I created the attribute with “attribute create” in the node above it, it is set to 1.
Oh, sorry, I don't understand. If the attribute is 1 in the input, VEX should be acting as if it's 1, unless you've set it to 0 somewhere before the if statement. If it's 1 in the input, the VEX code you posted sets it to 0, so it'd be 0 in the output either way.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
53 posts
Joined: March 2018
Offline
ndickson
animationalex
When I created the attribute with “attribute create” in the node above it, it is set to 1.
Oh, sorry, I don't understand. If the attribute is 1 in the input, VEX should be acting as if it's 1, unless you've set it to 0 somewhere before the if statement. If it's 1 in the input, the VEX code you posted sets it to 0, so it'd be 0 in the output either way.

What I was hoping this code would do is that when Houdini evaluates the node, it see the switch is at 1, runs the code, then turns off the switch so it will stop changing the values it is assigning when it changes frame number and evaluates again.
User Avatar
Member
1743 posts
Joined: March 2012
Offline
animationalex
What I was hoping this code would do is that when Houdini evaluates the node, it see the switch is at 1, runs the code, then turns off the switch so it will stop changing the values it is assigning when it changes frame number and evaluates again.
SOPs always read from their input and write to their output. They don't read from their previous output, (except sometimes for performance optimization, but it's required to be as if it read from its input).

If you want changes over time, you'll either need to change the condition to be something explicitly time dependent, like if (@Time == 0), or you'll need to use a Solver SOP, which uses DOPs internally to be able to operate on geometry of previous frames. It doesn't sound like you'll probably need either of those in this case, since you can probably just reorganize your network with the data flow of SOPs in mind, though I don't know enough about what you're trying to do to say for certain.

Hopefully that helps clarify things a bit.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
  • Quick Links