[Sidefx-houdini-list] HDK: Few questions

Edward Lam edward at sidefx.com
Wed Apr 5 09:13:31 EDT 2017

On 4/5/2017 5:22 AM, Pradeep Barua wrote:
> -How does GA_Offset work? How to remove holes from offset? The
> defragmentation should be done manually or it happens dynamically(I mean
> automatically by Houdini)?

I forget the exact rules now, but after your SOP cooks, the output gdp will 
often (not necessarily always?) defragment. There's no need to manually 
defragment unless you're making assumptions about the equivalence of GA_Index 
and GA_Offsets. Since defragment is an expensive operation, you usually just 
want to assume that GA_Index/GA_Offset values are different.

> -Drag header files? I noticed that even without including some of the
> headers, I'm able to use their members. Are those headers dragged by
> compiler? If so, is it good practice? And in what order(and how) headers are
> dragged?

The headers you include might include others. I advocate the "Include What You 
Use" philosophy. See: 

For a practical example of this, see this post where they improved full build 
times by 2x faster for the Unreal engine: 

> -Is the following right way to inherit attribs? I've two points(source and
> target), and have a polyline(GU_PrimPoly) from those then created few more
> points(sort of resample) by adding more in-between points to
> GU_PrimPoly::build(). I want to inherit point attribs from source point to
> newly created points.

In general, I avoid debugging other people's code but some other observations of 
your snippet:

- I'm not sure how you want to copy the attribute values here. Your tuple->get() 
call isn't given the source point GA_Offset to get data from.

- findAttribute() is slow. Do it outside of loops over points because the 
existence of attributes won't be changing.

- std::vector<GA_Offset*> seems wrong, GA_Offset is merely a 64-bit integer. 
std::vector<GA_Offset> would be better.

- GA_AIFTuple is good for when you want to handle different types of attributes 
in a more generic manner. However, this is typically slower than if you used 
type-specific GA_*Handle classes like GA_ROHandleF/GA_RWHandleF, 
GA_ROHandleI/GA_RWHandleI, GA_ROHandleV3/GA_RWHandleV3, etc.


More information about the Sidefx-houdini-list mailing list