HDK add points, vertices, primitives to SIM_Geometry

   3714   3   1
User Avatar
Member
69 posts
Joined: April 2013
Offline
i'm trying to add new points and primitives to an existing geometry in a DOP with the HDK.

this is what I'm doing:


//from the SIM_Object i find the object i want
SIM_Object *sim_obj = objects.findObjectById(obj_id);

const SIM_Geometry* sim_geo = sim_obj->getGeometry();

GU_DetailHandleAutoReadLock gdl(sim_geo->getGeometry());

const GU_Detail *gdp = gdl.getGdp();

gdp->appendPointOffset();


i can't add anything to the gdp. i get errors like this whenever i try (in this example, appendPointOffset):


error: passing ‘const GU_Detail’ as ‘this’ argument of ‘GA_Offset GEO_Detail::appendPointOffset()’ discards qualifiers


i think it might be because i should be using GU_DetailHandleAutoWriteLock instead of the GU_DetailHandleAutoReadLock, but I can't use the Write version. I get an error like this:


error: no matching function for call to ‘GU_DetailHandleAutoWriteLock::GU_DetailHandleAutoWriteLock(GU_ConstDetailHandle)’


any clues as to how i can do this? thanks.
User Avatar
Staff
794 posts
Joined: Oct. 2012
Offline
You'll want to use SIM_GeometryCopy (there's an example in the HDK docs of how to set this up as well).


SIM_GeometryCopy *geo = SIM_DATA_CREATE(obj, SIM_GEOMETRY_DATANAME, SIM_GeometryCopy, SIM_DATA_RETURN_EXISTING | SIM_DATA_ADOPT_EXISTING_ON_DELETE);

GU_DetailHandleAutoWriteLock gdl(geo->lockGeometry());

GU_Detail *gdp = gdl.getGdp();

geo->releaseGeometry();
User Avatar
Member
69 posts
Joined: April 2013
Offline
SIM_DATA_CREATE creates a new an empty SIM_GeometryCopy.

I think I need to use SIM_DATA_GET ? I saw an example of this is in the hair solver example.

I tried using SIM_DATA_GET, but i get NULL back.
User Avatar
Staff
794 posts
Joined: Oct. 2012
Offline
If you use the SIM_DATA_RETURN_EXISTING flag with SIM_DATA_CREATE then that shouldn't happen.

You can look at the Bullet solver for an example of how this works (the source code for it is distributed wtih Houdini). In SIM_SolverBullet.C, SIM_GeometryCopy is used when updating glue constraint networks.
  • Quick Links