Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Setting node dirty does not trigger an update.

    Cinema 4D SDK
    r21 c++
    3
    18
    2.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ManuelM
      Manuel
      last edited by

      Hi,

      Sorry i'm not able to reproduce that issue, it's working fine here.
      Could you provide the RegisterVideoPostPlugin function and how you send the message to the VP?

      Cheers,
      Manuel

      MAXON SDK Specialist

      MAXON Registered Developer

      O 1 Reply Last reply Reply Quote 0
      • O
        Ogers @Manuel
        last edited by Ogers

        Hello, here is the code.

        Bool Register3DelightPlugin(void)
        {
        	return RegisterVideoPostPlugin(ID_RENDERSETTINGS, "3Delight"_s, PLUGINFLAG_VIDEOPOST_ISRENDERER, RenderSettings::Alloc, "dlrendersettings"_s,  0, 0);
        }
        

        The message is sent through RenderManager which is inherited from Message Data.

        Bool RenderManager::CoreMessage(Int32 id, const BaseContainer& bc)
        {
        //This is executed when rendering has finished.
        	if (id == DL_FRAME_COMPLETED) 
        	{
        		ApplicationOutput("Frame has completed Rendering");
        		BaseDocument* doc = GetActiveDocument();
        	
        		RenderData* rd = doc->GetActiveRenderData();
        		bool has_vp = false;
        		BaseVideoPost* vp = rd->GetFirstVideoPost();
        		
        		while (vp != NULL && !has_vp) 
        		{
        			has_vp = (vp->GetType() == ID_RENDERSETTINGS); // Look for rendersettings
        
        			if (!has_vp) 
        			{
        				vp = vp->GetNext();
        			}
        		}
        
        		if (has_vp) 
        		{
        //Message to VP is sent correctly. This triggers the RenderSettings::Message function for case DLRenderFinished.
        			vp->Message(DLRenderFinished);
        		}
        		StatusSetText(String(""));
        		parser = 0x0;
        		RenderNextFrame();
        	} 
               return TRUE;
        }
        
        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          Hi,
          Sorry I'm probably missing something.

          I'm using R21.023, what's your version?
          What if you drag and drop the VP into the python console and add .Message(DLRenderFinished) ? (of course, the number itself must be used and not DLRenderFinished)

          I'm wondering if there's not a thread issue now.

          Cheers,
          Manuel

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • O
            Ogers
            last edited by

            Hello,
            I am using R21.027.
            From python console, it worked fine. After setting the node dirty, getDDescription function got executed. But I wonder what is different as the same event is being executed when the rendering finishes and the node is set Dirty except that getDDescription does not get executed after.

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by

              Hi,
              Cool we are progressing 😄
              Can you try something like that? This will execute the call to message directly in the MainThread.

              if (has_vp)
              {
                 maxon::ExecuteOnMainThread([]()
                   {
                     vp->Message(DLRenderFinished);
                   }
                 );
              }
              

              Cheers,
              Manuel

              MAXON SDK Specialist

              MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • O
                Ogers
                last edited by

                Hello,
                Tried that by still the same :/.

                Thanks,
                Ogers.

                1 Reply Last reply Reply Quote 0
                • ferdinandF
                  ferdinand
                  last edited by

                  Hello @everyone,

                  don't mind me, this is just a slightly bored myself surfing on private time and did not read the thread in its entirety. But what stands out to me is that you do this in your RenderManger::CoreMessage:

                  BaseDocument* doc = GetActiveDocument();
                  

                  Is there actually a guarantee that your render manager will only render the active document? And when you use the rendering logic provided by Cinema, the active document and rendering document will be two different documents, even when the rendering was spawned for the active document, because for rendering, a document is being cloned. So, unless this is intentional, you might be operating on the wrong document there, because as I do understand, this message of yours is coming in from a node/something in the rendered document.

                  Just pointing this out because it is a common pitfall in the Cinema 4D SDK.

                  Cheers,
                  Ferdinand

                  MAXON SDK Specialist
                  developers.maxon.net

                  1 Reply Last reply Reply Quote 0
                  • O
                    Ogers
                    last edited by Ogers

                    Hello,

                    BaseDocument* doc = GetActiveDocument();
                    BaseDocument* renderdoc = (BaseDocument*) doc->GetClone(COPYFLAGS::DOCUMENT, nullptr);
                    
                    RenderData* rd = renderdoc->GetActiveRenderData();
                    

                    If this is what you mean for getting the rendering document, I am using this way on my original code. I am not sure if the issue is related to this.

                    Cheers,
                    Ogers

                    1 Reply Last reply Reply Quote 0
                    • ManuelM
                      Manuel
                      last edited by

                      Hi,

                      as the VideoPostData is inside the current document, it's right to retrieve the current document. But as Ferdinand said, that's a common pitfall.

                      I was able to reproduce the issue. Using the Console automatically add an EventAdd(). That's why it was working using the console. If you send the message with the script manager, it will not work.

                      So, you have to "force" the UI update with an EventAdd(). SetDirty only set the VideoPostData dirty but doesn't trigger a UI update.
                      As it's the end of the render, the scene should not have changed too much and the redraw shouldn't take too much time.

                      	case DLRenderFinished:
                      		{
                      			//DLRenderFinished is executed successfully when rendering is finished, but this does not trigger an update on the UI.
                      			_render_started = false;
                      			i_node->SetDirty(DIRTYFLAGS::DESCRIPTION);
                      			EventAdd();
                      			break;
                      		}
                      

                      Just one question, that's strange to launch the render from the render preferences. Is that the final workflow?

                      Cheers,
                      Manuel

                      MAXON SDK Specialist

                      MAXON Registered Developer

                      O 1 Reply Last reply Reply Quote 0
                      • O
                        Ogers @Manuel
                        last edited by Ogers

                        Hello,
                        Trying to "force" the UI update using EventAdd() after setting the node dirty still does not trigger GetDDescription function. I thought this was what I was missing but seems there is something else.

                        I am not 100% sure if it will be the final workflow, but for now, that's our intention. We are trying to keep a uniform UI on all DCCs (as in the image below) and this way has proven to be efficient.
                        Of course, this will not be the only way to launch a render, but if we see it to be efficient in Cinema4D too then yes this will also be a way we will keep.
                        Unfortunately, our C4D plugin is too far away from other plugins that we support on other DCCs, and there's still a lot to do.

                        As for the buttons' workflow, it would be:
                        Clicking Render will set the button to Abort Render and make the other two buttons insensitive until rendering finishes (that is why I want to update the UI after rendering is finished), or abort render is clicked which this updates the UI fine.

                        The same goes for the other two buttons (Start IPR -> Abort IPR and make the other two buttons insensitive until you abort it).

                        a6afe6b4-f6e3-481e-bb85-cdcfa0bb9049-image.png

                        Cheers,
                        Ogers

                        1 Reply Last reply Reply Quote 0
                        • ManuelM
                          Manuel
                          last edited by

                          Hi,

                          I tried again to reproduce this issue but i can't. Would be interesting to send us some of your code using our mailbox [email protected]

                          Cheers,
                          Manuel

                          MAXON SDK Specialist

                          MAXON Registered Developer

                          1 Reply Last reply Reply Quote 0
                          • ferdinandF
                            ferdinand
                            last edited by

                            Hello @Ogers,

                            without any further questions, we will consider this topic as solved by Monday, the 25th and flag it accordingly.

                            Thank you for your understanding,
                            Ferdinand

                            MAXON SDK Specialist
                            developers.maxon.net

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post