Revision: 23200
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23200
Author:   genscher
Date:     2009-09-14 02:01:08 +0200 (Mon, 14 Sep 2009)

Log Message:
-----------
Smoke:
* Totally new try to get cache running
* Didn't try "bake" and such things yet

Hint
* Very verbose yet
* Please do only test new blend files, not old ones!

Please give me feedback on my blog about the old crashers.

Modified Paths:
--------------
    trunk/blender/intern/smoke/intern/FLUID_3D.cpp
    trunk/blender/intern/smoke/intern/FLUID_3D.h
    trunk/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp
    trunk/blender/intern/smoke/intern/smoke_API.cpp
    trunk/blender/source/blender/blenkernel/intern/smoke.c

Modified: trunk/blender/intern/smoke/intern/FLUID_3D.cpp
===================================================================
--- trunk/blender/intern/smoke/intern/FLUID_3D.cpp      2009-09-13 23:58:03 UTC 
(rev 23199)
+++ trunk/blender/intern/smoke/intern/FLUID_3D.cpp      2009-09-14 00:01:08 UTC 
(rev 23200)
@@ -182,6 +182,9 @@
 //////////////////////////////////////////////////////////////////////
 void FLUID_3D::step()
 {
+       // addSmokeTestCase(_density, _res);
+       // addSmokeTestCase(_heat, _res);
+       
        // wipe forces
        for (int i = 0; i < _totalCells; i++)
        {

Modified: trunk/blender/intern/smoke/intern/FLUID_3D.h
===================================================================
--- trunk/blender/intern/smoke/intern/FLUID_3D.h        2009-09-13 23:58:03 UTC 
(rev 23199)
+++ trunk/blender/intern/smoke/intern/FLUID_3D.h        2009-09-14 00:01:08 UTC 
(rev 23200)
@@ -47,7 +47,7 @@
                void initVectorNoise(int amplify);
 
                void addSmokeColumn();
-               static void addSmokeTestCase(float* field, Vec3Int res, float 
value);
+               static void addSmokeTestCase(float* field, Vec3Int res);
 
                void step();
                void addObstacle(OBSTACLE* obstacle);

Modified: trunk/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp
===================================================================
--- trunk/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp       2009-09-13 
23:58:03 UTC (rev 23199)
+++ trunk/blender/intern/smoke/intern/FLUID_3D_STATIC.cpp       2009-09-14 
00:01:08 UTC (rev 23200)
@@ -44,8 +44,8 @@
 // generic static version, so that it can be applied to the
 // WTURBULENCE grid as well
 //////////////////////////////////////////////////////////////////////
-/*
-void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res, float value)
+
+void FLUID_3D::addSmokeTestCase(float* field, Vec3Int res)
 {
        const int slabSize = res[0]*res[1]; int maxRes = (int)MAX3V(res);
        float dx = 1.0f / (float)maxRes;
@@ -57,23 +57,23 @@
   float heighMin = 0.05;
   float heighMax = 0.10;
 
-  for (int y = 0; y < res[1]; y++)
-    for (int z = (int)(heighMin*res[2]); z <= (int)(heighMax * res[1]); z++)
+  for (int y = 0; y < res[2]; y++)
+    for (int z = (int)(heighMin*res[2]); z <= (int)(heighMax * res[2]); z++)
       for (int x = 0; x < res[0]; x++)
       {
         float xLength = x * dx - xTotal * 0.4f;
-        float yLength = y * dx - zTotal * 0.5f;
+        float yLength = y * dx - yTotal * 0.5f;
         float radius = sqrtf(xLength * xLength + yLength * yLength);
 
         if (radius < 0.075f * xTotal)
         {
           int index = x + y * res[0] + z * slabSize;
-          field[index] = value;
+          field[index] = 1.0f;
         }
       }
 }
-*/
 
+
 //////////////////////////////////////////////////////////////////////
 // set x direction to Neumann boundary conditions
 //////////////////////////////////////////////////////////////////////
@@ -295,12 +295,10 @@
        const int xres = res[0];
        const int yres = res[1];
        const int zres = res[2];
-       static int hits = 0;
-       static int total = 0;
        const int slabSize = res[0] * res[1];
 
        // scale dt up to grid resolution
-#if PARALLEL==1 && !_WIN32
+#if PARALLEL==1
 #pragma omp parallel
 #pragma omp for  schedule(static)
 #endif

Modified: trunk/blender/intern/smoke/intern/smoke_API.cpp
===================================================================
--- trunk/blender/intern/smoke/intern/smoke_API.cpp     2009-09-13 23:58:03 UTC 
(rev 23199)
+++ trunk/blender/intern/smoke/intern/smoke_API.cpp     2009-09-14 00:01:08 UTC 
(rev 23200)
@@ -81,8 +81,7 @@
 
 extern "C" void smoke_turbulence_step(WTURBULENCE *wt, FLUID_3D *fluid)
 {
-       if(wt) 
-               wt->stepTurbulenceFull(fluid->_dt/fluid->_dx, 
fluid->_xVelocity, fluid->_yVelocity, fluid->_zVelocity, fluid->_obstacles); 
+       wt->stepTurbulenceFull(fluid->_dt/fluid->_dx, fluid->_xVelocity, 
fluid->_yVelocity, fluid->_zVelocity, fluid->_obstacles); 
 }
 
 extern "C" void smoke_initBlenderRNA(FLUID_3D *fluid, float *alpha, float 
*beta)

Modified: trunk/blender/source/blender/blenkernel/intern/smoke.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/smoke.c      2009-09-13 
23:58:03 UTC (rev 23199)
+++ trunk/blender/source/blender/blenkernel/intern/smoke.c      2009-09-14 
00:01:08 UTC (rev 23200)
@@ -167,6 +167,8 @@
                // calc other res with max_res provided
                VECSUB(size, max, min);
 
+               printf("size: %f, %f, %f\n", size[0], size[1], size[2]);
+
                // prevent crash when initializing a plane as domain
                if((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || 
(size[2] < FLT_EPSILON))
                        return 0;
@@ -210,6 +212,8 @@
                        }
                }
 
+               printf("smd->domain->dx: %f\n", smd->domain->dx);
+
                // TODO: put in failsafe if res<=0 - dg
 
                // printf("res[0]: %d, res[1]: %d, res[2]: %d\n", 
smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]);
@@ -595,11 +599,6 @@
                smoke_turbulence_free(smd->domain->wt);
                smd->domain->wt = NULL;
        }
-
-       smd->domain->point_cache[1]->flag &= ~PTCACHE_SIMULATION_VALID;
-       smd->domain->point_cache[1]->flag |= PTCACHE_OUTDATED;
-       smd->domain->point_cache[1]->simframe= 0;
-       smd->domain->point_cache[1]->last_exact= 0;
 }
 
 void smokeModifier_reset(struct SmokeModifierData *smd)
@@ -617,17 +616,15 @@
                                smoke_free(smd->domain->fluid);
                                smd->domain->fluid = NULL;
                        }
-                                       
-                       smd->domain->point_cache[0]->flag &= 
~PTCACHE_SIMULATION_VALID;
+
                        smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED;
-                       smd->domain->point_cache[0]->simframe= 0;
-                       smd->domain->point_cache[0]->last_exact= 0;
+                       smd->domain->point_cache[1]->flag |= PTCACHE_OUTDATED;
 
                        smokeModifier_reset_turbulence(smd);
 
                        smd->time = -1;
 
-                       // printf("reset domain end\n");
+                       printf("reset domain end\n");
                }
                else if(smd->flow)
                {
@@ -841,7 +838,7 @@
                                                        else if(pa->flag & 
(PARS_UNEXIST+PARS_NO_DISP)) continue;                                          
                                                                                
                     
                                                        // VECCOPY(pos, 
pa->state.co);                                                                  
                                                        // Mat4MulVecfl 
(ob->imat, pos);                                                                
                                                                                
-                                                       // 1. get corresponding 
cell                                                                    
+                                                       // 1. get corresponding 
cell    
                                                        
get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, pa->state.co, 
cell, 0);                                                                       
                                                             
                                                        // check if cell is 
valid (in the domain boundary)                                                  
                    
                                                        for(i = 0; i < 3; i++)  
                                                                
@@ -1102,214 +1099,103 @@
        }
        else if(smd->type & MOD_SMOKE_TYPE_DOMAIN)
        {
+               SmokeDomainSettings *sds = smd->domain;
+               float light[3]; 
                PointCache *cache = NULL;
                PTCacheID pid;
                PointCache *cache_wt = NULL;
                PTCacheID pid_wt;
+               int startframe, endframe, framenr;
                float timescale;
                int cache_result = 0, cache_result_wt = 0;
-               int startframe, endframe, framenr, badloading = 0;
-               SmokeDomainSettings *sds = smd->domain;
-               float light[3]; 
 
                framenr = scene->r.cfra;
 
-               cache = sds->point_cache[0];
+               printf("time: %d\n", scene->r.cfra);
 
+               if(framenr == smd->time)
+                       return;
+
+               cache = sds->point_cache[0];
                BKE_ptcache_id_from_smoke(&pid, ob, smd);
                BKE_ptcache_id_time(&pid, scene, framenr, &startframe, 
&endframe, &timescale);
 
                cache_wt = sds->point_cache[1];
                BKE_ptcache_id_from_smoke_turbulence(&pid_wt, ob, smd);
 
-               /* handle continuous simulation with the play button */
-               if(BKE_ptcache_get_continue_physics()) 
-               {
-                       // TODO
+               if(framenr < startframe)
                        return;
-               }
 
-               if(framenr < startframe)
-               {
-                       cache->flag &= ~PTCACHE_SIMULATION_VALID;
-                       cache->simframe= 0;
-                       cache->last_exact= 0;
-
-                       cache_wt->flag &= ~PTCACHE_SIMULATION_VALID;
-                       cache_wt->simframe= 0;
-                       cache_wt->last_exact= 0;
-
-                       // we got back in time, reset smoke in this case (TODO: 
use cache later)
-                       // smd->time = scene->r.cfra;
-                       // smokeModifier_reset(smd);
-
+               if(framenr > endframe)
                        return;
-               }
-               else if(framenr > endframe) 
-               {
-                       framenr = endframe;
 
-                       // we load last valid frame here 
-                       // and don't update the smd->time variable later
-                       badloading = 1;
-               }
-
-               if(!(cache->flag & PTCACHE_SIMULATION_VALID))
+               if(!smd->domain->fluid)
                {
                        BKE_ptcache_id_reset(scene, &pid, 
PTCACHE_RESET_OUTDATED);
-               }
-               if(sds->wt && !(cache_wt->flag & PTCACHE_SIMULATION_VALID))
-               {
                        BKE_ptcache_id_reset(scene, &pid_wt, 
PTCACHE_RESET_OUTDATED);
                }
 
-               if(smd->time == -1 && framenr!= startframe)
-                       return;
-
                if(!smokeModifier_init(smd, ob, scene, dm))
+               {
+                       printf("bad smokeModifier_init\n");
                        return;
+               }
 
-               if(!smd->domain->fluid)
-                               return;
-
                /* try to read from cache */
                cache_result =  BKE_ptcache_read_cache(&pid, (float)framenr, 
scene->r.frs_sec);
-               // printf("cache_result: %d\n", cache_result);
+               printf("cache_result: %d\n", cache_result);
 
                if(cache_result == PTCACHE_READ_EXACT) 
                {
-                       SmokeDomainSettings *sds = smd->domain;
-
                        cache->flag |= PTCACHE_SIMULATION_VALID;
                        cache->simframe= framenr;
-                       sds->v3dnum = framenr;
 
-                       if(!badloading)
-                               smd->time = scene->r.cfra;
-
-                       // check for wt cache
                        if(sds->wt)
                        {
                                cache_result_wt = 
BKE_ptcache_read_cache(&pid_wt, (float)framenr, scene->r.frs_sec);
-                               // printf("cache_result_wt: %d\n", 
cache_result_wt);
-
-                               // error handling
+                               
                                if(cache_result_wt == PTCACHE_READ_EXACT) 
                                {
                                        cache_wt->flag |= 
PTCACHE_SIMULATION_VALID;
                                        cache_wt->simframe= framenr;
                                }
-                               else if(cache_result_wt==PTCACHE_READ_OLD) 
-                               {
-                                       BKE_ptcache_id_reset(scene, &pid_wt, 
PTCACHE_RESET_FREE);
-                                       cache_wt->flag |= 
PTCACHE_SIMULATION_VALID;
-                               }
-                               else if(ob->id.lib || (cache_wt->flag & 
PTCACHE_BAKED)) 
-                               {
-                                       // if baked and nothing in cache, do 
nothing 
-                                       cache_wt->flag &= 
~PTCACHE_SIMULATION_VALID;
-                                       cache_wt->simframe= 0;
-                                       cache_wt->last_exact= 0;
-                               }
                        }
-
-                       // printf("PTCACHE_READ_EXACT\n");
                        return;
                }
-               else if(cache_result==PTCACHE_READ_OLD) 
-               {
-                       BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_FREE);
-                       cache->flag |= PTCACHE_SIMULATION_VALID;
 
-                       BKE_ptcache_id_reset(scene, &pid_wt, 
PTCACHE_RESET_FREE);
-                       cache_wt->flag |= PTCACHE_SIMULATION_VALID;
-               }
-               else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) 
-               {
-                       // if baked and nothing in cache, do nothing 
-                       cache->flag &= ~PTCACHE_SIMULATION_VALID;
-                       cache->simframe= 0;
-                       cache->last_exact= 0;
+               tstart();
 
-                       cache_wt->flag &= ~PTCACHE_SIMULATION_VALID;
-                       cache_wt->simframe= 0;
-                       cache_wt->last_exact= 0;
+               smoke_calc_domain(scene, ob, smd);
                
-                       // printf("PTCACHE_BAKED\n");
-                       return;
-               }
-               /*
-               else if((cache_result==0) && ((startframe!=framenr) && 
!(cache->flag & PTCACHE_SIMULATION_VALID || (framenr == smd->time))))
-               {

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to