Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / physics / physics_fluid.c
index df8b443..130dcba 100644 (file)
@@ -39,7 +39,7 @@
 /* types */
 #include "DNA_action_types.h"
 #include "DNA_object_types.h"
-#include "DNA_object_fluidsim_types.h" 
+#include "DNA_object_fluidsim_types.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
@@ -84,12 +84,12 @@ static float get_fluid_viscosity(FluidsimSettings *settings)
 static float get_fluid_rate(FluidsimSettings *settings)
 {
        float rate = 1.0f; /* default rate if not animated... */
-       
+
        rate = settings->animRate;
-       
+
        if (rate < 0.0f)
                rate = 0.0f;
-       
+
        return rate;
 }
 
@@ -111,10 +111,10 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings *
        else {
                float dim[3];
                float longest_axis;
-               
+
                BKE_object_dimensions_get(domainob, dim);
                longest_axis = max_fff(dim[0], dim[1], dim[2]);
-               
+
                return longest_axis * scene->unit.scale_length;
        }
 }
@@ -140,9 +140,9 @@ void fluidsimGetGeometryObjFilename(Object *ob, char *dst)  //, char *srcname)
 
 typedef struct FluidAnimChannels {
        int length;
-       
+
        double aniFrameTime;
-       
+
        float *timeAtFrame;
        float *DomainTime;
        float *DomainGravity;
@@ -151,21 +151,21 @@ typedef struct FluidAnimChannels {
 
 typedef struct FluidObject {
        struct FluidObject *next, *prev;
-       
+
        struct Object *object;
-       
+
        float *Translation;
        float *Rotation;
        float *Scale;
        float *Active;
-       
+
        float *InitialVelocity;
-       
+
        float *AttractforceStrength;
        float *AttractforceRadius;
        float *VelocityforceStrength;
        float *VelocityforceRadius;
-       
+
        float *VertexCache;
        int numVerts, numTris;
 } FluidObject;
@@ -177,10 +177,10 @@ typedef struct FluidObject {
 // simplify channels before printing
 // for API this is done anyway upon init
 #if 0
-static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries) 
-{ 
+static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries)
+{
        int i, j;
-       int channelSize = paramsize; 
+       int channelSize = paramsize;
 
        if (entries == 3) {
                elbeemSimplifyChannelVec3(channel, &channelSize);
@@ -222,11 +222,11 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char
 static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *channels)
 {
        int i;
-       
+
        channels->timeAtFrame = MEM_callocN((channels->length + 1) * sizeof(float), "timeAtFrame channel");
-       
+
        channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1
-       
+
        for (i=2; i <= channels->length; i++) {
                channels->timeAtFrame[i] = channels->timeAtFrame[i - 1] + (float)channels->aniFrameTime;
        }
@@ -256,25 +256,25 @@ static void set_vertex_channel(Depsgraph *depsgraph, float *channel, float time,
        int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd);
        int framesize = (3*fobj->numVerts) + 1;
        int j;
-       
+
        if (channel == NULL)
                return;
-       
+
        initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex);
-       
+
        /* don't allow mesh to change number of verts in anim sequence */
        if (numVerts != fobj->numVerts) {
                MEM_freeN(channel);
                channel = NULL;
                return;
        }
-       
+
        /* fill frame of channel with vertex locations */
        for (j=0; j < (3*numVerts); j++) {
                channel[i*framesize + j] = verts[j];
        }
        channel[i*framesize + framesize-1] = time;
-       
+
        MEM_freeN(verts);
        MEM_freeN(tris);
 }
@@ -296,7 +296,7 @@ static void free_domain_channels(FluidAnimChannels *channels)
 static void free_all_fluidobject_channels(ListBase *fobjects)
 {
        FluidObject *fobj;
-       
+
        for (fobj=fobjects->first; fobj; fobj=fobj->next) {
                if (fobj->Translation) {
                        MEM_freeN(fobj->Translation);
@@ -310,7 +310,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects)
                        MEM_freeN(fobj->InitialVelocity);
                        fobj->InitialVelocity = NULL;
                }
-               
+
                if (fobj->AttractforceStrength) {
                        MEM_freeN(fobj->AttractforceStrength);
                        fobj->AttractforceStrength = NULL;
@@ -321,7 +321,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects)
                        MEM_freeN(fobj->VelocityforceRadius);
                        fobj->VelocityforceRadius = NULL;
                }
-               
+
                if (fobj->VertexCache) {
                        MEM_freeN(fobj->VertexCache);
                        fobj->VertexCache = NULL;
@@ -341,105 +341,105 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
 
        /* init time values (assuming that time moves at a constant speed; may be overridden later) */
        init_time(domainSettings, channels);
-       
+
        /* allocate domain animation channels */
        channels->DomainGravity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "channel DomainGravity");
        channels->DomainViscosity = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainViscosity");
        channels->DomainTime = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime");
-       
+
        /* allocate fluid objects */
        for (base = FIRSTBASE(view_layer); base; base = base->next) {
                Object *ob = base->object;
                FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
-               
+
                if (fluidmd) {
                        FluidObject *fobj = MEM_callocN(sizeof(FluidObject), "Fluid Object");
                        fobj->object = ob;
-                       
+
                        if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) {
                                BLI_addtail(fobjects, fobj);
                                continue;
                        }
-                       
+
                        fobj->Translation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Translation");
                        fobj->Rotation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Rotation");
                        fobj->Scale = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Scale");
                        fobj->Active = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject Active");
                        fobj->InitialVelocity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject InitialVelocity");
-                       
+
                        if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) {
                                fobj->AttractforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceStrength");
                                fobj->AttractforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceRadius");
                                fobj->VelocityforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceStrength");
                                fobj->VelocityforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceRadius");
                        }
-                       
+
                        if (fluid_is_animated_mesh(fluidmd->fss)) {
                                float *verts=NULL;
                                int *tris=NULL, modifierIndex = BLI_findindex(&ob->modifiers, (ModifierData *)fluidmd);
 
                                initElbeemMesh(depsgraph, scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex);
                                fobj->VertexCache = MEM_callocN(length *((fobj->numVerts*CHANNEL_VEC)+1) * sizeof(float), "fluidobject VertexCache");
-                               
+
                                MEM_freeN(verts);
                                MEM_freeN(tris);
                        }
-                       
+
                        BLI_addtail(fobjects, fobj);
                }
        }
-       
+
        /* now we loop over the frames and fill the allocated channels with data */
        for (i=0; i < channels->length; i++) {
                FluidObject *fobj;
                float viscosity, gravity[3];
                float timeAtFrame, time;
-               
+
                eval_time = domainSettings->bakeStart + i;
-               
+
                /* XXX: This can't be used due to an anim sys optimization that ignores recalc object animation,
                 * leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ )
                 * --> BKE_animsys_evaluate_all_animation(G.main, eval_time);
                 * This doesn't work with drivers:
                 * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL);
                 */
-               
-               /* Modifying the global scene isn't nice, but we can do it in 
+
+               /* Modifying the global scene isn't nice, but we can do it in
                 * this part of the process before a threaded job is created */
                scene->r.cfra = (int)eval_time;
                ED_update_for_newframe(CTX_data_main(C), depsgraph);
-               
+
                /* now scene data should be current according to animation system, so we fill the channels */
-               
+
                /* Domain time */
                // TODO: have option for not running sim, time mangling, in which case second case comes in handy
                if (channels->DomainTime) {
                        time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime;
                        timeAtFrame = channels->timeAtFrame[i] + time;
-                       
+
                        channels->timeAtFrame[i+1] = timeAtFrame;
                        set_channel(channels->DomainTime, i, &time, i, CHANNEL_FLOAT);
                }
                else {
                        timeAtFrame = channels->timeAtFrame[i+1];
                }
-               
+
                /* Domain properties - gravity/viscosity */
                get_fluid_gravity(gravity, scene, domainSettings);
                set_channel(channels->DomainGravity, timeAtFrame, gravity, i, CHANNEL_VEC);
                viscosity = get_fluid_viscosity(domainSettings);
                set_channel(channels->DomainViscosity, timeAtFrame, &viscosity, i, CHANNEL_FLOAT);
-               
+
                /* object movement */
                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) > 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))
                                continue;
-                       
+
                        /* init euler rotation values and convert to elbeem format */
                        /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */
                        if (i) {
@@ -449,7 +449,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
 
                        mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat);
                        mul_v3_fl(rot_d, -180.0f / (float)M_PI);
-                       
+
                        set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC);
                        set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC);
                        set_channel(fobj->Scale, timeAtFrame, ob->size, i, CHANNEL_VEC);
@@ -457,14 +457,14 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
                        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);
                                set_channel(fobj->AttractforceRadius, timeAtFrame, &fluidmd->fss->attractforceRadius, i, CHANNEL_FLOAT);
                                set_channel(fobj->VelocityforceStrength, timeAtFrame, &fluidmd->fss->velocityforceStrength, i, CHANNEL_FLOAT);
                                set_channel(fobj->VelocityforceRadius, timeAtFrame, &fluidmd->fss->velocityforceRadius, i, CHANNEL_FLOAT);
                        }
-                       
+
                        if (fluid_is_animated_mesh(fluidmd->fss)) {
                                set_vertex_channel(depsgraph, fobj->VertexCache, timeAtFrame, scene, fobj, i);
                        }
@@ -476,72 +476,72 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
 {
        Depsgraph *depsgraph = CTX_data_depsgraph(C);
        FluidObject *fobj;
-       
+
        for (fobj=fobjects->first; fobj; fobj=fobj->next) {
                Object *ob = fobj->object;
                FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
                int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd);
-               
+
                float *verts=NULL;
                int *tris=NULL;
                int numVerts=0, numTris=0;
                bool deform = fluid_is_animated_mesh(fluidmd->fss);
-               
+
                elbeemMesh fsmesh;
-               
+
                if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
                        continue;
-               
+
                elbeemResetMesh(&fsmesh);
-               
+
                fsmesh.type = fluidmd->fss->type;
                fsmesh.name = ob->id.name;
-               
+
                initElbeemMesh(depsgraph, scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex);
-               
+
                fsmesh.numVertices   = numVerts;
                fsmesh.numTriangles  = numTris;
                fsmesh.vertices      = verts;
                fsmesh.triangles     = tris;
-               
-               fsmesh.channelSizeTranslation  = 
-               fsmesh.channelSizeRotation     = 
-               fsmesh.channelSizeScale        = 
-               fsmesh.channelSizeInitialVel   = 
+
+               fsmesh.channelSizeTranslation  =
+               fsmesh.channelSizeRotation     =
+               fsmesh.channelSizeScale        =
+               fsmesh.channelSizeInitialVel   =
                fsmesh.channelSizeActive       = length;
-               
+
                fsmesh.channelTranslation      = fobj->Translation;
                fsmesh.channelRotation         = fobj->Rotation;
                fsmesh.channelScale            = fobj->Scale;
                fsmesh.channelActive           = fobj->Active;
-               
+
                if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) {
                        fsmesh.channelInitialVel = fobj->InitialVelocity;
                        fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD) ? 1 : 0);
                }
-               
+
                if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP)
                        fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
                else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP)
                        fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
                else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP)
                        fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
-               
+
                fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue;
                fsmesh.volumeInitType = fluidmd->fss->volumeInitType;
                fsmesh.obstacleImpactFactor = fluidmd->fss->surfaceSmoothing; // misused value
-               
+
                if (fsmesh.type == OB_FLUIDSIM_CONTROL) {
                        fsmesh.cpsTimeStart = fluidmd->fss->cpsTimeStart;
                        fsmesh.cpsTimeEnd = fluidmd->fss->cpsTimeEnd;
                        fsmesh.cpsQuality = fluidmd->fss->cpsQuality;
                        fsmesh.obstacleType = (fluidmd->fss->flag & OB_FLUIDSIM_REVERSE);
-                       
-                       fsmesh.channelSizeAttractforceRadius = 
-                       fsmesh.channelSizeVelocityforceStrength = 
-                       fsmesh.channelSizeVelocityforceRadius = 
+
+                       fsmesh.channelSizeAttractforceRadius =
+                       fsmesh.channelSizeVelocityforceStrength =
+                       fsmesh.channelSizeVelocityforceRadius =
                        fsmesh.channelSizeAttractforceStrength = length;
-                       
+
                        fsmesh.channelAttractforceStrength = fobj->AttractforceStrength;
                        fsmesh.channelAttractforceRadius = fobj->AttractforceRadius;
                        fsmesh.channelVelocityforceStrength = fobj->VelocityforceStrength;
@@ -549,28 +549,28 @@ static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *s
                }
                else {
                        fsmesh.channelAttractforceStrength =
-                       fsmesh.channelAttractforceRadius = 
-                       fsmesh.channelVelocityforceStrength = 
-                       fsmesh.channelVelocityforceRadius = NULL; 
+                       fsmesh.channelAttractforceRadius =
+                       fsmesh.channelVelocityforceStrength =
+                       fsmesh.channelVelocityforceRadius = NULL;
                }
-               
+
                /* animated meshes */
                if (deform) {
                        fsmesh.channelSizeVertices = length;
                        fsmesh.channelVertices = fobj->VertexCache;
-                       
+
                        /* remove channels */
-                       fsmesh.channelTranslation      = 
-                       fsmesh.channelRotation         = 
+                       fsmesh.channelTranslation      =
+                       fsmesh.channelRotation         =
                        fsmesh.channelScale            = NULL;
-                       
+
                        /* Override user settings, only noslip is supported here! */
                        if (fsmesh.type != OB_FLUIDSIM_CONTROL)
                                fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
                }
-               
+
                elbeemAddMesh(&fsmesh);
-               
+
                if (verts) MEM_freeN(verts);
                if (tris) MEM_freeN(tris);
        }
@@ -589,7 +589,7 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
 
                /* only find objects with fluid modifiers */
                if (!fluidmdtmp || ob->type != OB_MESH) continue;
-                       
+
                if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) {
                        /* if no initial domain object given, find another potential domain */
                        if (!fsDomain) {
@@ -601,11 +601,11 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
                                return 0;
                        }
                }
-               
+
                /* count number of objects needed for animation channels */
                if ( !ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE) )
                        channelObjCount++;
-               
+
                /* count number of fluid input objects */
                if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW))
                        fluidInputCount++;
@@ -613,22 +613,22 @@ static int fluid_validate_scene(ReportList *reports, ViewLayer *view_layer, Obje
 
        if (newdomain)
                fsDomain = newdomain;
-       
+
        if (!fsDomain) {
                BKE_report(reports, RPT_ERROR, "No domain object found");
                return 0;
        }
-       
+
        if (channelObjCount >= 255) {
                BKE_report(reports, RPT_ERROR, "Cannot bake with more than 256 objects");
                return 0;
        }
-       
+
        if (fluidInputCount == 0) {
                BKE_report(reports, RPT_ERROR, "No fluid input objects in the scene");
                return 0;
        }
-       
+
        return 1;
 }
 
@@ -722,8 +722,8 @@ static int fluidbake_breakjob(void *customdata)
 
        if (fb->stop && *(fb->stop))
                return 1;
-       
-       /* this is not nice yet, need to make the jobs list template better 
+
+       /* this is not nice yet, need to make the jobs list template better
         * for identifying/acting upon various different jobs */
        /* but for now we'll reuse the render break... */
        return (G.is_break);
@@ -733,7 +733,7 @@ static int fluidbake_breakjob(void *customdata)
 static void fluidbake_updatejob(void *customdata, float progress)
 {
        FluidBakeJob *fb= (FluidBakeJob *)customdata;
-       
+
        *(fb->do_update) = true;
        *(fb->progress) = progress;
 }
@@ -741,13 +741,13 @@ static void fluidbake_updatejob(void *customdata, float progress)
 static void fluidbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
 {
        FluidBakeJob *fb= (FluidBakeJob *)customdata;
-       
+
        fb->stop= stop;
        fb->do_update = do_update;
        fb->progress = progress;
-       
+
        G.is_break = false;  /* XXX shared with render - replace with job 'stop' switch */
-       
+
        elbeemSimulate();
        *do_update = true;
        *stop = 0;
@@ -756,7 +756,7 @@ static void fluidbake_startjob(void *customdata, short *stop, short *do_update,
 static void fluidbake_endjob(void *customdata)
 {
        FluidBakeJob *fb= (FluidBakeJob *)customdata;
-       
+
        if (fb->settings) {
                MEM_freeN(fb->settings);
                fb->settings = NULL;
@@ -767,16 +767,16 @@ static int runSimulationCallback(void *data, int status, int frame)
 {
        FluidBakeJob *fb = (FluidBakeJob *)data;
        elbeemSimulationSettings *settings = fb->settings;
-       
+
        if (status == FLUIDSIM_CBSTATUS_NEWFRAME) {
                fluidbake_updatejob(fb, frame / (float)settings->noOfFrames);
                //printf("elbeem blender cb s%d, f%d, domainid:%d noOfFrames: %d\n", status, frame, settings->domainId, settings->noOfFrames ); // DEBUG
        }
-       
+
        if (fluidbake_breakjob(fb)) {
                return FLUIDSIM_CBRET_ABORT;
        }
-       
+
        return FLUIDSIM_CBRET_CONTINUE;
 }
 
@@ -790,12 +790,12 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects,
        BLI_freelistN(fobjects);
        MEM_freeN(fobjects);
        fobjects = NULL;
-       
+
        if (fsset) {
                MEM_freeN(fsset);
                fsset = NULL;
        }
-       
+
        if (fb) {
                MEM_freeN(fb);
                fb = NULL;
@@ -849,7 +849,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        FluidsimSettings *domainSettings;
 
        char debugStrBuffer[256];
-       
+
        int gridlevels = 0;
        const char *relbase= modifier_path_relbase(bmain, fsDomain);
        const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp
@@ -864,7 +864,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
 
        int noFrames;
        int origFrame = scene->r.cfra;
-       
+
        FluidAnimChannels *channels = MEM_callocN(sizeof(FluidAnimChannels), "fluid domain animation channels");
        ListBase *fobjects = MEM_callocN(sizeof(ListBase), "fluid objects");
        FluidsimModifierData *fluidmd = NULL;
@@ -874,14 +874,14 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        elbeemSimulationSettings *fsset= MEM_callocN(sizeof(elbeemSimulationSettings), "Fluid sim settings");
 
        fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job");
-       
+
        if (getenv(strEnvName)) {
                int dlevel = atoi(getenv(strEnvName));
                elbeemSetDebugLevel(dlevel);
                BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Debug messages activated due to envvar '%s'\n", strEnvName);
                elbeemDebugOut(debugStrBuffer);
        }
-       
+
        /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */;
        noFrames = scene->r.efra - 0;
        if (noFrames<=0) {
@@ -889,30 +889,30 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
                fluidbake_free_data(channels, fobjects, fsset, fb);
                return 0;
        }
-       
+
        /* check scene for sane object/modifier settings */
        if (!fluid_validate_scene(reports, view_layer, fsDomain)) {
                fluidbake_free_data(channels, fobjects, fsset, fb);
                return 0;
        }
-       
+
        /* these both have to be valid, otherwise we wouldn't be here */
        fluidmd = (FluidsimModifierData *)modifiers_findByType(fsDomain, eModifierType_Fluidsim);
        domainSettings = fluidmd->fss;
        mesh = fsDomain->data;
-       
+
        domainSettings->bakeStart = 1;
        domainSettings->bakeEnd = scene->r.efra;
-       
+
        // calculate bounding box
        fluid_get_bb(mesh->mvert, mesh->totvert, fsDomain->obmat, domainSettings->bbStart, domainSettings->bbSize);
-       
+
        // reset last valid frame
        domainSettings->lastgoodframe = -1;
 
        /* delete old baked files */
        fluidsim_delete_until_lastframe(domainSettings, relbase);
-       
+
        /* rough check of settings... */
        if (domainSettings->previewresxyz > domainSettings->resolutionxyz) {
                BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz,  domainSettings->resolutionxyz);
@@ -939,9 +939,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        }
        BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name, gridlevels);
        elbeemDebugOut(debugStrBuffer);
-       
-       
-       
+
+
+
        /* ******** prepare output file paths ******** */
        if (!fluid_init_filepaths(bmain, reports, domainSettings, fsDomain, targetDir, targetFile)) {
                fluidbake_free_data(channels, fobjects, fsset, fb);
@@ -950,20 +950,20 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
 
        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);
 
        /* reset to original current frame */
        scene->r.cfra = origFrame;
        ED_update_for_newframe(CTX_data_main(C), depsgraph);
-               
+
        /* ******** init domain object's matrix ******** */
        copy_m4_m4(domainMat, fsDomain->obmat);
        if (!invert_m4_m4(invDomMat, domainMat)) {
                BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::error - Invalid obj matrix?\n");
                elbeemDebugOut(debugStrBuffer);
-               BKE_report(reports, RPT_ERROR, "Invalid object matrix"); 
+               BKE_report(reports, RPT_ERROR, "Invalid object matrix");
 
                fluidbake_free_data(channels, fobjects, fsset, fb);
                return 0;
@@ -980,7 +980,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        // setup global settings
        copy_v3_v3(fsset->geoStart, domainSettings->bbStart);
        copy_v3_v3(fsset->geoSize, domainSettings->bbSize);
-       
+
        // simulate with 50^3
        fsset->resolutionxyz = (int)domainSettings->resolutionxyz;
        fsset->previewresxyz = (int)domainSettings->previewresxyz;
@@ -999,21 +999,21 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        // defaults for compressibility and adaptive grids
        fsset->gstar = domainSettings->gstar;
        fsset->maxRefine = domainSettings->maxRefine; // check <-> gridlevels
-       fsset->generateParticles = domainSettings->generateParticles; 
-       fsset->numTracerParticles = domainSettings->generateTracers; 
-       fsset->surfaceSmoothing = domainSettings->surfaceSmoothing; 
-       fsset->surfaceSubdivs = domainSettings->surfaceSubdivs; 
-       fsset->farFieldSize = domainSettings->farFieldSize; 
+       fsset->generateParticles = domainSettings->generateParticles;
+       fsset->numTracerParticles = domainSettings->generateTracers;
+       fsset->surfaceSmoothing = domainSettings->surfaceSmoothing;
+       fsset->surfaceSubdivs = domainSettings->surfaceSubdivs;
+       fsset->farFieldSize = domainSettings->farFieldSize;
        BLI_strncpy(fsset->outputPath, targetFile, sizeof(fsset->outputPath));
 
        // domain channels
-       fsset->channelSizeFrameTime = 
-       fsset->channelSizeViscosity = 
+       fsset->channelSizeFrameTime =
+       fsset->channelSizeViscosity =
        fsset->channelSizeGravity = channels->length;
        fsset->channelFrameTime = channels->DomainTime;
        fsset->channelViscosity = channels->DomainViscosity;
        fsset->channelGravity = channels->DomainGravity;
-       
+
        fsset->runsimCallback = &runSimulationCallback;
        fsset->runsimUserData = fb;
 
@@ -1041,13 +1041,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        /* ******** init solver with settings ******** */
        elbeemInit();
        elbeemAddDomain(fsset);
-       
+
        /* ******** export all fluid objects to elbeem ******** */
        export_fluid_objects(C, fobjects, scene, channels->length);
-       
+
        /* custom data for fluid bake job */
        fb->settings = fsset;
-       
+
        if (do_job) {
                wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation",
                                            WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_FLUID);
@@ -1119,7 +1119,7 @@ void FLUID_OT_bake(wmOperatorType *ot)
        ot->name = "Fluid Simulation Bake";
        ot->description = "Bake fluid simulation";
        ot->idname = "FLUID_OT_bake";
-       
+
        /* api callbacks */
        ot->invoke = fluid_bake_invoke;
        ot->exec = fluid_bake_exec;