Smoke:
authorDaniel Genrich <daniel.genrich@gmx.net>
Thu, 30 Jul 2009 22:11:28 +0000 (22:11 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Thu, 30 Jul 2009 22:11:28 +0000 (22:11 +0000)
a) Crash fixed when loading files with smoke
b) changed presets to be more low-cpu friendly
c) smoke looks thicker

Unsolved:
a) 3dview of smoke changes weirdly when looking at front/back. Just move around a cube with smoke and you know what I mean - odd shading. If someone likes to take a look: draw_object.c -> search for "smoke" there

intern/smoke/intern/VEC3.h
intern/smoke/intern/smoke_API.cpp
source/blender/blenkernel/intern/smoke.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_view3d/drawobject.c
source/blender/makesrna/intern/rna_modifier.c

index cc89b234e5aee69dd9b77fc2e962f25ae22d06e1..607f68279a2a4fed2e89217c75ba753556557233 100644 (file)
@@ -937,12 +937,14 @@ std::ostream&
 operator<<( std::ostream& os, const BasicVector::Vector3Dim<Scalar>& i )
 {
        char buf[256];
+#if 0
 #if _WIN32
   sprintf(buf,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
 #else
   snprintf(buf,256,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
 #endif
        os << std::string(buf); 
+#endif
   return os;
 }
 
index cacd58fce135eedcb27c722063879da96657c2e8..9c835cf87ee8e831aeb57801171ab4f7be8bc6d1 100644 (file)
@@ -49,7 +49,6 @@ extern "C" void smoke_free(FLUID_3D *fluid)
 
 extern "C" void smoke_step(FLUID_3D *fluid)
 {
-       // fluid->addSmokeColumn();
        fluid->step();
 }
 
index fd9840f4b11e1144d569e83255faf0a8d60fc7a1..7870e53963d1f8935ae2835998bed52d766fe8b6 100644 (file)
@@ -601,7 +601,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
                        smd->domain->fluid_group = NULL;
                        smd->domain->coll_group = NULL;
                        smd->domain->maxres = 48;
-                       smd->domain->amplify = 4;
+                       smd->domain->amplify = 2;
                        smd->domain->omega = 0.5;
                        smd->domain->alpha = -0.001;
                        smd->domain->beta = 0.1;
@@ -990,7 +990,7 @@ void smoke_prepare_View(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_tvox(smd, index, exp(-density[index] * smd->domain->dx));
+                                       smoke_set_tvox(smd, index, exp(-density[index] * 4.0 * smd->domain->dx));
        }
        smoke_calc_transparency(smd, light, 0);
 }
@@ -1022,7 +1022,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] * smd->domain->dx / smd->domain->amplify) );
+               smoke_set_bigtvox(smd, i, exp(-density[i] * 4.0 * smd->domain->dx / smd->domain->amplify) );
        }
        smoke_calc_transparency(smd, light, 1);
 }
index 8a376a0a17078de358a5e5e6f3ceab759688142e..3b976b7d6580cd4e51127a6ae4df3b47a9fec1e2 100644 (file)
@@ -3645,12 +3645,14 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
                else if (md->type==eModifierType_Smoke) {
                        SmokeModifierData *smd = (SmokeModifierData*) md;
 
+                       smd->point_cache = NULL;
+
                        if(smd->type==MOD_SMOKE_TYPE_DOMAIN)
                        {
                                smd->flow = NULL;
                                smd->coll = NULL;
-                               if(smd->domain)
-                                       smd->domain = newdataadr(fd, smd->domain);
+                               smd->domain = newdataadr(fd, smd->domain);
+                               smd->domain->smd = smd;
 
                                smd->domain->fluid = NULL;
                                smd->domain->tvox = NULL;
@@ -3666,6 +3668,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
                                smd->domain = NULL;
                                smd->coll = NULL;
                                smd->flow = newdataadr(fd, smd->flow);
+                               smd->flow->smd = smd;
                                smd->flow->psys = newdataadr(fd, smd->flow->psys);
                        }
                        else if(smd->type==MOD_SMOKE_TYPE_COLL)
@@ -10185,12 +10188,9 @@ static void expand_modifier(FileData *fd, Main *mainvar, ModifierData *md)
                        
                if(smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain)
                {       
-                       //if(smd->domain->coll_group)
-                               expand_doit(fd, mainvar, smd->domain->coll_group);
-                       //if(smd->domain->fluid_group)
-                               expand_doit(fd, mainvar, smd->domain->fluid_group);
-                       //if(smd->domain->eff_group)
-                               expand_doit(fd, mainvar, smd->domain->eff_group);
+                       expand_doit(fd, mainvar, smd->domain->coll_group);
+                       expand_doit(fd, mainvar, smd->domain->fluid_group);
+                       expand_doit(fd, mainvar, smd->domain->eff_group);
                }
        }
 }
index 572759017df891cf6c28994d523e2af592f4ad03..fc700d8a8ad29f55243f25e39a5033e72f7507c8 100644 (file)
@@ -5486,7 +5486,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
 
                                mod_texture = MAX3(1, smd->domain->visibility, (int)(res[mainaxis[0]] / smd->domain->max_textures ));
                                
-                               for (z = res[mainaxis[0]]-1; z >= 0; z--) // 2
+                               for (z = 0; z < res[mainaxis[0]]; z++) // 2
                                {
                                        float quad[4][3];
 
index 93e0380880999077ca3659f02fe2256c2f487a77..e9a46cc7d7f9425165c3416e3845acea87dbb6a2 100644 (file)
@@ -178,11 +178,15 @@ static void rna_Modifier_dependency_update(bContext *C, PointerRNA *ptr)
 static void rna_Smoke_set_type(bContext *C, PointerRNA *ptr)
 {
        SmokeModifierData *smd= (SmokeModifierData *)ptr->data;
+       Object *ob= (Object*)ptr->id.data;
                
        smokeModifier_free(smd); // XXX TODO: completely free all 3 pointers
        smokeModifier_createType(smd); // create regarding of selected type
        // particle_system_slot_add_exec(C, NULL);
        // particle_system_slot_remove_exec(C, NULL);
+
+       if(smd->type == MOD_SMOKE_TYPE_DOMAIN)
+               ob->dt = OB_WIRE;
        
        // update dependancy since a domain - other type switch could have happened
        rna_Modifier_dependency_update(C, ptr);