Jump to content

Recommended Posts

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

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.

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...