[SDK] Attaching MNMeshes in ModifyObject method [solved]


I’m trying to figure out how should I attach or completely replace a MNMesh of a PolyObject within the ModifyObject function.
This is how I tried to do this, but it crashes in an empty project without anything more than the ModifyObject function implemented:

if (os->obj->IsSubClassOf(polyObjectClassID))
	PolyObject *polyObj = (PolyObject*)os->obj;
	MNMesh &mnm = polyObj->GetMesh();

	MNMesh test(mnm); //duplicate the mesh
	mnm += test; //attach

It works only once, after I add the modifier to an Editable_Poly object, but any change in the mesh or parameter block value causes instant crash.

EDIT: Solved, the reason was the ChannelsChanged() function, which was returning GEOM_CHANNEL|TOPO_CHANNEL instead of OBJ_CHANNELS.