Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Variations in formatting simple inline if statements in Houdini Vex. Complex conditionals should utilize base formatting for clarity.
// Base formatting:
// Curly brackets for encapsulating multiple statements.
if(v@P.x > 0){
v@Cd = {1, 0, 0};
}
else{
v@Cd = {0, 1, 0};
}
// Inline formatting:
// Curly brackets omitted.
if(v@P.x > 0) v@Cd = {1, 0, 0}; else v@Cd = {0, 1, 0};
// Ternary formatting:
v@Cd = (v@P.x < 0) ? {1, 0, 0} : {0, 1, 0};
// Reference: https://www.sidefx.com/docs/houdini/vex/statement.html#if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment