Пример #1
0
DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene,
						Object *ob,
						DerivedMesh *dm,
						int useRenderParams, int UNUSED(isFinalCalc))
{
#ifdef WITH_MOD_FLUID
	DerivedMesh *result = NULL;
	int framenr;
	FluidsimSettings *fss = NULL;

	framenr= (int)scene->r.cfra;
	
	// only handle fluidsim domains
	if(fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
		return dm;
	
	// sanity check
	if(!fluidmd || (fluidmd && !fluidmd->fss))
		return dm;
	
	fss = fluidmd->fss;
	
	// timescale not supported yet
	// clmd->sim_parms->timescale= timescale;

	// support reversing of baked fluid frames here
	if((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0))
	{
		framenr = fss->lastgoodframe - framenr + 1;
		CLAMP(framenr, 1, fss->lastgoodframe);
	}
	
	/* try to read from cache */
	/* if the frame is there, fine, otherwise don't do anything */
	if((result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
		return result;
	
	return dm;
#else
	/* unused */
	(void)fluidmd;
	(void)scene;
	(void)ob;
	(void)dm;
	(void)useRenderParams;
	return NULL;
#endif
}
Пример #2
0
DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc)
{
#ifndef DISABLE_ELBEEM
	DerivedMesh *result = NULL;
	int framenr;
	FluidsimSettings *fss = NULL;

	framenr= (int)scene->r.cfra;
	
	// only handle fluidsim domains
	if(fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN))
		return dm;
	
	// sanity check
	if(!fluidmd || (fluidmd && !fluidmd->fss))
		return dm;
	
	fss = fluidmd->fss;
	
	// timescale not supported yet
	// clmd->sim_parms->timescale= timescale;
	
	// support reversing of baked fluid frames here
	if((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0))
	{
		framenr = fss->lastgoodframe - framenr + 1;
		CLAMP(framenr, 1, fss->lastgoodframe);
	}
	
	/* try to read from cache */
	if(((fss->lastgoodframe >= framenr) || (fss->lastgoodframe < 0)) && (result = fluidsim_read_cache(ob, dm, fluidmd, framenr, useRenderParams)))
	{
		// fss->lastgoodframe = framenr; // set also in src/fluidsim.c
		return result;
	}
	else
	{	
		// display last known good frame
		if(fss->lastgoodframe >= 0)
		{
			if((result = fluidsim_read_cache(ob, dm, fluidmd, fss->lastgoodframe, useRenderParams))) 
			{
				return result;
			}
			
			// it was supposed to be a valid frame but it isn't!
			fss->lastgoodframe = framenr - 1;
			
			
			// this could be likely the case when you load an old fluidsim
			if((result = fluidsim_read_cache(ob, dm, fluidmd, fss->lastgoodframe, useRenderParams))) 
			{
				return result;
			}
		}
		
		result = CDDM_copy(dm);

		if(result) 
		{
			return result;
		}
	}
	
	return dm;
#else
	return NULL;
#endif
}