[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27735] trunk/blender: Restored Fluid Sim baking
Matt Ebb
matt at mke3.net
Thu Mar 25 07:27:26 CET 2010
Revision: 27735
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27735
Author: broken
Date: 2010-03-25 07:27:25 +0100 (Thu, 25 Mar 2010)
Log Message:
-----------
Restored Fluid Sim baking
This commit restores fluid sim baking functionality in 2.5, it's been on the todo for
a while, and was previously almost completely non-functional. The old
code was quite complicated and specific to the 2.4 animation system, so I've
pretty much rewritten most of it.
This includes:
* Animated variables work again - just key them in the UI. Non-animateable values
should be already set non-animateable in RNA, hopefully I got them all.
Available are: Domain Gravity / Domain Viscosity / Object loc/rot/scale /
Object initial velocity / Deforming meshes / Fluid control Attract strength /
Fluid control Attract radius / Fluid control Velocity strength /
Fluid control Velocity radius / Object Active status (checkbox next to fluid type)
The Domain time scale is still not yet implemented.
* Fluid sim now use global scene units data by default - when enabled, the
scene's global gravity value is used and when units are set (metric/imperial)
the simulation real world size is taken from the object's actual measurements.
* The baking process is now done in the background, using the nifty threaded
Jobs system. It's non-blocking and your domain object will show the simulated
fluid as it becomes available for that frame.
A nice extra thing for the future would be to improve the visualisation of the
object's state while baking, and also the jobs system/ui could do with some
touchups - currently it has to share a bit from the 'render' job, and appears as
'Render' in the header. Progress bars for jobs in the header would be great too.
Modified Paths:
--------------
trunk/blender/release/scripts/ui/properties_physics_fluid.py
trunk/blender/source/blender/blenkernel/BKE_object.h
trunk/blender/source/blender/blenkernel/intern/fluidsim.c
trunk/blender/source/blender/blenkernel/intern/object.c
trunk/blender/source/blender/blenloader/intern/readfile.c
trunk/blender/source/blender/editors/include/ED_fluidsim.h
trunk/blender/source/blender/editors/physics/physics_fluid.c
trunk/blender/source/blender/editors/space_buttons/space_buttons.c
trunk/blender/source/blender/makesdna/DNA_object_fluidsim.h
trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c
trunk/blender/source/blender/makesrna/intern/rna_object.c
Modified: trunk/blender/release/scripts/ui/properties_physics_fluid.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_physics_fluid.py 2010-03-25 00:46:08 UTC (rev 27734)
+++ trunk/blender/release/scripts/ui/properties_physics_fluid.py 2010-03-25 06:27:25 UTC (rev 27735)
@@ -42,7 +42,7 @@
md = context.fluid
wide_ui = context.region.width > narrowui
- split = layout.split()
+ split = layout.split(percentage=0.5)
split.operator_context = 'EXEC_DEFAULT'
if md:
@@ -53,7 +53,7 @@
row = split.row(align=True)
row.prop(md, "render", text="")
row.prop(md, "realtime", text="")
-
+
fluid = md.settings
else:
@@ -67,10 +67,19 @@
if fluid:
if wide_ui:
- layout.prop(fluid, "type")
+ row = layout.row()
+ row.prop(fluid, "type")
+ if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
+ row.prop(fluid, "active", text="")
else:
layout.prop(fluid, "type", text="")
-
+ if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
+ layout.prop(fluid, "active", text="")
+
+ layout = layout.column()
+ if fluid.type not in ('NONE', 'DOMAIN', 'PARTICLE'):
+ layout.active = fluid.active
+
if fluid.type == 'DOMAIN':
layout.operator("fluid.bake", text="Bake Fluid Simulation", icon='MOD_FLUIDSIM')
split = layout.split()
@@ -220,15 +229,29 @@
layout = self.layout
fluid = context.fluid.settings
+ scene = context.scene
wide_ui = context.region.width > narrowui
split = layout.split()
col = split.column()
- col.label(text="Gravity:")
- col.prop(fluid, "gravity", text="")
- col.label(text="Real World Size:")
- col.prop(fluid, "real_world_size", text="Metres")
+ if scene.use_gravity:
+ col.label(text="Using Scene Gravity", icon="SCENE_DATA")
+ sub = col.column()
+ sub.enabled = False
+ sub.prop(fluid, "gravity", text="")
+ else:
+ col.label(text="Gravity:")
+ col.prop(fluid, "gravity", text="")
+
+ if scene.unit_settings.system != 'NONE':
+ col.label(text="Using Scene Size Units", icon="SCENE_DATA")
+ sub = col.column()
+ sub.enabled = False
+ sub.prop(fluid, "real_world_size", text="Metres")
+ else:
+ col.label(text="Real World Size:")
+ col.prop(fluid, "real_world_size", text="Metres")
if wide_ui:
col = split.column()
Modified: trunk/blender/source/blender/blenkernel/BKE_object.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_object.h 2010-03-25 00:46:08 UTC (rev 27734)
+++ trunk/blender/source/blender/blenkernel/BKE_object.h 2010-03-25 06:27:25 UTC (rev 27735)
@@ -111,6 +111,8 @@
struct BoundBox *unit_boundbox(void);
void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]);
struct BoundBox *object_get_boundbox(struct Object *ob);
+void object_get_dimensions(struct Object *ob, float *value);
+void object_set_dimensions(struct Object *ob, const float *value);
void object_boundbox_flag(struct Object *ob, int flag, int set);
void minmax_object(struct Object *ob, float *min, float *max);
int minmax_object_duplis(struct Scene *scene, struct Object *ob, float *min, float *max);
Modified: trunk/blender/source/blender/blenkernel/intern/fluidsim.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/fluidsim.c 2010-03-25 00:46:08 UTC (rev 27734)
+++ trunk/blender/source/blender/blenkernel/intern/fluidsim.c 2010-03-25 06:27:25 UTC (rev 27735)
@@ -148,7 +148,7 @@
fss->lastgoodframe = -1;
- fss->flag = 0;
+ fss->flag |= OB_FLUIDSIM_ACTIVE;
}
#endif
Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c 2010-03-25 00:46:08 UTC (rev 27734)
+++ trunk/blender/source/blender/blenkernel/intern/object.c 2010-03-25 06:27:25 UTC (rev 27735)
@@ -2305,6 +2305,44 @@
}
}
+void object_get_dimensions(Object *ob, float *value)
+{
+ BoundBox *bb = NULL;
+
+ bb= object_get_boundbox(ob);
+ if (bb) {
+ float scale[3];
+
+ mat4_to_size( scale,ob->obmat);
+
+ value[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
+ value[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
+ value[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
+ } else {
+ value[0] = value[1] = value[2] = 0.f;
+ }
+}
+
+void object_set_dimensions(Object *ob, const float *value)
+{
+ BoundBox *bb = NULL;
+
+ bb= object_get_boundbox(ob);
+ if (bb) {
+ float scale[3], len[3];
+
+ mat4_to_size( scale,ob->obmat);
+
+ len[0] = bb->vec[4][0] - bb->vec[0][0];
+ len[1] = bb->vec[2][1] - bb->vec[0][1];
+ len[2] = bb->vec[1][2] - bb->vec[0][2];
+
+ if (len[0] > 0.f) ob->size[0] = value[0] / len[0];
+ if (len[1] > 0.f) ob->size[1] = value[1] / len[1];
+ if (len[2] > 0.f) ob->size[2] = value[2] / len[2];
+ }
+}
+
void minmax_object(Object *ob, float *min, float *max)
{
BoundBox bb;
Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c 2010-03-25 00:46:08 UTC (rev 27734)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c 2010-03-25 06:27:25 UTC (rev 27735)
@@ -10659,8 +10659,8 @@
for(md= ob->modifiers.first; md; md= md->next) {
if (md->type == eModifierType_Fluidsim) {
FluidsimModifierData *fmd = (FluidsimModifierData *)md;
- /* fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
- temporarily commented out for matt_ebb */
+ fmd->fss->flag |= OB_FLUIDSIM_ACTIVE;
+ fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME;
}
}
}
Modified: trunk/blender/source/blender/editors/include/ED_fluidsim.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_fluidsim.h 2010-03-25 00:46:08 UTC (rev 27734)
+++ trunk/blender/source/blender/editors/include/ED_fluidsim.h 2010-03-25 06:27:25 UTC (rev 27735)
@@ -34,8 +34,6 @@
struct Object;
struct FluidsimSettings;
-extern double fluidsimViscosityPreset[6];
-extern char* fluidsimViscosityPresetString[6];
/* allocates and initializes fluidsim data */
struct FluidsimSettings* fluidsimSettingsNew(struct Object *srcob);
Modified: trunk/blender/source/blender/editors/physics/physics_fluid.c
===================================================================
--- trunk/blender/source/blender/editors/physics/physics_fluid.c 2010-03-25 00:46:08 UTC (rev 27734)
+++ trunk/blender/source/blender/editors/physics/physics_fluid.c 2010-03-25 06:27:25 UTC (rev 27735)
@@ -45,12 +45,17 @@
#include "MEM_guardedalloc.h"
/* types */
+#include "DNA_anim_types.h"
+#include "DNA_action_types.h"
+#include "DNA_object_types.h"
#include "DNA_object_fluidsim.h"
#include "BLI_blenlib.h"
#include "BLI_threads.h"
#include "BLI_math.h"
+#include "BKE_animsys.h"
+#include "BKE_armature.h"
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
@@ -67,6 +72,7 @@
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_softbody.h"
+#include "BKE_unit.h"
#include "LBM_fluidsim.h"
@@ -90,77 +96,102 @@
#include "PIL_time.h"
-/* XXX */
-/* from header info.c */
-static int start_progress_bar(void) {return 0;};
-static void end_progress_bar(struct wmWindow *win) {WM_cursor_restore(win);};
-static void waitcursor(int val) {};
-static int progress_bar(wmWindow *win, float done, char *busy_info) { WM_timecursor(win,done*100); return 0;}
-static int pupmenu() {return 0;}
-/* XXX */
+static float get_fluid_viscosity(FluidsimSettings *settings)
+{
+ switch (settings->viscosityMode) {
+ case 0: /* unused */
+ return -1.0;
+ case 2: /* water */
+ return 1.0e-6;
+ case 3: /* some (thick) oil */
+ return 5.0e-5;
+ case 4: /* ca. honey */
+ return 2.0e-3;
+ case 1: /* manual */
+ default:
+ return (1.0/pow(10.0, settings->viscosityExponent)) * settings->viscosityValue;
+ }
+}
-double fluidsimViscosityPreset[6] = {
- -1.0, /* unused */
- -1.0, /* manual */
- 1.0e-6, /* water */
- 5.0e-5, /* some (thick) oil */
- 2.0e-3, /* ca. honey */
- -1.0 /* end */
-};
+static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fss)
+{
+ if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
+ copy_v3_v3(gravity, scene->physics_settings.gravity);
+ } else {
+ copy_v3_v3(gravity, &fss->gravx);
+ }
+}
-char* fluidsimViscosityPresetString[6] = {
- "UNUSED", /* unused */
- "UNUSED", /* manual */
- " = 1.0 * 10^-6", /* water */
- " = 5.0 * 10^-5", /* some (thick) oil */
- " = 2.0 * 10^-3", /* ca. honey */
- "INVALID" /* end */
-};
+static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings *fss)
+{
+ if (!scene->unit.system) {
+ return fss->realsize;
+ } else {
+ float dim[3];
+ float longest_axis;
+
+ object_get_dimensions(domainob, dim);
+ longest_axis = MAX3(dim[0], dim[1], dim[2]);
+
+ return longest_axis * scene->unit.scale_length;
+ }
+}
+static int fluid_is_animated_mesh(FluidsimSettings *fss)
+{
+ return ((fss->type == OB_FLUIDSIM_CONTROL) || fss->domainNovecgen);
+}
+
/* ********************** fluid sim settings struct functions ********************** */
+#if 0
/* helper function */
void fluidsimGetGeometryObjFilename(Object *ob, char *dst) { //, char *srcname) {
//snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name);
snprintf(dst,FILE_MAXFILE, "fluidcfgdata_%s.bobj.gz", ob->id.name);
}
+#endif
+/* ********************** fluid sim channel helper functions ********************** */
+typedef struct FluidAnimChannels {
+ int length;
+
+ double aniFrameTime;
+
+ float *timeAtFrame;
+ float *DomainTime;
+ float *DomainGravity;
+ float *DomainViscosity;
+} FluidAnimChannels;
-/* ******************************************************************************** */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list