Bugfix [#29186] Object contribute to fluid sim animation start earlier than keyframe
Also fix: - Fluid simulation was always lagging 1 frame behind: E.g. the 250th frame in blender showed 249th frame of the fluid simulation. Change: - Animated enabled/disabled property only gets counted as "on" if value >= 1 Note that this bugfix should solve many problems with timings of animated fluid sim properties.
This commit is contained in:
@@ -787,7 +787,7 @@ ntlVec3Gfx ntlGeometryObject::getTranslation(double t) {
|
||||
}
|
||||
/*! get active flag time t*/
|
||||
float ntlGeometryObject::getGeoActive(double t) {
|
||||
float act = mcGeoActive.get(t); // if <= 0.0 -> off
|
||||
float act = (mcGeoActive.get(t) >= 1.) ? 1.0 : 0.0;
|
||||
return act;
|
||||
}
|
||||
|
||||
|
@@ -143,6 +143,7 @@ void ntlWorld::initDefaults()
|
||||
mFirstSim = 1;
|
||||
mSingleStepDebug = false;
|
||||
mFrameCnt = 0;
|
||||
mSimFrameCnt = 0;
|
||||
mpOpenGLRenderer = NULL;
|
||||
|
||||
/* create scene storage */
|
||||
@@ -406,7 +407,6 @@ int ntlWorld::advanceSims(int framenum)
|
||||
}
|
||||
|
||||
for(size_t i=0;i<mpSims->size();i++) { (*mpSims)[i]->setFrameNum(framenum); }
|
||||
double targetTime = mSimulationTime + (*mpSims)[mFirstSim]->getFrameTime(framenum);
|
||||
|
||||
// time stopped? nothing else to do...
|
||||
if( (*mpSims)[mFirstSim]->getFrameTime(framenum) <= 0.0 ){
|
||||
@@ -416,6 +416,13 @@ int ntlWorld::advanceSims(int framenum)
|
||||
(*mpSims)[mFirstSim]->checkCallerStatus(FLUIDSIM_CBSTATUS_STEP, 0);
|
||||
}
|
||||
|
||||
// Prevent bug [#29186] Object contribute to fluid sim animation start earlier than keyframe
|
||||
// Was: double targetTime = mSimulationTime + (*mpSims)[mFirstSim]->getFrameTime(framenum); - DG
|
||||
double totalTime = 0.0, targetTime = 0.0;
|
||||
for(size_t i = 0; i < mSimFrameCnt; i++)
|
||||
totalTime += (*mpSims)[mFirstSim]->getFrameTime(framenum);
|
||||
targetTime = totalTime + (*mpSims)[mFirstSim]->getFrameTime(framenum);
|
||||
|
||||
int gstate = 0;
|
||||
myTime_t advsstart = getTime();
|
||||
|
||||
@@ -461,6 +468,8 @@ int ntlWorld::advanceSims(int framenum)
|
||||
sim->prepareVisualization();
|
||||
}
|
||||
|
||||
mSimFrameCnt++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -115,6 +115,9 @@ class ntlWorld
|
||||
|
||||
/*! count no. of frame for viz render */
|
||||
int mFrameCnt;
|
||||
|
||||
/*! count no. of frame for correct sim time */
|
||||
int mSimFrameCnt;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -446,7 +446,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
|
||||
for (fobj=fobjects->first; fobj; fobj=fobj->next) {
|
||||
Object *ob = fobj->object;
|
||||
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
|
||||
float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE);
|
||||
float active= (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) > 0 ? 1 : 0);
|
||||
float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
|
||||
|
||||
if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
|
||||
@@ -467,6 +467,8 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
|
||||
set_channel(fobj->Scale, timeAtFrame, ob->size, i, CHANNEL_VEC);
|
||||
set_channel(fobj->Active, timeAtFrame, &active, i, CHANNEL_FLOAT);
|
||||
set_channel(fobj->InitialVelocity, timeAtFrame, &fluidmd->fss->iniVelx, i, CHANNEL_VEC);
|
||||
|
||||
// printf("Active: %f, Frame: %f\n", active, timeAtFrame);
|
||||
|
||||
if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) {
|
||||
set_channel(fobj->AttractforceStrength, timeAtFrame, &fluidmd->fss->attractforceStrength, i, CHANNEL_FLOAT);
|
||||
@@ -962,8 +964,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
|
||||
|
||||
/* ******** prepare output file paths ******** */
|
||||
outStringsChanged = fluid_init_filepaths(fsDomain, targetDir, targetFile, debugStrBuffer);
|
||||
channels->length = scene->r.efra;
|
||||
channels->aniFrameTime = (double)(domainSettings->animEnd - domainSettings->animStart) / (double)noFrames;
|
||||
channels->length = scene->r.efra; // DG TODO: why using endframe and not "noFrames" here? .. because "noFrames" is buggy too? (not using sfra)
|
||||
channels->aniFrameTime = (double)((double)domainSettings->animEnd - (double)domainSettings->animStart) / (double)noFrames;
|
||||
|
||||
/* ******** initialize and allocate animation channels ******** */
|
||||
fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects);
|
||||
|
@@ -426,7 +426,11 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm,
|
||||
FluidsimModifierData *fluidmd, int framenr, int useRenderParams)
|
||||
{
|
||||
int displaymode = 0;
|
||||
int curFrame = framenr - 1 /*scene->r.sfra*/; /* start with 0 at start frame */
|
||||
|
||||
int curFrame = framenr /* - 1 */ /*scene->r.sfra*/; /* start with 0 at start frame */
|
||||
/* why start with 0 as start frame?? Animations + time are frozen for frame 0 anyway. (See physics_fluid.c for that. - DG */
|
||||
/* If we start with frame 0, we need to remap all animation channels, too, because they will all be 1 frame late if using frame-1! - DG */
|
||||
|
||||
char targetFile[FILE_MAX];
|
||||
FluidsimSettings *fss = fluidmd->fss;
|
||||
DerivedMesh *dm = NULL;
|
||||
|
Reference in New Issue
Block a user