Detect whether animation is really happening

On 08/08/2013 at 13:15, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R13-R14 
Language(s) :     C++  ;

I want to find out if animation is really happening, that is: The timeline cursor is moving, either one frame by clicking one of the navigation buttons, or being dragged by the mouse or running at full speed.
The Execute flags normally will do the job:

// Not animating:
// Animating:  

The problem arises when the ANIMATION flag is set, even if there is no change in the frame number. For example, if I delete a tag, then invoke undo, the Execute event triggers, with the  ANIMATION flag set. I need to find a way to prevent this.. or at least find a way to detect that it is no "real" animation.

The reason I want this is because I have some code that runs when the user repositions objects, changes values and so on. But I do not want, nor need, this code to be executed when the "real" animation takes place, in order to save CPU power. 
At the same time, there is some important value checking that has to be carried out, only when there is no animation. When doing the Undo (inserting previously deleted tag), this check is not carried out, because my code is fooled by the ANIMATION flag. But in such cases, the code has to run..
Here is the short-form:
Any ideas?

On 08/08/2013 at 17:43, xxxxxxxx wrote:

I don't think there's a short form of this that covers all the bases (running, scrubbing, shuttling).
You can check if the scrubber is running:

      GePrint("Scrubber is moving");  

But this doesn't execute when using the forward & previous buttons. Or manually scrubbing.

Steve(Spedler) posted this code a while back. And it seems to do the trick pretty nicely:

     LONG curframe, startFrame, fps;  
   fps = doc->GetFps();                                //Get the frames per second setting  
   startFrame = doc->GetMinTime().GetFrame(fps);       //Get the start frame  
   curframe = doc->GetTime().GetFrame(fps);            //Get the current frame  
   if(curframe == startFrame)                          //If the scrubber is on the first frame  
        oldFrame = startFrame;                         //Set the oldFrame variable to this value  
                                                       //NOTE: oldFrame is a class member variable (type LONG)  
        //Do whatever else might be needed in the first frame of the animation  
   //If the time scrubber has moved in any fashion  
   if(curframe != oldFrame)  
        GePrint("Scrubber is moving");  
        //Note: that this won't be done on the first frame  
        //IMPORTANT!!! Now reset oldFrame so these actions aren't done again in this frame(infinite looping)  
        oldFrame = curframe;  

If you use it a lot. You can write it as your own method.
And then call it whenever you want with a single line of code.


On 09/08/2013 at 05:39, xxxxxxxx wrote:

Hi Scott,
yes I have several methods I have collected in a class I call PluginCommon. 
And this is a good solution!
OTOH, I am always afraid of extra, unnecessary overhead, and would prefer a flag telling me that the timeline cursor is moving. But maybe I am too occupied with this.. Normally most calculations take place lightning fast, and the CPU load mostly stems from rendering and other tasks. But I always have optimization in mind. At a frame rate of 25 fps and lots of stuff happening in the scene, my plugin is preferably not the one to blame for slow action.