Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorNils Thuerey <nils@thuerey.de>2006-11-05 19:30:29 +0300
committerNils Thuerey <nils@thuerey.de>2006-11-05 19:30:29 +0300
commit3bea663ffa27cab0a60b3ed1ac41d431ce55cecc (patch)
treec58fa1f791654b0b5e0d4057a0ec38ce541038c5 /source
parent64b9cda68eb4cd25bc9ce37d710a603b2fc4c81d (diff)
- bugfixes
#4742 exported normals are now correct #4821 & 4956 for complex movements in/outflows can now also use the animated mesh option - new features * isosurface subdivision: directly creates a finer surface mesh from the simulation data. this increases simulation time and harddisk usage, though, so be careful - usually values of 2-4 should be enough. * fluidsim particles: extended model for particle simulation and generation. When isosurface subdivision is enabled, the particles are now included in the surface generation, giving a better impression of a single connected surface. Note - the particles are only included in the final surface mesh, so the preview surface shows none of the particle effects. * particle loading: different types of particles can now be selected for display: drops, floats and tracers. This is a bit obsolete due to the extensions mentioned above, but might still be useful. Floats are just particles floating on the fluid surface, could be used for e.g. foam. * moving objects impact factor: this is another tweaking option, as the handling of moving objects is still not conserving mass. setting this to zero simply deletes the fluid, 1 is the default, while larger values cause a stronger impact. For tweaking the simulation: if fluid disappears, try increasing this value, and if too much is appearing reduce it. You can even use negative values for some strange results :) - more code cleanup, e.g. removed config file writing in fluidsim.c, added additional safety checks for particles & fluidsim domains (these currently dont work together). I also removed the "build particles" debug message in effects.c (seemed to be unnecessary?). Some more info on the new features: Here are two test animations showing the difference between using the particle generation with isosurface subdivision. This is how it would look with the old solver version: http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_1noparts.mpg and this with the new one: http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_fl6manc4_2wparts.mpg Both simulations use a resolution of 64, however, the version with particles takes significantly longer (almost twice as long). The .blend file for a similar setup can be found here: http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_testmanc4.blend (Minor Tips for this file: dont enable subdivions of characters until rendering, thus leave off for simulation, as it uses the rendering settings! For making nice pictures switch on subdivion, and OSA.) And here's a picture of old vs. new (for webpage or so): http://www10.informatik.uni-erlangen.de/~sinithue/blender/fluid6_manc4compare.png
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c4
-rw-r--r--source/blender/blenkernel/intern/effect.c14
-rw-r--r--source/blender/makesdna/DNA_object_fluidsim.h3
-rw-r--r--source/blender/src/buttons_object.c82
-rw-r--r--source/blender/src/fluidsim.c296
5 files changed, 85 insertions, 314 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 3ccdbe130a6..4dacfdc85d8 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -917,6 +917,7 @@ static DerivedMesh *getMeshDerivedMesh(Mesh *me, Object *ob, float (*vertCos)[3]
if((ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
(ob->fluidsimSettings->type & OB_FLUIDSIM_DOMAIN)&&
(ob->fluidsimSettings->meshSurface) &&
+ (1) && (!give_parteff(ob)) && // doesnt work together with particle systems!
(me->totvert == ((Mesh *)(ob->fluidsimSettings->meshSurface))->totvert) ) {
// dont recompute for fluidsim mesh, use from readBobjgz
// TODO? check for modifiers!?
@@ -2816,7 +2817,8 @@ static void mesh_calc_modifiers(Object *ob, float (*inputVertexCos)[3],
* domain objects
*/
if((G.obedit!=ob) && !needMapping) {
- if (ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
+ if((ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
+ (1) && (!give_parteff(ob)) ) { // doesnt work together with particle systems!
if(ob->fluidsimSettings->type & OB_FLUIDSIM_DOMAIN) {
loadFluidsimMesh(ob,useRenderParams);
fluidsimMeshUsed = 1;
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index a22bdad628e..08ea3b9abe1 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -1685,11 +1685,11 @@ void build_particle_system(Object *ob)
if(paf->keys) MEM_freeN(paf->keys); /* free as early as possible, for returns */
paf->keys= NULL;
- printf("build particles\n");
+ //printf("build particles\n");
- /* fluid sim particle import handling, actual loading */
+ /* fluid sim particle import handling, actual loading of particles from file */
#ifndef DISABLE_ELBEEM
- if( (1) && (ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
+ if( (1) && (ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) && // broken, disabled for now!
(ob->fluidsimSettings) &&
(ob->fluidsimSettings->type == OB_FLUIDSIM_PARTICLE)) {
char *suffix = "fluidsurface_particles_#";
@@ -1702,7 +1702,7 @@ void build_particle_system(Object *ob)
float vel[3];
if(ob==G.obedit) { // off...
- paf->totpart = 1;
+ paf->totpart = 0; // 1 or 0?
return;
}
@@ -1715,8 +1715,10 @@ void build_particle_system(Object *ob)
gzf = gzopen(filename, "rb");
if (!gzf) {
snprintf(debugStrBuffer,256,"readFsPartData::error - Unable to open file for reading '%s' \n", filename);
+fprintf(stderr,"readFsPartData::error - Unable to open file for reading '%s' \n", filename); // DEBUG!
//elbeemDebugOut(debugStrBuffer);
- paf->totpart = 1;
+ //fprintf(stderr,"NO PARTOP!\n");
+ paf->totpart = 0;
return;
}
@@ -1753,7 +1755,7 @@ void build_particle_system(Object *ob)
// convert range of 1.0-10.0 to shorts 1000-10000)
shsize = (short)(convertSize*1000.0);
pa->rt = shsize;
- //if(a<200) fprintf(stderr,"SREAD %f %d %d \n",convertSize,shsize,pa->rt);
+ //if(a<200) fprintf(stderr,"SREAD, %d/%d: %f %d %d \n",a,totpart, convertSize,shsize,pa->rt);
for(j=0; j<3; j++) {
float wrf;
diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h
index 5ddfc22045d..91c25d2ec1d 100644
--- a/source/blender/makesdna/DNA_object_fluidsim.h
+++ b/source/blender/makesdna/DNA_object_fluidsim.h
@@ -109,6 +109,9 @@ typedef struct FluidsimSettings {
float generateParticles;
/* smooth fluid surface? */
float surfaceSmoothing;
+ /* number of surface subdivisions*/
+ int surfaceSubdivs;
+ int unusedDNADummy;
/* particle display - size scaling, and alpha influence */
float particleInfSize, particleInfAlpha;
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 65cf065bd66..8f05e20af0c 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -1608,21 +1608,24 @@ void do_object_panels(unsigned short event)
break;
case B_FLUIDSIM_MAKEPART:
ob= OBACT;
- {
+ if(1) {
PartEff *paf= NULL;
/* prepare fluidsim particle display */
// simplified delete effect, create new - recalc some particles...
if(ob==NULL || ob->type!=OB_MESH) break;
ob->fluidsimSettings->type = 0;
// reset type, and init particle system once normally
- eff= ob->effect.first;
- //if((eff) && (eff->flag & SELECT)) { BLI_remlink(&ob->effect, eff); free_effect(eff); }
- if(!eff){ copy_act_effect(ob); DAG_scene_sort(G.scene); }
+ paf= give_parteff(ob);
+ if( (BLI_countlist(&ob->effect)<MAX_EFFECT) &&
+ (!paf)) {
+ // create new entry
+ copy_act_effect(ob); DAG_scene_sort(G.scene); }
paf = give_parteff(ob);
- paf->totpart = 1000; paf->sta = paf->end = 1.0; // generate some particles...
- build_particle_system(ob);
-
- ob->fluidsimSettings->type = OB_FLUIDSIM_PARTICLE;
+ if(paf) {
+ paf->totpart = 1000; paf->sta = paf->end = 1.0; // generate some particles...
+ build_particle_system(ob);
+ ob->fluidsimSettings->type = OB_FLUIDSIM_PARTICLE;
+ }
}
allqueue(REDRAWVIEW3D, 0);
allqueue(REDRAWBUTSOBJECT, 0);
@@ -1977,6 +1980,14 @@ void do_effects_panels(unsigned short event)
break;
case B_NEWEFFECT:
if(ob) {
+ if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
+ // NT particles and fluid meshes currently dont work together -> switch off beforehand
+ if(ob->fluidsimSettings->type == OB_FLUIDSIM_DOMAIN) {
+ pupmenu("Fluidsim Particle Error%t|Please disable the fluidsim domain before activating particles.%x0");
+ break;
+ //ob->fluidsimFlag = 0; ob->fluidsimSettings->type = 0; allqueue(REDRAWVIEW3D, 0);
+ }
+ }
if (BLI_countlist(&ob->effect)==MAX_EFFECT)
error("Unable to add: effect limit reached");
else
@@ -2610,8 +2621,8 @@ static void object_panel_fluidsim(Object *ob)
uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Obstacle", 230, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_OBSTACLE,20.0, 3.0, "Object is a fixed obstacle.");
yline -= lineHeight;
- uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Inflow", 90, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_INFLOW, 20.0, 4.0, "Object adds fluid to the simulation.");
- uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Outflow", 160, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_OUTFLOW, 20.0, 5.0, "Object removes fluid from the simulation.");
+ uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Inflow", 90, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_INFLOW, 20.0, 4.0, "Object adds fluid to the simulation.");
+ uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Outflow", 160, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_OUTFLOW, 20.0, 5.0, "Object removes fluid from the simulation.");
uiDefButS(block, ROW, B_FLUIDSIM_MAKEPART ,"Particle", 230, yline, 70,objHeight, &fss->type, 15.0, OB_FLUIDSIM_PARTICLE,20.0, 3.0, "Object is made a particle system to display particles generated by a fluidsim domain object.");
uiBlockEndAlign(block);
yline -= lineHeight;
@@ -2689,7 +2700,7 @@ static void object_panel_fluidsim(Object *ob)
uiDefButS(block, MENU, REDRAWVIEW3D, "Viscosity%t|Manual %x1|Water %x2|Oil %x3|Honey %x4",
0,yline, 90,objHeight, &fss->viscosityMode, 0, 0, 0, 0, "Set viscosity of the fluid to a preset value, or use manual input.");
if(fss->viscosityMode==1) {
- uiDefButF(block, NUM, B_DIFF, "Value:", 90, yline, 105,objHeight, &fss->viscosityValue, 0.0, 1.0, 10, 0, "Viscosity setting, value that is multiplied by 10 to the power of (exponent*-1).");
+ uiDefButF(block, NUM, B_DIFF, "Value:", 90, yline, 105,objHeight, &fss->viscosityValue, 0.0, 10.0, 10, 0, "Viscosity setting, value that is multiplied by 10 to the power of (exponent*-1).");
uiDefButS(block, NUM, B_DIFF, "Neg-Exp.:", 195, yline, 105,objHeight, &fss->viscosityExponent, 0, 10, 10, 0, "Negative exponent for the viscosity value (to simplify entering small values e.g. 5*10^-6.");
uiBlockEndAlign(block);
} else {
@@ -2715,8 +2726,8 @@ static void object_panel_fluidsim(Object *ob)
} else if(fss->show_advancedoptions == 2) {
// copied from obstacle...
//yline -= lineHeight + 5;
- uiDefBut(block, LABEL, 0, "Domain boundary type settings:", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
- yline -= lineHeight;
+ //uiDefBut(block, LABEL, 0, "Domain boundary type settings:", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
+ //yline -= lineHeight;
uiBlockBeginAlign(block); // domain
uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Noslip", 0, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_NOSLIP, 20.0, 1.0, "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects.");
@@ -2725,11 +2736,13 @@ static void object_panel_fluidsim(Object *ob)
uiBlockEndAlign(block);
yline -= lineHeight;
- uiDefBut(block, LABEL, 0, "PartSlipValue:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
if(fss->typeFlags&OB_FSBND_PARTSLIP) {
+ uiDefBut(block, LABEL, 0, "PartSlipValue:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->partSlipValue, 0.0, 1.0, 10,0, ".");
- } else { uiDefBut(block, LABEL, 0, "-", 200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, ""); }
- yline -= lineHeight;
+ yline -= lineHeight;
+ } else {
+ //uiDefBut(block, LABEL, 0, "-", 200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, "");
+ }
// copied from obstacle...
uiDefBut(block, LABEL, 0, "Tracer Particles:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
@@ -2738,6 +2751,9 @@ static void object_panel_fluidsim(Object *ob)
uiDefBut(block, LABEL, 0, "Generate Particles:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->generateParticles, 0.0, 10.0, 10,0, "Amount of particles to generate (0=off, 1=normal, >1=more).");
yline -= lineHeight;
+ uiDefBut(block, LABEL, 0, "Surface Subdiv:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
+ uiDefButI(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->surfaceSubdivs, 0.0, 5.0, 10,0, "Number of isosurface subdivisions. This is necessary for the inclusion of particles into the surface generation. Warning - can lead to longer computation times!");
+ yline -= lineHeight;
uiDefBut(block, LABEL, 0, "Surface Smoothing:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->surfaceSmoothing, 0.0, 5.0, 10,0, "Amount of surface smoothing (0=off, 1=normal, >1=stronger smoothing).");
@@ -2777,6 +2793,12 @@ static void object_panel_fluidsim(Object *ob)
yline -= lineHeight;
} else {
}
+
+ // domainNovecgen "misused" here
+ uiDefBut(block, LABEL, 0, "Animated Mesh:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
+ uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Export", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it.");
+ yline -= lineHeight;
+
} // fluid inflow
else if( (fss->type == OB_FLUIDSIM_OUTFLOW) ) {
yline -= lineHeight + 5;
@@ -2788,6 +2810,11 @@ static void object_panel_fluidsim(Object *ob)
uiBlockEndAlign(block);
yline -= lineHeight;
+ // domainNovecgen "misused" here
+ uiDefBut(block, LABEL, 0, "Animated Mesh:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
+ uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Export", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it.");
+ yline -= lineHeight;
+
//uiDefBut(block, LABEL, 0, "No additional settings as of now...", 0,yline,300,objHeight, NULL, 0.0, 0, 0, 0, "");
}
else if( (fss->type == OB_FLUIDSIM_OBSTACLE) ) {
@@ -2801,7 +2828,7 @@ static void object_panel_fluidsim(Object *ob)
yline -= lineHeight;
uiBlockBeginAlign(block); // obstacle
- uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Noslip", 00, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_NOSLIP, 20.0, 1.0, "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects.");
+ uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Noslip", 0, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_NOSLIP, 20.0, 1.0, "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects.");
uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Part", 100, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_PARTSLIP, 20.0, 2.0, "Mix between no-slip and free-slip. Non moving objects only!");
uiDefButS(block, ROW, REDRAWBUTSOBJECT ,"Free", 200, yline,100,objHeight, &fss->typeFlags, 15.0, OB_FSBND_FREESLIP, 20.0, 3.0, "Obstacle only causes zero normal velocity (=not sticky). Non moving objects only!");
uiBlockEndAlign(block);
@@ -2809,7 +2836,7 @@ static void object_panel_fluidsim(Object *ob)
// domainNovecgen "misused" here
uiDefBut(block, LABEL, 0, "Animated Mesh:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
- uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Export", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures), animated pos/rot/scale IPOs do not require it.");
+ uiDefButBitC(block, TOG, 1, REDRAWBUTSOBJECT, "Export", 200, yline,100,objHeight, &fss->domainNovecgen, 0, 0, 0, 0, "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it.");
yline -= lineHeight;
uiDefBut(block, LABEL, 0, "PartSlip Amount:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
@@ -2818,12 +2845,25 @@ static void object_panel_fluidsim(Object *ob)
} else { uiDefBut(block, LABEL, 0, "-", 200,yline,100,objHeight, NULL, 0.0, 0, 0, 0, ""); }
yline -= lineHeight;
+ // generateParticles "misused" here
+ uiDefBut(block, LABEL, 0, "Impact Factor:", 0,yline,200,objHeight, NULL, 0.0, 0, 0, 0, "");
+ uiDefButF(block, NUM, B_DIFF, "", 200, yline,100,objHeight, &fss->surfaceSmoothing, -2.0, 10.0, 10,0, "This is an unphsyical value for moving objects - it control the impact an obstacle has on the fluid, =0 behaves a bit like outflow (deleting fluid), =1 is default, while >1 results in high forces. Can be used to tweak total mass.");
+ yline -= lineHeight;
+
yline -= lineHeight; // obstacle
}
else if(fss->type == OB_FLUIDSIM_PARTICLE) {
+
+ //fss->type == 0; // off, broken...
+ if(1) {
+ // limited selection, old fixed: fss->typeFlags = (1<<5)|(1<<1);
+# define PARTBUT_WIDTH (300/3)
+ uiDefButBitS(block, TOG, (1<<2) , REDRAWBUTSOBJECT, "Drops", 0*PARTBUT_WIDTH, yline, PARTBUT_WIDTH,objHeight, &fss->typeFlags, 0, 0, 0, 0, "Show drop particles.");
+ uiDefButBitS(block, TOG, (1<<4) , REDRAWBUTSOBJECT, "Floats", 1*PARTBUT_WIDTH, yline, PARTBUT_WIDTH,objHeight, &fss->typeFlags, 0, 0, 0, 0, "Show floating foam particles.");
+ uiDefButBitS(block, TOG, (1<<5) , REDRAWBUTSOBJECT, "Tracer", 2*PARTBUT_WIDTH, yline, PARTBUT_WIDTH,objHeight, &fss->typeFlags, 0, 0, 0, 0, "Show tracer particles.");
+ yline -= lineHeight;
+# undef PARTBUT_WIDTH
- // fixed for now
- fss->typeFlags = (1<<5)|(1<<1);
uiDefBut(block, LABEL, 0, "Size Influence:", 0,yline,150,objHeight, NULL, 0.0, 0, 0, 0, "");
uiDefButF(block, NUM, B_DIFF, "", 150, yline,150,objHeight, &fss->particleInfSize, 0.0, 2.0, 10,0, "Amount of particle size scaling: 0=off (all same size), 1=full (range 0.2-2.0), >1=stronger.");
@@ -2840,7 +2880,7 @@ static void object_panel_fluidsim(Object *ob)
uiDefBut(block, TEX, B_FLUIDSIM_FORCEREDRAW,"", 20, yline, 280, objHeight, fss->surfdataPath, 0.0,79.0, 0, 0, "Enter fluid simulation bake directory/prefix to load particles from, same as for domain object.");
uiBlockEndAlign(block);
yline -= lineHeight;
-
+ } // disabled for now...
}
else {
diff --git a/source/blender/src/fluidsim.c b/source/blender/src/fluidsim.c
index c555aea654e..2103d39a753 100644
--- a/source/blender/src/fluidsim.c
+++ b/source/blender/src/fluidsim.c
@@ -199,6 +199,7 @@ FluidsimSettings *fluidsimSettingsNew(struct Object *srcob)
fss->bbSize[2] = 1.0;
fluidsimGetAxisAlignedBB(srcob->data, srcob->obmat, fss->bbStart, fss->bbSize, &fss->meshBB);
+ // todo - reuse default init from elbeem!
fss->typeFlags = 0;
fss->domainNovecgen = 0;
fss->volumeInitType = 1; // volume
@@ -207,6 +208,7 @@ FluidsimSettings *fluidsimSettingsNew(struct Object *srcob)
fss->generateTracers = 0;
fss->generateParticles = 0.0;
fss->surfaceSmoothing = 1.0;
+ fss->surfaceSubdivs = 1.0;
fss->particleInfSize = 0.0;
fss->particleInfAlpha = 0.0;
@@ -915,6 +917,7 @@ void fluidsimBake(struct Object *ob)
fsset.generateParticles = domainSettings->generateParticles;
fsset.numTracerParticles = domainSettings->generateTracers;
fsset.surfaceSmoothing = domainSettings->surfaceSmoothing;
+ fsset.surfaceSubdivs = domainSettings->surfaceSubdivs;
fsset.farFieldSize = domainSettings->farFieldSize;
strcpy( fsset.outputPath, targetFile);
@@ -929,10 +932,10 @@ void fluidsimBake(struct Object *ob)
fsset.runsimCallback = &runSimulationCallback;
fsset.runsimUserData = &fsset;
- if( (domainSettings->typeFlags&OB_FSBND_NOSLIP)) fsset.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP;
- else if((domainSettings->typeFlags&OB_FSBND_PARTSLIP)) fsset.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP;
- else if((domainSettings->typeFlags&OB_FSBND_FREESLIP)) fsset.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
- fsset.obstaclePartslip = domainSettings->partSlipValue;
+ if( (domainSettings->typeFlags&OB_FSBND_NOSLIP)) fsset.domainobsType = FLUIDSIM_OBSTACLE_NOSLIP;
+ else if((domainSettings->typeFlags&OB_FSBND_PARTSLIP)) fsset.domainobsType = FLUIDSIM_OBSTACLE_PARTSLIP;
+ else if((domainSettings->typeFlags&OB_FSBND_FREESLIP)) fsset.domainobsType = FLUIDSIM_OBSTACLE_FREESLIP;
+ fsset.domainobsPartslip = domainSettings->partSlipValue;
fsset.generateVertexVectors = (domainSettings->domainNovecgen==0);
// init blender trafo matrix
@@ -962,7 +965,7 @@ void fluidsimBake(struct Object *ob)
int *tris=NULL;
int numVerts=0, numTris=0;
int o = channelObjCount;
- int deform = (obit->fluidsimSettings->domainNovecgen);
+ int deform = (obit->fluidsimSettings->domainNovecgen); // misused value
elbeemMesh fsmesh;
elbeemResetMesh( &fsmesh );
fsmesh.type = obit->fluidsimSettings->type;;
@@ -996,6 +999,7 @@ void fluidsimBake(struct Object *ob)
else if((obit->fluidsimSettings->typeFlags&OB_FSBND_FREESLIP)) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP;
fsmesh.obstaclePartslip = obit->fluidsimSettings->partSlipValue;
fsmesh.volumeInitType = obit->fluidsimSettings->volumeInitType;
+ fsmesh.obstacleImpactFactor = obit->fluidsimSettings->surfaceSmoothing; // misused value
// animated meshes
if(deform) {
@@ -1093,287 +1097,7 @@ void fluidsimBake(struct Object *ob)
// --------------------------------------------------------------------------------------------
else
{ // write config file to be run with command line simulator
- fileCfg = fopen(targetFile, "w");
- if(!fileCfg) {
- snprintf(debugStrBuffer,256,"fluidsimBake::error - Unable to open file for writing '%s'\n", targetFile);
- elbeemDebugOut(debugStrBuffer);
-
- pupmenu("Fluidsim Bake Error%t|Unable to output files... Aborted%x0");
- FS_FREE_CHANNELS;
- return;
- }
- //ADD_CREATEDFILE(targetFile);
-
- fprintf(fileCfg, "# Blender ElBeem File , Source %s , Frame %d, to %s \n\n\n", G.sce, -1, targetFile );
- // file open -> valid settings -> store
- strncpy(domainSettings->surfdataPath, newSurfdataPath, FILE_MAXDIR);
-
- /* output simulation settings */
- {
- char *dtype[3] = { "no", "part", "free" };
- float pslip = domainSettings->partSlipValue; int bi=0;
- char *simString = "\n"
- "attribute \"simulation1\" { \n"
- " solver = \"fsgr\"; \n" "\n"
- " p_domainsize = " "%f" /* realsize */ "; \n"
- " p_anistart = " "%f" /* aniStart*/ "; \n"
- " p_normgstar = %f; \n" /* use gstar param? */
- " maxrefine = " "%d" /* maxRefine*/ "; \n"
- " size = " "%d" /* gridSize*/ "; \n"
- " surfacepreview = " "%d" /* previewSize*/ "; \n"
- " dump_velocities = " "%d" /* vector dump */ "; \n"
- " smoothsurface = %f; \n" /* smoothing */
- " domain_trafo = %f %f %f %f " /* remove blender object trafo */
- " %f %f %f %f "
- " %f %f %f %f "
- " %f %f %f %f ;\n"
- " smoothnormals = %f; \n"
- " geoinitid = 1; \n" "\n"
- " isovalue = 0.4900; \n"
- " isoweightmethod = 1; \n" "\n" ;
-
- fprintf(fileCfg, simString,
- (double)domainSettings->realsize, (double)domainSettings->animStart, (double)domainSettings->gstar,
- gridlevels, (int)domainSettings->resolutionxyz, (int)domainSettings->previewresxyz ,
- (int)(domainSettings->domainNovecgen==0), domainSettings->surfaceSmoothing,
- invDomMat[0][0],invDomMat[1][0],invDomMat[2][0],invDomMat[3][0],
- invDomMat[0][1],invDomMat[1][1],invDomMat[2][1],invDomMat[3][1],
- invDomMat[0][2],invDomMat[1][2],invDomMat[2][2],invDomMat[3][2],
- invDomMat[0][3],invDomMat[1][3],invDomMat[2][3],invDomMat[3][3]
- );
-
- if((domainSettings->typeFlags&OB_FSBND_NOSLIP)) bi=0;
- else if((domainSettings->typeFlags&OB_FSBND_PARTSLIP)) bi=1;
- else if((domainSettings->typeFlags&OB_FSBND_FREESLIP)) bi=2;
- fprintf(fileCfg, " domainbound = %s; domainpartslip=%f; \n", dtype[bi], pslip);
-
- fprintf(fileCfg," # org aniframetime: %f \n", aniFrameTime);
- fluidsimPrintChannel(fileCfg, channelDomainTime,allchannelSize,"p_aniframetime",CHANNEL_FLOAT);
- fluidsimPrintChannel(fileCfg, channelDomainViscosity,allchannelSize,"p_viscosity",CHANNEL_FLOAT);
- fluidsimPrintChannel(fileCfg, channelDomainGravity, allchannelSize,"p_gravity",CHANNEL_VEC);
-
- fprintf(fileCfg, " partgenprob = %f; \n", domainSettings->generateParticles); // debug test
- fprintf(fileCfg, " particles = %d; \n", domainSettings->generateTracers); // debug test
- fprintf(fileCfg, "\n} \n" );
- }
-
-
- fprintf(fileCfg, "raytracing {\n");
-
- /* output picture settings for preview renders */
- {
- char *rayString = "\n"
- " anistart= 0; \n"
- " aniframes= " "%d" /*1 frameEnd-frameStart+0*/ "; #cfgset \n"
- " frameSkip= false; \n"
- " filename= \"" "%s" /* rayPicFilename*/ "\"; #cfgset \n"
- " aspect 1.0; \n"
- " resolution " "%d %d" /*2,3 blendResx,blendResy*/ "; #cfgset \n"
- " antialias 1; \n"
- " ambientlight (1, 1, 1); \n"
- " maxRayDepth 6; \n"
- " treeMaxDepth 25; \n"
- " treeMaxTriangles 8; \n"
- " background (0.08, 0.08, 0.20); \n"
- " eyepoint= (" "%f %f %f"/*4,5,6 eyep*/ "); #cfgset \n"
- " lookat= (" "%f %f %f"/*7,8,9 lookatp*/ "); #cfgset \n"
- " upvec= (0 0 1); \n"
- " fovy= " "%f" /*blendFov*/ "; #cfgset \n"
- //" blenderattr= \"btrafoattr\"; \n"
- "\n\n";
-
- char *lightString = "\n"
- " light { \n"
- " type= omni; \n"
- " active= 1; \n"
- " color= (1.0, 1.0, 1.0); \n"
- " position= (" "%f %f %f"/*1,2,3 eyep*/ "); #cfgset \n"
- " castShadows= 1; \n"
- " } \n\n" ;
-
- struct Object *cam = G.scene->camera;
- float eyex=2.0, eyey=2.0, eyez=2.0;
- int resx = 200, resy=200;
- float lookatx=0.0, lookaty=0.0, lookatz=0.0;
- float fov = 45.0;
-
- strcpy(targetFile, targetDir);
- strcat(targetFile, suffixSurface);
- resx = G.scene->r.xsch;
- resy = G.scene->r.ysch;
- if((cam) && (cam->type == OB_CAMERA)) {
- Camera *camdata= G.scene->camera->data;
- double lens = camdata->lens;
- double imgRatio = (double)resx/(double)resy;
- fov = 360.0 * atan(16.0*imgRatio/lens) / M_PI;
- //R.near= camdata->clipsta; R.far= camdata->clipend;
-
- eyex = cam->loc[0];
- eyey = cam->loc[1];
- eyez = cam->loc[2];
- // TODO - place lookat in middle of domain?
- }
-
- fprintf(fileCfg, rayString,
- (noFrames+0), targetFile, resx,resy,
- eyex, eyey, eyez ,
- lookatx, lookaty, lookatz,
- fov
- );
- fprintf(fileCfg, lightString,
- eyex, eyey, eyez );
- }
-
-
- /* output fluid domain */
- {
- char * domainString = "\n"
- " geometry { \n"
- " type= fluidlbm; \n"
- " name = \"" "%s" /*name*/ "\"; #cfgset \n"
- " visible= 1; \n"
- " attributes= \"simulation1\"; \n"
- //" define { material_surf = \"fluidblue\"; } \n"
- " start= " "%f %f %f" /*bbstart*/ "; #cfgset \n"
- " end = " "%f %f %f" /*bbend */ "; #cfgset \n"
- " } \n"
- "\n";
- fprintf(fileCfg, domainString,
- fsDomain->id.name,
- bbStart[0], bbStart[1], bbStart[2],
- bbStart[0]+bbSize[0], bbStart[1]+bbSize[1], bbStart[2]+bbSize[2]
- );
- }
-
-
- /* setup geometry */
- {
- char *objectStringStart =
- " geometry { \n"
- " type= objmodel; \n"
- " name = \"" "%s" /* name */ "\"; #cfgset \n"
- " visible= 1; \n" // DEBUG , also obs invisible?
- " define { \n" ;
- char *outflowString =
- " geoinittype= \"" "%s" /* type */ "\"; #cfgset \n"
- " filename= \"" "%s" /* data filename */ "\"; #cfgset \n" ;
- char *obstacleString =
- " geoinittype= \"" "%s" /* type */ "\"; #cfgset \n"
- " geoinit_partslip = \"" "%f" /* partslip */ "\"; #cfgset \n"
- " geoinit_volumeinit = \"" "%d" /* volumeinit */ "\"; #cfgset \n"
- " filename= \"" "%s" /* data filename */ "\"; #cfgset \n" ;
- char *fluidString =
- " geoinittype= \"" "%s" /* type */ "\"; \n"
- " geoinit_volumeinit = \"" "%d" /* volumeinit */ "\"; #cfgset \n"
- " filename= \"" "%s" /* data filename */ "\"; #cfgset \n" ;
- char *inflowString =
- " geoinittype= \"" "%s" /* type */ "\"; \n"
- " geoinit_localinivel = " "%d" /* local coords */ "; #cfgset \n"
- " filename= \"" "%s" /* data filename */ "\"; #cfgset \n" ;
- char *objectStringEnd =
- " geoinit_intersect = 1; \n" /* always use accurate init here */
- " geoinitid= 1; \n"
- " } \n"
- " } \n"
- "\n" ;
- char fnameObjdat[FILE_MAXFILE];
-
- channelObjCount = 0;
- for(obit= G.main->object.first; obit; obit= obit->id.next) {
- if( (obit->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
- (obit->type==OB_MESH) && // if has to match 3 places! // CHECKMATCH
- (obit->fluidsimSettings->type != OB_FLUIDSIM_DOMAIN) &&
- (obit->fluidsimSettings->type != OB_FLUIDSIM_PARTICLE)
- ) {
- int deform = (obit->fluidsimSettings->domainNovecgen);
-
- fluidsimGetGeometryObjFilename(obit, fnameObjdat);
- strcpy(targetFile, targetDir);
- strcat(targetFile, fnameObjdat);
- fprintf(fileCfg, objectStringStart, obit->id.name ); // abs path
- // object type params
- if(obit->fluidsimSettings->type == OB_FLUIDSIM_FLUID) {
- fprintf(fileCfg, fluidString, "fluid",
- (int)obit->fluidsimSettings->volumeInitType, targetFile );
- }
- if(obit->fluidsimSettings->type == OB_FLUIDSIM_INFLOW) {
- int locc = ((obit->fluidsimSettings->typeFlags&OB_FSINFLOW_LOCALCOORD)?1:0);
- fprintf(fileCfg, inflowString, "inflow" ,locc
- , targetFile );
- }
- if(obit->fluidsimSettings->type == OB_FLUIDSIM_OBSTACLE) {
- char *btype[3] = { "bnd_no", "bnd_part", "bnd_free" };
- float pslip = obit->fluidsimSettings->partSlipValue; int bi=0;
- if((obit->fluidsimSettings->typeFlags&OB_FSBND_NOSLIP)) bi=0;
- else if((obit->fluidsimSettings->typeFlags&OB_FSBND_PARTSLIP)) bi=1;
- else if((obit->fluidsimSettings->typeFlags&OB_FSBND_FREESLIP)) bi=2;
- fprintf(fileCfg, obstacleString, btype[bi], pslip,
- (int)obit->fluidsimSettings->volumeInitType, targetFile); // abs path
- }
- if(obit->fluidsimSettings->type == OB_FLUIDSIM_OUTFLOW) {
- fprintf(fileCfg, outflowString, "outflow" , targetFile); // abs path
- }
-
- if(!deform) {
- fluidsimPrintChannel(fileCfg, channelObjMove[channelObjCount][0],allchannelSize, "translation", CHANNEL_VEC);
- fluidsimPrintChannel(fileCfg, channelObjMove[channelObjCount][1],allchannelSize, "rotation" , CHANNEL_VEC);
- fluidsimPrintChannel(fileCfg, channelObjMove[channelObjCount][2],allchannelSize, "scale" , CHANNEL_VEC);
- }
- fluidsimPrintChannel(fileCfg, channelObjActive[channelObjCount] ,allchannelSize, "geoactive" , CHANNEL_FLOAT);
- if( (obit->fluidsimSettings->type == OB_FLUIDSIM_FLUID) ||
- (obit->fluidsimSettings->type == OB_FLUIDSIM_INFLOW) ) {
- fluidsimPrintChannel(fileCfg, channelObjInivel[channelObjCount],allchannelSize,"initial_velocity" ,CHANNEL_VEC);
- }
- channelObjCount++;
-
- fprintf(fileCfg, objectStringEnd ); // abs path
-
- // check shape key animation
- //fprintf(stderr,"\n%d %d\n\n",(int)obit->parent,obit->partype); // DEBUG
- if(deform) {
- int frame;
- // use global coordinates for deforming/parented objects
- writeBobjgz(targetFile, obit, 1,0,0.);
- //for(int frame=0; frame<=G.scene->r.efra; frame++) {
- for(frame=0; frame<=allchannelSize; frame++) {
- G.scene->r.cfra = frame;
- scene_update_for_newframe(G.scene, G.scene->lay);
- writeBobjgz(targetFile, obit, 1,1, timeAtFrame[frame] ); // only append!
-
- //if(shapekey) snprintf(debugStrBuffer,256,"Shape frames: %d/%d, shapeKeys:%d",frame,allchannelSize,BLI_countlist(&shapekey->block));
- //else snprintf(debugStrBuffer,256,"Deform frames: %d/%d",frame,allchannelSize);
- //elbeemDebugOut(debugStrBuffer);
- }
- G.scene->r.cfra = startFrame;
- scene_update_for_newframe(G.scene, G.scene->lay);
- } else {
- // use normal trafos & non animated mesh
- writeBobjgz(targetFile, obit, 0,0,0.);
- }
-
- }
- }
- }
-
- /* fluid material */
- fprintf(fileCfg,
- " material { \n"
- " type= phong; \n"
- " name= \"fluidblue\"; \n"
- " diffuse= 0.3 0.5 0.9; \n"
- " ambient= 0.1 0.1 0.1; \n"
- " specular= 0.2 10.0; \n"
- " } \n" );
-
- fprintf(fileCfg, "} // end raytracing\n");
- fclose(fileCfg);
-
- strcpy(targetFile, targetDir);
- strcat(targetFile, suffixConfig);
- snprintf(debugStrBuffer,256,"fluidsimBake::msg: Wrote %s\n", targetFile);
- elbeemDebugOut(debugStrBuffer);
-
- pupmenu("Fluidsim Bake Message%t|Config files exported successfully!%x0");
+ pupmenu("Fluidsim Bake Message%t|Config file export not supported.%x0");
} // config file export done!
// --------------------------------------------------------------------------------------------