MrScienceOfficer Posted August 22, 2014 Share Posted August 22, 2014 (edited) Hi guys, Can someone be so kind and tell me whats wrong with this... GA_RWAttributeRef weightIdx = gdp->findAttribute(GA_ATTRIB_POINT, "weightIndex"); GA_RWAttributeRef pointIdx = gdp->findAttribute(GA_ATTRIB_POINT, "pointIndex"); GA_RWHandleV3 wIdx; GA_RWHandleV3 pIdx; if (!weightIdx.isValid()) { weightIdx = gdp->addFloatTuple(GA_ATTRIB_POINT, "weightIndex", 3); wIdx = GA_RWHandleV3(weightIdx); } if (!pointIdx.isValid()) { pointIdx = gdp->addFloatTuple(GA_ATTRIB_POINT, "pointIndex", 3); pIdx = GA_RWHandleV3(pointIdx); } It compiles just fine but when It throws always segmentation fault, but when i do this GA_RWHandleV3 wIdx(gdp->findAttribute(GA_ATTRIB_POINT, "weightIndex")); GA_RWHandleV3 pIdx(gdp->findAttribute(GA_ATTRIB_POINT, "pointIndex")) it works just fine, everything's the same except I add the attributes with nodes of course. What's the difference? Also how can I get a Handle for arbitrary sized float Tuple attribute like 9 or something, do I need a Handle to set it? Can I just use GA_RWAttributeRef? Edited August 23, 2014 by captain Quote Link to comment Share on other sites More sharing options...
edward Posted August 23, 2014 Share Posted August 23, 2014 If the weightIndex/pointIndex attributes already exist, then you fail to initialize wIdx and pIdx. You can probably do it less lines of (untested) code like // addFloatTuple will do nothing if the attribute already exists GA_RWHandleV3 wIdx(gdp->addFloatTuple(GA_ATTRIB_POINT, "weightIndex", 3)); if (wIdx.isInvalid()) return; // failed to add *new* weightIndex attribute To deal with non-specific tuple sizes, use a scalar handle like GA_RWHandleF and specify the tuple component when you call get/set. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted August 23, 2014 Author Share Posted August 23, 2014 Oh okay awesome, that was my first attempt but I must of muffed it up. Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.