Hello everyone,
I want to be able to write a callback function that sets the cd attribute to something but i couldn't manage to get a GU_Detail that allows attribute write. Even if i was able to modify the attribute handle, i couldnt manage to get it back to main scope. Pls take a look at my code. thanks.
PRM_Template(PRM_CALLBACK, 1 , &names[7] , 0 , 0 , 0, &setToPos),
//This crashes houdini
int SOP_myTest::setToPos(void *data, int index, float time, const PRM_Template *tplate){
SOP_myTest *me;
me = (SOP_myTest *) data;
OP_Context myContext(time);
GU_DetailHandle gdh(me->curGdh(index));
GU_Detail *gdp = gdh.writeLock();
GA_Offset ptoff;
UT_String string = NULL;
UT_Vector3 colorValue;
UT_Vector3 posValue;
GA_RWHandleV3 colorHandle(gdp , GA_ATTRIB_POINT , "Cd");
GA_ROHandleV3 normalHandle(gdp , GA_ATTRIB_POINT , "N");
GA_ROHandleV3 posHandle(gdp , GA_ATTRIB_POINT , "P");
GA_FOR_ALL_PTOFF(gdp, ptoff){
posValue = posHandle.get(ptoff);
colorHandle.set(ptoff, colorValue);
}
gdp->bumpAllDataIds();
return 1;
}
//This doesn't crash but does nothing..
GU_DetailHandleAutoWriteLock gdh(me->getCookedGeoHandle(myContext,0));
GU_Detail *gdp = gdh.getGdp();
//This also gets gdp but GA_RWHandleV3 colorHandle(gdp , GA_ATTRIB_POINT , "Cd"); does not accept const gdp.
const GU_Detail *gdp = me->curGdp(index);
//this crashes houdini too
const GU_DetailHandle gdh = me->curGdh(index);
GU_DetailHandle gdl = gdh.duplicateGeometry();
GU_Detail *gdp = gdl.writeLock();
//This gives me a const gdp too (can i convert from a const gdp to a write gdp ?)
const GU_Detail *gdp = me->getCookedGeo(myContext);
// This also does nothing
const GU_Detail *gdp = me->getCookedGeo(myContext);
GU_Detail *my_gdp = new GU_Detail;
my_gdp->duplicate(*gdp);