rob Posted December 16, 2008 Share Posted December 16, 2008 (edited) vector $myP = $isconnected_P ? $P : P; vector $myN = $isconnected_N ? $N : normalize(frontface(N, I)); This is a snippet of inner code from a vop and I just wanted clarification of what it means vector $position = $P; I would use this normally vector $position = $isconnected_P ?$P :P; I am not sure about this and why its even needed as if P , N are not connected its hardley going to work $isconnected_P ?$P :P Rob Edited December 16, 2008 by rob Quote Link to comment Share on other sites More sharing options...
rdg Posted December 16, 2008 Share Posted December 16, 2008 vector $myP = $isconnected_P ? $P : P; vector $myN = $isconnected_N ? $N : normalize(frontface(N, I)); This is a snippet of inner code from a vop and I just wanted clarification of what it means vector $position = $P; I would use this normally vector $position = $isconnected_P ?$P :P; I am not sure about this and why its even needed as if P , N are not connected its hardley going to work $isconnected_P ?$P :P Rob x = <boolean> ? <true> : <false>; This is called a tertiary comparator (if think) and is a shorthand for if then else. x gets the true expression assigned, if the boolean is true, else it gets the false expression. in your sample it means: If P is connected to the input of the node that generated this code, then use the value of this input, else use the global variable P. Quite handy if you want to make your code able to use custom versions of global variables. Also quite common when dealing with UVs, In this case you check if UVs are bound and switch to s and t if they aren't. Hope this helps. Georg Quote Link to comment Share on other sites More sharing options...
rob Posted December 16, 2008 Author Share Posted December 16, 2008 That really does help.! I better start using it ! Rob Quote Link to comment Share on other sites More sharing options...
rdg Posted December 16, 2008 Share Posted December 16, 2008 Errata: it's called: ternary operator 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.