FrankFirsching Posted June 12, 2005 Share Posted June 12, 2005 Hello! Yesterday I thought I could rewrite my Lego operator I did as an OTL as a custom SOP for speed reasons. My custom SOP is working, but I would like to allocate the points I need to represent the instances in one large block. Then iterate over all generated points and set their position. Unfortunately I have only found a way to append one point after another to the Geo_Detail object. Querying the GEO_PointList and calling resize() doesn't work. I immediately get a NULL pointer, when iterating through the resized list. Looking at the capacity() and entries() values, it seems that the resize() actually does a reserve only (speaking in STL terms). How can I set the number of points used by a GEO_Detail? Cheers Frank Quote Link to comment Share on other sites More sharing options...
edward Posted June 12, 2005 Share Posted June 12, 2005 I'm not sure that you can. Observer that GEO_PointList's super class is a GB_ElementList which in turn is a UT_PtrArray<GB_Element *>. So even if you called entries(unsigned int) on the GEO_PointList, all that means is that you pre-allocate a whole bunch of NULL pointers which isn't going to help you anyhow. If you have a SOP which just constantly recreates points/primitives (eg. a "generator" sop), then instead of calling gdp->clearAndDestroy() all the time, use gdp->stashAll() instead. What this function does is "stashes" all the existing point/primitive data structures into a "free list". Then when you call appendPoint()/insertPoint()/appendPrimitive()/insertPrimitive(), instead of allocating new memory, it grabs them from this free list instead. When you're all done, call gdp->destroyStashed() to deallocate the unused (if any) structures in the "free list". Quote Link to comment Share on other sites More sharing options...
FrankFirsching Posted June 13, 2005 Author Share Posted June 13, 2005 Thanks for the info edward. Looking deeper into the doxygen documentation, it seems, that Houdini doesn't store it's points in a continous chunk of memory, but scattered in memory (making it efficient through a small object allocator). This explains, why there is no function to allocate n points. Such a function would have to do the same amount of work as a bunch of appendPoint calls. Does this also mean, when I copy the input-geometry into my custom sop (via duplicateSource), the data will be shared? Houdini could set the pointers of the point array to the same points used by the input geometry. Quote Link to comment Share on other sites More sharing options...
edward Posted June 13, 2005 Share Posted June 13, 2005 No, unfortunately it's not that smart. It's doable of course if someone added copy-on-write logic. Not sure if it's worth it though. "Instancing" of entire gdp's is possible though but that is only if you're wholesale copying another sop. 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.