Jump to content
ah-fx

inputGeo vs duplicateSource

Recommended Posts

Hello Odforce,

I am newish to c++ and new to the hdk. I'am curious about the differences between

const GU_Detail * gpd1 = inputGeo(1);

and

GU_Detail * gdp1;
duplicateSource(1, context, gdp1);

I am mostly wondering what situations you would use one over the other. 

I have discovered that trying to use inputGeo causes GEO_Closure to complain:

GEO_Closure closure(*gdp1);
no known conversion for argument 1 from ‘const GU_Detail’ to ‘GEO_Detail&’

but GEO_Closure instantiation works with duplicateSource. I am guessing that it has to do with having a read only pointer vs a copy of the geo, but any details about the mechanics of working with geo from one sop to another would be useful.

Share this post


Link to post
Share on other sites
7 hours ago, ah-fx said:

I am mostly wondering what situations you would use one over the other. (...)  I am guessing that it has to do with having a read only pointer vs a copy of the geo (...)

Exactly. SOPs are usually modifying first input geometry, while using 2,3,4th as constant. So you usually use one of duplicate*() family for a first input making your own gdp a literal copy[1] of input node, then you use inputGeo() returning const point for others nodes geometry (not owned by yours) in read-only mode to not to waste resources.

SOPs don't have a write access to geometry owned by others nodes, so whenever you want to change something, you need to duplicate it. What is actually happening there, is yet another story, since SOPs cooking mechanics is kind of a tricky business (see [1]). 

Quote

but GEO_Closure instantiation works with duplicateSource.

I haven't checked, but I suspect GEO_Closure is actually allowed to modify gdp (like sorting prim lists?) so it might be a reason it needs non-const geometry. You can easily force convert const *gdp into *gdp. When you see a lot of crashes, you will know why :)

 

[1] - with an exception, that currently Houdini is not actually copying anything unless you start writing to the attribute. 

  • Like 2

Share this post


Link to post
Share on other sites

Cool, makes sense. Thanks Symek.

Is is possible to view the hdk source files? I've only been able to find the header files.

 

Share this post


Link to post
Share on other sites
45 minutes ago, ah-fx said:

Cool, makes sense. Thanks Symek.

Is is possible to view the hdk source files? I've only been able to find the header files.

Sure it's possible, you just need to work for Side Effects :)

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×