On 09/09/2017 at 19:29, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R14
Platform: Windows ;
Language(s) : C++ ;
---------
Hi folks,
Edit: same thing happens in the main thread too.
I'm running a threaded operation where I'm playing back a scene in memory. Nothing fancy, just trying to make the document increment one frame at a time. I'm doing this by:
//psuedo code, doc is in memory only
BaseTime tm;
tm.SetDenominator(1.0);
// for the purposes of here, lets assume we're wanting frame 23
tm.SetNumerator(1.0/doc->GetFps()*23);
doc->SetTime(tm); // does not set to frame 23
doc->ExecutePasses(this->Get(),TRUE,TRUE,TRUE,BUILDFLAGS_0); // always returns TRUE
// this always returns RENDERESULT_OK
REDERESULT render = RenderDocument(doc,rdata,nullptr,nullptr,Multipass,RENDERFLAGS_EXTERNAL|RENDERFLAGS_NODOCUMENTCLONE|RENDERFLAGS_PREVIEWRENDER,this->Get());
// if I print the frames from the basetime and the doc, this is what I get
GePrint("Time frame = " + RealToString(tm.GetFrame(..)); // CORRECT 23
GePrint("doc frame = " + RealToString(doc->GetTime().GetFrame(doc->GetFps()))); // INCORRECT 0
The problem I'm having is that the document is not animated to the correct frame. What I have noticed, is that the document changes time based on the frame rate. So if the frame rate is 30fps, then when I set the document time with any frame from 0-29, it only executes frame 0, and when the frame count reaches frame 30 the document is then set to the correct frame. The same thing happens from frames 30-59, the doc doesn't change until it gets to frame 60. It seems to go in multiples of the frame rate.
Is there something about BaseTime I'm not understanding, or doc->SetTime()? Is there something about doing this in a threaded environment means it won't animate correctly? Or, is this another issue, some function call I've missed? An incorrect flag? Something in my math? Something else?
WP.