bonassus Posted January 18, 2017 Share Posted January 18, 2017 I just followed a video tutorial found on the sideFX website titled :Houdini Quicktip#03 - Infecting points using VEX & the solver SOP. I I'm embarrassed to say i'm confused by the code snippet provided. The set up starts with scattered points and an attribute @infect = 1 added to one point. which by default gives all other points @infect = 0; Then an wrangle with this snippet is put in to a solver. if(@infect == 0){ int spnts[] = nearpoints(0,@P,1,5); foreach(int pt;spnts){ if(point(0,"infect",pt) == 1){ @infect = 1; @Cd = {1,0,0}; } } } this code works. But i'm confused why it does. Allow me to walk through the code as i understand it. if the points @infect value is 0 which on frame one is all points except one. gather the 5 nearest points and append them to the array spnts[] foreach of these 5 points with a @infect value of 0 check if its @infect attribute is equal to 1 and then set it to 1; What confuses me, first is this code is only operating on points with @infect == 0 because of the first conditional check. then the last conditional checks if @infect == 1 and if true sets it to 1. is't it already 1? sorry for the confused and confusing question. obviously I am on the rails somewhere. It would be super helpful is someone wants to enlighten me as to where my mistake is. thanks. B Quote Link to comment Share on other sites More sharing options...
dchow1992 Posted January 18, 2017 Share Posted January 18, 2017 you are opening your point cloud around points that are infect=0. when you set @infect = 1 you are setting the attribute on the current wrangle point, not the foreach point. you are looking around the current wrangle point for infected points so that you can become infected also 1 Quote Link to comment Share on other sites More sharing options...
bonassus Posted January 18, 2017 Author Share Posted January 18, 2017 Oh. now it makes more sense. thank you. The first if statement through me off. I just tested the code with out it and is apears to work just as well. I don't know why it was included in the first place. //if(@infect == 0){ int spnts[] = nearpoints(0,@P,1,5); foreach(int pt;spnts){ if(point(0,"infect",pt) == 1){ @infect = 1; @Cd = {1,0,0}; } } //} thank you! Quote Link to comment Share on other sites More sharing options...
dchow1992 Posted January 18, 2017 Share Posted January 18, 2017 the first statement is there so that you only run the code on non infected points since you don't need to infect already infected pts. if you are running this on millions of pts you'll see a performance gain 1 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.