diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2009-08-26 03:39:49 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2009-08-26 03:39:49 +0400 |
commit | 3f5a2a11944a2e983d62babe8bb02b03e14c805d (patch) | |
tree | b39ac059564ec9ff9514d08190faa137335845f4 | |
parent | c4a1c8fbeb86396788866d6dc3eb1b5b5dc3f67d (diff) |
Smoke:
*Bugfix for crash on using a plane as smoke domain (reported by DingTo)
* Bringing slowly high res back, not yet working
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 44 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 65 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 3 | ||||
-rw-r--r-- | source/blender/blenloader/intern/writefile.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_smoke_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_smoke.c | 10 |
7 files changed, 94 insertions, 39 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index d9740091912..42bea260450 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -703,11 +703,44 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->calldata= smd; pid->type= PTCACHE_TYPE_SMOKE_DOMAIN; - pid->stack_index= sds->point_cache->index; + pid->stack_index= sds->point_cache[0]->index; - pid->cache= sds->point_cache; - pid->cache_ptr= &sds->point_cache; - pid->ptcaches= &sds->ptcaches; + pid->cache= sds->point_cache[0]; + pid->cache_ptr= &(sds->point_cache[0]); + pid->ptcaches= &(sds->ptcaches[0]); + + pid->totpoint= pid->totwrite= ptcache_totpoint_smoke; + + pid->write_elem= NULL; + pid->read_elem= NULL; + + pid->read_stream = ptcache_read_smoke; + pid->write_stream = ptcache_write_smoke; + + pid->interpolate_elem= NULL; + + pid->write_header= ptcache_write_basic_header; + pid->read_header= ptcache_read_basic_header; + + pid->data_types= (1<<BPHYS_DATA_LOCATION); // bogus values tot make pointcache happy + pid->info_types= 0; +} + +void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) +{ + SmokeDomainSettings *sds = smd->domain; + + memset(pid, 0, sizeof(PTCacheID)); + + pid->ob= ob; + pid->calldata= smd; + + pid->type= PTCACHE_TYPE_SMOKE_HIGHRES; + pid->stack_index= sds->point_cache[1]->index; + + pid->cache= sds->point_cache[1]; + pid->cache_ptr= &sds->point_cache[1]; + pid->ptcaches= &sds->ptcaches[1]; pid->totpoint= pid->totwrite= ptcache_totpoint_smoke; @@ -1792,10 +1825,7 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) else if(pid->type == PTCACHE_TYPE_PARTICLES) psys_reset(pid->calldata, PSYS_RESET_DEPSGRAPH); else if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) - { smokeModifier_reset(pid->calldata); - printf("reset PTCACHE_TYPE_SMOKE_DOMAIN\n"); - } } if(clear) BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 28d1c264376..cd9679be486 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -166,6 +166,10 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // calc other res with max_res provided VECSUB(size, max, min); + + if((size[0] < FLT_EPSILON) || (size[1] < FLT_EPSILON) || (size[2] < FLT_EPSILON)) + return 0; + if(size[0] > size[1]) { if(size[0] > size[1]) @@ -213,13 +217,11 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive smd->time = scene->r.cfra; smd->domain->firstframe = smd->time; - /* - if(!smd->domain->wt) + if(!smd->domain->wt && (smd->domain->flags & MOD_SMOKE_HIGHRES)) { - smd->domain->wt = smoke_turbulence_init(sds->res, smd->domain->amplify + 1, smd->domain->noise); + smd->domain->wt = smoke_turbulence_init(smd->domain->res, smd->domain->amplify + 1, smd->domain->noise); smoke_turbulence_initBlenderRNA(smd->domain->wt, &smd->domain->strength); } - */ if(!smd->domain->view3d) { @@ -409,10 +411,10 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive { smd->coll->bvhtree = NULL; // bvhtree_build_from_smoke ( ob->obmat, dm->getFaceArray(dm), dm->getNumFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm), 0.0 ); } - + return 1; } - return 0; + return 1; } /*! init triangle divisions */ @@ -529,8 +531,10 @@ void smokeModifier_freeDomain(SmokeModifierData *smd) if(smd->domain->wt) smoke_turbulence_free(smd->domain->wt); - BKE_ptcache_free_list(&smd->domain->ptcaches); - smd->domain->point_cache = NULL; + BKE_ptcache_free_list(&(smd->domain->ptcaches[0])); + smd->domain->point_cache[0] = NULL; + BKE_ptcache_free_list(&(smd->domain->ptcaches[1])); + smd->domain->point_cache[1] = NULL; MEM_freeN(smd->domain); smd->domain = NULL; @@ -603,10 +607,15 @@ void smokeModifier_reset(struct SmokeModifierData *smd) smd->domain->wt = NULL; } - smd->domain->point_cache->flag &= ~PTCACHE_SIMULATION_VALID; - smd->domain->point_cache->flag |= PTCACHE_OUTDATED; - smd->domain->point_cache->simframe= 0; - smd->domain->point_cache->last_exact= 0; + 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_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; // printf("reset_domain\n"); } @@ -666,9 +675,13 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->domain->smd = smd; - smd->domain->point_cache = BKE_ptcache_add(&smd->domain->ptcaches); - smd->domain->point_cache->flag |= PTCACHE_DISK_CACHE; - smd->domain->point_cache->step = 1; + smd->domain->point_cache[0] = BKE_ptcache_add(&(smd->domain->ptcaches[0])); + smd->domain->point_cache[0]->flag |= PTCACHE_DISK_CACHE; + smd->domain->point_cache[0]->step = 1; + + smd->domain->point_cache[1] = BKE_ptcache_add(&(smd->domain->ptcaches[1])); + smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE; + smd->domain->point_cache[1]->step = 1; /* set some standard values */ smd->domain->fluid = NULL; @@ -775,8 +788,9 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } else if(smd->type & MOD_SMOKE_TYPE_DOMAIN) { - PointCache *cache; + PointCache *cache, *cache_wt; PTCacheID pid; + PTCacheID pid_wt; float timescale; int cache_result = 0; int startframe, endframe, framenr; @@ -788,7 +802,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM framenr = scene->r.cfra; - cache = sds->point_cache; + cache = sds->point_cache[0]; BKE_ptcache_id_from_smoke(&pid, ob, smd); BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); @@ -800,12 +814,15 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM cache->simframe= 0; cache->last_exact= 0; - smokeModifier_init(smd, ob, scene, dm); + if(!smokeModifier_init(smd, ob, scene, dm)) + return; + + if(!smd->domain->fluid) + return; smoke_simulate_domain(smd, scene, ob, dm); { - // float light[3] = {0.0,0.0,0.0}; // TODO: take real LAMP coordinates - dg Base *base_tmp = NULL; for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) @@ -852,7 +869,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); } - smokeModifier_init(smd, ob, scene, dm); + if(!smokeModifier_init(smd, ob, scene, dm)) + return; + + if(!smd->domain->fluid) + return; /* try to read from cache */ cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); @@ -904,8 +925,10 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smoke_simulate_domain(smd, scene, ob, dm); + if(sds->wt) + smoke_turbulence_step(sds->wt, sds->fluid); + { - // float light[3] = {0.0,0.0,0.0}; // TODO: take real LAMP coordinates - dg Base *base_tmp = NULL; for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 26e3d5bf6f1..aaba65b21af 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3695,7 +3695,8 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) smd->domain->view3d = NULL; smd->domain->tex = NULL; - direct_link_pointcache_list(fd, &smd->domain->ptcaches, &smd->domain->point_cache); + direct_link_pointcache_list(fd, &(smd->domain->ptcaches[0]), &(smd->domain->point_cache[0])); + direct_link_pointcache_list(fd, &(smd->domain->ptcaches[1]), &(smd->domain->point_cache[1])); } else if(smd->type==MOD_SMOKE_TYPE_FLOW) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index eb3f17f368c..26fd0cf6af6 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1136,7 +1136,10 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) */ if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) - write_pointcaches(wd, &smd->domain->ptcaches); + { + write_pointcaches(wd, &(smd->domain->ptcaches[0])); + write_pointcaches(wd, &(smd->domain->ptcaches[1])); + } } else if(md->type==eModifierType_Fluidsim) { FluidsimModifierData *fluidmd = (FluidsimModifierData*) md; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index bcb962bdcd7..6cf229ead31 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5316,7 +5316,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) md = modifiers_findByType(ob, eModifierType_Smoke); if (md) { SmokeModifierData *smd = (SmokeModifierData *)md; - if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) { + if(smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain && smd->domain->fluid) { GPU_create_smoke(smd); draw_volume(scene, ar, v3d, base, smd->domain->tex, smd->domain->res); GPU_free_smoke(smd); diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h index 542281e1960..a8ab4734af0 100644 --- a/source/blender/makesdna/DNA_smoke_types.h +++ b/source/blender/makesdna/DNA_smoke_types.h @@ -67,8 +67,8 @@ typedef struct SmokeDomainSettings { short diss_percent; short pad; int diss_speed;/* in frames */ - struct PointCache *point_cache; /* definition is in DNA_object_force.h */ - struct ListBase ptcaches; + struct PointCache *point_cache[2]; /* definition is in DNA_object_force.h */ + struct ListBase ptcaches[2]; struct WTURBULENCE *wt; // WTURBULENCE object, if active int pad3; float strength; diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index e671665bd17..5ef25edacf7 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -177,7 +177,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_range(prop, 1.0, 100.0); RNA_def_property_ui_range(prop, 1.0, 1000.0, 1, 0); RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "highres", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES); @@ -195,7 +195,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "point_cache"); + RNA_def_property_pointer_sdna(prop, NULL, "point_cache[0]"); RNA_def_property_struct_type(prop, "PointCache"); RNA_def_property_ui_text(prop, "Point Cache", ""); @@ -224,12 +224,10 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Strength", "Strength of wavelet noise"); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - /* - prop= RNA_def_property(srna, "point_cache_hr", PROP_POINTER, PROP_NEVER_NULL); - RNA_def_property_pointer_sdna(prop, NULL, "point_cache"); + prop= RNA_def_property(srna, "point_cache_turbulence", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "point_cache[1]"); RNA_def_property_struct_type(prop, "PointCache"); RNA_def_property_ui_text(prop, "Point Cache", ""); - */ } static void rna_def_smoke_flow_settings(BlenderRNA *brna) |