Hello! I have a problem with my deformer plugin.
Plugin not only deforms shape of an object, but also adds new polygons and points to it.
Problem appears when i try to use isoparms mode.
What i figured out:
Problem was in SendModelingCommand(). It was solved by making new document, executing passes and copy to original object.
Bool DeformerPlugin::Disconnect(BaseObject* main, BaseThread* thread) {
BaseSelect* select = ToPoly(main)->GetPolygonS();
select->DeselectAll();
AutoAlloc<BaseDocument> basedocBuffer;
BaseObject* clonedOp = (BaseObject*)main->GetClone(COPYFLAGS::NONE, nullptr);
basedocBuffer->InsertObject(clonedOp, nullptr, nullptr);
basedocBuffer->ExecutePasses(thread, true, true, true, BUILDFLAGS::INTERNALRENDERER);
ModelingCommandData mcd;
BaseContainer bc;
bc.SetData(MDATA_DISCONNECT_PRESERVEGROUPS, false);
mcd.doc = clonedOp->GetDocument();
mcd.op = clonedOp;
mcd.mode = MODELINGCOMMANDMODE::POLYGONSELECTION;
mcd.flags = MODELINGCOMMANDFLAGS::NONE;
mcd.bc = &bc;
if (!SendModelingCommand(MCOMMAND_DISCONNECT, mcd)) {
ApplicationOutput("Disconnect error.");
return false;
}
clonedOp->CopyTo(main, COPYFLAGS::NONE, nullptr);
clonedOp->CopyMatrixTo(main);
clonedOp->CopyTagsTo(main, NOTOK, NOTOK, NOTOK, nullptr);
return true;
}
I should mention that plugin works well with polygon mesh objects and problem appears only with generator objects in isoparm mode.
I guess problem is in Isoparm lines. I've tried to use BUILDFLAGS::ISOPARMS. I cannot use it with non-generator plugin. But i saw few plugins that change count of polygons and still work good. And due to my logic in code i cannot change plugin type to generator.
Although creating a temporary document has been a solution, it still doesn't work good. Cinema4d crash appears randomly while i'm testing it. Usually it happens when i reduce amount of detail, i guess it is something with caches.
What isoparms even are? Why should i use it and how to prevent cinema from crash?
And what about SetIsoparm()? Can i use it in deformer plugin somehow? And should i?