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
This commit is contained in:
Daniel Genrich 2009-07-30 22:11:28 +00:00
parent 9561d34dbb
commit da4ab9b14b
6 changed files with 18 additions and 13 deletions

@ -937,12 +937,14 @@ std::ostream&
operator<<( std::ostream& os, const BasicVector::Vector3Dim<Scalar>& i ) operator<<( std::ostream& os, const BasicVector::Vector3Dim<Scalar>& i )
{ {
char buf[256]; char buf[256];
#if 0
#if _WIN32 #if _WIN32
sprintf(buf,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]); sprintf(buf,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
#else #else
snprintf(buf,256,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]); snprintf(buf,256,globVecFormatStr, (double)i[0],(double)i[1],(double)i[2]);
#endif #endif
os << std::string(buf); os << std::string(buf);
#endif
return os; return os;
} }

@ -49,7 +49,6 @@ extern "C" void smoke_free(FLUID_3D *fluid)
extern "C" void smoke_step(FLUID_3D *fluid) extern "C" void smoke_step(FLUID_3D *fluid)
{ {
// fluid->addSmokeColumn();
fluid->step(); fluid->step();
} }

@ -601,7 +601,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
smd->domain->fluid_group = NULL; smd->domain->fluid_group = NULL;
smd->domain->coll_group = NULL; smd->domain->coll_group = NULL;
smd->domain->maxres = 48; smd->domain->maxres = 48;
smd->domain->amplify = 4; smd->domain->amplify = 2;
smd->domain->omega = 0.5; smd->domain->omega = 0.5;
smd->domain->alpha = -0.001; smd->domain->alpha = -0.001;
smd->domain->beta = 0.1; 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 // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4
// T_vox = exp(-C_ext * h) // T_vox = exp(-C_ext * h)
// C_ext/sigma_t = density * C_ext // 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); 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 // formula taken from "Visual Simulation of Smoke" / Fedkiw et al. pg. 4
// T_vox = exp(-C_ext * h) // T_vox = exp(-C_ext * h)
// C_ext/sigma_t = density * C_ext // 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); smoke_calc_transparency(smd, light, 1);
} }

@ -3645,12 +3645,14 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
else if (md->type==eModifierType_Smoke) { else if (md->type==eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData*) md; SmokeModifierData *smd = (SmokeModifierData*) md;
smd->point_cache = NULL;
if(smd->type==MOD_SMOKE_TYPE_DOMAIN) if(smd->type==MOD_SMOKE_TYPE_DOMAIN)
{ {
smd->flow = NULL; smd->flow = NULL;
smd->coll = 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->fluid = NULL;
smd->domain->tvox = NULL; smd->domain->tvox = NULL;
@ -3666,6 +3668,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
smd->domain = NULL; smd->domain = NULL;
smd->coll = NULL; smd->coll = NULL;
smd->flow = newdataadr(fd, smd->flow); smd->flow = newdataadr(fd, smd->flow);
smd->flow->smd = smd;
smd->flow->psys = newdataadr(fd, smd->flow->psys); smd->flow->psys = newdataadr(fd, smd->flow->psys);
} }
else if(smd->type==MOD_SMOKE_TYPE_COLL) 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->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain)
{ {
//if(smd->domain->coll_group) expand_doit(fd, mainvar, smd->domain->coll_group);
expand_doit(fd, mainvar, smd->domain->coll_group); expand_doit(fd, mainvar, smd->domain->fluid_group);
//if(smd->domain->fluid_group) expand_doit(fd, mainvar, smd->domain->eff_group);
expand_doit(fd, mainvar, smd->domain->fluid_group);
//if(smd->domain->eff_group)
expand_doit(fd, mainvar, smd->domain->eff_group);
} }
} }
} }

@ -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 )); 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]; float quad[4][3];

@ -178,11 +178,15 @@ static void rna_Modifier_dependency_update(bContext *C, PointerRNA *ptr)
static void rna_Smoke_set_type(bContext *C, PointerRNA *ptr) static void rna_Smoke_set_type(bContext *C, PointerRNA *ptr)
{ {
SmokeModifierData *smd= (SmokeModifierData *)ptr->data; SmokeModifierData *smd= (SmokeModifierData *)ptr->data;
Object *ob= (Object*)ptr->id.data;
smokeModifier_free(smd); // XXX TODO: completely free all 3 pointers smokeModifier_free(smd); // XXX TODO: completely free all 3 pointers
smokeModifier_createType(smd); // create regarding of selected type smokeModifier_createType(smd); // create regarding of selected type
// particle_system_slot_add_exec(C, NULL); // particle_system_slot_add_exec(C, NULL);
// particle_system_slot_remove_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 // update dependancy since a domain - other type switch could have happened
rna_Modifier_dependency_update(C, ptr); rna_Modifier_dependency_update(C, ptr);