Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Saving Topology Data for Modifiers C++

Saving Topology Data for Modifiers C++

Anonymous
Not applicable
578 Views
1 Reply
Message 1 of 2

Saving Topology Data for Modifiers C++

Anonymous
Not applicable

Right now I'm trying to find a way to avoid rebuilding my MNMesh's topology every frame while animating.  Everytime I begin in ModifyObject I get a fresh new mesh that has been untouched by anything and then I'm subdiving in my Modifier.  Once finished and returns back to my modifier for another pass I have the original mesh un-modified.

 

What I'd like to do is save a pointer in my modifier to the Face data and the Mapping data. If no topology or my modifiers setting change, I'd like to just reuse those pointers to that data. This will increase performace so the only thing that needs to be updated is my vertex data.

 

The problem is when my modifier is finished 3ds max cleans up the MNMesh's Face data and Mapping data.  The pointer end up pointing to gargbage data.

 

Is there any way to prevent Face and Map data from being deleted every time my modifier is called?

 

Thanks for you time.

 

 

0 Likes
Accepted solutions (1)
579 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Accepted solution

I ended up figuring out a fix for myself...

 

For now on PolyObject I call ConvertToType for a TriObject and store it as it creates a new object as opposed to just giving me a pointer to the old one (Max doesn't delete it then). Then the next cycle I check if anything has changed, if not then I call FreeChannels on the object passed in by 3ds for the channels I'm passing in. Then I use ShallowCopy on those same channels, but that only creates pointers to that information for the Object passed in and will be deleted when it's passed back to Max. After ShallowCopy to prevent the delete I call NewAndCopyChannels on those channels which will give those pointers their own data to point to so my stored object isn't deleted.

 

So for now that fixes the issue I had, I'm not sure if I'll run into anything else related to this change but that was the optimization fix I needed.

0 Likes