[Closed] SDK: Update/Redraw mesh after changing smoothing groups
I’m writing a plugin using the SDK that makes changes to the smoothing groups of a MNMesh. When that function has completed, I want to update/redraw the model to actually make those changes visible. I’ve been searching around, but could not find a definite way on how to do this. I came across functions like buildRenderNormals, buildNormals, InvalidateGeomCache, etc. But these functions in isolation don’t seem to do completely what I want.
I suspect that there’s some combination of functions I should call, but I’m not sure which. Any ideas?
Thanks.
check the “mesh->invalidate…” functions.
they rebuild the mesh after you’ve changed the things you need.
EDIT:
I saw now that you said you already tried some of what I suggested.
I would assume these functions would help…
Can you elaborate a bit (if they do not suit your needs?).
Maybe a screenshot or two?
Does the settings look fine when you convert the object to mesh\poly?(this rebuilds mesh too).
Hmm ok so it seems like sometimes it works with mesh->invalidateGeomCache(), and sometimes it doesn’t… quite odd. Indeed converting the object to an editable poly shows the changes.
When it does not update, I can still see the result as it should be when switching to polygon mode and selecting all faces.
Here’s a (shortened) example of what I’m doing:
MNMesh* mesh = poly->GetMeshPtr();
mesh->Resmooth(false);
mesh->invalidateGeomCache();
Using 3dsmax 2010 x64 btw.
Also, occasionally I get very odd artifacts in the shading:
This only happens occasionally. Sometimes it updates fine, sometimes nothing happens, sometimes these artifacts come up.
Ok I think I figured out the required function calls. I just put in everything I could find which might be it, and then started taking things away one by one… :
mesh->buildRenderNormals();
mesh->InvalidateTopoCache(false);
This does not redraw the object in the viewport of course. And actually, using this does nothing either:
Interface* ip = GetCOREInterface();
ip->RedrawViews(ip->GetTime());
I could do ForceCompleteRedraw(false) instead, but that seems a bit over the top, doesn’t it?
i don’t have time to look deeper into mnmesh update (honestly i’ve never used it) but … definitely the forcing of scene redraw is not a method. is can be wrong but it has to be the method something like ‘set mnmesh’. and it has to be the method of updating. my point is – a mnmesh doesn’t make any sense without the node… so the mnmesh has to be set to get updated…
I found this in some old Sparks archive which seems to do the trick nicely:
mesh->InvalidateTopoCache(false);
node->NotifyDependents(FOREVER, TOPO_CHANNEL, REFMSG_CHANGE);
Interface* ip = GetCOREInterface();
ip->RedrawViews(ip->GetTime());
node here is the INode* the mesh belongs to. And it turns out the buildRenderNormals call was not needed.
I wonder if its maybe a good idea to store the interface pointer somewhere when initializing the plugin.