HDK: threading FOR_ALL_GPOINTS

   3644   3   1
User Avatar
Member
23 posts
Joined: July 2008
Offline
Hi,
Usually we do something like this when updating geometry.

FOR_ALL_GPOINTS(gdp, ppt)
{
UT_Vector4& p = ppt->getPos();

//do some magic with p…..
}

Which of course is really slow in the case of the gdp being large.
My question is, is there a better (faster) way of updating the points? Perhaps a way to use multithreading, which in this case would be several loops each in its own thread going through individual parts of the gdp. Just simple threading of a loop (where iterations are independent of each other) in other words….

How can this be done using HDK? If there is nothing built in, then I’m just interested in how to split up “FOR_ALL_GPOINTS” into several smaller parts and I can do the threading myself.

Thanks!
User Avatar
Member
7737 posts
Joined: July 2005
Offline
gdp->points() returns a GEO_PointList which is ultimately just derived from UT_PtrArray<GEO_Point *>. So you can easily divide up the work yourself using gdp->points().entries(). To play nicely with everything else in Houdini, use of UT_ThreadedAlgorithm is recommended since that will obey HOUDINI_MAXTHREADS, nested UT_ThreadedAlgorithms, cross-platform, etc.
User Avatar
Member
23 posts
Joined: July 2008
Offline
Nice, that's really simple!

Thanks a bunch!

edit: looked at the macros in UT_ThreadedAlgorithm.h, they really make life easier
User Avatar
Member
543 posts
Joined: July 2005
Offline
Cool! Just what the doctor ordered.


Thx,
Mark
========================================================
You are no age between space
  • Quick Links