Macha Posted November 1, 2013 Share Posted November 1, 2013 (edited) I want to write some values into a point attribute. For testing purposes I just use 0.1 on all points. Why does this code crash Houdini? What is the proper way to do it? GA_RWAttributeRef myatt; myatt = gdp->findFloatTuple(GA_ATTRIB_POINT, "myatt",1); if (!myatt.isValid()) { myatt = gdp->addFloatTuple(GA_ATTRIB_POINT, "myatt",1); } GA_RWHandleF atthandle(myatt.getAttribute()); for (GA_Iterator it(gdp->getPointRange()); !it.atEnd(); it.advance()) { GA_Offset offset = it.getOffset(); //tuple->set(myatt.getAttribute(), offset, 0.1, 1); atthandle.set(offset,1.0); }[/CODE] Edited November 1, 2013 by Macha Quote Link to comment Share on other sites More sharing options...
Macha Posted November 1, 2013 Author Share Posted November 1, 2013 Oohps, that seems to work now. I guess, the question is then whether this is the good way to do it? Quote Link to comment Share on other sites More sharing options...
graham Posted November 1, 2013 Share Posted November 1, 2013 Yeah, that's about the right way to do it. If you are trying to set all the values constant you could just do attHandle.makeConstant(1.0) to avoid iteration. Quote Link to comment Share on other sites More sharing options...
kgmcnamara Posted May 5, 2015 Share Posted May 5, 2015 (edited) Is there any way to use setBlock or setBlockFromIndices to avoid iteration if you're not setting all the values the same? Keeps crashing when I try, but I think I'm messing up the offsets. Edited May 5, 2015 by kgmcnamara Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted May 6, 2015 Share Posted May 6, 2015 (edited) setBlockFromIndices wouldn't segfault as long as the stride and components don't cause overflow. However for setBlock you could defragment the gdp to insure there are holes. Edited May 6, 2015 by captain 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.