SDK clarification



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/08/2009 at 04:31, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   10.5 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    Hi,

    I am making a plugin based on the EdgeCutTool from the SDK examples.
    I have got it working but I have 2 questions about the SDK documentation.

    1. AddUndo
    In the ModelingEdgeCut the following call is made:

    if (undo)
         AddUndo(doc, arr, UNDO_CHANGE)

    The function AddUndo is located in the reversenormals.cpp, and there I can see that the doc->AddUndo() is called.
    If you change the offset or the scale in the parameters you can see that this function is called multiple times.
    If you select the undo command from the menu all these undo's get undone with only one click.

    And that is how I would want it to work, so that is good.

    My question however is that in the SDK it states:
    Add an undo type to the list of undo operations started with StartUndo().

    Since the StartUndo() is not called I presume that starting the tool calls a StartUndo?
    and when finished with the tool a EndUndo gets added automatically?

    2. Threading info
    In the Important threading information section in the SDK, the following is said:

    All parts of the execution/drawing pipeline of CINEMA 4D are threaded.
    This means that all calls to draw etc. are made from a thread.
    For all threaded functions it's forbidden to: Change the structure of objects attached to the scene.

    And further on about the
    Scene modifications:

    Before making modifications in the active scene, for example from a dialog, you always need to call StopAllThreads().
    You have to do this even if you yourself are in the main thread, since there could be other threads that read from the scene.

    And this is said in the StopAllThreads entry of the BaseDocument:
    Stop all running threads.
    Note: Be sure to call this routine always when you're modifying a document asynchronously.

    In the EdgeCutTools example no call to the StopAllThreads is done.

    So, I would like to know if this is correct:
    When threaded is used in the SDK it means that it is not called from the maint hread
    All plugin types are none threaded unless we manually start a new thread or open a dialog
    We only need to call StopAllThreads if we are on a manually created thread or dialog.

    The parts of execution/drawing pipeline are a special situation, where extra rules apply, and the above no longer applies.

    Thanks,

    Nebu



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/08/2009 at 09:42, xxxxxxxx wrote:

    I figured out the first question, changing the parameters fires the InteractiveModeling_Rewind in the BaseDocument.

    I am still interested if someone has some insight on the threading part though.

    Cheers,

    Nebu


Log in to reply