Jump to content

Easy and generic way of copying an attribute into another


Recommended Posts

Let's say I have two attributes, P and P1.

P is the usual position attribute and P1 is a clone of the former one. So I do my stuff on P1 and I want to copy them back to P. Is there any easy way in the HDK to do this?

At the moment I am just doing a loop through all the point, initiate the handlers for the attributes and doing the get/set to copy values from one to the other.

But I was wondering if there is a more general solution, something like passing two GA_Attribute*, and copy one into another no matter the attribute type.

Thanks

Edited by lisux
Link to comment
Share on other sites

You can use GA_AIFCopyData to do this. It should properly share the data since it's basically the same data referenced by 2 names.  Something like this (I think).

 

const GA_AIFCopyData        *copy;
GA_Attribute *pattr, *p1attr;
 
// Attach attrs
 
copy = p1attr->getAIFCopyData();
copy->copy(*pattr, gdp->getPointRange(), *p1attr, gdp->getPointRange());
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...