Hey @aimidi,
I need further optimization, and I need to check whether the scene (tags, objects, et cetera) has been changed. Does BaseDocument.Polygonize()copy the Dirty and HDirty of the object?
This why I hinted at Polygonize() not always being up to the task. There is unfortunately no easy way to get informed about specific classic API scene graph changes. There is the broad core message EVMSG_CHANGE which is sent by EventAdd() and will inform you that 'something' changed but exactly not what did change. Which makes it quite a bit of work to synchronize two scene graphs in a performant way, the classic API one from Cinema 4D and one from an external render engine, as you then have to determine the change yourself. And if it is a relevant one, as you might not care about all scene elements of the Cinema 4D scene graph in the render engine scene graph.
One useful pattern to use in this context are GeMarker and the MAXON_CREATOR unique ID attached to nodes. This is because scene elements get reallocated quite often in the Cinema 4D scene graph, so you cannot simply have an object 'MyCube' in your renderer scene graph which holds a BaseObject pointer to its Cinema 4D scene counter part for synchronization purposes.
And to answer your question about dirty flags: No, Polygonize() will copy objects and transform generators into discrete geometry. They cannot share dirty flags (see example at the end).
Cheers,
Ferdinand
import c4d
def main():
"""
"""
docFirst = doc.GetFirstObject()
print (f"{docFirst.GetHDirty(c4d.HDIRTYFLAGS_ALL)=}")
temp = doc.Polygonize()
tempFirst = temp.GetFirstObject()
print (f"{tempFirst.GetHDirty(c4d.HDIRTYFLAGS_ALL)=}")
if __name__=='__main__':
main()
docFirst.GetHDirty(c4d.HDIRTYFLAGS_ALL)=5
tempFirst.GetHDirty(c4d.HDIRTYFLAGS_ALL)=3