[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37441] trunk/blender: Elbeem / Fluidsim update:

Daniel Genrich daniel.genrich at gmx.net
Mon Jun 13 01:51:31 CEST 2011


Revision: 37441
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37441
Author:   genscher
Date:     2011-06-12 23:51:30 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
Elbeem / Fluidsim update:
a) Enable the possibility to remove the "air bubble" around submerged collision object. This feature is enabled as standard for new files. The code was found in elbeem by nudelZ, coded and provided by Nils Th?\195?\188rey (thanks!)
b) Old baked files gets deleted if a new bake gets started (were overwritten before and resulted in weird old bake + new bake mixture) (idea by nudelZ)

Modified Paths:
--------------
    trunk/blender/intern/elbeem/extern/elbeem.h
    trunk/blender/intern/elbeem/intern/simulation_object.cpp
    trunk/blender/intern/elbeem/intern/solver_class.h
    trunk/blender/intern/elbeem/intern/solver_init.cpp
    trunk/blender/intern/elbeem/intern/solver_interface.h
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py
    trunk/blender/source/blender/editors/physics/physics_fluid.c
    trunk/blender/source/blender/makesdna/DNA_object_fluidsim.h
    trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c
    trunk/blender/source/blender/modifiers/intern/MOD_fluidsim_util.c

Modified: trunk/blender/intern/elbeem/extern/elbeem.h
===================================================================
--- trunk/blender/intern/elbeem/extern/elbeem.h	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/intern/elbeem/extern/elbeem.h	2011-06-12 23:51:30 UTC (rev 37441)
@@ -77,6 +77,10 @@
 	/* boundary types and settings for domain walls */
 	short domainobsType;
 	float domainobsPartslip;
+
+	/* what surfaces to generate */
+	int mFsSurfGenSetting;
+
 	/* generate speed vectors for vertices (e.g. for image based motion blur)*/
 	short generateVertexVectors;
 	/* strength of surface smoothing */
@@ -108,11 +112,13 @@
 #define OB_FLUIDSIM_PARTICLE    64
 #define OB_FLUIDSIM_CONTROL 	128
 
-// defines for elbeemMesh->obstacleType below
+// defines for elbeemMesh->obstacleType below (low bits) high bits (>=64) are reserved for mFsSurfGenSetting flags which are defined in solver_class.h
 #define FLUIDSIM_OBSTACLE_NOSLIP     1
 #define FLUIDSIM_OBSTACLE_PARTSLIP   2
 #define FLUIDSIM_OBSTACLE_FREESLIP   3
+#define FLUIDSIM_FSSG_NOOBS			 64
 
+
 #define OB_VOLUMEINIT_VOLUME 1
 #define OB_VOLUMEINIT_SHELL  2
 #define OB_VOLUMEINIT_BOTH   (OB_VOLUMEINIT_SHELL|OB_VOLUMEINIT_VOLUME)

Modified: trunk/blender/intern/elbeem/intern/simulation_object.cpp
===================================================================
--- trunk/blender/intern/elbeem/intern/simulation_object.cpp	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/intern/elbeem/intern/simulation_object.cpp	2011-06-12 23:51:30 UTC (rev 37441)
@@ -181,6 +181,9 @@
 		mpLbm->setGenerateParticles(mpElbeemSettings->generateParticles);
 		// set initial particles
 		mpParts->setNumInitialParticles(mpElbeemSettings->numTracerParticles);
+		
+		// surface generation flag
+		mpLbm->setSurfGenSettings(mpElbeemSettings->mFsSurfGenSetting);
 
 		string dinitType = string("no");
 		if     (mpElbeemSettings->domainobsType==FLUIDSIM_OBSTACLE_PARTSLIP) dinitType = string("part"); 

Modified: trunk/blender/intern/elbeem/intern/solver_class.h
===================================================================
--- trunk/blender/intern/elbeem/intern/solver_class.h	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/intern/elbeem/intern/solver_class.h	2011-06-12 23:51:30 UTC (rev 37441)
@@ -308,6 +308,9 @@
 		//! for raytracing, preprocess
 		void prepareVisualization( void );
 
+		/* surface generation settings */
+		virtual void setSurfGenSettings(short value);
+
 	protected:
 
 		//! internal quick print function (for debugging) 

Modified: trunk/blender/intern/elbeem/intern/solver_init.cpp
===================================================================
--- trunk/blender/intern/elbeem/intern/solver_init.cpp	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/intern/elbeem/intern/solver_init.cpp	2011-06-12 23:51:30 UTC (rev 37441)
@@ -539,6 +539,15 @@
 
 
 /******************************************************************************
+ * (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM")
+ *****************************************************************************/
+void LbmFsgrSolver::setSurfGenSettings(short value)
+{
+	mFsSurfGenSetting = value;
+}
+
+
+/******************************************************************************
  * Initialize omegas and forces on all levels (for init/timestep change)
  *****************************************************************************/
 void LbmFsgrSolver::initLevelOmegas()

Modified: trunk/blender/intern/elbeem/intern/solver_interface.h
===================================================================
--- trunk/blender/intern/elbeem/intern/solver_interface.h	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/intern/elbeem/intern/solver_interface.h	2011-06-12 23:51:30 UTC (rev 37441)
@@ -271,6 +271,9 @@
 		/*! debug object display */
 		virtual vector<ntlGeometryObject*> getDebugObjects() { vector<ntlGeometryObject*> empty(0); return empty; }
 
+		/* surface generation settings */
+		virtual void setSurfGenSettings(short value) = 0;
+
 #if LBM_USE_GUI==1
 		/*! show simulation info */
 		virtual void debugDisplay(int) = 0;

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py	2011-06-12 23:51:30 UTC (rev 37441)
@@ -257,6 +257,7 @@
         col.prop(fluid, "slip_type", text="")
         if fluid.slip_type == 'PARTIALSLIP':
             col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
+        col.prop(fluid, "surface_noobs")
 
         col = split.column()
         col.label(text="Surface:")

Modified: trunk/blender/source/blender/editors/physics/physics_fluid.c
===================================================================
--- trunk/blender/source/blender/editors/physics/physics_fluid.c	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/source/blender/editors/physics/physics_fluid.c	2011-06-12 23:51:30 UTC (rev 37441)
@@ -56,6 +56,7 @@
 #include "DNA_object_fluidsim.h"	
 
 #include "BLI_blenlib.h"
+#include "BLI_fileops.h"
 #include "BLI_threads.h"
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
@@ -125,7 +126,7 @@
 	if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
 		copy_v3_v3(gravity, scene->physics_settings.gravity);
 	} else {
-		copy_v3_v3(gravity, &fss->gravx);
+		copy_v3_v3(gravity, fss->grav);
 	}
 }
 
@@ -442,8 +443,8 @@
 		for (fobj=fobjects->first; fobj; fobj=fobj->next) {
 			Object *ob = fobj->object;
 			FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
-			float active= (float)(fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE);
-			float rot_d[3], old_rot[3] = {0.f, 0.f, 0.f};
+			float active= (float)(fluidmd->fss->flag && OB_FLUIDSIM_ACTIVE);
+			float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f};
 			
 			if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE))
 				continue;
@@ -809,6 +810,44 @@
 	}
 }
 
+/* copied from rna_fluidsim.c: fluidsim_find_lastframe() */
+static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
+{
+	char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
+	char targetDirVel[FILE_MAXFILE+FILE_MAXDIR], targetFileVel[FILE_MAXFILE+FILE_MAXDIR];
+	char previewDir[FILE_MAXFILE+FILE_MAXDIR], previewFile[FILE_MAXFILE+FILE_MAXDIR];
+	int curFrame = 1, exists = 0;
+
+	BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath);
+	BLI_snprintf(targetDirVel, sizeof(targetDir), "%sfluidsurface_final_####.bvel.gz", fss->surfdataPath);
+	BLI_snprintf(previewDir, sizeof(targetDir), "%sfluidsurface_preview_####.bobj.gz", fss->surfdataPath);
+
+	BLI_path_abs(targetDir, G.main->name);
+	BLI_path_abs(targetDirVel, G.main->name);
+	BLI_path_abs(previewDir, G.main->name);
+
+	do {
+		BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
+		BLI_strncpy(targetFileVel, targetDirVel, sizeof(targetFileVel));
+		BLI_strncpy(previewFile, previewDir, sizeof(previewFile));
+
+		BLI_path_frame(targetFile, curFrame, 0);
+		BLI_path_frame(targetFileVel, curFrame, 0);
+		BLI_path_frame(previewFile, curFrame, 0);
+
+		curFrame++;
+
+		if(exists = BLI_exist(targetFile))
+		{
+			BLI_delete(targetFile, 0, 0);
+			BLI_delete(targetFileVel, 0, 0);
+			BLI_delete(previewFile, 0, 0);
+		}
+	} while(exists);
+
+	return;
+}
+
 static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
 {
 	Scene *scene= CTX_data_scene(C);
@@ -878,6 +917,9 @@
 	
 	// reset last valid frame
 	domainSettings->lastgoodframe = -1;
+
+	/* delete old baked files */
+	fluidsim_delete_until_lastframe(domainSettings);
 	
 	/* rough check of settings... */
 	if(domainSettings->previewresxyz > domainSettings->resolutionxyz) {
@@ -1018,6 +1060,13 @@
 	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;
+
+	/* use domainobsType also for surface generation flag (bit: >=64) */
+	if(domainSettings->typeFlags & OB_FSSG_NOOBS)
+		fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS;
+	else
+		fsset->mFsSurfGenSetting = 0; // "normal" mode
+
 	fsset->generateVertexVectors = (domainSettings->domainNovecgen==0);
 
 	// init blender domain transform matrix

Modified: trunk/blender/source/blender/makesdna/DNA_object_fluidsim.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_object_fluidsim.h	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/source/blender/makesdna/DNA_object_fluidsim.h	2011-06-12 23:51:30 UTC (rev 37441)
@@ -69,7 +69,7 @@
 	short viscosityMode;
 	short viscosityExponent;
 	/* gravity strength */
-	float gravx,gravy,gravz;
+	float grav[3];
 	/* anim start end time (in seconds) */
 	float animStart, animEnd;
 	/* bake start end time (in blender frames) */
@@ -161,6 +161,9 @@
 #define OB_FSBND_FREESLIP       (1<<(OB_TYPEFLAG_START+4))
 #define OB_FSINFLOW_LOCALCOORD  (1<<(OB_TYPEFLAG_START+5))
 
+/* surface generation flag (part of enabling chapter 6 of "Free Surface Flows with Moving and Deforming Objects for LBM") */
+#define OB_FSSG_NOOBS			(1<<(OB_TYPEFLAG_START+6))
+
 // guiDisplayMode particle flags
 #define OB_FSDOM_GEOM     1
 #define OB_FSDOM_PREVIEW  2

Modified: trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c	2011-06-12 20:27:28 UTC (rev 37440)
+++ trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c	2011-06-12 23:51:30 UTC (rev 37441)
@@ -312,7 +312,7 @@
 
 	/* advanced settings */
 	prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
-	RNA_def_property_float_sdna(prop, NULL, "gravx");
+	RNA_def_property_float_sdna(prop, NULL, "grav");
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_range(prop, -1000.1, 1000.1);
 	RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction");
@@ -384,6 +384,12 @@
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list