diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2009-08-26 01:53:52 +0400 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2009-08-26 01:53:52 +0400 |
commit | 6a5773d4a8633374a1f54864c077a0cd5fa122ea (patch) | |
tree | 72454f9913ebf63c561f9c9e8ddefbb5190771c0 /source/blender/blenkernel | |
parent | cfcd355c27ba1f923d04dec1f735989b260b190c (diff) |
Smoke:
* Deleting high res modifier again
* fixing smoke + continue physics drawing
* fixing cache reset when changing dissolve
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_smoke.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 56 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 17 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/smoke.c | 47 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/smokehighres.c | 137 |
5 files changed, 45 insertions, 216 deletions
diff --git a/source/blender/blenkernel/BKE_smoke.h b/source/blender/blenkernel/BKE_smoke.h index bd8581112f8..fddcf0fea83 100644 --- a/source/blender/blenkernel/BKE_smoke.h +++ b/source/blender/blenkernel/BKE_smoke.h @@ -40,9 +40,5 @@ void smokeModifier_free (struct SmokeModifierData *smd); void smokeModifier_reset(struct SmokeModifierData *smd); void smokeModifier_createType(struct SmokeModifierData *smd); -// high res modifier -void smokeHRModifier_do(struct SmokeHRModifierData *shrmd, struct Scene *scene, struct Object *ob, int useRenderParams, int isFinalCalc); -void smokeHRModifier_free(struct SmokeHRModifierData *shrmd); - #endif /* BKE_SMOKE_H_ */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c78227a363f..7a0eb882083 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5879,50 +5879,6 @@ static void smokeModifier_updateDepgraph( */ } - -/* Smoke High Resolution */ - -static void smokeHRModifier_initData(ModifierData *md) -{ - SmokeHRModifierData *shrmd = (SmokeHRModifierData*) md; - - shrmd->wt = NULL; - shrmd->time = -1; - shrmd->strength = 2.0f; - shrmd->amplify = 1; - shrmd->noise = MOD_SMOKE_NOISEWAVE; - shrmd->point_cache = BKE_ptcache_add(&shrmd->ptcaches); - shrmd->point_cache->flag |= PTCACHE_DISK_CACHE; - shrmd->point_cache->step = 1; -} - -static void smokeHRModifier_freeData(ModifierData *md) -{ - SmokeHRModifierData *shrmd = (SmokeHRModifierData*) md; - - smokeHRModifier_free (shrmd); -} - -static void smokeHRModifier_deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int useRenderParams, int isFinalCalc) -{ - SmokeHRModifierData *shrmd = (SmokeHRModifierData*) md; - smokeHRModifier_do(shrmd, md->scene, ob, useRenderParams, isFinalCalc); -} - -static int smokeHRModifier_dependsOnTime(ModifierData *md) -{ - return 1; -} - -static void smokeHRModifier_updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, Object *ob, - DagNode *obNode) -{ - ; -} - /* Cloth */ static void clothModifier_initData(ModifierData *md) @@ -8624,18 +8580,6 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) mti->deformVerts = smokeModifier_deformVerts; mti->dependsOnTime = smokeModifier_dependsOnTime; mti->updateDepgraph = smokeModifier_updateDepgraph; - - mti = INIT_TYPE(SmokeHR); - mti->type = eModifierTypeType_OnlyDeform; - mti->initData = smokeHRModifier_initData; - mti->freeData = smokeHRModifier_freeData; - mti->flags = eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single - | eModifierTypeFlag_NoUserAdd; - mti->deformVerts = smokeHRModifier_deformVerts; - mti->dependsOnTime = smokeHRModifier_dependsOnTime; - mti->updateDepgraph = smokeHRModifier_updateDepgraph; mti = INIT_TYPE(Cloth); mti->type = eModifierTypeType_Nonconstructive; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 4110570760f..d9740091912 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -479,23 +479,6 @@ static int ptcache_totpoint_smoke(void *smoke_v) return 0; } -static int ptcache_totpoint_smoke_turbulence(void *smoke_v) -{ - SmokeHRModifierData *shrmd= (SmokeHRModifierData *)smoke_v; - - if(shrmd->wt) { - /* - unsigned int res[3]; - - smoke_turbulence_get_res(sds->wt, res); - return res[0]*res[1]*res[2]; - */ - return 0; - } - else - return 0; -} - // forward decleration static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 7af67364bc5..28d1c264376 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -213,6 +213,14 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive smd->time = scene->r.cfra; smd->domain->firstframe = smd->time; + /* + if(!smd->domain->wt) + { + smd->domain->wt = smoke_turbulence_init(sds->res, smd->domain->amplify + 1, smd->domain->noise); + smoke_turbulence_initBlenderRNA(smd->domain->wt, &smd->domain->strength); + } + */ + if(!smd->domain->view3d) { // TVox is for transparency @@ -518,6 +526,9 @@ void smokeModifier_freeDomain(SmokeModifierData *smd) if(smd->domain->fluid) smoke_free(smd->domain->fluid); + if(smd->domain->wt) + smoke_turbulence_free(smd->domain->wt); + BKE_ptcache_free_list(&smd->domain->ptcaches); smd->domain->point_cache = NULL; @@ -585,6 +596,12 @@ void smokeModifier_reset(struct SmokeModifierData *smd) smoke_free(smd->domain->fluid); smd->domain->fluid = NULL; } + + if(smd->domain->wt) + { + smoke_turbulence_free(smd->domain->wt); + smd->domain->wt = NULL; + } smd->domain->point_cache->flag &= ~PTCACHE_SIMULATION_VALID; smd->domain->point_cache->flag |= PTCACHE_OUTDATED; @@ -663,6 +680,10 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->domain->beta = 0.1; smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG; smd->domain->diss_speed = 5; + smd->domain->strength = 2.0f; + smd->domain->amplify = 1; + smd->domain->noise = MOD_SMOKE_NOISEWAVE; + smd->domain->wt = NULL; // init 3dview buffer smd->domain->view3d = NULL; @@ -783,6 +804,28 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM 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) + { + if(base_tmp->object->type == OB_LAMP) + { + Lamp *la = (Lamp *)base_tmp->object->data; + + if(la->type == LA_LOCAL) + { + VECCOPY(light, base_tmp->object->obmat[3]); + have_lamp = 1; + break; + } + } + } + } + + smoke_prepare_View(smd, (float)framenr, light, have_lamp); + return; } @@ -885,11 +928,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM BKE_ptcache_write_cache(&pid, framenr); - // printf("Writing cache_low\n"); + // printf("Writing cache_low, %d\n", framenr); tend(); - printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); + // printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); } } diff --git a/source/blender/blenkernel/intern/smokehighres.c b/source/blender/blenkernel/intern/smokehighres.c deleted file mode 100644 index 6a2e0549158..00000000000 --- a/source/blender/blenkernel/intern/smokehighres.c +++ /dev/null @@ -1,137 +0,0 @@ -/** - * smokehighres.c - * - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) Blender Foundation. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): Daniel Genrich - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/* Part of the code copied from elbeem fluid library, copyright by Nils Thuerey */ - -#include "DNA_scene_types.h" -#include "DNA_listBase.h" -#include "DNA_modifier_types.h" -#include "DNA_object_types.h" -#include "DNA_smoke_types.h" - -#include "BKE_modifier.h" -#include "BKE_smoke.h" -#include "BKE_pointcache.h" - -#include "smoke_API.h" - -// we need different handling for the high-res feature -/* -if(bigdensity) -{ - // init all surrounding cells according to amplification, too - int i, j, k; - - smoke_turbulence_get_res(smd->domain->wt, bigres); - - 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 + 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; - } -} -*/ - -static void smokeHRinit(SmokeHRModifierData *shrmd, SmokeDomainSettings *sds) -{ - if(!shrmd->wt) - { - shrmd->wt = smoke_turbulence_init(sds->res, shrmd->amplify + 1, shrmd->noise); - smoke_turbulence_initBlenderRNA(shrmd->wt, &shrmd->strength); - } -} - -void smokeHRModifier_free(SmokeHRModifierData *shrmd) -{ - if(shrmd->wt) - smoke_turbulence_free(shrmd->wt); - - BKE_ptcache_free_list(&shrmd->ptcaches); - shrmd->point_cache = NULL; -} - -void smokeHRModifier_do(SmokeHRModifierData *shrmd, Scene *scene, Object *ob, int useRenderParams, int isFinalCalc) -{ - ModifierData *md = NULL; - SmokeModifierData *smd = NULL; - SmokeDomainSettings *sds = NULL; - - // find underlaying smoke domain - smd = (SmokeModifierData *)modifiers_findByType(ob, eModifierType_Smoke); - if(!(smd && smd->type == MOD_SMOKE_TYPE_DOMAIN)) - return; - - sds = smd->domain; - - smokeHRinit(shrmd, sds); - - // smoke_turbulence_dissolve(shrmd->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); - - // smoke_turbulence_step(shrmd->wt, sds->fluid); -} - - -// update necessary information for 3dview ("high res" option) -void smoke_prepare_bigView(SmokeHRModifierData *shrmd, float *light) -{ - float *density = NULL; - size_t i = 0; - int bigres[3]; -/* - smoke_turbulence_get_res(shrmd->wt, bigres); - - if(!smd->domain->traybig) - { - // TRay is for self shadowing - smd->domain->traybig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tRayBig"); - } - if(!smd->domain->tvoxbig) - { - // TVox is for tranaparency - smd->domain->tvoxbig = MEM_callocN(sizeof(float)*bigres[0]*bigres[1]*bigres[2], "Smoke_tVoxBig"); - } - - density = smoke_turbulence_get_density(smd->domain->wt); - for (i = 0; i < bigres[0] * bigres[1] * bigres[2]; i++) - { - // Transparency computation - // 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 + 1)) ); - } - smoke_calc_transparency(smd, light, 1); - */ -} - - |