From ce273aee084fd367245d20a15b307d4ad99584d8 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Fri, 7 Aug 2009 13:19:17 +0000 Subject: smoke: - Bugfix: a bit too fast ;-) Better do it right too (problem with res > 150) - fixing high res view button which disappeared sometimes - fixing tooltip --- intern/smoke/intern/FLUID_3D_SOLVERS.cpp | 6 +- source/blender/blenkernel/intern/smoke.c | 90 +++--------------------------- source/blender/makesrna/intern/rna_smoke.c | 2 +- 3 files changed, 12 insertions(+), 86 deletions(-) diff --git a/intern/smoke/intern/FLUID_3D_SOLVERS.cpp b/intern/smoke/intern/FLUID_3D_SOLVERS.cpp index c6142bbb4bc..51929e1194b 100644 --- a/intern/smoke/intern/FLUID_3D_SOLVERS.cpp +++ b/intern/smoke/intern/FLUID_3D_SOLVERS.cpp @@ -85,7 +85,7 @@ void FLUID_3D::solvePressurePre(float* field, float* b, unsigned char* skip) //while ((i < _iterations) && (deltaNew > eps*delta0)) float maxR = 2.0f * eps; // while (i < _iterations) - while ((i < _iterations) && (maxR > eps)) + while ((i < _iterations) && (maxR > 0.001*eps)) { // (s) q = Ad (p) index = _slabSize + _xRes + 1; @@ -183,7 +183,7 @@ void FLUID_3D::solvePressurePre(float* field, float* b, unsigned char* skip) // i = i + 1 i++; } - cout << i << " iterations converged to " << maxR << endl; + // cout << i << " iterations converged to " << sqrt(maxR) << endl; } ////////////////////////////////////////////////////////////////////// @@ -330,7 +330,7 @@ void FLUID_3D::solvePressure(float* field, float* b, unsigned char* skip) // i = i + 1 i++; } - cout << i << " iterations converged to " << maxR << endl; + // cout << i << " iterations converged to " << maxR << endl; } ////////////////////////////////////////////////////////////////////// diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 3b9f19c5386..0d46e4baa88 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -126,82 +126,6 @@ void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *tris, int n #define TRI_UVOFFSET (1./4.) - -BVHTree *bvhtree_build_from_smoke ( float mat[4][4], MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon ) -{ - BVHTree *tree; - float co[12]; - int i; - MFace *tface = mfaces; - - // calc quads - // todo - - tree = BLI_bvhtree_new ( numfaces, epsilon, 2, 6 ); - - // fill tree - for ( i = 0; i < numfaces; i++, tface++ ) - { - VECCOPY ( &co[0*3], x[tface->v1].co ); - Mat4MulVecfl (mat, &co[0*3]); - VECCOPY ( &co[1*3], x[tface->v2].co ); - Mat4MulVecfl (mat, &co[1*3]); - VECCOPY ( &co[2*3], x[tface->v3].co ); - Mat4MulVecfl (mat, &co[2*3]); - - if ( tface->v4 ) - { - VECCOPY ( &co[3*3], x[tface->v4].co ); - Mat4MulVecfl (mat, &co[3*3]); - } - - BLI_bvhtree_insert ( tree, i, co, ( mfaces->v4 ? 4 : 3 ) ); - } - - // balance tree - BLI_bvhtree_balance ( tree ); - - return tree; -} - -void bvhtree_update_from_smoke ( float mat[4][4], BVHTree * bvhtree, MFace *faces, int numfaces, MVert *x, int numverts) -{ - int i; - MFace *mfaces = faces; - float co[12]; - int ret = 0; - - if ( !bvhtree ) - return; - - if ( x ) - { - for ( i = 0; i < numfaces; i++, mfaces++ ) - { - VECCOPY ( &co[0*3], x[mfaces->v1].co ); - Mat4MulVecfl (mat, &co[0*3]); - VECCOPY ( &co[1*3], x[mfaces->v2].co ); - Mat4MulVecfl (mat, &co[1*3]); - VECCOPY ( &co[2*3], x[mfaces->v3].co ); - Mat4MulVecfl (mat, &co[2*3]); - - if ( mfaces->v4 ) - { - VECCOPY ( &co[3*3], x[mfaces->v4].co ); - Mat4MulVecfl (mat, &co[3*3]); - } - - ret = BLI_bvhtree_update_node ( bvhtree, i, co, NULL, ( mfaces->v4 ? 4 : 3 ) ); - - // check if tree is already full - if ( !ret ) - break; - } - - BLI_bvhtree_update_tree ( bvhtree ); - } -} - int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm) { if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid) @@ -641,7 +565,14 @@ void smokeModifier_reset(struct SmokeModifierData *smd) smd->domain->bind = NULL; } smd->domain->max_textures = 0; - smd->domain->viewsettings = 0; // reset view for new frame + if(smd->domain->viewsettings < MOD_SMOKE_VIEW_USEBIG) + { + smd->domain->viewsettings = 0; + } + else + { + smd->domain->viewsettings = MOD_SMOKE_VIEW_USEBIG; + } if(smd->domain->tray) MEM_freeN(smd->domain->tray); @@ -795,11 +726,6 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM // XXX TODO smd->time = scene->r.cfra; - if(smd->coll->bvhtree) - bvhtree_update_from_smoke ( ob->obmat, smd->coll->bvhtree, dm->getFaceArray(dm), dm->getNumFaces(dm), dm->getVertArray(dm), dm->getNumVerts(dm)); - else - printf("smoke coll with no bvh\n"); - if(smd->coll->dm) smd->coll->dm->release(smd->coll->dm); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index eb9d09564ae..eefafcc32b4 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -155,7 +155,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "viewhighres", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "viewsettings", MOD_SMOKE_VIEW_USEBIG); - RNA_def_property_ui_text(prop, "Show high res", "Show high resolution (using amplification)."); + RNA_def_property_ui_text(prop, "Show High Resolution", "Show high resolution (using amplification)."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_redraw"); prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); -- cgit v1.2.3