Jump to content

Array Detail Attribute


Macha

Recommended Posts

I make a detail attribute called orids

 	const char *        attName= "orids";
	GA_RWAttributeRef   oridsAtt      = gdp->findIntTuple(GA_ATTRIB_GLOBAL, attName, setSize);    
	if (!oridsAtt.isValid())
	{
	    oridsAtt = gdp->addIntTuple(GA_ATTRIB_GLOBAL, attName, setSize);           
	}             
    	GA_RWHandleI oridsHandle(oridsAtt.getAttribute());

and I want to populate it from values that I have stored in a set. I probably have to convert the set to an array, but whatever I try, I cannot set the values except for the first array item. For example, as a test, this will just set the first array item to 5 and leave all others on 0:

	GA_Size		gasize(setSize);
	GA_Offset 	gaoffset;
	int	test[] = {1,2,3,4,5};
	oridsHandle.setBlock(gaoffset, gasize, test);

I also tried looping over the set and setting the attribute that way:

	int i=0;
	for (set<int>::iterator it=oridsSet.begin();it!=oridsSet.end(); ++it)
	{
		oridsHandle.set(GA_Offset(i++),*it);
	}

But again, it only sets the value in the very first array position.

 

 

How do I set array detail attributes?

Edited by Macha
Link to comment
Share on other sites

  • 4 weeks later...

Edward, I too ran into this problem, and though your solution works, I have a big block of data that I'm writing to the node and would like, for performance reasons, to write it as a block. Is there a reason why the GA_RWHandleI::setBlock method writes all the values as the same? Is it a bug in the hdk implementation?

 

Thanks.

Fernando.

Link to comment
Share on other sites

No, it's not a bug. setBlock() sets the data from the range [source, source + nelements) to the *elements* [startoff to startoff + nelements) using the given source stride and component. If you had a point attribute, then this would set the attribute values for nelements number of points. In the case of the detail (aka global) attribute, there is only ONE element. So it doesn't make sense to use setBlock(). In this case we have an attribute of length setSize which we want to set all of its components.

 

Here's a rough pic.

 

post-209-0-92804700-1414552563_thumb.png

Link to comment
Share on other sites

Thank you for your explanation, that makes sense. My question then is, if I have a large number of floats that I want to add to an object (they are weights for a deformation algorithm, so they are not particular to any point but to the whole mesh), what would be the fastest way to do it without setting them one by one inside a loop?

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