VEX - addprim function: Conditions that change returned value

   2731   5   0
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Hello,

I'm working on some vex code in a point wrangler that is set for points and detail ( run over only once ).

I have created an array of ‘struct’ that each has the vertex informatation needed to create different size polyline boxes.

I wanted to to take advantage of the return value created by the addprim function when I create the box with my function that uses the addvertex function and the vectors of the struc that represent their ‘point’ positions for the different members of the array.

In that function at the moment I've wanted to include adding the ability to color the box so I've included an argument for an addprimattrib function that can set the initial color.

However, if I want to change the color I have to run the function again and that seems a bit ‘wasteful’( it would redraw the box with the addvertex functions ) when I could just use the setprimattrib function which can use the origianl value returned by addprim to do that.

But the docs say ( of the addprim function ):

The returned value is a primitive number that can be used with the setprimattrib to change the value of the primitive, but is not the final primitive number of the primitive.

So I am wondering what could possibly change the final primitive number?

Am I ok if all I want is that returned addprim value to stay the same as I refer to it in other functions of the same point wrangler that addprim was used to create the original returned value?

Does it only possibly change further down the “pipeline” which follows after that point wrangler node?

Comments on this are appreciated - Thank you.


User Avatar
Member
606 posts
Joined: July 2013
Offline
For simple VEX questions, you can get away with a screenshot of the issue and posting sample VEX code.

For complex VEX questions, you'll be better off with a screenshot and a sample hipnc file.
Houdini Indie
Karma/Redshift 3D
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Hi Daryl,

I'm not having any problems, but just trying to understand what the docs mean so as to avoid any potential future problems as I develope my code.

So I guess I should simplify the question and not provide a context.

So the simple question would be:

What would cause the primitive number to change ( the one being returned by the vex add prim function ) if, as the docs say is not the final primitive number of the primitive.

Thanks
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
Correct me if i'm wrong but I think the doc's are implying that because a wrangle is multi threaded, it's making temporary prim id's when the prims are created (so it doesn't have to ping the other threads for id lookups) and then all the new prim id's are remapped/sorted when the wrangle finishes and passes data to the put port.

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
606 posts
Joined: July 2013
Offline
Bonsak is correct.

The id's returned from addprim are what I would describe as volatile: they are not cached and can be changed by other factors.

It may make more sense described this way: Wrangle geometry is only created after all Elements are processed. So, you call addprim, it gives you a volatile prim id for that element iteration, and then once all Elements are processed, the real prim ids are calculated for each prim.

For a particular Element iteration you may add several prims, for the very next Element iteration you could delete 2 prims, so on and so on, all multi-threaded. So, its only after all Elements are processed that Houdini builds the resultant Geometry, resulting in (potentially) new prim id's.
Houdini Indie
Karma/Redshift 3D
User Avatar
Member
2042 posts
Joined: Sept. 2015
Offline
Ok..thanks guys..this is making sense to me now.
  • Quick Links