addpoint creates to much points

   1405   5   0
User Avatar
Member
14 posts
Joined: Dec. 2017
Offline
Hi guys, i have this simple vex-code here. The if-loop gets called two times, so just two points should be added, but for some reasons hundreds get added. Its pretty straight-forward, what am i missing? Starring for two hours at this and cant find my mistake.
In Attribute Wrangle, with Group: Points and Run over: Points. The attribute choosenInt is there too with the right numbers.

int Temp[];
    
for(int i=0; i < @ptnum ;i++) {
           Temp[i] = point(0,"choosenInt",i);
  
    if(Temp[i]==2) {
        printf("%i\n", Temp[i]);             
        addpoint(0 , 0);   
        
    }
}
Edited by JonathanPie - Sept. 3, 2018 07:38:38
User Avatar
Member
14 posts
Joined: Dec. 2017
Offline
It works with npoints(0) instead of @ptnum together with Run Over: Detailed. Although printf gave me just two prints the paralell working of points must have started the loop as often as i have points. So 73 times and every time 2 points were added. Still strange, i would have thought Printf would give me a message every time.
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
i would have thought Printf would give me a message every time.

In detail mode with npoints(0) instead of @ptnum you will get a printf output for every point that has an attribute value of 2 for ‘choosenInt’ and the same number of new points.
Edited by BabaJ - Sept. 3, 2018 09:16:29
User Avatar
Member
14 posts
Joined: Dec. 2017
Offline
In Detail-mode everything is as expected. What i meant was the printf in my first post(Run over points). Addpoint fires a few hundred times but printf just twice(2 is twice in chooseInt), which is weird i think. Cause they share the same if-loop-body.
User Avatar
Member
2036 posts
Joined: Sept. 2015
Offline
I think that's because the compiler is being ‘smart’, those values for printf, in your case are coming from only two points, and the values are not changing.

So there's no need to repeat the output more than once for each one.

However, although it's not what you intended, your creating multiple points for those same values, so Houdini does that because it's geometry and that's what you specified.

I also saw this on Odforce from edward:
VEX multithreads in buckets of 1024 elements. So because your printf is not varying, it only prints once per 1024 elements.

So just to see, try to multiply your source so you get multiples of 1024 and you should see the printf printing twice * multiples of those ‘bucket’ sets of 1024.
Edited by BabaJ - Sept. 3, 2018 14:02:50
User Avatar
Member
14 posts
Joined: Dec. 2017
Offline
Ok i see, i wouldnt have thought of that, but it makes sense. ParalellProcessing is still challenging for me sometimes. Thx a lot BabaJ.
  • Quick Links