Notifications
Clear all

[Closed] [SDK] deleting MNMesh's faces

Hi,
I’m struggling with this issue for the whole day… How to do it properly?
For now I’m trying to delete all the triangles in my MNMesh, here’s my code:

for (int face=0; face<mnm.numf; face++)
{
   if (mnm.f[face].deg == 3)
   {
      mnm.f[face].SetFlag(MN_DEAD);
   }
}
mnm.CollapseDeadStructs();

//create an EditablePoly object with my MNMesh
PolyObject *pObj = CreateEditablePolyObject();
pObj->mm = *(new MNMesh(mnm));
INode* someNode = GetCOREInterface()->CreateObjectNode(pObj);

And I thought it works correctly – the faces are gone. The problems occured later, when I used the very simple “detach elements” script, which always leads to “–Unknown system exception”. Similar things happen when I’m modyfing this EditablePoly by hand, for example detaching some part of polygons – the Max freezes and loses the edge selection on that object. This problem occurs almost always after I delete some faces in my plugin that way. How to do this correctly?