Smoke: fixing collision objects again (bug introduced in decoupling commit) - thanks...
authorDaniel Genrich <daniel.genrich@gmx.net>
Sat, 8 Aug 2009 20:41:44 +0000 (20:41 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Sat, 8 Aug 2009 20:41:44 +0000 (20:41 +0000)
source/blender/blenkernel/intern/smoke.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_view3d/drawobject.c

index 0d46e4baa88b75df6ffe5a76453b70a9f8c01544..bd93126d365b8e6bb1034f9728f58278bbee0b7f 100644 (file)
@@ -566,13 +566,9 @@ void smokeModifier_reset(struct SmokeModifierData *smd)
                        }
                        smd->domain->max_textures = 0;
                        if(smd->domain->viewsettings < MOD_SMOKE_VIEW_USEBIG)
-                       {
                                smd->domain->viewsettings = 0;
-                       }
                        else
-                       {
                                smd->domain->viewsettings = MOD_SMOKE_VIEW_USEBIG;
-                       }
 
                        if(smd->domain->tray)
                                MEM_freeN(smd->domain->tray);
@@ -753,9 +749,13 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
                        
                        tstart();
 
-                       sds->viewsettings = 0; // reset view for new frame
+                       /* reset view for new frame */
+                       if(sds->viewsettings < MOD_SMOKE_VIEW_USEBIG)
+                               sds->viewsettings = 0;
+                       else
+                               sds->viewsettings = MOD_SMOKE_VIEW_USEBIG;
 
-                       // check for 2nd domain, if not there -> no groups are necessary
+                       /* check for 2nd domain, if not there -> no groups are necessary */
                        for(base = scene->base.first; base; base= base->next) 
                        {
                                Object *ob1= base->object;
@@ -889,11 +889,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
 
                                                                                        smoke_get_bigres(smd->domain->fluid, bigres);
 
-                                                                                       for(i = 0; i < smd->domain->amplify; i++)
-                                                                                               for(j = 0; j < smd->domain->amplify; j++)
-                                                                                                       for(k = 0; k < smd->domain->amplify; k++)
+                                                                                       for(i = 0; i < smd->domain->amplify + 1; i++)
+                                                                                               for(j = 0; j < smd->domain->amplify + 1; j++)
+                                                                                                       for(k = 0; k < smd->domain->amplify + 1; k++)
                                                                                                        {
-                                                                                                               index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k);
+                                                                                                               index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k);
                                                                                                                bigdensity[index] = sfs->density;
                                                                                                        }
                                                                                }
@@ -914,11 +914,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM
 
                                                                                        smoke_get_bigres(smd->domain->fluid, bigres);
 
-                                                                                       for(i = 0; i < smd->domain->amplify; i++)
-                                                                                               for(j = 0; j < smd->domain->amplify; j++)
-                                                                                                       for(k = 0; k < smd->domain->amplify; k++)
+                                                                                       for(i = 0; i < smd->domain->amplify + 1; i++)
+                                                                                               for(j = 0; j < smd->domain->amplify + 1; j++)
+                                                                                                       for(k = 0; k < smd->domain->amplify + 1; k++)
                                                                                                        {
-                                                                                                               index = smoke_get_index(smd->domain->amplify * cell[0] + i, bigres[0], smd->domain->amplify * cell[1] + j, bigres[1], smd->domain->amplify * cell[2] + k);
+                                                                                                               index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k);
                                                                                                                bigdensity[index] = 0.f;
                                                                                                        }
                                                                                }
@@ -1138,7 +1138,7 @@ void smoke_prepare_bigView(SmokeModifierData *smd, float *light)
                // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4
                // T_vox = exp(-C_ext * h)
                // C_ext/sigma_t = density * C_ext
-               smoke_set_bigtvox(smd, i, exp(-density[i] * 7.0 * smd->domain->dx / smd->domain->amplify) );
+               smoke_set_bigtvox(smd, i, exp(-density[i] * 7.0 * smd->domain->dx / (smd->domain->amplify + 1)) );
        }
        smoke_calc_transparency(smd, light, 1);
 }
@@ -1353,7 +1353,7 @@ static void get_bigcell(struct SmokeModifierData *smd, float *pos, int *cell, in
 
        VECSUB(tmp, pos, smd->domain->p0);
 
-       VecMulf(tmp, smd->domain->amplify / smd->domain->dx );
+       VecMulf(tmp, (smd->domain->amplify + 1)/ smd->domain->dx );
 
        if(correct)
        {
@@ -1402,7 +1402,7 @@ void smoke_calc_transparency(struct SmokeModifierData *smd, float *light, int bi
        else
        {
                smoke_get_bigres(smd->domain->fluid, res);
-               bigfactor = 1.0 / smd->domain->amplify;
+               bigfactor = 1.0 / (smd->domain->amplify + 1);
        }
 
 #pragma omp parallel for schedule(static) private(y, z) shared(big, smd, light, res, bigfactor)
index 6bcb110948085087f32f6a3f29dfd43222b804ba..019392ebcb2f6387897b7f2697a26dbce17b6be3 100644 (file)
@@ -3665,7 +3665,11 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
                                smd->domain->traybig = NULL;
                                smd->domain->bind = NULL;
                                smd->domain->max_textures = 0;
-                               smd->domain->viewsettings = 0; // reset view for new frame
+                               // reset 3dview
+                               if(smd->domain->viewsettings < MOD_SMOKE_VIEW_USEBIG)
+                                       smd->domain->viewsettings = 0;
+                               else
+                                       smd->domain->viewsettings = MOD_SMOKE_VIEW_USEBIG;
                        }
                        else if(smd->type==MOD_SMOKE_TYPE_FLOW)
                        {
index 996c7316570557615a4bb380b5b5c48a7f109f3e..dd1f44c55cb954533be658499ca09b8cf1282a24 100644 (file)
@@ -5368,7 +5368,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
                        else
                        {
                                smoke_get_bigres(smd->domain->fluid, res);
-                               bigfactor = 1.0 / smd->domain->amplify;
+                               bigfactor = 1.0 / (smd->domain->amplify + 1);
                        }
 
                        wmLoadMatrix(rv3d->viewmat);