[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47920] branches/smoke2: - Fix moving obstacles: Velocity near the border of moving obstacles was set to zero.
Daniel Genrich
daniel.genrich at gmx.net
Thu Jun 14 23:45:54 CEST 2012
Revision: 47920
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47920
Author: genscher
Date: 2012-06-14 21:45:41 +0000 (Thu, 14 Jun 2012)
Log Message:
-----------
- Fix moving obstacles: Velocity near the border of moving obstacles was set to zero.
- Fix drawing of obstacles: Did not draw all obstacle cells
Modified Paths:
--------------
branches/smoke2/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
branches/smoke2/source/blender/blenkernel/intern/smoke.c
branches/smoke2/source/blender/editors/space_view3d/drawvolume.c
Modified: branches/smoke2/intern/smoke/intern/FLUID_3D_SOLVERS.cpp
===================================================================
--- branches/smoke2/intern/smoke/intern/FLUID_3D_SOLVERS.cpp 2012-06-14 20:15:55 UTC (rev 47919)
+++ branches/smoke2/intern/smoke/intern/FLUID_3D_SOLVERS.cpp 2012-06-14 21:45:41 UTC (rev 47920)
@@ -323,7 +323,7 @@
// i = i + 1
i++;
}
- cout << i << " iterations converged to " << sqrt(maxR) << endl;
+ // cout << i << " iterations converged to " << sqrt(maxR) << endl;
if (_h) delete[] _h;
if (_Precond) delete[] _Precond;
Modified: branches/smoke2/source/blender/blenkernel/intern/smoke.c
===================================================================
--- branches/smoke2/source/blender/blenkernel/intern/smoke.c 2012-06-14 20:15:55 UTC (rev 47919)
+++ branches/smoke2/source/blender/blenkernel/intern/smoke.c 2012-06-14 21:45:41 UTC (rev 47920)
@@ -103,7 +103,7 @@
{
QueryPerformanceCounter ( &liCurrentTime );
}
-static double UNUSED_FUNCTION(tval)( void )
+static double tval( void )
{
return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart ));
}
@@ -631,8 +631,6 @@
static void obstacles_from_derivedmesh(Object *coll_ob, SmokeDomainSettings *sds, SmokeCollSettings *scs, unsigned char *obstacle_map, float *velocityX, float *velocityY, float *velocityZ, float dt)
{
- printf("obstacles_from_derivedmesh\n");
-
if (!scs->dm) return;
{
DerivedMesh *dm = NULL;
@@ -642,12 +640,15 @@
BVHTreeFromMesh treeData = {0};
int numverts, i, z;
int *res = sds->res;
+ float *density = smoke_get_density(sds->fluid);
- float surface_distance = 0.5f + FLT_EPSILON;
+ float surface_distance = 0.6;
float *vert_vel = NULL;
int has_velocity = 0;
+ tstart();
+
dm = CDDM_copy(scs->dm);
CDDM_calc_normals(dm);
mvert = dm->getVertArray(dm);
@@ -655,9 +656,10 @@
numverts = dm->getNumVerts(dm);
dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT);
- printf("obstacles_from_derivedmesh with DM\n");
-
// DG TODO
+ // if(scs->type > SM_COLL_STATIC)
+ // if line above is used, the code is in trouble if the object moves but is declared as "does not move"
+
// if (sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY)
{
vert_vel = MEM_callocN(sizeof(float) * numverts * 3, "smoke_obs_velocity");
@@ -755,9 +757,11 @@
}
/* tag obstacle cells */
- obstacle_map[index] = 1 | 8;
+ obstacle_map[index] = 1;
+ density[index] = 0.0f;
- // DEBUG printf("added obstacle\n");
+ if(has_velocity)
+ obstacle_map[index] |= 8;
}
}
}
@@ -768,6 +772,9 @@
if (vert_vel) MEM_freeN(vert_vel);
+ tend();
+ printf ( "Time: %f\n\n", ( float ) tval() );
+
}
}
@@ -793,14 +800,16 @@
// TODO: delete old obstacle flags
for(z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
{
- //if(obstacles[z])
- // {
+#if 0
+ if(obstacles[z])
+ {
// density[z] = 0;
- //velxOrig[z] = 0;
- //velyOrig[z] = 0;
- //velzOrig[z] = 0;
- //}
+ velxOrig[z] = 0;
+ velyOrig[z] = 0;
+ velzOrig[z] = 0;
+ }
+#endif
if(obstacles[z] & 8) // Do not delete static obstacles
{
@@ -832,6 +841,17 @@
if(collobjs)
MEM_freeN(collobjs);
+
+ /* obstacle cells should not contain any velocity from the smoke simulation */
+ for(z = 0; z < sds->res[0] * sds->res[1] * sds->res[2]; z++)
+ {
+ if(obstacles[z])
+ {
+ velxOrig[z] = 0;
+ velyOrig[z] = 0;
+ velzOrig[z] = 0;
+ }
+ }
}
static void update_flowsfluids(Scene *scene, Object *ob, SmokeDomainSettings *sds, float time)
@@ -1281,8 +1301,6 @@
smd->coll->dm = CDDM_copy(dm);
DM_ensure_tessface(smd->coll->dm);
-
- printf("Collision: Created dm!\n");
}
if(scene->r.cfra > smd->time)
@@ -1354,7 +1372,7 @@
if (framenr != scene->r.cfra)
return;
- tstart();
+ // tstart();
smoke_calc_domain(scene, ob, smd);
@@ -1406,7 +1424,7 @@
if(framenr != startframe)
BKE_ptcache_write(&pid, framenr);
- tend();
+ //tend();
// printf ( "Frame: %d, Time: %f\n\n", (int)smd->time, ( float ) tval() );
}
}
Modified: branches/smoke2/source/blender/editors/space_view3d/drawvolume.c
===================================================================
--- branches/smoke2/source/blender/editors/space_view3d/drawvolume.c 2012-06-14 20:15:55 UTC (rev 47919)
+++ branches/smoke2/source/blender/editors/space_view3d/drawvolume.c 2012-06-14 21:45:41 UTC (rev 47920)
@@ -507,7 +507,8 @@
float *min = domain->p0;
float cell_size = domain->dx * domain->scale;
- float step_size = ((float)MAX3(res[0], res[1], res[2]))/16.f;
+ //float step_size = ((float)MAX3(res[0], res[1], res[2]))/16.f;
+ float step_size = 1.0f;
for (x=0; x<res[0]; x+=step_size)
for (y=0; y<res[1]; y+=step_size)
More information about the Bf-blender-cvs
mailing list