Jump to content

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.

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...