[Bf-blender-cvs] [201b4051ba6] master: Fluid: Fix missing WITH_FLUID in draw code

2020-07-31 Thread Sebastián Barschkis
Commit: 201b4051ba6b5eed0500067b27f5fe910fe06909
Author: Sebastián Barschkis
Date:   Fri Jul 31 15:19:29 2020 +0200
Branches: master
https://developer.blender.org/rB201b4051ba6b5eed0500067b27f5fe910fe06909

Fluid: Fix missing WITH_FLUID in draw code

The new draw code from 486c7b87fb06  was just missing a WITH_FLUID flag.

===

M   source/blender/draw/CMakeLists.txt

===

diff --git a/source/blender/draw/CMakeLists.txt 
b/source/blender/draw/CMakeLists.txt
index 8bd4832e446..f85b03dc517 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -404,6 +404,13 @@ 
data_to_c_simple(engines/overlay/shaders/xray_fade_frag.glsl SRC)
 list(APPEND INC
 )
 
+if(WITH_MOD_FLUID)
+  list(APPEND INC
+../../../intern/mantaflow/extern
+  )
+  add_definitions(-DWITH_FLUID)
+endif()
+
 if(WITH_FREESTYLE)
   add_definitions(-DWITH_FREESTYLE)
 endif()

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [b1d3850333a] master: Cleanup: Fluid renaming from old 'manta' naming to new 'fluid' naming

2020-07-03 Thread Sebastián Barschkis
Commit: b1d3850333adfe36c6ff94b8307fdafc9cc5148c
Author: Sebastián Barschkis
Date:   Fri Jul 3 11:51:15 2020 +0200
Branches: master
https://developer.blender.org/rBb1d3850333adfe36c6ff94b8307fdafc9cc5148c

Cleanup: Fluid renaming from old 'manta' naming to new 'fluid' naming

Changed variable names from mmd, mds, mfs, and mes to fmd, fds, ffs, and fes. 
The author of this commits lights a candle for all the merge conflicts this 
will cause.

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   source/blender/blenkernel/BKE_fluid.h
M   source/blender/blenkernel/BKE_pointcache.h
M   source/blender/blenkernel/intern/bpath.c
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenkernel/intern/object.c
M   source/blender/blenkernel/intern/particle.c
M   source/blender/blenkernel/intern/particle_system.c
M   source/blender/blenkernel/intern/pointcache.c
M   source/blender/blenloader/intern/readfile.c
M   source/blender/blenloader/intern/versioning_250.c
M   source/blender/blenloader/intern/versioning_260.c
M   source/blender/blenloader/intern/versioning_270.c
M   source/blender/blenloader/intern/writefile.c
M   source/blender/draw/engines/eevee/eevee_volumes.c
M   source/blender/draw/engines/overlay/overlay_extra.c
M   source/blender/draw/engines/workbench/workbench_volume.c
M   source/blender/editors/physics/physics_fluid.c
M   source/blender/gpu/GPU_draw.h
M   source/blender/gpu/intern/gpu_draw_smoke.c
M   source/blender/makesdna/DNA_fluid_types.h
M   source/blender/makesrna/intern/rna_fluid.c
M   source/blender/makesrna/intern/rna_modifier.c
M   source/blender/makesrna/intern/rna_object_force.c
M   source/blender/modifiers/intern/MOD_fluid.c

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index d78aa6732b1..1dbfc6bdd9c 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -31,52 +31,52 @@ extern "C" {
 struct MANTA;
 
 /* Fluid functions */
-struct MANTA *manta_init(int *res, struct FluidModifierData *mmd);
+struct MANTA *manta_init(int *res, struct FluidModifierData *fmd);
 void manta_free(struct MANTA *fluid);
-void manta_ensure_obstacle(struct MANTA *fluid, struct FluidModifierData *mmd);
-void manta_ensure_guiding(struct MANTA *fluid, struct FluidModifierData *mmd);
-void manta_ensure_invelocity(struct MANTA *fluid, struct FluidModifierData 
*mmd);
-void manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *mmd);
-int manta_write_config(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
-int manta_write_data(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
-int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
-int manta_read_config(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+void manta_ensure_obstacle(struct MANTA *fluid, struct FluidModifierData *fmd);
+void manta_ensure_guiding(struct MANTA *fluid, struct FluidModifierData *fmd);
+void manta_ensure_invelocity(struct MANTA *fluid, struct FluidModifierData 
*fmd);
+void manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *fmd);
+int manta_write_config(struct MANTA *fluid, struct FluidModifierData *fmd, int 
framenr);
+int manta_write_data(struct MANTA *fluid, struct FluidModifierData *fmd, int 
framenr);
+int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *fmd, int 
framenr);
+int manta_read_config(struct MANTA *fluid, struct FluidModifierData *fmd, int 
framenr);
 int manta_read_data(struct MANTA *fluid,
-struct FluidModifierData *mmd,
+struct FluidModifierData *fmd,
 int framenr,
 bool resumable);
 int manta_read_noise(struct MANTA *fluid,
- struct FluidModifierData *mmd,
+ struct FluidModifierData *fmd,
  int framenr,
  bool resumable);
-int manta_read_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+int manta_read_mesh(struct MANTA *fluid, struct FluidModifierData *fmd, int 
framenr);
 int manta_read_particles(struct MANTA *fluid,
- struct FluidModifierData *mmd,
+ struct FluidModifierData *fmd,
  int framenr,
  bool resumable);
 int manta_read_guiding(struct MANTA *fluid,
-   struct FluidModifierData *mmd,
+   struct FluidModifierData *fmd,
int framenr,
  

[Bf-blender-cvs] [fb0f0f4d79a] master: Fluid: Added offset to control frame range

2020-07-02 Thread Sebastián Barschkis
Commit: fb0f0f4d79a7cc89f31787615d25a98ca263bef5
Author: Sebastián Barschkis
Date:   Thu Jul 2 16:30:05 2020 +0200
Branches: master
https://developer.blender.org/rBfb0f0f4d79a7cc89f31787615d25a98ca263bef5

Fluid: Added offset to control frame range

Added an offset field to control when to load the simulation files. Since this 
is a very small but helpful addition it is in my view safe to commit at this 
point of the bcon cycle.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesdna/DNA_fluid_types.h
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 0bfa70b008b..13073d182d1 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -1135,22 +1135,22 @@ class PHYSICS_PT_cache(PhysicButtonsPanel, Panel):
 flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, 
even_rows=False, align=False)
 
 col = flow.column()
-col.prop(domain, "cache_type", expand=False)
-col.enabled = not is_baking_any
-
-col.separator()
-
 row = col.row()
-col = row.column(align=True)
-col.prop(domain, "cache_frame_start", text="Frame Start")
-col.prop(domain, "cache_frame_end", text="End")
-row.enabled = not is_baking_any
+row = row.column(align=True)
+row.prop(domain, "cache_frame_start", text="Frame Start")
+row.prop(domain, "cache_frame_end", text="End")
+row = col.row()
+row.enabled = domain.cache_type in {'MODULAR', 'ALL'}
+row.prop(domain, "cache_frame_offset", text="Offset")
 
 col.separator()
 
 col = flow.column()
-col.enabled = not is_baking_any and not has_baked_data
-col.prop(domain, "cache_resumable", text="Is Resumable")
+col.prop(domain, "cache_type", expand=False)
+
+row = col.row()
+row.enabled = not is_baking_any and not has_baked_data
+row.prop(domain, "cache_resumable", text="Is Resumable")
 
 row = col.row()
 row.enabled = not is_baking_any and not has_baked_data
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 98573ea98ec..946c7577ad8 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3724,10 +3724,31 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   bool is_startframe, has_advanced;
   is_startframe = (scene_framenr == mds->cache_frame_start);
   has_advanced = (scene_framenr == mmd->time + 1);
+  int mode = mds->cache_type;
 
   /* Do not process modifier if current frame is out of cache range. */
-  if (scene_framenr < mds->cache_frame_start || scene_framenr > 
mds->cache_frame_end) {
-return;
+  switch (mode) {
+case FLUID_DOMAIN_CACHE_ALL:
+case FLUID_DOMAIN_CACHE_MODULAR:
+  if (mds->cache_frame_offset > 0) {
+if (scene_framenr < mds->cache_frame_start ||
+scene_framenr > mds->cache_frame_end + mds->cache_frame_offset) {
+  return;
+}
+  }
+  else {
+if (scene_framenr < mds->cache_frame_start + mds->cache_frame_offset ||
+scene_framenr > mds->cache_frame_end) {
+  return;
+}
+  }
+  break;
+case FLUID_DOMAIN_CACHE_REPLAY:
+default:
+  if (scene_framenr < mds->cache_frame_start || scene_framenr > 
mds->cache_frame_end) {
+return;
+  }
+  break;
   }
 
   /* Reset fluid if no fluid present. Also resets active fields. */
@@ -3865,7 +3886,6 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   with_gdomain = (mds->guide_source == FLUID_DOMAIN_GUIDE_SRC_DOMAIN);
 
   int o_res[3], o_min[3], o_max[3], o_shift[3];
-  int mode = mds->cache_type;
 
   /* Cache mode specific settings. */
   switch (mode) {
@@ -3875,6 +3895,12 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   if (!baking_data && !baking_noise && !baking_mesh && !baking_particles 
&& !baking_guide) {
 read_cache = true;
 bake_cache = false;
+
+/* Apply frame offset. */
+data_frame -= mmd->domain->cache_frame_offset;
+noise_frame -= mmd->domain->cache_frame_offset;
+mesh_frame -= mmd->domain->cache_frame_offset;
+particles_frame -= mmd->doma

[Bf-blender-cvs] [84e1e0cf95d] master: Fix T78170: Mantaflow Crash | Whitewater Particles Baking

2020-06-26 Thread Sebastián Barschkis
Commit: 84e1e0cf95dace47e2a35a0ca3adb18be7ec4699
Author: Sebastián Barschkis
Date:   Fri Jun 26 18:29:14 2020 +0200
Branches: master
https://developer.blender.org/rB84e1e0cf95dace47e2a35a0ca3adb18be7ec4699

Fix T78170: Mantaflow Crash | Whitewater Particles Baking

Fixed issue in the upstream Mantaflow repository.

===

M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp

===

diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index e4183ec342b..73ff70b10a0 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 5ae24e860cf15f1310666e119575cc01bea48598"
+#define MANTA_GIT_VERSION "commit d80d3c821de74315ab26b5efd153d41477b976c4"
diff --git a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp 
b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
index 5e24b6f28db..5aae7285f1a 100644
--- a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
+++ b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
@@ -118,7 +118,9 @@ struct knFlipComputeSecondaryParticlePotentials : public 
KernelBase {
 for (IndexInt x = i - radius; x <= i + radius; x++) {
   for (IndexInt y = j - radius; y <= j + radius; y++) {
 for (IndexInt z = k - radius; z <= k + radius; z++) {
-  if ((x == i && y == j && z == k) || !flags.isInBounds(Vec3i(x, y, 
z)) ||
+  // ensure that xyz is in bounds: use bnd=1 to ensure that 
vel.getCentered() always has a
+  // neighbor cell
+  if ((x == i && y == j && z == k) || !flags.isInBounds(Vec3i(x, y, 
z), 1) ||
   (flags(x, y, z) & jtype))
 continue;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2036b9771e5] master: Fluid: Fix typos from OpenVDB update

2020-06-26 Thread Sebastián Barschkis
Commit: 2036b9771e5b2cbc7490cfb3c572c8329bf0bf73
Author: Sebastián Barschkis
Date:   Fri Jun 26 11:47:22 2020 +0200
Branches: master
https://developer.blender.org/rB2036b9771e5b2cbc7490cfb3c572c8329bf0bf73

Fluid: Fix typos from OpenVDB update

Some typos that were not noticed in 995185894289.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 0ccc9d2b57c..a008100a3e2 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -1280,7 +1280,7 @@ bool MANTA::readNoise(FluidModifierData *mmd, int 
framenr, bool resumable)
   FluidDomainSettings *mds = mmd->domain;
 
   string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_NOISE);
-  string resumable_cache = (resumable) ? "False" : "True";
+  string resumable_cache = (!resumable) ? "False" : "True";
 
   /* Support older caches which had more granular file format control. */
   char format = (!strcmp(mds->cache_id, FLUID_CACHE_VERSION)) ? 
mds->cache_data_format :
diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index c97ab2eb988..612d01b85ef 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -551,7 +551,7 @@ const std::string smoke_load_noise =
 "\n\
 def smoke_load_noise_$ID$(path, framenr, file_format, resumable):\n\
 mantaMsg('Smoke load noise')\n\
-dict = { **smoke_noise_dict_final_s$ID$, **smoke_data_dict_resume_s$ID$ } 
if resumable else { **smoke_noise_dict_final_s$ID$ } \n\
+dict = { **smoke_noise_dict_final_s$ID$, **smoke_noise_dict_resume_s$ID$ } 
if resumable else { **smoke_noise_dict_final_s$ID$ } \n\
 fluid_file_import_s$ID$(dict=dict, path=path, framenr=framenr, 
file_format=file_format, file_name=file_noise_s$ID$)\n\
 \n\
 if resumable:\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [31ad8bda74e] master: Fix T77204: Mantaflow Initial velocity bugged?

2020-06-25 Thread Sebastián Barschkis
Commit: 31ad8bda74ec8228db03b5969145c499b0f5a6f3
Author: Sebastián Barschkis
Date:   Thu Jun 25 18:02:58 2020 +0200
Branches: master
https://developer.blender.org/rB31ad8bda74ec8228db03b5969145c499b0f5a6f3

Fix T77204: Mantaflow Initial velocity bugged?

Always initialize the particle velocity of newly sampled particles to 0 if 
there are no initial velocities. Clearing the grid source makes sure that new 
particles will get a 0 velocity - and not interpolated from the associated grid.

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index d7ba220d2c3..04505206601 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -211,10 +211,10 @@ def liquid_adaptive_step_$ID$(framenr):\n\
 if using_invel_s$ID$:\n\
 extrapolateVec3Simple(vel=invelC_s$ID$, phi=phiIn_s$ID$, distance=6, 
inside=True)\n\
 resampleVec3ToMac(source=invelC_s$ID$, target=invel_s$ID$)\n\
-pVel_pp$ID$.setSource(invel_s$ID$, isMAC=True)\n\
-# ensure that pvel has vel as source (important when resuming bake jobs)\n\
+pVel_pp$ID$.setSource(grid=invel_s$ID$, isMAC=True)\n\
+# reset pvel grid source before sampling new particles - ensures that new 
particles are initialized with 0 velocity\n\
 else:\n\
-pVel_pp$ID$.setSource(vel_s$ID$, isMAC=True)\n\
+pVel_pp$ID$.setSource(grid=None, isMAC=False)\n\
 \n\
 sampleLevelsetWithParticles(phi=phiIn_s$ID$, flags=flags_s$ID$, 
parts=pp_s$ID$, discretization=particleNumber_s$ID$, 
randomness=randomness_s$ID$)\n\
 flags_s$ID$.updateFromLevelset(phi_s$ID$)\n\
@@ -310,7 +310,7 @@ def liquid_step_$ID$():\n\
 extrapolateMACSimple(flags=flags_s$ID$, vel=vel_s$ID$)\n\
 \n\
 # set source grids for resampling, used in adjustNumber!\n\
-pVel_pp$ID$.setSource(vel_s$ID$, isMAC=True)\n\
+pVel_pp$ID$.setSource(grid=vel_s$ID$, isMAC=True)\n\
 adjustNumber(parts=pp_s$ID$, vel=vel_s$ID$, flags=flags_s$ID$, 
minParticles=minParticles_s$ID$, maxParticles=maxParticles_s$ID$, 
phi=phi_s$ID$, exclude=phiObs_s$ID$, radiusFactor=radiusFactor_s$ID$, 
narrowBand=adjustedNarrowBandWidth_s$ID$)\n\
 flipVelocityUpdate(vel=vel_s$ID$, velOld=velOld_s$ID$, flags=flags_s$ID$, 
parts=pp_s$ID$, partVel=pVel_pp$ID$, flipRatio=flipRatio_s$ID$)\n";
 
@@ -347,7 +347,7 @@ def liquid_step_mesh_$ID$():\n\
 # Vert vel vector needs to pull data from vel grid with correct dim\n\
 if using_speedvectors_s$ID$:\n\
 interpolateMACGrid(target=vel_sm$ID$, source=vel_s$ID$)\n\
-mVel_mesh$ID$.setSource(vel_sm$ID$, isMAC=True)\n\
+mVel_mesh$ID$.setSource(grid=vel_sm$ID$, isMAC=True)\n\
 \n\
 # Set 0.5 boundary at walls + account for extra wall thickness in 
fractions mode + account for grid scaling:\n\
 # E.g. at upres=1 we expect 1 cell border (or 2 with fractions), at 
upres=2 we expect 2 cell border (or 4 with fractions), etc.\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [495b0eff9a2] master: Fix T77285: Incorrect Mantaflow fluid border interaction when collision is turned off

2020-06-25 Thread Sebastián Barschkis
Commit: 495b0eff9a2d5e3f32c6fd954107bfbf709f33c3
Author: Sebastián Barschkis
Date:   Thu Jun 25 16:49:16 2020 +0200
Branches: master
https://developer.blender.org/rB495b0eff9a2d5e3f32c6fd954107bfbf709f33c3

Fix T77285: Incorrect Mantaflow fluid border interaction when collision is 
turned off

Incorrect boolean for 'open' domain borders.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index e81b2b2e268..0ccc9d2b57c 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -755,7 +755,7 @@ void MANTA::initializeRNAMap(FluidModifierData *mmd)
   mRNAMap["USING_OUTFLOW"] = getBooleanString(mds->active_fields & 
FLUID_DOMAIN_ACTIVE_OUTFLOW);
   mRNAMap["USING_LOG_DISSOLVE"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_DISSOLVE_LOG);
   mRNAMap["USING_DISSOLVE"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_DISSOLVE);
-  mRNAMap["DO_OPEN"] = getBooleanString(mds->border_collisions == 0);
+  mRNAMap["DOMAIN_CLOSED"] = getBooleanString(borderCollisions.compare("") == 
0);
   mRNAMap["CACHE_RESUMABLE"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_RESUMABLE_CACHE);
   mRNAMap["USING_ADAPTIVETIME"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_ADAPTIVE_TIME);
   mRNAMap["USING_SPEEDVECTORS"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_SPEED_VECTORS);
diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index 0fb577cc109..62274101859 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -96,7 +96,7 @@ gravity_s$ID$ = vec3($GRAVITY_X$, $GRAVITY_Y$, $GRAVITY_Z$) # 
in SI unit (e.g. m
 gs_s$ID$  = vec3($RESX$, $RESY$, $RESZ$)\n\
 maxVel_s$ID$  = 0\n\
 \n\
-doOpen_s$ID$   = $DO_OPEN$\n\
+domainClosed_s$ID$ = $DOMAIN_CLOSED$\n\
 boundConditions_s$ID$  = '$BOUND_CONDITIONS$'\n\
 boundaryWidth_s$ID$= $BOUNDARY_WIDTH$\n\
 deleteInObstacle_s$ID$ = $DELETE_IN_OBSTACLE$\n\
diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index 1dec61c02da..d7ba220d2c3 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -257,7 +257,7 @@ def liquid_step_$ID$():\n\
 extrapolateLsSimple(phi=phi_s$ID$, distance=3)\n\
 phi_s$ID$.setBoundNeumann(0) # make sure no particles are placed at outer 
boundary\n\
 \n\
-if doOpen_s$ID$ or using_outflow_s$ID$:\n\
+if not domainClosed_s$ID$ or using_outflow_s$ID$:\n\
 resetOutflow(flags=flags_s$ID$, phi=phi_s$ID$, parts=pp_s$ID$, 
index=gpi_s$ID$, indexSys=pindex_s$ID$)\n\
 flags_s$ID$.updateFromLevelset(phi_s$ID$)\n\
 \n\
@@ -298,10 +298,10 @@ def liquid_step_$ID$():\n\
 \n\
 if using_guiding_s$ID$:\n\
 mantaMsg('Guiding and pressure')\n\
-PD_fluid_guiding(vel=vel_s$ID$, velT=velT_s$ID$, flags=flags_s$ID$, 
phi=phi_s$ID$, curv=curvature_s$ID$, surfTens=surfaceTension_s$ID$, 
fractions=fractions_s$ID$, weight=weightGuide_s$ID$, blurRadius=beta_sg$ID$, 
pressure=pressure_s$ID$, tau=tau_sg$ID$, sigma=sigma_sg$ID$, 
theta=theta_sg$ID$, zeroPressureFixing=not doOpen_s$ID$)\n\
+PD_fluid_guiding(vel=vel_s$ID$, velT=velT_s$ID$, flags=flags_s$ID$, 
phi=phi_s$ID$, curv=curvature_s$ID$, surfTens=surfaceTension_s$ID$, 
fractions=fractions_s$ID$, weight=weightGuide_s$ID$, blurRadius=beta_sg$ID$, 
pressure=pressure_s$ID$, tau=tau_sg$ID$, sigma=sigma_sg$ID$, 
theta=theta_sg$ID$, zeroPressureFixing=domainClosed_s$ID$)\n\
 else:\n\
 mantaMsg('Pressure')\n\
-solvePressure(flags=flags_s$ID$, vel=vel_s$ID$, 
pressure=pressure_s$ID$, phi=phi_s$ID$, curv=curvature_s$ID$, 
surfTens=surfaceTension_s$ID$, fractions=fractions_s$ID$, obvel=obvel_s$ID$ if 
using_fractions_s$ID$ else None)\n\
+solvePressure(flags=flags_s$ID$, vel=vel_s$ID$, 
pressure=pressure_s$ID$, phi=phi_s$ID$, curv=curvature_s$ID$, 
surfTens=surfaceTension_s$ID$, fractions=fractions_s$ID$, obvel=obvel_s$ID$ if 
using_fractions_s$ID$ else None, zeroPressureFixing=domainClosed_s$ID$)\n\
 \n\
 extrapolateMACSimple(flags=flags_s$ID$, vel=vel_s$ID$, distance=4, 
intoObs=True if using_fractions_s$ID$ else False)\n\
 setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=None if 
using_fractions_s$ID$ else obvel_s$ID$, phiObs=phiObs_s$ID$, 
fractions=fractions_s$ID$)\n\
diff --git a/intern/mantaflow/intern/strings/smoke

[Bf-blender-cvs] [ac0852cea0d] master: Fluid: Fix OpenVDB compiler warnings

2020-06-24 Thread Sebastián Barschkis
Commit: ac0852cea0d607b97de1930841fadb1ac1b019e9
Author: Sebastián Barschkis
Date:   Wed Jun 24 18:36:42 2020 +0200
Branches: master
https://developer.blender.org/rBac0852cea0d607b97de1930841fadb1ac1b019e9

Fluid: Fix OpenVDB compiler warnings

Kudos to brecht for noticing the issue

===

M   extern/mantaflow/preprocessed/fileio/iovdb.cpp
M   extern/mantaflow/preprocessed/gitinfo.h

===

diff --git a/extern/mantaflow/preprocessed/fileio/iovdb.cpp 
b/extern/mantaflow/preprocessed/fileio/iovdb.cpp
index 31958dcb977..b31f7e0e760 100644
--- a/extern/mantaflow/preprocessed/fileio/iovdb.cpp
+++ b/extern/mantaflow/preprocessed/fileio/iovdb.cpp
@@ -478,7 +478,7 @@ int readObjectsVDB(const string , 
std::vector *objects, floa
 }
 
 // For every manta object, we loop through the vdb grid list and check for 
a match
-for (const openvdb::GridBase::Ptr vdbGrid : gridsVDB) {
+for (const openvdb::GridBase::Ptr  : gridsVDB) {
   bool nameMatch = (vdbGrid->getName() == (*iter)->getName());
 
   // Sanity checks: Only load valid grids and make sure names match.
diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index 1e96ee26de2..e4183ec342b 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 6725e6840a906167cc63474a22fc822d9aebf3e7"
+#define MANTA_GIT_VERSION "commit 5ae24e860cf15f1310666e119575cc01bea48598"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c2ab069dfca] master: Fluid: Use OpenVDB as the default cache format for liquids too

2020-06-24 Thread Sebastián Barschkis
Commit: c2ab069dfca3c2c82313d7f5d2fa2c0a97dbe514
Author: Sebastián Barschkis
Date:   Wed Jun 24 18:38:56 2020 +0200
Branches: master
https://developer.blender.org/rBc2ab069dfca3c2c82313d7f5d2fa2c0a97dbe514

Fluid: Use OpenVDB as the default cache format for liquids too

With the updated OpenVDB setup, it is now perfectly fine to use OpenVDB for 
liquid domains.

===

M   release/scripts/startup/bl_operators/object_quick_effects.py
M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/release/scripts/startup/bl_operators/object_quick_effects.py 
b/release/scripts/startup/bl_operators/object_quick_effects.py
index 59b66b427f1..311631ac65f 100644
--- a/release/scripts/startup/bl_operators/object_quick_effects.py
+++ b/release/scripts/startup/bl_operators/object_quick_effects.py
@@ -399,6 +399,9 @@ class QuickSmoke(ObjectModeOperator, Operator):
 if self.style == 'FIRE' or self.style == 'BOTH':
 obj.modifiers[-1].domain_settings.use_noise = True
 
+# ensure correct cache file format for smoke
+obj.modifiers[-1].domain_settings.cache_data_format = 'OPENVDB'
+
 # Setup material
 
 # Cycles and Eevee
@@ -511,7 +514,8 @@ class QuickLiquid(Operator):
 obj.modifiers[-1].domain_settings.use_collision_border_top = True
 obj.modifiers[-1].domain_settings.use_collision_border_bottom = True
 
-# set correct cache file format for liquid
+# ensure correct cache file formats for liquid
+obj.modifiers[-1].domain_settings.cache_data_format = 'OPENVDB'
 obj.modifiers[-1].domain_settings.cache_mesh_format = 'BOBJECT'
 
 # change domain type, will also allocate and show particle system for 
FLIP
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 103c3bb119d..98573ea98ec 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4583,13 +4583,9 @@ void BKE_fluid_particles_set(FluidDomainSettings 
*settings, int value, bool clea
 
 void BKE_fluid_domain_type_set(Object *object, FluidDomainSettings *settings, 
int type)
 {
-  /* Set common values for liquid/smoke domain: cache type,
-   * border collision and viewport draw-type. */
+  /* Set values for border collision:
+   * Liquids should have a closed domain, smoke domains should be open. */
   if (type == FLUID_DOMAIN_TYPE_GAS) {
-BKE_fluid_cachetype_mesh_set(settings, FLUID_DOMAIN_FILE_BIN_OBJECT);
-BKE_fluid_cachetype_data_set(settings, FLUID_DOMAIN_FILE_UNI);
-BKE_fluid_cachetype_particle_set(settings, FLUID_DOMAIN_FILE_UNI);
-BKE_fluid_cachetype_noise_set(settings, FLUID_DOMAIN_FILE_UNI);
 BKE_fluid_collisionextents_set(settings, FLUID_DOMAIN_BORDER_FRONT, 1);
 BKE_fluid_collisionextents_set(settings, FLUID_DOMAIN_BORDER_BACK, 1);
 BKE_fluid_collisionextents_set(settings, FLUID_DOMAIN_BORDER_RIGHT, 1);
@@ -4599,10 +4595,6 @@ void BKE_fluid_domain_type_set(Object *object, 
FluidDomainSettings *settings, in
 object->dt = OB_WIRE;
   }
   else if (type == FLUID_DOMAIN_TYPE_LIQUID) {
-BKE_fluid_cachetype_mesh_set(settings, FLUID_DOMAIN_FILE_BIN_OBJECT);
-BKE_fluid_cachetype_data_set(settings, FLUID_DOMAIN_FILE_UNI);
-BKE_fluid_cachetype_particle_set(settings, FLUID_DOMAIN_FILE_UNI);
-BKE_fluid_cachetype_noise_set(settings, FLUID_DOMAIN_FILE_UNI);
 BKE_fluid_collisionextents_set(settings, FLUID_DOMAIN_BORDER_FRONT, 0);
 BKE_fluid_collisionextents_set(settings, FLUID_DOMAIN_BORDER_BACK, 0);
 BKE_fluid_collisionextents_set(settings, FLUID_DOMAIN_BORDER_RIGHT, 0);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ba380fc0bf7] master: Fix T78213: Windows 10 Build Errors: Extern_Manaflow error messages

2020-06-24 Thread Sebastián Barschkis
Commit: ba380fc0bf7b646d2c5d4832f6111879b3dd3f97
Author: Sebastián Barschkis
Date:   Wed Jun 24 18:01:26 2020 +0200
Branches: master
https://developer.blender.org/rBba380fc0bf7b646d2c5d4832f6111879b3dd3f97

Fix T78213: Windows 10 Build Errors: Extern_Manaflow error messages

Kudos to LazyDodo for figuring this out

===

M   extern/mantaflow/helper/util/randomstream.h
M   extern/mantaflow/preprocessed/gitinfo.h

===

diff --git a/extern/mantaflow/helper/util/randomstream.h 
b/extern/mantaflow/helper/util/randomstream.h
index 35b9c7d8858..6c20ddc6a14 100644
--- a/extern/mantaflow/helper/util/randomstream.h
+++ b/extern/mantaflow/helper/util/randomstream.h
@@ -16,13 +16,13 @@
 #ifndef _RANDOMSTREAM_H
 #define _RANDOMSTREAM_H
 
-namespace Manta {
-
 #include 
 #include 
 #include 
 #include "vectorbase.h"
 
+namespace Manta {
+
 class MTRand {
   // Data
  public:
diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index ad7ce45cbce..1e96ee26de2 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 2c83bddc59cd5140e5dd91b172167a7cba9d4960"
+#define MANTA_GIT_VERSION "commit 6725e6840a906167cc63474a22fc822d9aebf3e7"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9fe64948abe] master: Fluid: Updated Mantaflow source with latest OpenVDB changes

2020-06-24 Thread Sebastián Barschkis
Commit: 9fe64948abe991d18c1af3a52d81e87c24d39687
Author: Sebastián Barschkis
Date:   Wed Jun 24 12:00:13 2020 +0200
Branches: master
https://developer.blender.org/rB9fe64948abe991d18c1af3a52d81e87c24d39687

Fluid: Updated Mantaflow source with latest OpenVDB changes

This updated set of Mantaflow files includes the improved  OpenVDB file IO. 
With this update it is finally possible to store multiple grids per file. It is 
also possible to save particle systems and particle data to OpenVDB files.

===

M   extern/mantaflow/CMakeLists.txt
M   extern/mantaflow/helper/pwrapper/pconvert.cpp
M   extern/mantaflow/helper/pwrapper/pconvert.h
M   extern/mantaflow/preprocessed/fileio/iogrids.cpp
M   extern/mantaflow/preprocessed/fileio/iomeshes.cpp
M   extern/mantaflow/preprocessed/fileio/ioparticles.cpp
M   extern/mantaflow/preprocessed/fileio/ioutil.cpp
A   extern/mantaflow/preprocessed/fileio/iovdb.cpp
A   extern/mantaflow/preprocessed/fileio/mantaio.cpp
M   extern/mantaflow/preprocessed/fileio/mantaio.h
M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/grid.cpp
M   extern/mantaflow/preprocessed/grid.h
M   extern/mantaflow/preprocessed/grid4d.cpp
M   extern/mantaflow/preprocessed/grid4d.h
M   extern/mantaflow/preprocessed/particle.cpp
M   extern/mantaflow/preprocessed/particle.h
M   extern/mantaflow/preprocessed/python/defines.py.reg.cpp
M   extern/mantaflow/preprocessed/registration.cpp

===

diff --git a/extern/mantaflow/CMakeLists.txt b/extern/mantaflow/CMakeLists.txt
index bdee06349d2..8b7453bf4c5 100644
--- a/extern/mantaflow/CMakeLists.txt
+++ b/extern/mantaflow/CMakeLists.txt
@@ -54,6 +54,10 @@ if(WITH_OPENVDB)
   add_definitions(-DOPENVDB_STATICLIB)
 endif()
 
+if(WITH_OPENVDB_BLOSC)
+  add_definitions(-DOPENVDB_BLOSC=1)
+endif()
+
 if(WIN32)
   add_definitions(-D_USE_MATH_DEFINES)
 endif()
@@ -106,10 +110,12 @@ set(SRC
   ${MANTA_PP}/fastmarch.cpp
   ${MANTA_PP}/fastmarch.h
   ${MANTA_PP}/fastmarch.h.reg.cpp
-  ${MANTA_PP}/fileio/ioutil.cpp
   ${MANTA_PP}/fileio/iogrids.cpp
   ${MANTA_PP}/fileio/iomeshes.cpp
   ${MANTA_PP}/fileio/ioparticles.cpp
+  ${MANTA_PP}/fileio/ioutil.cpp
+  ${MANTA_PP}/fileio/iovdb.cpp
+  ${MANTA_PP}/fileio/mantaio.cpp
   ${MANTA_PP}/fileio/mantaio.h
   ${MANTA_PP}/fileio/mantaio.h.reg.cpp
   ${MANTA_PP}/fluidsolver.cpp
diff --git a/extern/mantaflow/helper/pwrapper/pconvert.cpp 
b/extern/mantaflow/helper/pwrapper/pconvert.cpp
index 9ada75519fc..861a2c070bd 100644
--- a/extern/mantaflow/helper/pwrapper/pconvert.cpp
+++ b/extern/mantaflow/helper/pwrapper/pconvert.cpp
@@ -96,6 +96,37 @@ template<> PyObject *toPy(const PbClass_Ptr )
 {
   return obj->getPyObject();
 }
+template<> PyObject *toPy>(const std::vector 
)
+{
+  PyObject *listObj = PyList_New(vec.size());
+  if (!listObj)
+throw logic_error("Unable to allocate memory for Python list");
+  for (unsigned int i = 0; i < vec.size(); i++) {
+PbClass *pb = vec[i];
+PyObject *item = pb->getPyObject();
+if (!item) {
+  Py_DECREF(listObj);
+  throw logic_error("Unable to allocate memory for Python list");
+}
+PyList_SET_ITEM(listObj, i, item);
+  }
+  return listObj;
+}
+template<> PyObject *toPy>(const std::vector )
+{
+  PyObject *listObj = PyList_New(vec.size());
+  if (!listObj)
+throw logic_error("Unable to allocate memory for Python list");
+  for (unsigned int i = 0; i < vec.size(); i++) {
+PyObject *item = toPy(vec[i]);
+if (!item) {
+  Py_DECREF(listObj);
+  throw logic_error("Unable to allocate memory for Python list");
+}
+PyList_SET_ITEM(listObj, i, item);
+  }
+  return listObj;
+}
 
 template<> float fromPy(PyObject *obj)
 {
@@ -125,6 +156,42 @@ template<> PyObject *fromPy(PyObject *obj)
 {
   return obj;
 }
+template<> PbClass *fromPy(PyObject *obj)
+{
+  PbClass *pbo = Pb::objFromPy(obj);
+
+  if (!PyType_Check(obj))
+return pbo;
+
+  const char *tname = ((PyTypeObject *)obj)->tp_name;
+  pbo->setName(tname);
+
+  return pbo;
+}
+template<> std::vector fromPy>(PyObject *obj)
+{
+  std::vector vec;
+  if (PyList_Check(obj)) {
+int sz = PyList_Size(obj);
+for (int i = 0; i < sz; ++i) {
+  PyObject *lobj = PyList_GetItem(obj, i);
+  vec.push_back(fromPy(lobj));
+}
+  }
+  return vec;
+}
+template<> std::vector fromPy>(PyObject *obj)
+{
+  std::vector vec;
+  if (PyList_Check(obj)) {
+int sz = PyList_Size(obj);
+for (int i = 0; i < sz; ++i) {
+  PyObject *lobj = PyList_GetItem(obj, i);
+  vec.push_back(fromPy(lobj));
+}
+  }
+  return vec;
+}
 template<> int fromPy(PyObject *obj)
 {
 #if PY_MAJOR_VERSION <= 2
@@ -259,11 +326,10 @@ template T *tmpAlloc(PyObject 

[Bf-blender-cvs] [99518589428] master: Fluid: Improved OpenVDB support for fluid caches

2020-06-24 Thread Sebastián Barschkis
Commit: 9951858942893adeb4eef27ec8a8471a179e9c59
Author: Sebastián Barschkis
Date:   Wed Jun 24 15:30:49 2020 +0200
Branches: master
https://developer.blender.org/rB9951858942893adeb4eef27ec8a8471a179e9c59

Fluid: Improved OpenVDB support for fluid caches

This commit makes uses of the new OpenVDB IO in Mantaflow (introduced in 
781f783a66ac).

From now on, fluid cache files in OpenVDB format will contain a list of grids 
per frame (before: one .vdb file per grid per frame). Besides regular grids, 
particle systems are also stored using OpenVDBs PointGrid data structures.

All older cache formats will remain fully functional:
- Uni caches (.uni) files are still available from the UI and can be used as 
before
- Raw caches (.raw) are no longer available from the UI, but loading them is 
still possible
- Old OpenVDB caches (one .vdb per grid) can no longer be baked either, but 
loading them is still possible.

It is also no longer possible to choose file formats for 'Noise' and 
'Particles'. Instead there are now options to set the file format for 
'Volumetric' and for 'Mesh' data.

Known issues (planned to be resolved soon):
- OpenVDB files are currently not taking into consideration the clipping value 
(FluidDomainSettings). Empty cells are therefore being written too. Depending 
on the scene, this can make file sizes unnecessarily large.
- Domains are not being exported at their world position. Instead they are 
always clipped to the origin.

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h
M   release/scripts/startup/bl_operators/object_quick_effects.py
M   release/scripts/startup/bl_ui/properties_physics_fluid.py
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenkernel/intern/pointcache.c
M   source/blender/editors/physics/physics_fluid.c
M   source/blender/makesdna/DNA_fluid_types.h
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index 7825ad14d7d..d78aa6732b1 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -41,23 +41,23 @@ int manta_write_config(struct MANTA *fluid, struct 
FluidModifierData *mmd, int f
 int manta_write_data(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_read_config(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
-int manta_read_data(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
-int manta_read_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+int manta_read_data(struct MANTA *fluid,
+struct FluidModifierData *mmd,
+int framenr,
+bool resumable);
+int manta_read_noise(struct MANTA *fluid,
+ struct FluidModifierData *mmd,
+ int framenr,
+ bool resumable);
 int manta_read_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
-int manta_read_particles(struct MANTA *fluid, struct FluidModifierData *mmd, 
int framenr);
+int manta_read_particles(struct MANTA *fluid,
+ struct FluidModifierData *mmd,
+ int framenr,
+ bool resumable);
 int manta_read_guiding(struct MANTA *fluid,
struct FluidModifierData *mmd,
int framenr,
bool sourceDomain);
-int manta_update_liquid_structures(struct MANTA *fluid,
-   struct FluidModifierData *mmd,
-   int framenr);
-int manta_update_mesh_structures(struct MANTA *fluid, struct FluidModifierData 
*mmd, int framenr);
-int manta_update_particle_structures(struct MANTA *fluid,
- struct FluidModifierData *mmd,
- int framenr);
-int manta_update_smoke_structures(struct MANTA *fluid, struct 
FluidModifierData *mmd, int framenr);
-int manta_update_noise_structures(struct MANTA *fluid, struct 
FluidModifierData *mmd, int framenr);
 int manta_bake_data(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_bake_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_bake_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
diff --git a/intern/mantaflow/intern

[Bf-blender-cvs] [b91b90f0dd3] master: Fluid: Cleanup internal Python object names

2020-06-05 Thread Sebastián Barschkis
Commit: b91b90f0dd3c9bff3b1a6e563c2cce293722ed16
Author: Sebastián Barschkis
Date:   Fri Jun 5 18:51:45 2020 +0200
Branches: master
https://developer.blender.org/rBb91b90f0dd3c9bff3b1a6e563c2cce293722ed16

Fluid: Cleanup internal Python object names

Manta Python objects should not carry the global ID in their names.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h
M   source/blender/makesdna/DNA_fluid_types.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 95013958561..e760cef8641 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -858,23 +858,144 @@ void MANTA::initializeRNAMap(FluidModifierData *mmd)
   mRNAMap["GRAVITY_Y"] = to_string(mds->gravity[1]);
   mRNAMap["GRAVITY_Z"] = to_string(mds->gravity[2]);
   mRNAMap["CACHE_DIR"] = cacheDirectory;
-  mRNAMap["NAME_DENSITY"] = FLUID_GRIDNAME_DENSITY;
-  mRNAMap["NAME_SHADOW"] = FLUID_GRIDNAME_SHADOW;
-  mRNAMap["NAME_HEAT"] = FLUID_GRIDNAME_HEAT;
-  mRNAMap["NAME_VELOCITY"] = FLUID_GRIDNAME_VELOCITY;
-  mRNAMap["NAME_COLORR"] = FLUID_GRIDNAME_COLORR;
-  mRNAMap["NAME_COLORG"] = FLUID_GRIDNAME_COLORG;
-  mRNAMap["NAME_COLORB"] = FLUID_GRIDNAME_COLORB;
-  mRNAMap["NAME_FLAME"] = FLUID_GRIDNAME_FLAME;
-  mRNAMap["NAME_FUEL"] = FLUID_GRIDNAME_FUEL;
-  mRNAMap["NAME_REACT"] = FLUID_GRIDNAME_REACT;
-  mRNAMap["NAME_DENSITYNOISE"] = FLUID_GRIDNAME_DENSITYNOISE;
-  mRNAMap["NAME_COLORRNOISE"] = FLUID_GRIDNAME_COLORRNOISE;
-  mRNAMap["NAME_COLORGNOISE"] = FLUID_GRIDNAME_COLORGNOISE;
-  mRNAMap["NAME_COLORBNOISE"] = FLUID_GRIDNAME_COLORBNOISE;
-  mRNAMap["NAME_FLAMENOISE"] = FLUID_GRIDNAME_FLAMENOISE;
-  mRNAMap["NAME_FUELNOISE"] = FLUID_GRIDNAME_FUELNOISE;
-  mRNAMap["NAME_REACTNOISE"] = FLUID_GRIDNAME_REACTNOISE;
+
+  /* Fluid object names. */
+  mRNAMap["NAME_FLAGS"] = FLUID_NAME_FLAGS;
+  mRNAMap["NAME_VELOCITY"] = FLUID_NAME_VELOCITY;
+  mRNAMap["NAME_VELOCITYTMP"] = FLUID_NAME_VELOCITYTMP;
+  mRNAMap["NAME_VELOCITY_X"] = FLUID_NAME_VELOCITYX;
+  mRNAMap["NAME_VELOCITY_Y"] = FLUID_NAME_VELOCITYY;
+  mRNAMap["NAME_VELOCITY_Z"] = FLUID_NAME_VELOCITYZ;
+  mRNAMap["NAME_PRESSURE"] = FLUID_NAME_PRESSURE;
+  mRNAMap["NAME_PHIOBS"] = FLUID_NAME_PHIOBS;
+  mRNAMap["NAME_PHISIN"] = FLUID_NAME_PHISIN;
+  mRNAMap["NAME_PHIIN"] = FLUID_NAME_PHIIN;
+  mRNAMap["NAME_PHIOUT"] = FLUID_NAME_PHIOUT;
+  mRNAMap["NAME_FORCES"] = FLUID_NAME_FORCES;
+  mRNAMap["NAME_FORCES_X"] = FLUID_NAME_FORCE_X;
+  mRNAMap["NAME_FORCES_Y"] = FLUID_NAME_FORCE_Y;
+  mRNAMap["NAME_FORCES_Z"] = FLUID_NAME_FORCE_Z;
+  mRNAMap["NAME_NUMOBS"] = FLUID_NAME_NUMOBS;
+  mRNAMap["NAME_PHIOBSSIN"] = FLUID_NAME_PHIOBSSIN;
+  mRNAMap["NAME_PHIOBSIN"] = FLUID_NAME_PHIOBSIN;
+  mRNAMap["NAME_OBVEL"] = FLUID_NAME_OBVEL;
+  mRNAMap["NAME_OBVELC"] = FLUID_NAME_OBVELC;
+  mRNAMap["NAME_OBVEL_X"] = FLUID_NAME_OBVEL_X;
+  mRNAMap["NAME_OBVEL_Y"] = FLUID_NAME_OBVEL_Y;
+  mRNAMap["NAME_OBVEL_Z"] = FLUID_NAME_OBVEL_Z;
+  mRNAMap["NAME_FRACTIONS"] = FLUID_NAME_FRACTIONS;
+  mRNAMap["NAME_INVELC"] = FLUID_NAME_INVELC;
+  mRNAMap["NAME_INVEL"] = FLUID_NAME_INVEL;
+  mRNAMap["NAME_INVEL_X"] = FLUID_NAME_INVEL_X;
+  mRNAMap["NAME_INVEL_Y"] = FLUID_NAME_INVEL_Y;
+  mRNAMap["NAME_INVEL_Z"] = FLUID_NAME_INVEL_Z;
+  mRNAMap["NAME_PHIOUTSIN"] = FLUID_NAME_PHIOUTSIN;
+  mRNAMap["NAME_PHIOUTIN"] = FLUID_NAME_PHIOUTIN;
+
+  /* Smoke object names. */
+  mRNAMap["NAME_SHADOW"] = FLUID_NAME_SHADOW;
+  mRNAMap["NAME_EMISSION"] = FLUID_NAME_EMISSION;
+  mRNAMap["NAME_EMISSIONIN"] = FLUID_NAME_EMISSIONIN;
+  mRNAMap["NAME_DENSITY"] = FLUID_NAME_DENSITY;
+  mRNAMap["NAME_DENSITYIN"] = FLUID_NAME_DENSITYIN;
+  mRNAMap["NAME_HEAT"] = FLUID_NAME_HEAT;
+  mRNAMap["NAME_HEATIN"] = FLUID_NAME_HEATIN;
+  mRNAMap["NAME_COLORR"] = FLUID_NAME_COLORR;
+  mRNAMap["NAME_COLORG"] = FLUID_NAME_COLORG;
+  mRNAMap["NAME_COLORB"] = FLUID_NAME_COLORB;
+  mRNAMap["NAME_COLORRIN"] = FLUID_NAME_COLORRIN;
+  mRNAMap["NAME_COLORGIN"] = FLUID_NAME_COLORGIN;
+  mRNAMap["NAME_COLORBIN"] = FLUID_NAME_COLORBIN;
+  mRNAMa

[Bf-blender-cvs] [df17ee202b5] master: Fix T77203: Mantaflow Bake All cannot be resumed

2020-06-03 Thread Sebastián Barschkis
Commit: df17ee202b5bc13967f430d21553a16b6417ca45
Author: Sebastián Barschkis
Date:   Wed Jun 3 14:54:18 2020 +0200
Branches: master
https://developer.blender.org/rBdf17ee202b5bc13967f430d21553a16b6417ca45

Fix T77203: Mantaflow Bake All cannot be resumed

The manual is also more explicit about this now (rBM6725).

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 2c8ed363738..833cd05dd81 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -1174,7 +1174,7 @@ class PHYSICS_PT_cache(PhysicButtonsPanel, Panel):
 
 if domain.is_cache_baking_data and not domain.has_cache_baked_data:
 split.enabled = False
-split.operator("fluid.pause_bake", text="Baking All - ESC to 
pause")
+split.operator("fluid.pause_bake", text="Baking All - ESC to 
cancel")
 elif not domain.has_cache_baked_data and not 
domain.is_cache_baking_data:
 split.operator("fluid.bake_all", text="Bake All")
 else:

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [aa0e98d7079] master: Merge branch 'blender-v2.83-release'

2020-05-20 Thread Sebastián Barschkis
Commit: aa0e98d7079cedbe6c536b29f1ff01474d9a3925
Author: Sebastián Barschkis
Date:   Wed May 20 16:52:03 2020 +0200
Branches: master
https://developer.blender.org/rBaa0e98d7079cedbe6c536b29f1ff01474d9a3925

Merge branch 'blender-v2.83-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c1545c9a9d1] blender-v2.83-release: Fluid: Fix for non-moving liquid particles

2020-05-20 Thread Sebastián Barschkis
Commit: c1545c9a9d18cc708801b4b40efeab3efc8d
Author: Sebastián Barschkis
Date:   Wed May 20 16:37:29 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBc1545c9a9d18cc708801b4b40efeab3efc8d

Fluid: Fix for non-moving liquid particles

Issue was introduced in 7bb3d9787ead with new Mantaflow files from 61280e5af3da.

===

M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/particle.h

===

diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index 786f6aad4b1..023974fd6cd 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 534495ae4528094e382e4daadbacaa32d5878de1"
+#define MANTA_GIT_VERSION "commit b61bf9efa7a1d8ca98635076a7e9f2c4dacb2914"
diff --git a/extern/mantaflow/preprocessed/particle.h 
b/extern/mantaflow/preprocessed/particle.h
index 74c565593fd..d9dd3f49c38 100644
--- a/extern/mantaflow/preprocessed/particle.h
+++ b/extern/mantaflow/preprocessed/particle.h
@@ -2468,15 +2468,15 @@ template void ParticleSystem::compress()
 //! insert buffered positions as new particles, update additional particle data
 template void ParticleSystem::insertBufferedParticles()
 {
+  // clear new flag everywhere
+  for (IndexInt i = 0; i < (IndexInt)mData.size(); ++i)
+mData[i].flag &= ~PNEW;
+
   if (mNewBufferPos.size() == 0)
 return;
   IndexInt newCnt = mData.size();
   resizeAll(newCnt + mNewBufferPos.size());
 
-  // clear new flag everywhere
-  for (IndexInt i = 0; i < (IndexInt)mData.size(); ++i)
-mData[i].flag &= ~PNEW;
-
   for (IndexInt i = 0; i < (IndexInt)mNewBufferPos.size(); ++i) {
 int flag = (mNewBufferFlag.size() > 0) ? mNewBufferFlag[i] : 0;
 // note, other fields are not initialized here...

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0a19b8a5b44] master: OpenSubdiv: Remove old GPU code

2020-05-19 Thread Sebastián Barschkis
Commit: 0a19b8a5b44e18a22d41d67b82785504eeb65ce2
Author: Sebastián Barschkis
Date:   Tue May 19 21:35:29 2020 +0200
Branches: master
https://developer.blender.org/rB0a19b8a5b44e18a22d41d67b82785504eeb65ce2

OpenSubdiv: Remove old GPU code

This code was accidentally reintroduced in e73d7d27dc66.

===

M   intern/opensubdiv/CMakeLists.txt

===

diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index 06fa637eb32..13565a6ed28 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -90,10 +90,6 @@ if(WITH_OPENSUBDIV)
   OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
   OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE)
 
-  data_to_c_simple(shader/gpu_shader_opensubdiv_vertex.glsl SRC)
-  data_to_c_simple(shader/gpu_shader_opensubdiv_geometry.glsl SRC)
-  data_to_c_simple(shader/gpu_shader_opensubdiv_fragment.glsl SRC)
-
   add_definitions(${GL_DEFINITIONS})
   add_definitions(-DOSD_USES_GLEW)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e73d7d27dc6] master: Merge branch 'blender-v2.83-release'

2020-05-19 Thread Sebastián Barschkis
Commit: e73d7d27dc667e726b2e8c8874c3596e86e622cf
Author: Sebastián Barschkis
Date:   Tue May 19 21:23:54 2020 +0200
Branches: master
https://developer.blender.org/rBe73d7d27dc667e726b2e8c8874c3596e86e622cf

Merge branch 'blender-v2.83-release'

===



===

diff --cc intern/opensubdiv/CMakeLists.txt
index ffebdd93492,c411e58be35..06fa637eb32
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@@ -90,8 -101,12 +90,12 @@@ if(WITH_OPENSUBDIV
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE)
  
-   add_definitions(-DGLEW_STATIC)
+   data_to_c_simple(shader/gpu_shader_opensubdiv_vertex.glsl SRC)
+   data_to_c_simple(shader/gpu_shader_opensubdiv_geometry.glsl SRC)
+   data_to_c_simple(shader/gpu_shader_opensubdiv_fragment.glsl SRC)
+ 
 -  add_definitions(-DOSD_USES_GLEW)
+   add_definitions(${GL_DEFINITIONS})
 +  add_definitions(-DOSD_USES_GLEW)
  
if(WIN32)
  add_definitions(-DNOMINMAX)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [61280e5af3d] blender-v2.83-release: Fluid: Updated Mantaflow source files

2020-05-19 Thread Sebastián Barschkis
Commit: 61280e5af3da50286ae3f42fa673ca7545bd0bd8
Author: Sebastián Barschkis
Date:   Tue May 19 21:09:43 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB61280e5af3da50286ae3f42fa673ca7545bd0bd8

Fluid: Updated Mantaflow source files

Includes changes for particle skipping during advection.

===

M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/particle.h

===

diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index 791dd001bbe..786f6aad4b1 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 21303fab2eda588ec22988bf9e5762d2001c131f"
+#define MANTA_GIT_VERSION "commit 534495ae4528094e382e4daadbacaa32d5878de1"
diff --git a/extern/mantaflow/preprocessed/particle.h 
b/extern/mantaflow/preprocessed/particle.h
index 2d41397a961..74c565593fd 100644
--- a/extern/mantaflow/preprocessed/particle.h
+++ b/extern/mantaflow/preprocessed/particle.h
@@ -469,6 +469,7 @@ template class ParticleSystem : public 
ParticleBase {
 const int integrationMode,
 const bool deleteInObstacle = true,
 const bool stopInObstacle = true,
+const bool skipNew = false,
 const ParticleDataImpl *ptype = NULL,
 const int exclude = 0);
   static PyObject *_W_9(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
@@ -486,13 +487,20 @@ template class ParticleSystem : public 
ParticleBase {
 const int integrationMode = _args.get("integrationMode", 2, 
&_lock);
 const bool deleteInObstacle = _args.getOpt("deleteInObstacle", 
3, true, &_lock);
 const bool stopInObstacle = _args.getOpt("stopInObstacle", 4, 
true, &_lock);
+const bool skipNew = _args.getOpt("skipNew", 5, false, &_lock);
 const ParticleDataImpl *ptype = 
_args.getPtrOpt>(
-"ptype", 5, NULL, &_lock);
-const int exclude = _args.getOpt("exclude", 6, 0, &_lock);
+"ptype", 6, NULL, &_lock);
+const int exclude = _args.getOpt("exclude", 7, 0, &_lock);
 pbo->_args.copy(_args);
 _retval = getPyNone();
-pbo->advectInGrid(
-flags, vel, integrationMode, deleteInObstacle, stopInObstacle, 
ptype, exclude);
+pbo->advectInGrid(flags,
+  vel,
+  integrationMode,
+  deleteInObstacle,
+  stopInObstacle,
+  skipNew,
+  ptype,
+  exclude);
 pbo->_args.check();
   }
   pbFinalizePlugin(pbo->getParent(), "ParticleSystem::advectInGrid", 
!noTiming);
@@ -1863,6 +1871,7 @@ template struct _GridAdvectKernel : public 
KernelBase {
 const Real dt,
 const bool deleteInObstacle,
 const bool stopInObstacle,
+const bool skipNew,
 const ParticleDataImpl *ptype,
 const int exclude,
 std::vector )
@@ -1873,6 +1882,7 @@ template struct _GridAdvectKernel : public 
KernelBase {
 dt(dt),
 deleteInObstacle(deleteInObstacle),
 stopInObstacle(stopInObstacle),
+skipNew(skipNew),
 ptype(ptype),
 exclude(exclude),
 u(u)
@@ -1885,11 +1895,13 @@ template struct _GridAdvectKernel : public 
KernelBase {
  const Real dt,
  const bool deleteInObstacle,
  const bool stopInObstacle,
+ const bool skipNew,
  const ParticleDataImpl *ptype,
  const int exclude,
  std::vector ) const
   {
-if ((p[idx].flag & ParticleBase::PDELETE) || (ptype && ((*ptype)[idx] & 
exclude))) {
+if ((p[idx].flag & ParticleBase::PDELETE) || (ptype && ((*ptype)[idx] & 
exclude)) ||
+(skipNew && (p[idx].flag & ParticleBase::PNEW))) {
   u[idx] = 0.;
   return;
 }
@@ -1910,7 +1922,7 @@ template struct _GridAdvectKernel : public 
KernelBase {
   void operator()(const tbb::blocked_range &__r) const
   {
 for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
-  op(idx, p, vel, flags, dt, deleteInObstacle, stopInObstacle, ptype, 
exclude, u);
+  op(idx, p, vel, flags, dt, deleteInObstacle, stopInObstacle, skipNew, 
ptype, exclude, u);
   }
   void run()
   {
@@ -1922,6 +1934,7 @@ template struct _GridAdvectKernel : public 
KernelBase {
   const Real dt;
   

[Bf-blender-cvs] [7bb3d9787ea] blender-v2.83-release: Fix T76812: [Mantaflow] Inflow particles not continuous

2020-05-19 Thread Sebastián Barschkis
Commit: 7bb3d9787ead90d2a389eeccf05d7be9c56f03e6
Author: Sebastián Barschkis
Date:   Tue May 19 21:12:22 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB7bb3d9787ead90d2a389eeccf05d7be9c56f03e6

Fix T76812: [Mantaflow] Inflow particles not continuous

Makes use of the new particle skipping option introduced in f25a882955cb.

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index e70ede206ba..57f0cbc20b7 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -232,7 +232,7 @@ def liquid_step_$ID$():\n\
 mantaMsg('Liquid step')\n\
 \n\
 mantaMsg('Advecting particles')\n\
-pp_s$ID$.advectInGrid(flags=flags_s$ID$, vel=vel_s$ID$, 
integrationMode=IntRK4, deleteInObstacle=deleteInObstacle_s$ID$, 
stopInObstacle=False)\n\
+pp_s$ID$.advectInGrid(flags=flags_s$ID$, vel=vel_s$ID$, 
integrationMode=IntRK4, deleteInObstacle=deleteInObstacle_s$ID$, 
stopInObstacle=False, skipNew=True)\n\
 \n\
 mantaMsg('Pushing particles out of obstacles')\n\
 pushOutofObs(parts=pp_s$ID$, flags=flags_s$ID$, phiObs=phiObs_s$ID$)\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [338abd6f68d] master: Merge branch 'blender-v2.83-release'

2020-05-19 Thread Sebastián Barschkis
Commit: 338abd6f68d8ba8fc7546d90eedf1eae1ed1a7c0
Author: Sebastián Barschkis
Date:   Tue May 19 16:03:24 2020 +0200
Branches: master
https://developer.blender.org/rB338abd6f68d8ba8fc7546d90eedf1eae1ed1a7c0

Merge branch 'blender-v2.83-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0c20fce2f2b] blender-v2.83-release: Fix T76697: [Mantaflow] mesh generation does not account for some particles

2020-05-19 Thread Sebastián Barschkis
Commit: 0c20fce2f2bf3ef8ebca8bc20d676a1d65d5203d
Author: Sebastián Barschkis
Date:   Tue May 19 16:02:38 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB0c20fce2f2bf3ef8ebca8bc20d676a1d65d5203d

Fix T76697: [Mantaflow] mesh generation does not account for some particles

Adapted mesh generation to account for domains with disabled fractionstoo.

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index 9d1f1024ddb..e70ede206ba 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -349,7 +349,10 @@ def liquid_step_mesh_$ID$():\n\
 interpolateMACGrid(target=vel_sm$ID$, source=vel_s$ID$)\n\
 mVel_mesh$ID$.setSource(vel_sm$ID$, isMAC=True)\n\
 \n\
-phi_sm$ID$.setBound(0.5,int(((upres_sm$ID$)*2)-2) )\n\
+# Set 0.5 boundary at walls + account for extra wall thickness in 
fractions mode + account for grid scaling:\n\
+# E.g. at upres=1 we expect 1 cell border (or 2 with fractions), at 
upres=2 we expect 2 cell border (or 4 with fractions), etc.\n\
+# Use -1 since setBound() starts counting at 0 (and additional -1 for 
fractions to account for solid/fluid interface cells)\n\
+phi_sm$ID$.setBound(value=0.5, boundaryWidth=(upres_sm$ID$*2)-2 if 
using_fractions_s$ID$ else upres_sm$ID$-1)\n\
 phi_sm$ID$.createMesh(mesh_sm$ID$)\n";
 
 const std::string liquid_step_particles =

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4fa1fc29bd4] master: Fluid: Cleanup unused variables

2020-05-19 Thread Sebastián Barschkis
Commit: 4fa1fc29bd45835e26ff3497af8cf2a7c61d3c73
Author: Sebastián Barschkis
Date:   Tue May 19 12:33:17 2020 +0200
Branches: master
https://developer.blender.org/rB4fa1fc29bd45835e26ff3497af8cf2a7c61d3c73

Fluid: Cleanup unused variables

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index a2666135c34..95013958561 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -564,7 +564,7 @@ MANTA::~MANTA()
   result = runPythonString(pythonCommands);
 
   assert(result);
-  (void)result;  // not needed in release
+  UNUSED_VARS(result);
 }
 
 /**
@@ -2997,7 +2997,7 @@ bool MANTA::updateGridsFromUni(string filename, 
vector grids)
 return false;
   }
   assert(expectedBytes == readBytes);
-  (void)expectedBytes;
+  UNUSED_VARS(expectedBytes);
 
   if (with_debug)
 cout << "Fluid: Read successfully: " << filename << endl;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [35f9c3b9a42] master: Merge branch 'blender-v2.83-release'

2020-05-18 Thread Sebastián Barschkis
Commit: 35f9c3b9a42c5a1d6de816e9fe94583cfa470a7c
Author: Sebastián Barschkis
Date:   Mon May 18 17:35:30 2020 +0200
Branches: master
https://developer.blender.org/rB35f9c3b9a42c5a1d6de816e9fe94583cfa470a7c

Merge branch 'blender-v2.83-release'

===



===

diff --cc intern/mantaflow/intern/MANTA_main.cpp
index 0b7f9b2590e,e6da083f3e5..a2666135c34
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@@ -70,30 -61,30 +70,31 @@@ int MANTA::with_debug(0)
  MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID)
  {
if (with_debug)
 -std::cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", "
 -  << res[2] << ")" << std::endl;
 -
 -  mmd->domain->fluid = this;
 -
 -  mUsingLiquid = (mmd->domain->type == FLUID_DOMAIN_TYPE_LIQUID);
 -  mUsingSmoke = (mmd->domain->type == FLUID_DOMAIN_TYPE_GAS);
 -  mUsingNoise = (mmd->domain->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
 -  mUsingFractions = (mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS) && 
mUsingLiquid;
 -  mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
 -  mUsingDiffusion = (mmd->domain->flags & FLUID_DOMAIN_USE_DIFFUSION) && 
mUsingLiquid;
 -  mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && 
mUsingLiquid;
 -  mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE);
 -  mUsingDrops = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
 -  mUsingBubbles = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) 
&& mUsingLiquid;
 -  mUsingFloats = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
 -  mUsingTracers = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) 
&& mUsingLiquid;
 -
 -  mUsingHeat = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && 
mUsingSmoke;
 -  mUsingFire = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && 
mUsingSmoke;
 -  mUsingColors = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
 -  mUsingObstacle = (mmd->domain->active_fields & 
FLUID_DOMAIN_ACTIVE_OBSTACLE);
 -  mUsingInvel = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
 -  mUsingOutflow = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
 +cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", " << res[2]
 + << ")" << endl;
 +
 +  FluidDomainSettings *mds = mmd->domain;
 +  mds->fluid = this;
 +
 +  mUsingLiquid = (mds->type == FLUID_DOMAIN_TYPE_LIQUID);
 +  mUsingSmoke = (mds->type == FLUID_DOMAIN_TYPE_GAS);
 +  mUsingNoise = (mds->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
 +  mUsingFractions = (mds->flags & FLUID_DOMAIN_USE_FRACTIONS) && mUsingLiquid;
 +  mUsingMesh = (mds->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
++  mUsingDiffusion = (mds->flags & FLUID_DOMAIN_USE_DIFFUSION) && mUsingLiquid;
 +  mUsingMVel = (mds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
 +  mUsingGuiding = (mds->flags & FLUID_DOMAIN_USE_GUIDE);
 +  mUsingDrops = (mds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
 +  mUsingBubbles = (mds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && 
mUsingLiquid;
 +  mUsingFloats = (mds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
 +  mUsingTracers = (mds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) && 
mUsingLiquid;
 +
 +  mUsingHeat = (mds->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && mUsingSmoke;
 +  mUsingFire = (mds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
 +  mUsingColors = (mds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
 +  mUsingObstacle = (mds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
 +  mUsingInvel = (mds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
 +  mUsingOutflow = (mds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
  
// Simulation constants
mTempAmb = 0;  // TODO: Maybe use this later for buoyancy calculation
@@@ -226,16 -216,20 +227,20 @@@
mTotalCellsMesh = mResXMesh * mResYMesh * mResZMesh;
  
// Initialize Mantaflow variables in Python
 -  initM

[Bf-blender-cvs] [9bc7ea54961] blender-v2.83-release: Fix T76814: [Mantaflow] Surface Tension always works

2020-05-18 Thread Sebastián Barschkis
Commit: 9bc7ea549612d7216bb65df671157dd4cdca7726
Author: Sebastián Barschkis
Date:   Mon May 18 17:19:43 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB9bc7ea549612d7216bb65df671157dd4cdca7726

Fix T76814: [Mantaflow] Surface Tension always works

Initialize the curvature grid and compute the laplacian only if the diffusion 
flag is set.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 35d4629d195..e6da083f3e5 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -71,6 +71,7 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   mUsingNoise = (mmd->domain->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
   mUsingFractions = (mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS) && 
mUsingLiquid;
   mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
+  mUsingDiffusion = (mmd->domain->flags & FLUID_DOMAIN_USE_DIFFUSION) && 
mUsingLiquid;
   mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && 
mUsingLiquid;
   mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE);
   mUsingDrops = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
@@ -219,6 +220,10 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   initLiquidMesh(mmd);
 }
 
+if (mUsingDiffusion) {
+  initCurvature(mmd);
+}
+
 if (mUsingGuiding) {
   mResGuiding = (mmd->domain->guide_parent) ? mmd->domain->guide_res : 
mmd->domain->res;
   initGuiding(mmd);
@@ -427,6 +432,16 @@ void MANTA::initLiquidMesh(FluidModifierData *mmd)
   mUsingMesh = true;
 }
 
+void MANTA::initCurvature(FluidModifierData *mmd)
+{
+  std::vector pythonCommands;
+  std::string finalString = parseScript(liquid_alloc_curvature, mmd);
+  pythonCommands.push_back(finalString);
+
+  runPythonString(pythonCommands);
+  mUsingDiffusion = true;
+}
+
 void MANTA::initObstacle(FluidModifierData *mmd)
 {
   if (!mPhiObsIn) {
diff --git a/intern/mantaflow/intern/MANTA_main.h 
b/intern/mantaflow/intern/MANTA_main.h
index 21946431f28..5c40fdf7dd8 100644
--- a/intern/mantaflow/intern/MANTA_main.h
+++ b/intern/mantaflow/intern/MANTA_main.h
@@ -66,6 +66,7 @@ struct MANTA {
   void initLiquid(FluidModifierData *mmd);
   void initLiquidMesh(FluidModifierData *mmd);
   void initObstacle(FluidModifierData *mmd);
+  void initCurvature(FluidModifierData *mmd);
   void initGuiding(FluidModifierData *mmd);
   void initFractions(FluidModifierData *mmd);
   void initInVelocity(FluidModifierData *mmd);
@@ -753,6 +754,7 @@ struct MANTA {
   bool mUsingOutflow;
   bool mUsingNoise;
   bool mUsingMesh;
+  bool mUsingDiffusion;
   bool mUsingMVel;
   bool mUsingLiquid;
   bool mUsingSmoke;
diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index f20b218427c..9d1f1024ddb 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -80,11 +80,11 @@ mantaMsg('Liquid alloc')\n\
 phiParts_s$ID$   = s$ID$.create(LevelsetGrid)\n\
 phi_s$ID$= s$ID$.create(LevelsetGrid)\n\
 phiTmp_s$ID$ = s$ID$.create(LevelsetGrid)\n\
-curvature_s$ID$  = s$ID$.create(RealGrid)\n\
 velOld_s$ID$ = s$ID$.create(MACGrid)\n\
 velParts_s$ID$   = s$ID$.create(MACGrid)\n\
 mapWeights_s$ID$ = s$ID$.create(MACGrid)\n\
 fractions_s$ID$  = None # allocated dynamically\n\
+curvature_s$ID$  = None\n\
 \n\
 pp_s$ID$ = s$ID$.create(BasicParticleSystem)\n\
 pVel_pp$ID$  = pp_s$ID$.create(PdataVec3)\n\
@@ -124,6 +124,11 @@ liquid_mesh_dict_s$ID$ = dict(lMesh=mesh_sm$ID$)\n\
 if using_speedvectors_s$ID$:\n\
 liquid_meshvel_dict_s$ID$ = dict(lVelMesh=mVel_mesh$ID$)\n";
 
+const std::string liquid_alloc_curvature =
+"\n\
+mantaMsg('Liquid alloc curvature')\n\
+curvature_s$ID$  = s$ID$.create(RealGrid)\n";
+
 const std::string liquid_alloc_particles =
 "\n\
 ppSnd_sp$ID$ = sp$ID$.create(BasicParticleSystem)\n\
@@ -284,12 +289,13 @@ def liquid_step_$ID$():\n\
 alphaV = viscosity_s$ID$ * s$ID$.timestep * 
float(res_s$ID$*res_s$ID$)\n\
 setWallBcs(flags=flags_s$ID$, vel=vel_s$ID$, obvel=None if 
using_fractions_s$ID$ else obvel_s$ID$, phiObs=phiObs_s$ID$, 
fractions=fractions_s$ID$)\n\
 cgSolveDiffusion(flags_s$ID$, vel_s$ID$, alphaV)\n\
+\n\
+mantaMsg('Curvature')\n\
+getLaplacian(laplacian=curvature_s$ID$, grid=phi_s$ID$)\n\
+curvature

[Bf-blender-cvs] [a975cb92077] master: Fluid: Foundation for new OpenVDB file IO

2020-05-17 Thread Sebastián Barschkis
Commit: a975cb920772dcae69dd38ed32cddfd1d647c721
Author: Sebastián Barschkis
Date:   Sun May 17 16:59:48 2020 +0200
Branches: master
https://developer.blender.org/rBa975cb920772dcae69dd38ed32cddfd1d647c721

Fluid: Foundation for new OpenVDB file IO

This commit lays the foundation for support for OpenVDB caching with multiple 
grids per cache file.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesdna/DNA_fluid_types.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 133e84d71a7..d3f0a0f2aaa 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -843,6 +843,23 @@ void MANTA::initializeRNAMap(FluidModifierData *mmd)
   mRNAMap["GRAVITY_Y"] = to_string(mds->gravity[1]);
   mRNAMap["GRAVITY_Z"] = to_string(mds->gravity[2]);
   mRNAMap["CACHE_DIR"] = cacheDirectory;
+  mRNAMap["NAME_DENSITY"] = FLUID_GRIDNAME_DENSITY;
+  mRNAMap["NAME_SHADOW"] = FLUID_GRIDNAME_SHADOW;
+  mRNAMap["NAME_HEAT"] = FLUID_GRIDNAME_HEAT;
+  mRNAMap["NAME_VELOCITY"] = FLUID_GRIDNAME_VELOCITY;
+  mRNAMap["NAME_COLORR"] = FLUID_GRIDNAME_COLORR;
+  mRNAMap["NAME_COLORG"] = FLUID_GRIDNAME_COLORG;
+  mRNAMap["NAME_COLORB"] = FLUID_GRIDNAME_COLORB;
+  mRNAMap["NAME_FLAME"] = FLUID_GRIDNAME_FLAME;
+  mRNAMap["NAME_FUEL"] = FLUID_GRIDNAME_FUEL;
+  mRNAMap["NAME_REACT"] = FLUID_GRIDNAME_REACT;
+  mRNAMap["NAME_DENSITYNOISE"] = FLUID_GRIDNAME_DENSITYNOISE;
+  mRNAMap["NAME_COLORRNOISE"] = FLUID_GRIDNAME_COLORRNOISE;
+  mRNAMap["NAME_COLORGNOISE"] = FLUID_GRIDNAME_COLORGNOISE;
+  mRNAMap["NAME_COLORBNOISE"] = FLUID_GRIDNAME_COLORBNOISE;
+  mRNAMap["NAME_FLAMENOISE"] = FLUID_GRIDNAME_FLAMENOISE;
+  mRNAMap["NAME_FUELNOISE"] = FLUID_GRIDNAME_FUELNOISE;
+  mRNAMap["NAME_REACTNOISE"] = FLUID_GRIDNAME_REACTNOISE;
 }
 
 string MANTA::getRealValue(const string )
@@ -933,8 +950,7 @@ bool MANTA::updateFlipStructures(FluidModifierData *mmd, 
int framenr)
   mFlipParticleVelocity->clear();
 
   string pformat = getCacheFileEnding(mds->cache_particle_format);
-  string file = getFile(
-  mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_PP, pformat.c_str(), 
framenr);
+  string file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_FILENAME_PP, 
pformat, framenr);
 
   expected += 1;
   if (BLI_exists(file.c_str())) {
@@ -942,7 +958,7 @@ bool MANTA::updateFlipStructures(FluidModifierData *mmd, 
int framenr)
 assert(result == expected);
   }
 
-  file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_PVEL, 
pformat.c_str(), framenr);
+  file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_FILENAME_PVEL, pformat, 
framenr);
   expected += 1;
   if (BLI_exists(file.c_str())) {
 result += updateParticlesFromFile(file, false, true);
@@ -980,7 +996,7 @@ bool MANTA::updateMeshStructures(FluidModifierData *mmd, 
int framenr)
 
   string mformat = getCacheFileEnding(mds->cache_mesh_format);
   string dformat = getCacheFileEnding(mds->cache_data_format);
-  string file = getFile(mmd, FLUID_DOMAIN_DIR_MESH, FLUID_DOMAIN_FILE_MESH, 
mformat, framenr);
+  string file = getFile(mmd, FLUID_DOMAIN_DIR_MESH, FLUID_FILENAME_MESH, 
mformat, framenr);
 
   expected += 1;
   if (BLI_exists(file.c_str())) {
@@ -989,7 +1005,7 @@ bool MANTA::updateMeshStructures(FluidModifierData *mmd, 
int framenr)
   }
 
   if (mUsingMVel) {
-file = getFile(mmd, FLUID_DOMAIN_DIR_MESH, FLUID_DOMAIN_FILE_MESHVEL, 
dformat, framenr);
+file = getFile(mmd, FLUID_DOMAIN_DIR_MESH, FLUID_FILENAME_MESHVEL, 
dformat, framenr);
 expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateMeshFromFile(file);
@@ -1025,8 +1041,7 @@ bool MANTA::updateParticleStructures(FluidModifierData 
*mmd, int framenr)
   mSndParticleLife->clear();
 
   string pformat = getCacheFileEnding(mds->cache_particle_format);
-  string file = getFile(
-  mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_DOMAIN_FILE_PPSND, pformat, 
framenr);
+  string file = getFile(mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_FILENAME_PPSND, 
pformat, framenr);
 
   expected += 1;
   if (BLI_exists(file.c_str())) {
@@ -1034,14 +1049,14 @@ bool MANTA::updateParticleStructures(FluidModifierData 
*mmd, int framenr)
 assert(result == expected);
   }
 
-  file = getFile(mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_DOMAIN_FILE_PVELSND, 
pformat, framenr);
+  file = getFile(mmd, FLUID_DOMAIN_DIR_PARTICLES, FLUID_FILENAME_PVELSND, 
pformat, framenr);
   e

[Bf-blender-cvs] [dde7a762c3e] master: Fluid: Bake cache for more frames by default

2020-05-17 Thread Sebastián Barschkis
Commit: dde7a762c3e3439560c4e2a72d96774308be9fe0
Author: Sebastián Barschkis
Date:   Sun May 17 17:08:59 2020 +0200
Branches: master
https://developer.blender.org/rBdde7a762c3e3439560c4e2a72d96774308be9fe0

Fluid: Bake cache for more frames by default

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 0fd5dc65277..1d0a62fd7b5 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4919,7 +4919,7 @@ void BKE_fluid_modifier_create_type_data(struct 
FluidModifierData *mmd)
 
 /* cache options */
 mmd->domain->cache_frame_start = 1;
-mmd->domain->cache_frame_end = 50;
+mmd->domain->cache_frame_end = 250;
 mmd->domain->cache_frame_pause_data = 0;
 mmd->domain->cache_frame_pause_noise = 0;
 mmd->domain->cache_frame_pause_mesh = 0;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0abe5936b7f] master: Fluid: Cleanup namespace std

2020-05-17 Thread Sebastián Barschkis
Commit: 0abe5936b7f63d1bb7e0e43f700299732d5c0827
Author: Sebastián Barschkis
Date:   Thu May 14 11:08:42 2020 +0200
Branches: master
https://developer.blender.org/rB0abe5936b7f63d1bb7e0e43f700299732d5c0827

Fluid: Cleanup namespace std

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 11ce32fb828..133e84d71a7 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -574,8 +574,8 @@ bool MANTA::runPythonString(vector commands)
 manta_main_module = PyImport_ImportModule("__main__");
   }
 
-  for (vector::iterator it = commands.begin(); it != 
commands.end(); ++it) {
-std::string command = *it;
+  for (vector::iterator it = commands.begin(); it != commands.end(); 
++it) {
+string command = *it;
 
 PyObject *globals_dict = PyModule_GetDict(manta_main_module);
 PyObject *return_value = PyRun_String(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fe257cc3841] master: Fix T74060: Smoke flow force field not working with Mantaflow Gas

2020-05-17 Thread Sebastián Barschkis
Commit: fe257cc38410cb1ee4c458ca3120c15d25f9b1ab
Author: Sebastián Barschkis
Date:   Sun May 17 17:07:34 2020 +0200
Branches: master
https://developer.blender.org/rBfe257cc38410cb1ee4c458ca3120c15d25f9b1ab

Fix T74060: Smoke flow force field not working with Mantaflow Gas

cb252ca8d316 was also needed to fix the velocity loading from the cache.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 26d710c8c7d..0fd5dc65277 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4378,8 +4378,8 @@ static void 
manta_smoke_calc_transparency(FluidDomainSettings *mds, ViewLayer *v
   }
 }
 
-/* get smoke velocity and density at given coordinates
- * returns fluid density or -1.0f if outside domain. */
+/* Get fluid velocity and density at given coordinates
+ * Returns fluid density or -1.0f if outside domain. */
 float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float 
velocity[3])
 {
   FluidModifierData *mmd = (FluidModifierData *)BKE_modifiers_findby_type(ob, 
eModifierType_Fluid);
@@ -4388,16 +4388,15 @@ float BKE_fluid_get_velocity_at(struct Object *ob, 
float position[3], float velo
   if (mmd && (mmd->type & MOD_FLUID_TYPE_DOMAIN) && mmd->domain && 
mmd->domain->fluid) {
 FluidDomainSettings *mds = mmd->domain;
 float time_mult = 25.f * DT_DEFAULT;
+float size_mult = MAX3(mds->global_size[0], mds->global_size[1], 
mds->global_size[2]) /
+  mds->maxres;
 float vel_mag;
-float *velX = manta_get_velocity_x(mds->fluid);
-float *velY = manta_get_velocity_y(mds->fluid);
-float *velZ = manta_get_velocity_z(mds->fluid);
 float density = 0.0f, fuel = 0.0f;
 float pos[3];
 copy_v3_v3(pos, position);
 manta_pos_to_cell(mds, pos);
 
-/* check if point is outside domain max bounds */
+/* Check if position is outside domain max bounds. */
 if (pos[0] < mds->res_min[0] || pos[1] < mds->res_min[1] || pos[2] < 
mds->res_min[2]) {
   return -1.0f;
 }
@@ -4410,9 +4409,8 @@ float BKE_fluid_get_velocity_at(struct Object *ob, float 
position[3], float velo
 pos[1] = (pos[1] - mds->res_min[1]) / ((float)mds->res[1]);
 pos[2] = (pos[2] - mds->res_min[2]) / ((float)mds->res[2]);
 
-/* check if point is outside active area */
-if (mmd->domain->type == FLUID_DOMAIN_TYPE_GAS &&
-mmd->domain->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) {
+/* Check if position is outside active area. */
+if (mds->type == FLUID_DOMAIN_TYPE_GAS && mds->flags & 
FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) {
   if (pos[0] < 0.0f || pos[1] < 0.0f || pos[2] < 0.0f) {
 return 0.0f;
   }
@@ -4421,21 +4419,22 @@ float BKE_fluid_get_velocity_at(struct Object *ob, 
float position[3], float velo
   }
 }
 
-/* get interpolated velocity */
-velocity[0] = BLI_voxel_sample_trilinear(velX, mds->res, pos) * 
mds->global_size[0] *
-  time_mult;
-velocity[1] = BLI_voxel_sample_trilinear(velY, mds->res, pos) * 
mds->global_size[1] *
-  time_mult;
-velocity[2] = BLI_voxel_sample_trilinear(velZ, mds->res, pos) * 
mds->global_size[2] *
-  time_mult;
+/* Get interpolated velocity at given position. */
+velocity[0] = BLI_voxel_sample_trilinear(manta_get_velocity_x(mds->fluid), 
mds->res, pos);
+velocity[1] = BLI_voxel_sample_trilinear(manta_get_velocity_y(mds->fluid), 
mds->res, pos);
+velocity[2] = BLI_voxel_sample_trilinear(manta_get_velocity_z(mds->fluid), 
mds->res, pos);
+
+/* Convert simulation units to Blender units. */
+mul_v3_fl(velocity, size_mult);
+mul_v3_fl(velocity, time_mult);
 
-/* convert velocity direction to global space */
+/* Convert velocity direction to global space. */
 vel_mag = len_v3(velocity);
 mul_mat3_m4_v3(mds->obmat, velocity);
 normalize_v3(velocity);
 mul_v3_fl(velocity, vel_mag);
 
-/* use max value of fuel or smoke density */
+/* Use max value of fuel or smoke density. */
 density = BLI_voxel_sample_trilinear(manta_smoke_get_density(mds->fluid), 
mds->res, pos);
 if (manta_smoke_has_fuel(mds->fluid)) {
   fuel = BLI_voxel_sample_trilinear(manta_smoke_get_fuel(mds->fluid), 
mds->res, pos);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [13769bcbe5c] master: Fluid: Rename smoke flow forces to fluid flow forces

2020-05-14 Thread Sebastián Barschkis
Commit: 13769bcbe5ccce70736ff73107d9284396043379
Author: Sebastián Barschkis
Date:   Thu May 14 10:30:11 2020 +0200
Branches: master
https://developer.blender.org/rB13769bcbe5ccce70736ff73107d9284396043379

Fluid: Rename smoke flow forces to fluid flow forces

Better to use more general term since in theory these forces can be used for 
smoke and liquid.

===

R100release/datafiles/blender_icons16/icon16_force_smokeflow.dat
release/datafiles/blender_icons16/icon16_force_fluidflow.dat
R100release/datafiles/blender_icons32/icon32_force_smokeflow.dat
release/datafiles/blender_icons32/icon32_force_fluidflow.dat
M   release/scripts/startup/bl_ui/properties_physics_field.py
M   source/blender/blenkernel/intern/effect.c
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M   source/blender/depsgraph/intern/depsgraph_physics.cc
M   source/blender/editors/datafiles/CMakeLists.txt
M   source/blender/editors/include/UI_icons.h
M   source/blender/editors/object/object_add.c
M   source/blender/makesdna/DNA_object_force_types.h
M   source/blender/makesrna/intern/rna_object_force.c
M   source/blender/modifiers/intern/MOD_fluid.c

===

diff --git a/release/datafiles/blender_icons16/icon16_force_smokeflow.dat 
b/release/datafiles/blender_icons16/icon16_force_fluidflow.dat
similarity index 100%
rename from release/datafiles/blender_icons16/icon16_force_smokeflow.dat
rename to release/datafiles/blender_icons16/icon16_force_fluidflow.dat
diff --git a/release/datafiles/blender_icons32/icon32_force_smokeflow.dat 
b/release/datafiles/blender_icons32/icon32_force_fluidflow.dat
similarity index 100%
rename from release/datafiles/blender_icons32/icon32_force_smokeflow.dat
rename to release/datafiles/blender_icons32/icon32_force_fluidflow.dat
diff --git a/release/scripts/startup/bl_ui/properties_physics_field.py 
b/release/scripts/startup/bl_ui/properties_physics_field.py
index 00dc068a51a..d1ff1dc9f5e 100644
--- a/release/scripts/startup/bl_ui/properties_physics_field.py
+++ b/release/scripts/startup/bl_ui/properties_physics_field.py
@@ -123,7 +123,7 @@ class PHYSICS_PT_field_settings(PhysicButtonsPanel, Panel):
 col.prop(field, "use_object_coords")
 col.prop(field, "use_2d_force")
 
-elif field.type == 'SMOKE_FLOW':
+elif field.type == 'FLUID_FLOW':
 col = flow.column()
 col.prop(field, "strength")
 col.prop(field, "flow")
diff --git a/source/blender/blenkernel/intern/effect.c 
b/source/blender/blenkernel/intern/effect.c
index bfb03dea39c..fe2c9ed51b8 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -113,7 +113,7 @@ PartDeflect *BKE_partdeflect_new(int type)
 case PFIELD_TEXTURE:
   pd->f_size = 1.0f;
   break;
-case PFIELD_SMOKEFLOW:
+case PFIELD_FLUIDFLOW:
   pd->f_flow = 1.0f;
   break;
   }
@@ -1024,7 +1024,7 @@ static void do_physical_effector(EffectorCache *eff,
 
   mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp));
   break;
-case PFIELD_SMOKEFLOW:
+case PFIELD_FLUIDFLOW:
   zero_v3(force);
 #ifdef WITH_FLUID
   if (pd->f_source) {
@@ -1046,7 +1046,7 @@ static void do_physical_effector(EffectorCache *eff,
   if (pd->flag & PFIELD_DO_LOCATION) {
 madd_v3_v3fl(total_force, force, 1.0f / point->vel_to_sec);
 
-if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG, PFIELD_SMOKEFLOW) 
== 0 &&
+if (ELEM(pd->forcefield, PFIELD_HARMONIC, PFIELD_DRAG, PFIELD_FLUIDFLOW) 
== 0 &&
 pd->f_flow != 0.0f) {
   madd_v3_v3fl(total_force, point->vel, -pd->f_flow * efd->falloff);
 }
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 6e4c343eac3..fddc6b5e0ee 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3196,7 +3196,7 @@ static void update_effectors(
 {
   ListBase *effectors;
   /* make sure smoke flow influence is 0.0f */
-  mds->effector_weights->weight[PFIELD_SMOKEFLOW] = 0.0f;
+  mds->effector_weights->weight[PFIELD_FLUIDFLOW] = 0.0f;
   effectors = BKE_effectors_create(depsgraph, ob, NULL, mds->effector_weights);
 
   if (effectors) {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc 
b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 8f977e07f17..ae90ad8a281 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -433,7 +433,7 @@ void 
DepsgraphRelationBuilder::add_particle_forcefield_relations(const 

[Bf-blender-cvs] [9db08b77e4d] master: Fluid: Fix for refactor 99ee1de094a1

2020-05-13 Thread Sebastián Barschkis
Commit: 9db08b77e4d6b3564721a42391cbbcef08e04f9b
Author: Sebastián Barschkis
Date:   Wed May 13 13:04:49 2020 +0200
Branches: master
https://developer.blender.org/rB9db08b77e4d6b3564721a42391cbbcef08e04f9b

Fluid: Fix for refactor 99ee1de094a1

Fix incorrect file IO functions.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 6671fbc0d7d..11ce32fb828 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -797,13 +797,13 @@ void MANTA::initializeRNAMap(FluidModifierData *mmd)
   mRNAMap["FLAME_SMOKE_COLOR_X"] = to_string(mds->flame_smoke_color[0]);
   mRNAMap["FLAME_SMOKE_COLOR_Y"] = to_string(mds->flame_smoke_color[1]);
   mRNAMap["FLAME_SMOKE_COLOR_Z"] = to_string(mds->flame_smoke_color[2]);
-  mRNAMap["CURRENT_FRAME"] = to_string(mmd->time);
+  mRNAMap["CURRENT_FRAME"] = to_string(int(mmd->time));
   mRNAMap["START_FRAME"] = to_string(mds->cache_frame_start);
   mRNAMap["END_FRAME"] = to_string(mds->cache_frame_end);
-  mRNAMap["CACHE_DATA_FORMAT"] = to_string(mds->cache_data_format);
-  mRNAMap["CACHE_MESH_FORMAT"] = to_string(mds->cache_mesh_format);
-  mRNAMap["CACHE_NOISE_FORMAT"] = to_string(mds->cache_noise_format);
-  mRNAMap["CACHE_PARTICLE_FORMAT"] = to_string(mds->cache_particle_format);
+  mRNAMap["CACHE_DATA_FORMAT"] = getCacheFileEnding(mds->cache_data_format);
+  mRNAMap["CACHE_MESH_FORMAT"] = getCacheFileEnding(mds->cache_mesh_format);
+  mRNAMap["CACHE_NOISE_FORMAT"] = getCacheFileEnding(mds->cache_noise_format);
+  mRNAMap["CACHE_PARTICLE_FORMAT"] = 
getCacheFileEnding(mds->cache_particle_format);
   mRNAMap["SIMULATION_METHOD"] = simulationMethod;
   mRNAMap["FLIP_RATIO"] = to_string(mds->flip_ratio);
   mRNAMap["PARTICLE_RANDOMNESS"] = to_string(mds->particle_randomness);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ebbaae625f7] master: Fluid: Updated Mantaflow source files

2020-05-08 Thread Sebastián Barschkis
Commit: ebbaae625f7e3f713fb7918fd59b32b7d9678861
Author: Sebastián Barschkis
Date:   Fri May 8 16:56:07 2020 +0200
Branches: master
https://developer.blender.org/rBebbaae625f7e3f713fb7918fd59b32b7d9678861

Fluid: Updated Mantaflow source files

Includes more flexible options for dt, dx in secondary particles plugin.

===

M   extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp

===

diff --git a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp 
b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
index a8913a218c1..5e24b6f28db 100644
--- a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
+++ b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
@@ -982,9 +982,14 @@ void flipSampleSecondaryParticles(const std::string mode,
   const Real c_b,
   const Real k_ta,
   const Real k_wc,
-  const Real dt,
+  const Real dt = 0,
   const int itype = FlagGrid::TypeFluid)
 {
+
+  float timestep = dt;
+  if (dt <= 0)
+timestep = flags.getParent()->getDt();
+
   if (mode == "single") {
 knFlipSampleSecondaryParticles(flags,
v,
@@ -1001,7 +1006,7 @@ void flipSampleSecondaryParticles(const std::string mode,
c_b,
k_ta,
k_wc,
-   dt,
+   timestep,
itype);
   }
   else if (mode == "multiple") {
@@ -1020,7 +1025,7 @@ void flipSampleSecondaryParticles(const std::string mode,
 c_b,
 k_ta,
 k_wc,
-dt,
+timestep,
 itype);
   }
   else {
@@ -1053,7 +1058,7 @@ static PyObject *_W_1(PyObject *_self, PyObject 
*_linargs, PyObject *_kwds)
   const Real c_b = _args.get("c_b", 13, &_lock);
   const Real k_ta = _args.get("k_ta", 14, &_lock);
   const Real k_wc = _args.get("k_wc", 15, &_lock);
-  const Real dt = _args.get("dt", 16, &_lock);
+  const Real dt = _args.getOpt("dt", 16, 0, &_lock);
   const int itype = _args.getOpt("itype", 17, FlagGrid::TypeFluid, 
&_lock);
   _retval = getPyNone();
   flipSampleSecondaryParticles(mode,
@@ -1691,13 +1696,20 @@ void flipUpdateSecondaryParticles(const std::string 
mode,
   const Real k_d,
   const Real c_s,
   const Real c_b,
-  const Real dt,
+  const Real dt = 0,
+  bool scale = true,
   const int exclude = ParticleBase::PTRACER,
   const int antitunneling = 0,
   const int itype = FlagGrid::TypeFluid)
 {
 
-  Vec3 g = gravity / flags.getDx();
+  float gridScale = (scale) ? flags.getParent()->getDx() : 1;
+  Vec3 g = gravity / gridScale;
+
+  float timestep = dt;
+  if (dt <= 0)
+timestep = flags.getParent()->getDt();
+
   if (mode == "linear") {
 knFlipUpdateSecondaryParticlesLinear(pts_sec,
  v_sec,
@@ -1711,7 +1723,7 @@ void flipUpdateSecondaryParticles(const std::string mode,
  k_d,
  c_s,
  c_b,
- dt,
+ timestep,
  exclude,
  antitunneling);
   }
@@ -1729,7 +1741,7 @@ void flipUpdateSecondaryParticles(const std::string mode,
 k_d,
 c_s,
 c_b,
-dt,
+timestep,
 exclude,
 antitunneling,
 itype);
@@ -1764,10 +1776,11 @@ static PyObject *_W_2(PyObject *_self, PyObject 
*_linargs, PyObject *_kwds)
   const Real k_d = _args.get("k_d", 11, &_lock);
   const Real c_s = _args.get("c_s", 12, &

[Bf-blender-cvs] [385559843e6] master: Fluid: Adjusted secondary particles timestep and gravity options

2020-05-08 Thread Sebastián Barschkis
Commit: 385559843e6fd0fddf97bae07c9544acd73b73c8
Author: Sebastián Barschkis
Date:   Fri May 8 16:59:00 2020 +0200
Branches: master
https://developer.blender.org/rB385559843e6fd0fddf97bae07c9544acd73b73c8

Fluid: Adjusted secondary particles timestep and gravity options

Secondary particles are now compatible with the new gravity setup.

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index ee1f0878687..cdacea16953 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -372,8 +372,8 @@ def liquid_step_particles_$ID$():\n\
 \n\
 # Actual secondary particle simulation\n\
 flipComputeSecondaryParticlePotentials(potTA=trappedAir_sp$ID$, 
potWC=waveCrest_sp$ID$, potKE=kineticEnergy_sp$ID$, 
neighborRatio=neighborRatio_sp$ID$, flags=flags_sp$ID$, v=vel_sp$ID$, 
normal=normal_sp$ID$, phi=phi_sp$ID$, radius=pot_radius_sp$ID$, 
tauMinTA=tauMin_ta_sp$ID$, tauMaxTA=tauMax_ta_sp$ID$, 
tauMinWC=tauMin_wc_sp$ID$, tauMaxWC=tauMax_wc_sp$ID$, tauMinKE=tauMin_k_sp$ID$, 
tauMaxKE=tauMax_k_sp$ID$, scaleFromManta=ratioMetersToRes_s$ID$)\n\
-flipSampleSecondaryParticles(mode='single', flags=flags_sp$ID$, 
v=vel_sp$ID$, pts_sec=ppSnd_sp$ID$, v_sec=pVelSnd_pp$ID$, 
l_sec=pLifeSnd_pp$ID$, lMin=lMin_sp$ID$, lMax=lMax_sp$ID$, 
potTA=trappedAir_sp$ID$, potWC=waveCrest_sp$ID$, potKE=kineticEnergy_sp$ID$, 
neighborRatio=neighborRatio_sp$ID$, c_s=c_s_sp$ID$, c_b=c_b_sp$ID$, 
k_ta=k_ta_sp$ID$, k_wc=k_wc_sp$ID$, dt=sp$ID$.timestep)\n\
-flipUpdateSecondaryParticles(mode='linear', pts_sec=ppSnd_sp$ID$, 
v_sec=pVelSnd_pp$ID$, l_sec=pLifeSnd_pp$ID$, f_sec=pForceSnd_pp$ID$, 
flags=flags_sp$ID$, v=vel_sp$ID$, neighborRatio=neighborRatio_sp$ID$, 
radius=update_radius_sp$ID$, gravity=gravity_s$ID$, k_b=k_b_sp$ID$, 
k_d=k_d_sp$ID$, c_s=c_s_sp$ID$, c_b=c_b_sp$ID$, dt=sp$ID$.timestep)\n\
+flipSampleSecondaryParticles(mode='single', flags=flags_sp$ID$, 
v=vel_sp$ID$, pts_sec=ppSnd_sp$ID$, v_sec=pVelSnd_pp$ID$, 
l_sec=pLifeSnd_pp$ID$, lMin=lMin_sp$ID$, lMax=lMax_sp$ID$, 
potTA=trappedAir_sp$ID$, potWC=waveCrest_sp$ID$, potKE=kineticEnergy_sp$ID$, 
neighborRatio=neighborRatio_sp$ID$, c_s=c_s_sp$ID$, c_b=c_b_sp$ID$, 
k_ta=k_ta_sp$ID$, k_wc=k_wc_sp$ID$)\n\
+flipUpdateSecondaryParticles(mode='linear', pts_sec=ppSnd_sp$ID$, 
v_sec=pVelSnd_pp$ID$, l_sec=pLifeSnd_pp$ID$, f_sec=pForceSnd_pp$ID$, 
flags=flags_sp$ID$, v=vel_sp$ID$, neighborRatio=neighborRatio_sp$ID$, 
radius=update_radius_sp$ID$, gravity=gravity_s$ID$, scale=False, 
k_b=k_b_sp$ID$, k_d=k_d_sp$ID$, c_s=c_s_sp$ID$, c_b=c_b_sp$ID$)\n\
 if using_snd_pushout_sp$ID$:\n\
 pushOutofObs(parts=ppSnd_sp$ID$, flags=flags_sp$ID$, 
phiObs=phiObs_sp$ID$, shift=1.0)\n\
 flipDeleteParticlesInObstacle(pts=ppSnd_sp$ID$, flags=flags_sp$ID$) # 
delete particles inside obstacle and outflow cells\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [18f833be298] master: Additional fix for T76426: Mantaflow Liquid - Gravity not respecting Time Scale from domain.

2020-05-08 Thread Sebastián Barschkis
Commit: 18f833be2986c3432b28802a783c4ff5a10abafa
Author: Sebastián Barschkis
Date:   Fri May 8 13:11:23 2020 +0200
Branches: master
https://developer.blender.org/rB18f833be2986c3432b28802a783c4ff5a10abafa

Additional fix for T76426: Mantaflow Liquid - Gravity not respecting Time Scale 
from domain.

Removed time scale from another conversion factor. See also changes from 
6400f54b4cc6.

===

M   intern/mantaflow/intern/strings/fluid_script.h

===

diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index b237d782f09..922e591c001 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -118,7 +118,13 @@ using_diffusion_s$ID$= $USING_DIFFUSION$\n\
 timeScale_s$ID$= $TIME_SCALE$\n\
 timeTotal_s$ID$= $TIME_TOTAL$\n\
 timePerFrame_s$ID$ = $TIME_PER_FRAME$\n\
-frameLength_s$ID$  = $FRAME_LENGTH$\n\
+\n\
+# In Blender fluid.c: frame_length = DT_DEFAULT * (25.0 / fps) * time_scale\n\
+# with DT_DEFAULT = 0.1\n\
+frameLength_s$ID$ = $FRAME_LENGTH$\n\
+frameLengthUnscaled_s$ID$  = frameLength_s$ID$ / timeScale_s$ID$\n\
+frameLengthRaw_s$ID$ = 0.1 * 25 # dt = 0.1 at 25 fps\n\
+\n\
 dt0_s$ID$  = $DT$\n\
 cflCond_s$ID$  = $CFL$\n\
 timestepsMin_s$ID$ = $TIMESTEPS_MIN$\n\
@@ -140,10 +146,10 @@ mantaMsg('1 Mantaflow cell is ' + 
str(ratioMetersToRes_s$ID$) + ' Blender length
 ratioResToBLength_s$ID$ = float(res_s$ID$) / float(domainSize_s$ID$) # [cells 
/ blength] (blength: cm, m, or km, ... )\n\
 mantaMsg('1 Blender length unit is ' + str(ratioResToBLength_s$ID$) + ' 
Mantaflow cells long.')\n\
 \n\
-ratioBTimeToTimstep_s$ID$ = float(1) / float(0.1 * 25) # the time within 1 
blender time unit, see also fluid.c\n\
+ratioBTimeToTimstep_s$ID$ = float(1) / float(frameLengthRaw_s$ID$) # the time 
within 1 blender time unit, see also fluid.c\n\
 mantaMsg('1 Blender time unit is ' + str(ratioBTimeToTimstep_s$ID$) + ' 
Mantaflow time units long.')\n\
 \n\
-ratioFrameToFramelength_s$ID$ = float(1) / float(frameLength_s$ID$) # the time 
within 1 frame\n\
+ratioFrameToFramelength_s$ID$ = float(1) / float(frameLengthUnscaled_s$ID$ ) # 
the time within 1 frame\n\
 mantaMsg('frame / frameLength is ' + str(ratioFrameToFramelength_s$ID$) + ' 
Mantaflow time units long.')\n\
 \n\
 scaleAcceleration_s$ID$ = ratioResToBLength_s$ID$ * 
(ratioBTimeToTimstep_s$ID$**2)# [meters/btime^2] to [cells/timestep^2] (btime: 
sec, min, or h, ...)\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ab122c73ba3] master: Fluid: Use cached value for total time value

2020-05-07 Thread Sebastián Barschkis
Commit: ab122c73ba3504b5bada7f124115a557a7b466ee
Author: Sebastián Barschkis
Date:   Thu May 7 17:33:17 2020 +0200
Branches: master
https://developer.blender.org/rBab122c73ba3504b5bada7f124115a557a7b466ee

Fluid: Use cached value for total time value

The old time_total initialization was in trouble if scenes made use of a 
variable framelength (e.g. by animating the time scale parameter).

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 58d49622597..b8dc631b08e 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -1254,6 +1254,7 @@ bool MANTA::writeConfiguration(FluidModifierData *mmd, 
int framenr)
   gzwrite(gzf, >res_min, 3 * sizeof(int));
   gzwrite(gzf, >res_max, 3 * sizeof(int));
   gzwrite(gzf, >active_color, 3 * sizeof(float));
+  gzwrite(gzf, >time_total, sizeof(int));
 
   return (gzclose(gzf) == Z_OK);
 }
@@ -1353,6 +1354,8 @@ bool MANTA::readConfiguration(FluidModifierData *mmd, int 
framenr)
   gzread(gzf, >res_min, 3 * sizeof(int));
   gzread(gzf, >res_max, 3 * sizeof(int));
   gzread(gzf, >active_color, 3 * sizeof(float));
+  gzread(gzf, >time_total, sizeof(int));
+
   mds->total_cells = mds->res[0] * mds->res[1] * mds->res[2];
 
   return (gzclose(gzf) == Z_OK);
diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index 0619da67f64..b237d782f09 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -552,7 +552,7 @@ def bake_noise_process_$ID$(framenr, format_data, 
format_noise, path_data, path_
 \n\
 sn$ID$.frame = framenr\n\
 sn$ID$.frameLength = frameLength_s$ID$\n\
-sn$ID$.timeTotal = abs(framenr - start_frame_s$ID$) * frameLength_s$ID$\n\
+sn$ID$.timeTotal = timeTotal_s$ID$\n\
 sn$ID$.timestep = frameLength_s$ID$ # no adaptive timestep for noise\n\
 \n\
 smoke_step_noise_$ID$(framenr)\n\
@@ -570,7 +570,7 @@ def bake_mesh_process_$ID$(framenr, format_data, 
format_mesh, format_particles,
 \n\
 sm$ID$.frame = framenr\n\
 sm$ID$.frameLength = frameLength_s$ID$\n\
-sm$ID$.timeTotal = abs(framenr - start_frame_s$ID$) * frameLength_s$ID$\n\
+sm$ID$.timeTotal = timeTotal_s$ID$\n\
 sm$ID$.timestep = frameLength_s$ID$ # no adaptive timestep for mesh\n\
 \n\
 #if using_smoke_s$ID$:\n\
@@ -594,7 +594,7 @@ def bake_particles_process_$ID$(framenr, format_data, 
format_particles, path_dat
 \n\
 sp$ID$.frame = framenr\n\
 sp$ID$.frameLength = frameLength_s$ID$\n\
-sp$ID$.timeTotal = abs(framenr - start_frame_s$ID$) * frameLength_s$ID$\n\
+sp$ID$.timeTotal = timeTotal_s$ID$\n\
 sp$ID$.timestep = frameLength_s$ID$ # no adaptive timestep for particles\n\
 \n\
 #if using_smoke_s$ID$:\n\
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index e1682c557c8..b6986f12bb9 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -533,7 +533,6 @@ static bool BKE_fluid_modifier_init(
 /* Initially dt is equal to frame length (dt can change with adaptive-time 
stepping though). */
 mds->dt = mds->frame_length;
 mds->time_per_frame = 0;
-mds->time_total = abs(scene_framenr - mds->cache_frame_start) * 
mds->frame_length;
 
 mmd->time = scene_framenr;
 
@@ -3547,7 +3546,7 @@ static int manta_step(
 Depsgraph *depsgraph, Scene *scene, Object *ob, Mesh *me, 
FluidModifierData *mmd, int frame)
 {
   FluidDomainSettings *mds = mmd->domain;
-  float dt, frame_length, time_total;
+  float dt, frame_length, time_total, time_total_old;
   float time_per_frame;
   bool init_resolution = true;
 
@@ -3571,6 +3570,8 @@ static int manta_step(
   dt = mds->dt;
   time_per_frame = 0;
   time_total = mds->time_total;
+  /* Keep track of original total time to correct small errors at end of step. 
*/
+  time_total_old = mds->time_total;
 
   BLI_mutex_lock(_update_lock);
 
@@ -3616,6 +3617,8 @@ static int manta_step(
 mds->time_per_frame = time_per_frame;
 mds->time_total = time_total;
   }
+  /* Total time must not exceed framecount times framelength. Correct tiny 
errors here. */
+  CLAMP(mds->time_total, mds->time_total, time_total_old + mds->frame_length);
 
   if (mds->type == FLUID_DOMAIN_TYPE_GAS && result) {
 manta_smoke_calc_transparency(mds, 
DEG_get_evaluated_view_layer(depsgraph));
@@ -3771,8 +3774,6 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   mds->frame_length = DT_DEF

[Bf-blender-cvs] [6400f54b4cc] master: Fix T76426: Mantaflow Liquid - Gravity not respecting Time Scale from domain.

2020-05-07 Thread Sebastián Barschkis
Commit: 6400f54b4cc6d9cdb420ac4f62dd5eb0387aa7c0
Author: Sebastián Barschkis
Date:   Thu May 7 17:15:15 2020 +0200
Branches: master
https://developer.blender.org/rB6400f54b4cc6d9cdb420ac4f62dd5eb0387aa7c0

Fix T76426: Mantaflow Liquid - Gravity not respecting Time Scale from domain.

Removed timescale from conversion factor - factors should stay constant even if 
timescale changes.

===

M   intern/mantaflow/intern/strings/fluid_script.h

===

diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index c0a23f77d7a..0619da67f64 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -140,7 +140,7 @@ mantaMsg('1 Mantaflow cell is ' + 
str(ratioMetersToRes_s$ID$) + ' Blender length
 ratioResToBLength_s$ID$ = float(res_s$ID$) / float(domainSize_s$ID$) # [cells 
/ blength] (blength: cm, m, or km, ... )\n\
 mantaMsg('1 Blender length unit is ' + str(ratioResToBLength_s$ID$) + ' 
Mantaflow cells long.')\n\
 \n\
-ratioBTimeToTimstep_s$ID$ = float(1) / float(0.1 * 25 * timeScale_s$ID$) # the 
time within 1 blender time unit, see also fluid.c\n\
+ratioBTimeToTimstep_s$ID$ = float(1) / float(0.1 * 25) # the time within 1 
blender time unit, see also fluid.c\n\
 mantaMsg('1 Blender time unit is ' + str(ratioBTimeToTimstep_s$ID$) + ' 
Mantaflow time units long.')\n\
 \n\
 ratioFrameToFramelength_s$ID$ = float(1) / float(frameLength_s$ID$) # the time 
within 1 frame\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [578e9767108] master: Merge branch 'blender-v2.83-release'

2020-05-06 Thread Sebastián Barschkis
Commit: 578e97671083455e271ac4dfff4e81fdd63ce1d5
Author: Sebastián Barschkis
Date:   Wed May 6 13:25:48 2020 +0200
Branches: master
https://developer.blender.org/rB578e97671083455e271ac4dfff4e81fdd63ce1d5

Merge branch 'blender-v2.83-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [11d440f1a26] blender-v2.83-release: Fix T76430: Quick smoke not rendering Cycles and Eevee

2020-05-06 Thread Sebastián Barschkis
Commit: 11d440f1a261a0b80d909af77261ee47710a4170
Author: Sebastián Barschkis
Date:   Wed May 6 13:24:53 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB11d440f1a261a0b80d909af77261ee47710a4170

Fix T76430: Quick smoke not rendering Cycles and Eevee

Temporary fix that will skip cache invalidation from flow / effector objects.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 96efac8f2c5..7adac2d4a4d 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3762,14 +3762,16 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
 MEM_freeN(objs);
   }
 
+  /* TODO (sebbas): Cache reset for when flow / effector object need update 
flag is set. */
+#  if 0
   /* If the just updated flags now carry the 'outdated' flag, reset the cache 
here!
* Plus sanity check: Do not clear cache on file load. */
   if (mds->cache_flag & FLUID_DOMAIN_OUTDATED_DATA &&
   ((mds->flags & FLUID_DOMAIN_FILE_LOAD) == 0)) {
-mds->cache_flag &= ~FLUID_DOMAIN_OUTDATED_DATA;
 BKE_fluid_cache_free_all(mds, ob);
 BKE_fluid_modifier_reset_ex(mmd, false);
   }
+#  endif
 
   /* Fluid domain init must not fail in order to continue modifier evaluation. 
*/
   if (!mds->fluid && !BKE_fluid_modifier_init(mmd, depsgraph, ob, scene, me)) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [375a50dad9c] master: Merge branch 'blender-v2.83-release'

2020-05-04 Thread Sebastián Barschkis
Commit: 375a50dad9c5829e2ed205216e0bb7317635868e
Author: Sebastián Barschkis
Date:   Mon May 4 18:18:15 2020 +0200
Branches: master
https://developer.blender.org/rB375a50dad9c5829e2ed205216e0bb7317635868e

Merge branch 'blender-v2.83-release'

===



===

diff --cc intern/mantaflow/intern/MANTA_main.cpp
index fd273b728e7,d6c1d05e0da..58d49622597
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@@ -3062,7 -3232,7 +3062,7 @@@ void MANTA::updatePointers(
  
  bool MANTA::hasConfig(FluidModifierData *mmd, int framenr)
  {
-   string extension = getCacheFileEnding(mmd->domain->cache_data_format);
 -  std::string extension = FLUID_DOMAIN_EXTENSION_UNI;
++  string extension = FLUID_DOMAIN_EXTENSION_UNI;
return BLI_exists(
getFile(mmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_DOMAIN_FILE_CONFIG, 
extension, framenr).c_str());
  }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8b5868cc15d] blender-v2.83-release: Fix T75883: Smoke simulations with Adaptive Domain broken for 'Final' bakes with OpenVDB in 2.83

2020-05-04 Thread Sebastián Barschkis
Commit: 8b5868cc15dac0a967bb7cd03e0ed2a15026fb35
Author: Sebastián Barschkis
Date:   Mon May 4 18:16:09 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB8b5868cc15dac0a967bb7cd03e0ed2a15026fb35

Fix T75883: Smoke simulations with Adaptive Domain broken for 'Final' bakes 
with OpenVDB in 2.83

Config files always use the .uni extenstion.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index a56ce4c1f60..d6c1d05e0da 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -3232,7 +3232,7 @@ void MANTA::updatePointers()
 
 bool MANTA::hasConfig(FluidModifierData *mmd, int framenr)
 {
-  std::string extension = getCacheFileEnding(mmd->domain->cache_data_format);
+  std::string extension = FLUID_DOMAIN_EXTENSION_UNI;
   return BLI_exists(
   getFile(mmd, FLUID_DOMAIN_DIR_CONFIG, FLUID_DOMAIN_FILE_CONFIG, 
extension, framenr).c_str());
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6ea71cb1041] master: Fluid: Fix for refactor 99ee1de094a1

2020-05-04 Thread Sebastián Barschkis
Commit: 6ea71cb104109d7108f964742dff2b9c2766917a
Author: Sebastián Barschkis
Date:   Mon May 4 13:36:23 2020 +0200
Branches: master
https://developer.blender.org/rB6ea71cb104109d7108f964742dff2b9c2766917a

Fluid: Fix for refactor 99ee1de094a1

Use booleans instead of 0 / 1 in Python

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index d59c7464934..fd273b728e7 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -627,6 +627,11 @@ static string getCacheFileEnding(char cache_format)
   }
 }
 
+static string getBooleanString(int value)
+{
+  return (value) ? "True" : "False";
+}
+
 void MANTA::initializeRNAMap(FluidModifierData *mmd)
 {
   if (with_debug)
@@ -643,10 +648,6 @@ void MANTA::initializeRNAMap(FluidModifierData *mmd)
   FluidDomainSettings *mds = mmd->domain;
   bool is2D = (mds->solver_res == 2);
 
-  int openDomain = (FLUID_DOMAIN_BORDER_BACK | FLUID_DOMAIN_BORDER_FRONT |
-FLUID_DOMAIN_BORDER_LEFT | FLUID_DOMAIN_BORDER_RIGHT |
-FLUID_DOMAIN_BORDER_BOTTOM | FLUID_DOMAIN_BORDER_TOP);
-
   string borderCollisions = "";
   if ((mds->border_collisions & FLUID_DOMAIN_BORDER_LEFT) == 0)
 borderCollisions += "x";
@@ -693,20 +694,38 @@ void MANTA::initializeRNAMap(FluidModifierData *mmd)
 
   string cacheDirectory(mds->cache_directory);
 
-  mRNAMap["USING_SMOKE"] = to_string((mds->type == FLUID_DOMAIN_TYPE_GAS) != 
0);
-  mRNAMap["USING_LIQUID"] = to_string((mds->type == FLUID_DOMAIN_TYPE_LIQUID) 
!= 0);
-  mRNAMap["USING_COLORS"] = to_string((mds->active_fields & 
FLUID_DOMAIN_ACTIVE_COLORS) != 0);
-  mRNAMap["USING_HEAT"] = to_string((mds->active_fields & 
FLUID_DOMAIN_ACTIVE_HEAT) != 0);
-  mRNAMap["USING_FIRE"] = to_string((mds->active_fields & 
FLUID_DOMAIN_ACTIVE_FIRE) != 0);
-  mRNAMap["USING_NOISE"] = to_string((mds->flags & FLUID_DOMAIN_USE_NOISE) != 
0);
-  mRNAMap["USING_OBSTACLE"] = to_string((mds->active_fields & 
FLUID_DOMAIN_ACTIVE_OBSTACLE) != 0);
-  mRNAMap["USING_GUIDING"] = to_string((mds->flags & FLUID_DOMAIN_USE_GUIDE) 
!= 0);
-  mRNAMap["USING_INVEL"] = to_string((mds->active_fields & 
FLUID_DOMAIN_ACTIVE_INVEL) != 0);
-  mRNAMap["USING_OUTFLOW"] = to_string((mds->active_fields & 
FLUID_DOMAIN_ACTIVE_OUTFLOW) != 0);
-  mRNAMap["USING_LOG_DISSOLVE"] = to_string((mds->flags & 
FLUID_DOMAIN_USE_DISSOLVE_LOG) != 0);
-  mRNAMap["USING_DISSOLVE"] = to_string((mds->flags & 
FLUID_DOMAIN_USE_DISSOLVE) != 0);
+  float viscosity = mds->viscosity_base * pow(10.0f, -mds->viscosity_exponent);
+  float domainSize = MAX3(mds->global_size[0], mds->global_size[1], 
mds->global_size[2]);
+
+  mRNAMap["USING_SMOKE"] = getBooleanString(mds->type == 
FLUID_DOMAIN_TYPE_GAS);
+  mRNAMap["USING_LIQUID"] = getBooleanString(mds->type == 
FLUID_DOMAIN_TYPE_LIQUID);
+  mRNAMap["USING_COLORS"] = getBooleanString(mds->active_fields & 
FLUID_DOMAIN_ACTIVE_COLORS);
+  mRNAMap["USING_HEAT"] = getBooleanString(mds->active_fields & 
FLUID_DOMAIN_ACTIVE_HEAT);
+  mRNAMap["USING_FIRE"] = getBooleanString(mds->active_fields & 
FLUID_DOMAIN_ACTIVE_FIRE);
+  mRNAMap["USING_NOISE"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_NOISE);
+  mRNAMap["USING_OBSTACLE"] = getBooleanString(mds->active_fields & 
FLUID_DOMAIN_ACTIVE_OBSTACLE);
+  mRNAMap["USING_GUIDING"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_GUIDE);
+  mRNAMap["USING_INVEL"] = getBooleanString(mds->active_fields & 
FLUID_DOMAIN_ACTIVE_INVEL);
+  mRNAMap["USING_OUTFLOW"] = getBooleanString(mds->active_fields & 
FLUID_DOMAIN_ACTIVE_OUTFLOW);
+  mRNAMap["USING_LOG_DISSOLVE"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_DISSOLVE_LOG);
+  mRNAMap["USING_DISSOLVE"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_DISSOLVE);
+  mRNAMap["DO_OPEN"] = getBooleanString(mds->border_collisions == 0);
+  mRNAMap["CACHE_RESUMABLE"] = getBooleanString(mds->cache_type != 
FLUID_DOMAIN_CACHE_FINAL);
+  mRNAMap["USING_ADAPTIVETIME"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_ADAPTIVE_TIME);
+  mRNAMap["USING_SPEEDVECTORS"] = getBooleanString(mds->flags & 
FLUID_DOMAIN_USE_SPEED_VECTORS);
+  mRNAMap["USING_FRACTIONS"] = getBooleanString(mds->

[Bf-blender-cvs] [70fe988dc49] master: Fluid: Cleanup use of std in MANTA wrapper

2020-05-03 Thread Sebastián Barschkis
Commit: 70fe988dc497ce4de6269aa28f579c528e2ac797
Author: Sebastián Barschkis
Date:   Sun May 3 21:10:38 2020 +0200
Branches: master
https://developer.blender.org/rB70fe988dc497ce4de6269aa28f579c528e2ac797

Fluid: Cleanup use of std in MANTA wrapper

Moved std namespace to beginning of class.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 995cce4a1ce..d59c7464934 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -48,7 +48,16 @@
 
 #include "MEM_guardedalloc.h"
 
-std::atomic MANTA::solverID(0);
+using std::cerr;
+using std::cout;
+using std::endl;
+using std::ifstream;
+using std::istringstream;
+using std::ofstream;
+using std::ostringstream;
+using std::to_string;
+
+atomic MANTA::solverID(0);
 int MANTA::with_debug(0);
 
 /* Number of particles that the cache reads at once (with zlib). */
@@ -61,8 +70,8 @@ int MANTA::with_debug(0);
 MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID)
 {
   if (with_debug)
-std::cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", "
-  << res[2] << ")" << std::endl;
+cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", " << res[2]
+ << ")" << endl;
 
   FluidDomainSettings *mds = mmd->domain;
   mds->fluid = this;
@@ -274,32 +283,32 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
 void MANTA::initDomain(FluidModifierData *mmd)
 {
   // Vector will hold all python commands that are to be executed
-  std::vector pythonCommands;
+  vector pythonCommands;
 
   // Set manta debug level first
   pythonCommands.push_back(manta_import + manta_debuglevel);
 
-  std::ostringstream ss;
+  ostringstream ss;
   ss << "set_manta_debuglevel(" << with_debug << ")";
   pythonCommands.push_back(ss.str());
 
   // Now init basic fluid domain
-  std::string tmpString = fluid_variables + fluid_solver + fluid_alloc + 
fluid_cache_helper +
-  fluid_bake_multiprocessing + fluid_bake_data + 
fluid_bake_noise +
-  fluid_bake_mesh + fluid_bake_particles + 
fluid_bake_guiding +
-  fluid_file_import + fluid_file_export + 
fluid_save_data +
-  fluid_load_data + fluid_pre_step + fluid_post_step +
-  fluid_adapt_time_step + fluid_time_stepping;
-  std::string finalString = parseScript(tmpString, mmd);
+  string tmpString = fluid_variables + fluid_solver + fluid_alloc + 
fluid_cache_helper +
+ fluid_bake_multiprocessing + fluid_bake_data + 
fluid_bake_noise +
+ fluid_bake_mesh + fluid_bake_particles + 
fluid_bake_guiding +
+ fluid_file_import + fluid_file_export + fluid_save_data + 
fluid_load_data +
+ fluid_pre_step + fluid_post_step + fluid_adapt_time_step +
+ fluid_time_stepping;
+  string finalString = parseScript(tmpString, mmd);
   pythonCommands.push_back(finalString);
   runPythonString(pythonCommands);
 }
 
 void MANTA::initNoise(FluidModifierData *mmd)
 {
-  std::vector pythonCommands;
-  std::string tmpString = fluid_variables_noise + fluid_solver_noise;
-  std::string finalString = parseScript(tmpString, mmd);
+  vector pythonCommands;
+  string tmpString = fluid_variables_noise + fluid_solver_noise;
+  string finalString = parseScript(tmpString, mmd);
   pythonCommands.push_back(finalString);
 
   runPythonString(pythonCommands);
@@ -307,10 +316,10 @@ void MANTA::initNoise(FluidModifierData *mmd)
 
 void MANTA::initSmoke(FluidModifierData *mmd)
 {
-  std::vector pythonCommands;
-  std::string tmpString = smoke_variables + smoke_alloc + smoke_adaptive_step 
+ smoke_save_data +
-  smoke_load_data + smoke_step;
-  std::string finalString = parseScript(tmpString, mmd);
+  vector pythonCommands;
+  string tmpString = smoke_variables + smoke_alloc + smoke_adaptive_step + 
smoke_save_data +
+ smoke_load_data + smoke_step;
+  string finalString = parseScript(tmpString, mmd);
   pythonCommands.push_back(finalString);
 
   runPythonString(pythonCommands);
@@ -318,10 +327,10 @@ void MANTA::initSmoke(FluidModifierData *mmd)
 
 void MANTA::initSmokeNoise(FluidModifierData *mmd)
 {
-  std::vector pythonCommands;
-  std::string tmpString = smoke_variables_noise + smoke_alloc_noise + 
sm

[Bf-blender-cvs] [82f9ed93056] master: Fluid: Cleanup in main MANTA wrapper

2020-05-03 Thread Sebastián Barschkis
Commit: 82f9ed930561159eee9adcc6f5713d9456ecbeb6
Author: Sebastián Barschkis
Date:   Sun May 3 18:52:48 2020 +0200
Branches: master
https://developer.blender.org/rB82f9ed930561159eee9adcc6f5713d9456ecbeb6

Fluid: Cleanup in main MANTA wrapper

Use shorter variable names.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 1e32548bee2..995cce4a1ce 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -64,26 +64,27 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
 std::cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", "
   << res[2] << ")" << std::endl;
 
-  mmd->domain->fluid = this;
-
-  mUsingLiquid = (mmd->domain->type == FLUID_DOMAIN_TYPE_LIQUID);
-  mUsingSmoke = (mmd->domain->type == FLUID_DOMAIN_TYPE_GAS);
-  mUsingNoise = (mmd->domain->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
-  mUsingFractions = (mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS) && 
mUsingLiquid;
-  mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
-  mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && 
mUsingLiquid;
-  mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE);
-  mUsingDrops = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
-  mUsingBubbles = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) 
&& mUsingLiquid;
-  mUsingFloats = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
-  mUsingTracers = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) 
&& mUsingLiquid;
-
-  mUsingHeat = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && 
mUsingSmoke;
-  mUsingFire = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && 
mUsingSmoke;
-  mUsingColors = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
-  mUsingObstacle = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
-  mUsingInvel = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
-  mUsingOutflow = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
+  FluidDomainSettings *mds = mmd->domain;
+  mds->fluid = this;
+
+  mUsingLiquid = (mds->type == FLUID_DOMAIN_TYPE_LIQUID);
+  mUsingSmoke = (mds->type == FLUID_DOMAIN_TYPE_GAS);
+  mUsingNoise = (mds->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
+  mUsingFractions = (mds->flags & FLUID_DOMAIN_USE_FRACTIONS) && mUsingLiquid;
+  mUsingMesh = (mds->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
+  mUsingMVel = (mds->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && mUsingLiquid;
+  mUsingGuiding = (mds->flags & FLUID_DOMAIN_USE_GUIDE);
+  mUsingDrops = (mds->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
+  mUsingBubbles = (mds->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) && 
mUsingLiquid;
+  mUsingFloats = (mds->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
+  mUsingTracers = (mds->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) && 
mUsingLiquid;
+
+  mUsingHeat = (mds->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && mUsingSmoke;
+  mUsingFire = (mds->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && mUsingSmoke;
+  mUsingColors = (mds->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
+  mUsingObstacle = (mds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
+  mUsingInvel = (mds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
+  mUsingOutflow = (mds->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
 
   // Simulation constants
   mTempAmb = 0;  // TODO: Maybe use this later for buoyancy calculation
@@ -91,10 +92,8 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   mResY = res[1];
   mResZ = res[2];
   mMaxRes = MAX3(mResX, mResY, mResZ);
-  mConstantScaling = 64.0f / mMaxRes;
-  mConstantScaling = (mConstantScaling < 1.0f) ? 1.0f : mConstantScaling;
   mTotalCells = mResX * mResY * mResZ;
-  mResGuiding = mmd->domain->res;
+  mResGuiding = mds->res;
 
   // Smoke low res grids
   mDensity = nullptr;
@@ -200,7 +199,7 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   initOutflow();
 
 if (mUsingDrops || mUsingB

[Bf-blender-cvs] [99ee1de094a] master: Fluid: Refactored 'Modifier Data to Python' value transfer function

2020-05-03 Thread Sebastián Barschkis
Commit: 99ee1de094a1744391a1bcddec56e53e3d180c4e
Author: Sebastián Barschkis
Date:   Sun May 3 18:33:34 2020 +0200
Branches: master
https://developer.blender.org/rB99ee1de094a1744391a1bcddec56e53e3d180c4e

Fluid: Refactored 'Modifier Data to Python' value transfer function

This function needed a bigger cleanup, especially after the problem from T76276.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index c1ac3d3a22d..1e32548bee2 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -184,17 +184,20 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   // Setup Mantaflow in Python
   initializeMantaflow();
 
+  // Initializa RNA map with values that Python will need
+  initializeRNAMap(mmd);
+
   // Initialize Mantaflow variables in Python
   // Liquid
   if (mUsingLiquid) {
-initDomain(mmd);
-initLiquid(mmd);
+initDomain();
+initLiquid();
 if (mUsingObstacle)
-  initObstacle(mmd);
+  initObstacle();
 if (mUsingInvel)
-  initInVelocity(mmd);
+  initInVelocity();
 if (mUsingOutflow)
-  initOutflow(mmd);
+  initOutflow();
 
 if (mUsingDrops || mUsingBubbles || mUsingFloats || mUsingTracers) {
   mUpresParticle = mmd->domain->particle_scale;
@@ -203,8 +206,8 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   mResZParticle = mUpresParticle * mResZ;
   mTotalCellsParticles = mResXParticle * mResYParticle * mResZParticle;
 
-  initSndParts(mmd);
-  initLiquidSndParts(mmd);
+  initSndParts();
+  initLiquidSndParts();
 }
 
 if (mUsingMesh) {
@@ -215,39 +218,39 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   mTotalCellsMesh = mResXMesh * mResYMesh * mResZMesh;
 
   // Initialize Mantaflow variables in Python
-  initMesh(mmd);
-  initLiquidMesh(mmd);
+  initMesh();
+  initLiquidMesh();
 }
 
 if (mUsingGuiding) {
   mResGuiding = (mmd->domain->guide_parent) ? mmd->domain->guide_res : 
mmd->domain->res;
-  initGuiding(mmd);
+  initGuiding();
 }
 if (mUsingFractions) {
-  initFractions(mmd);
+  initFractions();
 }
   }
 
   // Smoke
   if (mUsingSmoke) {
-initDomain(mmd);
-initSmoke(mmd);
+initDomain();
+initSmoke();
 if (mUsingHeat)
-  initHeat(mmd);
+  initHeat();
 if (mUsingFire)
-  initFire(mmd);
+  initFire();
 if (mUsingColors)
-  initColors(mmd);
+  initColors();
 if (mUsingObstacle)
-  initObstacle(mmd);
+  initObstacle();
 if (mUsingInvel)
-  initInVelocity(mmd);
+  initInVelocity();
 if (mUsingOutflow)
-  initOutflow(mmd);
+  initOutflow();
 
 if (mUsingGuiding) {
   mResGuiding = (mmd->domain->guide_parent) ? mmd->domain->guide_res : 
mmd->domain->res;
-  initGuiding(mmd);
+  initGuiding();
 }
 
 if (mUsingNoise) {
@@ -258,12 +261,12 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   mTotalCellsHigh = mResXNoise * mResYNoise * mResZNoise;
 
   // Initialize Mantaflow variables in Python
-  initNoise(mmd);
-  initSmokeNoise(mmd);
+  initNoise();
+  initSmokeNoise();
   if (mUsingFire)
-initFireHigh(mmd);
+initFireHigh();
   if (mUsingColors)
-initColorsHigh(mmd);
+initColorsHigh();
 }
   }
   updatePointers();
@@ -529,6 +532,9 @@ MANTA::~MANTA()
   tmpString += manta_import;
   tmpString += fluid_delete_all;
 
+  // Initializa RNA map with values that Python will need
+  initializeRNAMap();
+
   // Leave out mmd argument in parseScript since only looking up IDs
   std::string finalString = parseScript(tmpString);
   pythonCommands.push_back(finalString);
@@ -613,401 +619,232 @@ static std::string getCacheFileEnding(char cache_format)
   }
 }
 
-std::string MANTA::getRealValue(const std::string , FluidModifierData 
*mmd)
+void MANTA::initializeRNAMap(FluidModifierData *mmd)
 {
-  std::ostringstream ss;
-  bool is2D = false;
-  int tmpVar;
-  float tmpFloat;
+  if (with_debug)
+std::cout << "MANTA::initializeRNAMap()" << std::endl;
 
-  if (varName == "ID") {
-ss << mCurrentID;
-return ss.str();
-  }
+  mRNAMap["ID"] = std::to_string(mCurrentID);
 
   if (!mmd) {
-std::cerr << "Fluid Error -- Invalid modifier data." << std::endl;
-ss << "ERROR - INVALID MODIFIER DATA";
-return ss.str();
-  }
-
-  is2D = (mmd->domain->solver_res == 2);
-
-  if (varName == "USING_SMOKE"

[Bf-blender-cvs] [713ad9d9715] master: Fix T76276: Compiler Error C1061 due to too many nested if/else in MANTA_main.cpp

2020-04-30 Thread Sebastián Barschkis
Commit: 713ad9d9715a570627e762b16fda110476e3ba2b
Author: Sebastián Barschkis
Date:   Thu Apr 30 20:54:25 2020 +0200
Branches: master
https://developer.blender.org/rB713ad9d9715a570627e762b16fda110476e3ba2b

Fix T76276: Compiler Error C1061 due to too many nested if/else in 
MANTA_main.cpp

The compiler error should be fixed by removing the 'else if' blocks. However, 
this function should still be refactored in the future.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 9e5d9bf4656..c1ac3d3a22d 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -635,36 +635,36 @@ std::string MANTA::getRealValue(const std::string 
, FluidModifierData *m
 
   if (varName == "USING_SMOKE")
 ss << ((mmd->domain->type == FLUID_DOMAIN_TYPE_GAS) ? "True" : "False");
-  else if (varName == "USING_LIQUID")
+  if (varName == "USING_LIQUID")
 ss << ((mmd->domain->type == FLUID_DOMAIN_TYPE_LIQUID) ? "True" : "False");
-  else if (varName == "USING_COLORS")
+  if (varName == "USING_COLORS")
 ss << (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_COLORS ? "True" : 
"False");
-  else if (varName == "USING_HEAT")
+  if (varName == "USING_HEAT")
 ss << (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_HEAT ? "True" : 
"False");
-  else if (varName == "USING_FIRE")
+  if (varName == "USING_FIRE")
 ss << (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_FIRE ? "True" : 
"False");
-  else if (varName == "USING_NOISE")
+  if (varName == "USING_NOISE")
 ss << (mmd->domain->flags & FLUID_DOMAIN_USE_NOISE ? "True" : "False");
-  else if (varName == "USING_OBSTACLE")
+  if (varName == "USING_OBSTACLE")
 ss << (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE ? "True" 
: "False");
-  else if (varName == "USING_GUIDING")
+  if (varName == "USING_GUIDING")
 ss << (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE ? "True" : "False");
-  else if (varName == "USING_INVEL")
+  if (varName == "USING_INVEL")
 ss << (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL ? "True" : 
"False");
-  else if (varName == "USING_OUTFLOW")
+  if (varName == "USING_OUTFLOW")
 ss << (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW ? "True" : 
"False");
-  else if (varName == "USING_LOG_DISSOLVE")
+  if (varName == "USING_LOG_DISSOLVE")
 ss << (mmd->domain->flags & FLUID_DOMAIN_USE_DISSOLVE_LOG ? "True" : 
"False");
-  else if (varName == "USING_DISSOLVE")
+  if (varName == "USING_DISSOLVE")
 ss << (mmd->domain->flags & FLUID_DOMAIN_USE_DISSOLVE ? "True" : "False");
-  else if (varName == "SOLVER_DIM")
+  if (varName == "SOLVER_DIM")
 ss << mmd->domain->solver_res;
-  else if (varName == "DO_OPEN") {
+  if (varName == "DO_OPEN") {
 tmpVar = (FLUID_DOMAIN_BORDER_BACK | FLUID_DOMAIN_BORDER_FRONT | 
FLUID_DOMAIN_BORDER_LEFT |
   FLUID_DOMAIN_BORDER_RIGHT | FLUID_DOMAIN_BORDER_BOTTOM | 
FLUID_DOMAIN_BORDER_TOP);
 ss << (((mmd->domain->border_collisions & tmpVar) == tmpVar) ? "False" : 
"True");
   }
-  else if (varName == "BOUND_CONDITIONS") {
+  if (varName == "BOUND_CONDITIONS") {
 if (mmd->domain->solver_res == 2) {
   if ((mmd->domain->border_collisions & FLUID_DOMAIN_BORDER_LEFT) == 0)
 ss << "x";
@@ -690,13 +690,13 @@ std::string MANTA::getRealValue(const std::string 
, FluidModifierData *m
 ss << "Z";
 }
   }
-  else if (varName == "BOUNDARY_WIDTH")
+  if (varName == "BOUNDARY_WIDTH")
 ss << mmd->domain->boundary_width;
-  else if (varName == "RES")
+  if (varName == "RES")
 ss << mMaxRes;
-  else if (varName == "RESX")
+  if (varName == "RESX")
 ss << mResX;
-  else if (varName == "RESY")
+  if (varName == "RESY")
 if (is2D) {
   ss << mResZ;
 }
@@ -711,35 +711,35 @@ std::string MANTA::getRealValue(const std::string 
, FluidModifierDa

[Bf-blender-cvs] [31d3f034ab8] master: Fix T76097: Simulations don't take animated gravity into account

2020-04-30 Thread Sebastián Barschkis
Commit: 31d3f034ab8b7531eded7b0200d6ec77ba29b6a2
Author: Sebastián Barschkis
Date:   Thu Apr 30 18:08:52 2020 +0200
Branches: master
https://developer.blender.org/rB31d3f034ab8b7531eded7b0200d6ec77ba29b6a2

Fix T76097: Simulations don't take animated gravity into account

Together with 21485e94aac1 this commit should fix the issue with animated 
gravity values.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 2b99133fe97..5340fa63f38 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3772,6 +3772,12 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   /* Get distance between cache start and current frame for total time. */
   mds->time_total = abs(scene_framenr - mds->cache_frame_start) * 
mds->frame_length;
 
+  /* Ensure that gravity is copied over every frame (could be keyframed). */
+  if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) {
+copy_v3_v3(mds->gravity, scene->physics_settings.gravity);
+mul_v3_fl(mds->gravity, mds->effector_weights->global_gravity);
+  }
+
   int next_frame = scene_framenr + 1;
   int prev_frame = scene_framenr - 1;
   /* Ensure positivity of previous frame. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c4a850b7c22] master: Updated Mantaflow source files

2020-04-30 Thread Sebastián Barschkis
Commit: c4a850b7c224e16c61397f357b876db6fc7afc5c
Author: Sebastián Barschkis
Date:   Thu Apr 30 16:30:07 2020 +0200
Branches: master
https://developer.blender.org/rBc4a850b7c224e16c61397f357b876db6fc7afc5c

Updated Mantaflow source files

===

M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/plugin/extforces.cpp

===

diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index 791dd001bbe..e5cd4a3d6ce 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 21303fab2eda588ec22988bf9e5762d2001c131f"
+#define MANTA_GIT_VERSION "commit b4a2742bd743e2913fba94dd35846042e2650212"
diff --git a/extern/mantaflow/preprocessed/plugin/extforces.cpp 
b/extern/mantaflow/preprocessed/plugin/extforces.cpp
index 36221fbbc10..798bb3daeee 100644
--- a/extern/mantaflow/preprocessed/plugin/extforces.cpp
+++ b/extern/mantaflow/preprocessed/plugin/extforces.cpp
@@ -244,13 +244,15 @@ struct KnApplyForce : public KernelBase {
   bool additive;
 };
 
-//! add gravity forces to all fluid cells, automatically adapts to different 
grid sizes
+//! add gravity forces to all fluid cells, optionally  adapts to different 
grid sizes automatically
 void addGravity(const FlagGrid ,
 MACGrid ,
 Vec3 gravity,
-const Grid *exclude = NULL)
+const Grid *exclude = NULL,
+bool scale = true)
 {
-  Vec3 f = gravity * flags.getParent()->getDt() / flags.getDx();
+  float gridScale = (scale) ? flags.getDx() : 1;
+  Vec3 f = gravity * flags.getParent()->getDt() / gridScale;
   KnApplyForce(flags, vel, f, exclude, true);
 }
 static PyObject *_W_0(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
@@ -267,8 +269,9 @@ static PyObject *_W_0(PyObject *_self, PyObject *_linargs, 
PyObject *_kwds)
   MACGrid  = *_args.getPtr("vel", 1, &_lock);
   Vec3 gravity = _args.get("gravity", 2, &_lock);
   const Grid *exclude = _args.getPtrOpt>("exclude", 3, 
NULL, &_lock);
+  bool scale = _args.getOpt("scale", 4, true, &_lock);
   _retval = getPyNone();
-  addGravity(flags, vel, gravity, exclude);
+  addGravity(flags, vel, gravity, exclude, scale);
   _args.check();
 }
 pbFinalizePlugin(parent, "addGravity", !noTiming);
@@ -287,14 +290,13 @@ void PbRegister_addGravity()
 }
 }
 
-//! add gravity forces to all fluid cells , but dont account for changing cell 
size
+//! Deprecated: use addGravity(scale=false) instead
 void addGravityNoScale(const FlagGrid ,
MACGrid ,
const Vec3 ,
const Grid *exclude = NULL)
 {
-  const Vec3 f = gravity * flags.getParent()->getDt();
-  KnApplyForce(flags, vel, f, exclude, true);
+  addGravity(flags, vel, gravity, exclude, false);
 }
 static PyObject *_W_1(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
 {
@@ -412,14 +414,17 @@ struct KnAddBuoyancy : public KernelBase {
   Vec3 strength;
 };
 
-//! add Buoyancy force based on fctor (e.g. smoke density)
+//! add Buoyancy force based on factor (e.g. smoke density), optionally adapts 
to different grid
+//! sizes automatically
 void addBuoyancy(const FlagGrid ,
  const Grid ,
  MACGrid ,
  Vec3 gravity,
- Real coefficient = 1.)
+ Real coefficient = 1.,
+ bool scale = true)
 {
-  Vec3 f = -gravity * flags.getParent()->getDt() / flags.getParent()->getDx() 
* coefficient;
+  float gridScale = (scale) ? flags.getDx() : 1;
+  Vec3 f = -gravity * flags.getParent()->getDt() / gridScale * coefficient;
   KnAddBuoyancy(flags, density, vel, f);
 }
 static PyObject *_W_2(PyObject *_self, PyObject *_linargs, PyObject *_kwds)
@@ -437,8 +442,9 @@ static PyObject *_W_2(PyObject *_self, PyObject *_linargs, 
PyObject *_kwds)
   MACGrid  = *_args.getPtr("vel", 2, &_lock);
   Vec3 gravity = _args.get("gravity", 3, &_lock);
   Real coefficient = _args.getOpt("coefficient", 4, 1., &_lock);
+  bool scale = _args.getOpt("scale", 5, true, &_lock);
   _retval = getPyNone();
-  addBuoyancy(flags, density, vel, gravity, coefficient);
+  addBuoyancy(flags, density, vel, gravity, coefficient, scale);
   _args.check();
 }
 pbFinalizePlugin(parent, "addBuoyancy", !noTiming);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e7e6b02ed99] master: Fluid: Minor cleanup and sanity checks

2020-04-30 Thread Sebastián Barschkis
Commit: e7e6b02ed997d53eb5237c4398c2f0b7902bffaa
Author: Sebastián Barschkis
Date:   Thu Apr 30 16:11:56 2020 +0200
Branches: master
https://developer.blender.org/rBe7e6b02ed997d53eb5237c4398c2f0b7902bffaa

Fluid: Minor cleanup and sanity checks

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 96efac8f2c5..1da6d9e3769 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -81,6 +81,8 @@
 
 #  include "RE_shader_ext.h"
 
+#  include "CLG_log.h"
+
 #  include "manta_fluid_API.h"
 
 #endif /* WITH_FLUID */
@@ -96,6 +98,8 @@ static void BKE_fluid_modifier_reset_ex(struct 
FluidModifierData *mmd, bool need
 #ifdef WITH_FLUID
 // #define DEBUG_PRINT
 
+static CLG_LogRef LOG = {"bke.fluid"};
+
 /*  */
 /** \name Fluid API
  * \{ */
@@ -948,11 +952,7 @@ static void sample_effector(FluidEffectorSettings *mes,
 velocity_map[index * 3 + 2] += hit_vel[2];
 #  ifdef DEBUG_PRINT
 /* Debugging: Print object velocities. */
-printf("adding effector object vel: [%f, %f, %f], dx is: %f\n",
-   hit_vel[0],
-   hit_vel[1],
-   hit_vel[2],
-   mds->dx);
+printf("adding effector object vel: [%f, %f, %f]\n", hit_vel[0], 
hit_vel[1], hit_vel[2]);
 #  endif
   }
 }
@@ -3773,6 +3773,7 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
 
   /* Fluid domain init must not fail in order to continue modifier evaluation. 
*/
   if (!mds->fluid && !BKE_fluid_modifier_init(mmd, depsgraph, ob, scene, me)) {
+CLOG_ERROR(, "Fluid initialization failed. Should not happen!");
 return;
   }
   BLI_assert(mds->fluid);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [21485e94aac] master: Fluid: Refactored fluid gravity settings

2020-04-30 Thread Sebastián Barschkis
Commit: 21485e94aac1bc01d032f666ebc54c6008f4d303
Author: Sebastián Barschkis
Date:   Thu Apr 30 17:32:47 2020 +0200
Branches: master
https://developer.blender.org/rB21485e94aac1bc01d032f666ebc54c6008f4d303

Fluid: Refactored fluid gravity settings

Refactored setup that converts from Blender to Mantaflow units.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index a56ce4c1f60..9e5d9bf4656 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -711,6 +711,8 @@ std::string MANTA::getRealValue(const std::string , 
FluidModifierData *m
   ss << mResZ;
 }
   }
+  else if (varName == "TIME_SCALE")
+ss << mmd->domain->time_scale;
   else if (varName == "FRAME_LENGTH")
 ss << mmd->domain->frame_length;
   else if (varName == "CFL")
diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index dd2111db7d7..c0a23f77d7a 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -92,7 +92,7 @@ const std::string fluid_variables =
 mantaMsg('Fluid variables')\n\
 dim_s$ID$ = $SOLVER_DIM$\n\
 res_s$ID$ = $RES$\n\
-gravity_s$ID$ = vec3($GRAVITY_X$, $GRAVITY_Y$, $GRAVITY_Z$)\n\
+gravity_s$ID$ = vec3($GRAVITY_X$, $GRAVITY_Y$, $GRAVITY_Z$) # in SI unit (e.g. 
m/s^2)\n\
 gs_s$ID$  = vec3($RESX$, $RESY$, $RESZ$)\n\
 maxVel_s$ID$  = 0\n\
 \n\
@@ -115,6 +115,7 @@ using_speedvectors_s$ID$ = $USING_SPEEDVECTORS$\n\
 using_diffusion_s$ID$= $USING_DIFFUSION$\n\
 \n\
 # Fluid time params\n\
+timeScale_s$ID$= $TIME_SCALE$\n\
 timeTotal_s$ID$= $TIME_TOTAL$\n\
 timePerFrame_s$ID$ = $TIME_PER_FRAME$\n\
 frameLength_s$ID$  = $FRAME_LENGTH$\n\
@@ -132,8 +133,29 @@ end_frame_s$ID$ = $END_FRAME$\n\
 domainSize_s$ID$ = $FLUID_DOMAIN_SIZE$ # longest domain side in meters\n\
 viscosity_s$ID$ = $FLUID_VISCOSITY$ / (domainSize_s$ID$*domainSize_s$ID$) # 
kinematic viscosity in m^2/s\n\
 \n\
-# Factor to convert blender velocities to manta velocities\n\
-toMantaUnitsFac_s$ID$ = (1.0 / (1.0 / res_s$ID$))\n # = dt/dx * 1/dt ";
+# Factors to convert Blender units to Manta units\n\
+ratioMetersToRes_s$ID$ = float(domainSize_s$ID$) / float(res_s$ID$) # [meters 
/ cells]\n\
+mantaMsg('1 Mantaflow cell is ' + str(ratioMetersToRes_s$ID$) + ' Blender 
length units long.')\n\
+\n\
+ratioResToBLength_s$ID$ = float(res_s$ID$) / float(domainSize_s$ID$) # [cells 
/ blength] (blength: cm, m, or km, ... )\n\
+mantaMsg('1 Blender length unit is ' + str(ratioResToBLength_s$ID$) + ' 
Mantaflow cells long.')\n\
+\n\
+ratioBTimeToTimstep_s$ID$ = float(1) / float(0.1 * 25 * timeScale_s$ID$) # the 
time within 1 blender time unit, see also fluid.c\n\
+mantaMsg('1 Blender time unit is ' + str(ratioBTimeToTimstep_s$ID$) + ' 
Mantaflow time units long.')\n\
+\n\
+ratioFrameToFramelength_s$ID$ = float(1) / float(frameLength_s$ID$) # the time 
within 1 frame\n\
+mantaMsg('frame / frameLength is ' + str(ratioFrameToFramelength_s$ID$) + ' 
Mantaflow time units long.')\n\
+\n\
+scaleAcceleration_s$ID$ = ratioResToBLength_s$ID$ * 
(ratioBTimeToTimstep_s$ID$**2)# [meters/btime^2] to [cells/timestep^2] (btime: 
sec, min, or h, ...)\n\
+mantaMsg('scaleAcceleration is ' + str(scaleAcceleration_s$ID$))\n\
+\n\
+scaleSpeedFrames_s$ID$ = ratioResToBLength_s$ID$ * 
ratioFrameToFramelength_s$ID$ # [blength/frame] to [cells/frameLength]\n\
+mantaMsg('scaleSpeed is ' + str(scaleSpeedFrames_s$ID$))\n\
+\n\
+scaleSpeedTime_s$ID$ = ratioResToBLength_s$ID$ * ratioBTimeToTimstep_s$ID$ # 
[blength/btime] to [cells/frameLength]\n\
+mantaMsg('scaleSpeedTime is ' + str(scaleSpeedTime_s$ID$))\n\
+\n\
+gravity_s$ID$ *= scaleAcceleration_s$ID$ # scale from world acceleration to 
cell based acceleration\n";
 
 const std::string fluid_variables_noise =
 "\n\
@@ -342,17 +364,16 @@ def fluid_pre_step_$ID$():\n\
 y_obvel_s$ID$.safeDivide(numObs_s$ID$)\n\
 z_obvel_s$ID$.safeDivide(numObs_s$ID$)\n\
 \n\
-x_obvel_s$ID$.multConst(toMantaUnitsFac_s$ID$)\n\
-y_obvel_s$ID$.multConst(toMantaUnitsFac_s$ID$)\n\
-z_obvel_s$ID$.multConst(toMantaUnitsFac_s$ID$)\n\
-\n\
+x_obvel_s$ID$.multConst(scaleSpeedFrames_s$ID$)\n\
+y_obvel_s$ID$.multConst(scaleSpeedFrames_s$ID$)\n\
+z_obvel_s$ID$.multConst(scaleSpeedFrames_s$ID$)\n\
 copyRealToVec3(sourceX=x_obvel_s$ID$, sou

[Bf-blender-cvs] [dc0a564c061] master: Merge branch 'blender-v2.83-release'

2020-04-30 Thread Sebastián Barschkis
Commit: dc0a564c0616e181e06cd4f38b6c0920ea9e2348
Author: Sebastián Barschkis
Date:   Thu Apr 30 15:55:35 2020 +0200
Branches: master
https://developer.blender.org/rBdc0a564c0616e181e06cd4f38b6c0920ea9e2348

Merge branch 'blender-v2.83-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4d63dfca4c6] blender-v2.83-release: Fluid: Reset noise emission value at the beginning of an adaptive frame

2020-04-30 Thread Sebastián Barschkis
Commit: 4d63dfca4c63a3a0d159050bebd2ac05b3408838
Author: Sebastián Barschkis
Date:   Mon Apr 27 13:22:47 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB4d63dfca4c63a3a0d159050bebd2ac05b3408838

Fluid: Reset noise emission value at the beginning of an adaptive frame

Emission values should not accumulate beyond one frame, only during the 
adaptive steps of one frame.

===

M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index 146106fd147..fdb58543cec 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -302,6 +302,9 @@ def smoke_adaptive_step_$ID$(framenr):\n\
 setObstacleFlags(flags=flags_s$ID$, phiObs=phiObs_s$ID$, 
phiOut=phiOut_s$ID$, phiIn=phiIn_s$ID$, boundaryWidth=1)\n\
 flags_s$ID$.fillGrid()\n\
 \n\
+# reset emission accumulation at the beginning of an adaptive frame\n\
+if not s$ID$.timePerFrame:\n\
+emission_s$ID$.setConst(0.)\n\
 # accumulate emission value per adaptive step for later use in noise 
computation\n\
 emission_s$ID$.join(emissionIn_s$ID$)\n\
 \n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9ee7fc15afd] blender-v2.83-release: Fluid: Removed domain size option from diffusion panel

2020-04-30 Thread Sebastián Barschkis
Commit: 9ee7fc15afdaf2649ecae1478fe6ad3ad89af325
Author: Sebastián Barschkis
Date:   Thu Apr 30 15:40:47 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB9ee7fc15afdaf2649ecae1478fe6ad3ad89af325

Fluid: Removed domain size option from diffusion panel

Domain size parameter no longer needed (unsed right now). Domain size is 
directly taken from object.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesdna/DNA_fluid_types.h
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index d6d2526384a..de526506f68 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -1002,7 +1002,6 @@ class PHYSICS_PT_diffusion(PhysicButtonsPanel, Panel):
 col.prop(domain, "viscosity_exponent", text="Exponent", slider=True)
 
 col = flow.column()
-col.prop(domain, "domain_size", text="Real World Size")
 col.prop(domain, "surface_tension", text="Surface Tension")
 
 
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index d4f54daa773..96efac8f2c5 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4889,7 +4889,6 @@ void BKE_fluid_modifier_create_type_data(struct 
FluidModifierData *mmd)
 mmd->domain->surface_tension = 0.0f;
 mmd->domain->viscosity_base = 1.0f;
 mmd->domain->viscosity_exponent = 6.0f;
-mmd->domain->domain_size = 0.5f;
 
 /* mesh options */
 mmd->domain->mesh_velocities = NULL;
@@ -5133,7 +5132,6 @@ void BKE_fluid_modifier_copy(const struct 
FluidModifierData *mmd,
 tmds->surface_tension = mds->surface_tension;
 tmds->viscosity_base = mds->viscosity_base;
 tmds->viscosity_exponent = mds->viscosity_exponent;
-tmds->domain_size = mds->domain_size;
 
 /* mesh options */
 if (mds->mesh_velocities) {
diff --git a/source/blender/makesdna/DNA_fluid_types.h 
b/source/blender/makesdna/DNA_fluid_types.h
index 166b3c22932..6583aa2 100644
--- a/source/blender/makesdna/DNA_fluid_types.h
+++ b/source/blender/makesdna/DNA_fluid_types.h
@@ -393,7 +393,6 @@ typedef struct FluidDomainSettings {
   float surface_tension;
   float viscosity_base;
   int viscosity_exponent;
-  float domain_size;
 
   /* Mesh options. */
   float mesh_concave_upper;
@@ -404,7 +403,7 @@ typedef struct FluidDomainSettings {
   int mesh_scale;
   int totvert;
   short mesh_generator;
-  char _pad5[2]; /* Unused. */
+  char _pad5[6]; /* Unused. */
 
   /* Secondary particle options. */
   int particle_type;
diff --git a/source/blender/makesrna/intern/rna_fluid.c 
b/source/blender/makesrna/intern/rna_fluid.c
index d89bdcd074f..0a6554a1cea 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -1687,11 +1687,6 @@ static void rna_def_fluid_domain_settings(BlenderRNA 
*brna)
   "e.g. 5*10^-6)");
   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, 
"rna_Fluid_datacache_reset");
 
-  prop = RNA_def_property(srna, "domain_size", PROP_FLOAT, PROP_NONE);
-  RNA_def_property_range(prop, 0.001, 1.0);
-  RNA_def_property_ui_text(prop, "Meters", "Domain size in meters (longest 
domain side)");
-  RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, 
"rna_Fluid_domain_reset");
-
   /*  mesh options options */
 
   prop = RNA_def_property(srna, "mesh_concave_upper", PROP_FLOAT, PROP_NONE);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cdc399a0553] master: Merge branch 'blender-v2.83-release'

2020-04-22 Thread Sebastián Barschkis
Commit: cdc399a05537506f7afe977554d774d84b140e77
Author: Sebastián Barschkis
Date:   Wed Apr 22 17:05:04 2020 +0200
Branches: master
https://developer.blender.org/rBcdc399a05537506f7afe977554d774d84b140e77

Merge branch 'blender-v2.83-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [fdea3dd7e71] blender-v2.83-release: Fluid: Fix for inconsistent behavior with flow and effector objects

2020-04-22 Thread Sebastián Barschkis
Commit: fdea3dd7e7109a814561e4a83ff3331badf04e24
Author: Sebastián Barschkis
Date:   Sun Apr 19 20:15:57 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBfdea3dd7e7109a814561e4a83ff3331badf04e24

Fluid: Fix for inconsistent behavior with flow and effector objects

Fixes issue with flow and effector objects which were not being used after 
resuming a bake job.
This issue has been reported in T75729 and T75758.

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h
M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index 85cc04b4a52..7825ad14d7d 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -107,6 +107,7 @@ float *manta_get_phistatic_in(struct MANTA *fluid);
 float *manta_get_phiobs_in(struct MANTA *fluid);
 float *manta_get_phiobsstatic_in(struct MANTA *fluid);
 float *manta_get_phiout_in(struct MANTA *fluid);
+float *manta_get_phioutstatic_in(struct MANTA *fluid);
 
 /* Smoke functions */
 void manta_smoke_export_script(struct MANTA *smoke, struct FluidModifierData 
*mmd);
diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 539e3080c54..a56ce4c1f60 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -141,6 +141,7 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   mPhiIn = nullptr;
   mPhiStaticIn = nullptr;
   mPhiOutIn = nullptr;
+  mPhiOutStaticIn = nullptr;
   mPhi = nullptr;
 
   // Mesh
@@ -1926,6 +1927,7 @@ void MANTA::exportSmokeScript(FluidModifierData *mmd)
   bool obstacle = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE;
   bool guiding = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
   bool invel = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
+  bool outflow = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
 
   std::string manta_script;
 
@@ -1968,6 +1970,8 @@ void MANTA::exportSmokeScript(FluidModifierData *mmd)
 manta_script += fluid_alloc_obstacle;
   if (invel)
 manta_script += fluid_alloc_invel;
+  if (outflow)
+manta_script += fluid_alloc_outflow;
 
   // Noise field
   if (noise)
@@ -2032,6 +2036,7 @@ void MANTA::exportLiquidScript(FluidModifierData *mmd)
   bool fractions = mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS;
   bool guiding = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
   bool invel = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
+  bool outflow = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
 
   std::string manta_script;
 
@@ -2070,6 +2075,8 @@ void MANTA::exportLiquidScript(FluidModifierData *mmd)
 manta_script += fluid_alloc_fractions;
   if (invel)
 manta_script += fluid_alloc_invel;
+  if (outflow)
+manta_script += fluid_alloc_outflow;
 
   // Domain init
   manta_script += header_gridinit + liquid_init_phi;
@@ -3119,6 +3126,8 @@ void MANTA::updatePointers()
 
   if (mUsingOutflow) {
 mPhiOutIn = (float *)pyObjectToPointer(callPythonFunction("phiOutIn" + 
solver_ext, func));
+mPhiOutStaticIn = (float *)pyObjectToPointer(
+callPythonFunction("phiOutSIn" + solver_ext, func));
   }
   if (mUsingObstacle) {
 mPhiObsIn = (float *)pyObjectToPointer(callPythonFunction("phiObsIn" + 
solver_ext, func));
@@ -3230,7 +3239,7 @@ bool MANTA::hasConfig(FluidModifierData *mmd, int framenr)
 
 bool MANTA::hasData(FluidModifierData *mmd, int framenr)
 {
-  std::string filename = (mUsingSmoke) ? FLUID_DOMAIN_FILE_DENSITY : 
FLUID_DOMAIN_FILE_PHI;
+  std::string filename = (mUsingSmoke) ? FLUID_DOMAIN_FILE_DENSITY : 
FLUID_DOMAIN_FILE_PP;
   std::string extension = getCacheFileEnding(mmd->domain->cache_data_format);
   return BLI_exists(getFile(mmd, FLUID_DOMAIN_DIR_DATA, filename, extension, 
framenr).c_str());
 }
diff --git a/intern/mantaflow/intern/MANTA_main.h 
b/intern/mantaflow/intern/MANTA_main.h
index caac63d8e39..21946431f28 100644
--- a/intern/mantaflow/intern/MANTA_main.h
+++ b/intern/mantaflow/intern/MANTA_main.h
@@ -405,6 +405,10 @@ struct MANTA {
   {
 return mPhiOutIn;
   }
+  inline float *getPhiOutStaticIn()
+  {
+return mPhiOutStaticIn;
+  }
   inline float *getPhi()
   {
 return mPhi;
@@ -844,6 +848,7 @@ struct MANTA {
   float *mPhiObsStaticIn;
   float *mPhiGuideIn;
   f

[Bf-blender-cvs] [07ed64aae6f] blender-v2.83-release: Fluid: Use maximum for initial velocity grid application

2020-04-22 Thread Sebastián Barschkis
Commit: 07ed64aae6fde5429ffe0ab7e30d240009a98e37
Author: Sebastián Barschkis
Date:   Wed Apr 22 15:00:52 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB07ed64aae6fde5429ffe0ab7e30d240009a98e37

Fluid: Use maximum for initial velocity grid application

Using MAX2 when writing intial velocities into the grid prevents overriding 
initial velocities when using multiple flow objects that are close to each 
other.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index bde0abe1499..9709b74516b 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3110,9 +3110,9 @@ static void update_flowsfluids(struct Depsgraph 
*depsgraph,
   levelset,
   emission_in);
   if (mfs->flags & FLUID_FLOW_INITVELOCITY) {
-velx_initial[d_index] = velocity_map[e_index * 3];
-vely_initial[d_index] = velocity_map[e_index * 3 + 1];
-velz_initial[d_index] = velocity_map[e_index * 3 + 2];
+velx_initial[d_index] = MAX2(velx_initial[d_index], 
velocity_map[e_index * 3]);
+vely_initial[d_index] = MAX2(vely_initial[d_index], 
velocity_map[e_index * 3 + 1]);
+velz_initial[d_index] = MAX2(velz_initial[d_index], 
velocity_map[e_index * 3 + 2]);
   }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [06e3df4ce45] blender-v2.83-release: Fix T75681: Mantaflow crash when trying to bake a cupcake: The CG solver diverged, residual norm > 1e30

2020-04-22 Thread Sebastián Barschkis
Commit: 06e3df4ce45ffe093f01bdb8eff2c7b1cf26f26b
Author: Sebastián Barschkis
Date:   Wed Apr 15 13:56:47 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB06e3df4ce45ffe093f01bdb8eff2c7b1cf26f26b

Fix T75681: Mantaflow crash when trying to bake a cupcake: The CG solver 
diverged, residual norm > 1e30

Ensures that there are no enclosed holes between an obstacle and the domain 
walls.

===

M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index b0bf6f85914..34994f115d7 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -173,14 +173,14 @@ def liquid_adaptive_step_$ID$(framenr):\n\
 if using_obstacle_s$ID$:\n\
 mantaMsg('Initializing obstacle levelset')\n\
 phiObsIn_s$ID$.join(phiObsSIn_s$ID$) # Join static obstacle map\n\
-phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
 phiObs_s$ID$.join(phiObsIn_s$ID$)\n\
 \n\
 # Using boundaryWidth=2 to not search beginning from walls (just a 
performance optimization)\n\
 # Additional sanity check: fill holes in phiObs which can result after 
joining with phiObsIn\n\
-phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2 if 
using_fractions_s$ID$ else 1)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=3)\n\
 \n\
diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index 7a855ff2cb8..cb651eb40b3 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -279,14 +279,14 @@ def smoke_adaptive_step_$ID$(framenr):\n\
 if using_obstacle_s$ID$:\n\
 mantaMsg('Initializing obstacle levelset')\n\
 phiObsIn_s$ID$.join(phiObsSIn_s$ID$) # Join static obstacle map\n\
-phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
 phiObs_s$ID$.join(phiObsIn_s$ID$)\n\
 \n\
 # Using boundaryWidth=2 to not search beginning from walls (just a 
performance optimization)\n\
 # Additional sanity check: fill holes in phiObs which can result after 
joining with phiObsIn\n\
-phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=3, inside=False)\n\
 \n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [40e9dc638b7] blender-v2.83-release: Fluid: Remove noise bake call from Python

2020-04-22 Thread Sebastián Barschkis
Commit: 40e9dc638b7f6a70d702cd06e244001b4ccb94a9
Author: Sebastián Barschkis
Date:   Wed Apr 15 13:59:05 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB40e9dc638b7f6a70d702cd06e244001b4ccb94a9

Fluid: Remove noise bake call from Python

Saving noise cache files is handled in fluid.c.

===

M   intern/mantaflow/intern/strings/fluid_script.h

===

diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index 0aad0546aea..e81a44109ef 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -527,7 +527,6 @@ def bake_noise_process_$ID$(framenr, format_data, 
format_noise, path_data, path_
 sn$ID$.timestep = frameLength_s$ID$ # no adaptive timestep for noise\n\
 \n\
 smoke_step_noise_$ID$(framenr)\n\
-smoke_save_noise_$ID$(path_noise, framenr, format_noise, resumable)\n\
 \n\
 def bake_noise_$ID$(path_data, path_noise, framenr, format_data, format_noise, 
resumable):\n\
 if not withMPBake or isWindows:\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [650f9cfe938] blender-v2.83-release: Fluid: Improved cache 'Replay' option

2020-04-22 Thread Sebastián Barschkis
Commit: 650f9cfe938f5e65e45a90223ce03c6b232a6217
Author: Sebastián Barschkis
Date:   Wed Apr 15 14:16:13 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB650f9cfe938f5e65e45a90223ce03c6b232a6217

Fluid: Improved cache 'Replay' option

When using the 'Replay' cache mode the cache needs to be invalidated whenever 
simulation variables have been changed.
The invalidation will always only affect the according subcaches, e.g. when 
changing a mesh paramter only the mesh cache will be invalidated, the base 
cache will remain intact.
Before this change Blender always invalidated the entire cache.

===

M   source/blender/blenkernel/BKE_fluid.h
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesdna/DNA_fluid_types.h
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/source/blender/blenkernel/BKE_fluid.h 
b/source/blender/blenkernel/BKE_fluid.h
index e8b4c819c62..e06a1a9fb92 100644
--- a/source/blender/blenkernel/BKE_fluid.h
+++ b/source/blender/blenkernel/BKE_fluid.h
@@ -61,6 +61,7 @@ void BKE_fluid_reallocate_copy_fluid(struct 
FluidDomainSettings *mds,
  int o_max[3],
  int o_shift[3],
  int n_shift[3]);
+void BKE_fluid_cache_free_all(struct FluidDomainSettings *mds, struct Object 
*ob);
 void BKE_fluid_cache_free(struct FluidDomainSettings *mds, struct Object *ob, 
int cache_map);
 void BKE_fluid_cache_new_name_for_current_session(int maxlen, char *r_name);
 
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 8697cd03827..578a6a13bb7 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -334,6 +334,14 @@ void BKE_fluid_reallocate_copy_fluid(FluidDomainSettings 
*mds,
   manta_free(fluid_old);
 }
 
+void BKE_fluid_cache_free_all(FluidDomainSettings *mds, Object *ob)
+{
+  int cache_map = (FLUID_DOMAIN_OUTDATED_DATA | FLUID_DOMAIN_OUTDATED_NOISE |
+   FLUID_DOMAIN_OUTDATED_MESH | 
FLUID_DOMAIN_OUTDATED_PARTICLES |
+   FLUID_DOMAIN_OUTDATED_GUIDE);
+  BKE_fluid_cache_free(mds, ob, cache_map);
+}
+
 void BKE_fluid_cache_free(FluidDomainSettings *mds, Object *ob, int cache_map)
 {
   char temp_dir[FILE_MAX];
@@ -1130,7 +1138,18 @@ static void obstacles_from_mesh(Object *coll_ob,
   }
 }
 
+static void ensure_obstaclefields(FluidDomainSettings *mds)
+{
+  if (mds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE) {
+manta_ensure_obstacle(mds->fluid, mds->mmd);
+  }
+  if (mds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE) {
+manta_ensure_guiding(mds->fluid, mds->mmd);
+  }
+}
+
 static void update_obstacleflags(FluidDomainSettings *mds,
+ Object *domain,
  Object **coll_ob_array,
  int coll_ob_array_len)
 {
@@ -1157,6 +1176,11 @@ static void update_obstacleflags(FluidDomainSettings 
*mds,
   if (!mes) {
 break;
   }
+  if (mes->flags & FLUID_EFFECTOR_NEEDS_UPDATE) {
+mes->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
+BKE_fluid_cache_free_all(mds, domain);
+mds->cache_flag |= FLUID_DOMAIN_OUTDATED_DATA;
+  }
   if (mes->type == FLUID_EFFECTOR_TYPE_COLLISION) {
 active_fields |= FLUID_DOMAIN_ACTIVE_OBSTACLE;
   }
@@ -1165,13 +1189,6 @@ static void update_obstacleflags(FluidDomainSettings 
*mds,
   }
 }
   }
-  /* Finally, initialize new data fields if any */
-  if (active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE) {
-manta_ensure_obstacle(mds->fluid, mds->mmd);
-  }
-  if (active_fields & FLUID_DOMAIN_ACTIVE_GUIDE) {
-manta_ensure_guiding(mds->fluid, mds->mmd);
-  }
   mds->active_fields = active_fields;
 }
 
@@ -1193,7 +1210,8 @@ static void update_obstacles(Depsgraph *depsgraph,
   depsgraph, ob, mds->effector_group, , eModifierType_Fluid);
 
   /* Update all effector related flags and ensure that corresponding grids get 
initialized. */
-  update_obstacleflags(mds, effecobjs, numeffecobjs);
+  update_obstacleflags(mds, ob, effecobjs, numeffecobjs);
+  ensure_obstaclefields(mds);
 
   /* Initialize effector maps for each flow. */
   bb_maps = MEM_callocN(sizeof(struct FluidObjectBB) * numeffecobjs, 
"fluid_effector_bb_maps");
@@ -2573,21 +2591,49 @@ BLI_INLINE void apply_inflow_fields(FluidFlowSettings 
*mfs,
   }
 }
 
-static void update_flowsflags(FluidDomainSettings *mds, Object **flowobjs, int 
numflowobj)
+static void ensure_flowsfields(FluidDomainSettings *mds)
+{
+  if (mds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL) {
+manta_ensure_invelocity(mds->fluid, mds->mmd);
+  }
+  if (mds->active_fields

[Bf-blender-cvs] [f148bd3795e] blender-v2.83-release: Fluid: Fixes for cache 'Replay' mode

2020-04-22 Thread Sebastián Barschkis
Commit: f148bd3795ea352642b33d11a027347abac11367
Author: Sebastián Barschkis
Date:   Wed Apr 22 14:58:41 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBf148bd3795ea352642b33d11a027347abac11367

Fluid: Fixes for cache 'Replay' mode

General fixes and improvements for the cache. Previous commits on fluids broke 
the 'Replay' cache a bit.

===

M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenloader/intern/readfile.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 0f6b85b366b..bde0abe1499 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1149,7 +1149,6 @@ static void ensure_obstaclefields(FluidDomainSettings 
*mds)
 }
 
 static void update_obstacleflags(FluidDomainSettings *mds,
- Object *domain,
  Object **coll_ob_array,
  int coll_ob_array_len)
 {
@@ -1178,7 +1177,6 @@ static void update_obstacleflags(FluidDomainSettings *mds,
   }
   if (mes->flags & FLUID_EFFECTOR_NEEDS_UPDATE) {
 mes->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
-BKE_fluid_cache_free_all(mds, domain);
 mds->cache_flag |= FLUID_DOMAIN_OUTDATED_DATA;
   }
   if (mes->type == FLUID_EFFECTOR_TYPE_COLLISION) {
@@ -1341,7 +1339,7 @@ static void update_obstacles(Depsgraph *depsgraph,
   depsgraph, ob, mds->effector_group, , eModifierType_Fluid);
 
   /* Update all effector related flags and ensure that corresponding grids get 
initialized. */
-  update_obstacleflags(mds, ob, effecobjs, numeffecobjs);
+  update_obstacleflags(mds, effecobjs, numeffecobjs);
   ensure_obstaclefields(mds);
 
   /* Allocate effector map for each effector object. */
@@ -2637,10 +2635,7 @@ static void ensure_flowsfields(FluidDomainSettings *mds)
   }
 }
 
-static void update_flowsflags(FluidDomainSettings *mds,
-  Object *domain,
-  Object **flowobjs,
-  int numflowobj)
+static void update_flowsflags(FluidDomainSettings *mds, Object **flowobjs, int 
numflowobj)
 {
   int active_fields = mds->active_fields;
   uint flow_index;
@@ -2668,7 +2663,6 @@ static void update_flowsflags(FluidDomainSettings *mds,
   }
   if (mfs->flags & FLUID_FLOW_NEEDS_UPDATE) {
 mfs->flags &= ~FLUID_FLOW_NEEDS_UPDATE;
-BKE_fluid_cache_free_all(mds, domain);
 mds->cache_flag |= FLUID_DOMAIN_OUTDATED_DATA;
   }
   if (mfs->flags & FLUID_FLOW_INITVELOCITY) {
@@ -2910,7 +2904,7 @@ static void update_flowsfluids(struct Depsgraph 
*depsgraph,
   depsgraph, ob, mds->fluid_group, , eModifierType_Fluid);
 
   /* Update all flow related flags and ensure that corresponding grids get 
initialized. */
-  update_flowsflags(mds, ob, flowobjs, numflowobjs);
+  update_flowsflags(mds, flowobjs, numflowobjs);
   ensure_flowsfields(mds);
 
   /* Allocate emission map for each flow object. */
@@ -3092,8 +3086,9 @@ static void update_flowsfluids(struct Depsgraph 
*depsgraph,
 }
 /* Main inflow application. */
 else if (is_geometry || is_inflow) {
-  float *levelset = ((is_first_frame || is_resume) && is_static) ? 
phistatic_in :
-   
phi_in;
+  float *levelset = ((is_first_frame || is_resume) && is_static && 
!is_geometry) ?
+phistatic_in :
+phi_in;
   apply_inflow_fields(mfs,
   emission_map[e_index],
   distance_map[e_index],
@@ -3731,18 +3726,8 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
 return;
   }
 
-  bool bake_outdated = mds->cache_flag &
-   (FLUID_DOMAIN_OUTDATED_DATA | 
FLUID_DOMAIN_OUTDATED_NOISE |
-FLUID_DOMAIN_OUTDATED_MESH | 
FLUID_DOMAIN_OUTDATED_PARTICLES |
-FLUID_DOMAIN_OUTDATED_GUIDE);
-
-  /* Exit early if cache is outdated. */
-  if (bake_outdated) {
-return;
-  }
-
-  /* Reset fluid if no fluid present. */
-  if (!mds->fluid || mds->cache_flag & FLUID_DOMAIN_OUTDATED_DATA) {
+  /* Reset fluid if no fluid present. Also resets active fields. */
+  if (!mds->fluid) {
 BKE_fluid_modifier_reset_ex(mmd, false);
   }
 
@@ -3750,19 +3735,29 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   const char *relbase = modifier_path_relbase_from_global(ob);
   BLI_path_abs(mds->cache_directory, relbase);
 
+  /* Ensure that all flags are

[Bf-blender-cvs] [6485d8b78a9] blender-v2.83-release: Fluid: Fix for caches being released when file is loaded

2020-04-22 Thread Sebastián Barschkis
Commit: 6485d8b78a9b284eb2771175e961d5a5eeb86502
Author: Sebastián Barschkis
Date:   Sun Apr 19 21:13:27 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB6485d8b78a9b284eb2771175e961d5a5eeb86502

Fluid: Fix for caches being released when file is loaded

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 08b5b788afd..0f6b85b366b 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4163,6 +4163,12 @@ struct Mesh *BKE_fluid_modifier_do(
 mmd->domain->cache_flag &= ~FLUID_DOMAIN_OUTDATED_PARTICLES;
 mmd->domain->cache_flag &= ~FLUID_DOMAIN_OUTDATED_GUIDE;
   }
+  else if (mmd->type & MOD_FLUID_TYPE_FLOW && mmd->flow) {
+mmd->flow->flags &= ~FLUID_FLOW_NEEDS_UPDATE;
+  }
+  else if (mmd->type & MOD_FLUID_TYPE_EFFEC && mmd->effector) {
+mmd->effector->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
+  }
   if (!result) {
 result = BKE_mesh_copy_for_eval(me, false);
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [abdd4117b1e] blender-v2.83-release: Fluid: Cleanup in MANTA main class

2020-04-22 Thread Sebastián Barschkis
Commit: abdd4117b1e35d7df8755c7188be521e0bfb8756
Author: Sebastián Barschkis
Date:   Wed Apr 15 14:03:22 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBabdd4117b1e35d7df8755c7188be521e0bfb8756

Fluid: Cleanup in MANTA main class

More concise return types for cache import functions and general cleanup.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 79c8625ec48..539e3080c54 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -61,28 +61,29 @@ int MANTA::with_debug(0);
 MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID)
 {
   if (with_debug)
-std::cout << "MANTA: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", "
+std::cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", "
   << res[2] << ")" << std::endl;
 
   mmd->domain->fluid = this;
 
   mUsingLiquid = (mmd->domain->type == FLUID_DOMAIN_TYPE_LIQUID);
   mUsingSmoke = (mmd->domain->type == FLUID_DOMAIN_TYPE_GAS);
-  mUsingHeat = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && 
mUsingSmoke;
-  mUsingFire = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && 
mUsingSmoke;
-  mUsingColors = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingNoise = (mmd->domain->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
   mUsingFractions = (mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS) && 
mUsingLiquid;
+  mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
+  mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && 
mUsingLiquid;
+  mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE);
   mUsingDrops = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
   mUsingBubbles = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) 
&& mUsingLiquid;
   mUsingFloats = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
   mUsingTracers = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) 
&& mUsingLiquid;
-  mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
-  mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && 
mUsingLiquid;
+
+  mUsingHeat = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && 
mUsingSmoke;
+  mUsingFire = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && 
mUsingSmoke;
+  mUsingColors = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingObstacle = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
   mUsingInvel = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
   mUsingOutflow = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
-  mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE);
 
   // Simulation constants
   mTempAmb = 0;  // TODO: Maybe use this later for buoyancy calculation
@@ -566,7 +567,7 @@ bool MANTA::runPythonString(std::vector 
commands)
 void MANTA::initializeMantaflow()
 {
   if (with_debug)
-std::cout << "Fluid: Initializing Mantaflow framework." << std::endl;
+std::cout << "Fluid: Initializing Mantaflow framework" << std::endl;
 
   std::string filename = "manta_scene_" + std::to_string(mCurrentID) + ".py";
   std::vector fill = std::vector();
@@ -581,7 +582,7 @@ void MANTA::initializeMantaflow()
 void MANTA::terminateMantaflow()
 {
   if (with_debug)
-std::cout << "Fluid: Releasing Mantaflow framework." << std::endl;
+std::cout << "Fluid: Releasing Mantaflow framework" << std::endl;
 
   PyGILState_STATE gilstate = PyGILState_Ensure();
   Pb::finalize();  // Namespace from Mantaflow (registry)
@@ -1078,8 +1079,7 @@ bool MANTA::updateFlipStructures(FluidModifierData *mmd, 
int framenr)
 assert(result == expected);
   }
 
-  mFlipFromFile = true;
-  return (result == expected);
+  return mFlipFromFile = (result == expected);
 }
 
 bool MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr)
@@ -1126,8 +1126,7 @@ bool MANTA::updateMeshStructures(FluidModifierData *mmd, 
int framen

[Bf-blender-cvs] [5cae44ef6d4] blender-v2.83-release: Fluid: Minor UI fix for diffusion panel

2020-04-22 Thread Sebastián Barschkis
Commit: 5cae44ef6d49253c9019fdaa84c9b76ecf98f141
Author: Sebastián Barschkis
Date:   Wed Apr 15 13:49:41 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB5cae44ef6d49253c9019fdaa84c9b76ecf98f141

Fluid: Minor UI fix for diffusion panel

Was missing active option.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 390b5de7d37..960d2dff101 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -988,6 +988,7 @@ class PHYSICS_PT_diffusion(PhysicButtonsPanel, Panel):
 layout.use_property_split = True
 
 domain = context.fluid.domain_settings
+layout.active = domain.use_diffusion
 
 is_baking_any = domain.is_cache_baking_any
 has_baked_any = domain.has_cache_baked_any

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d19277c72f1] blender-v2.83-release: Fluid: Added missing outflow object type to enable / disable flow flag

2020-04-22 Thread Sebastián Barschkis
Commit: d19277c72f1a5acc08eefde9c6c05e2cd4358205
Author: Sebastián Barschkis
Date:   Sun Apr 19 19:43:05 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBd19277c72f1a5acc08eefde9c6c05e2cd4358205

Fluid: Added missing outflow object type to enable / disable flow flag

There is no reason to not include outflow objects here too.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 960d2dff101..d6d2526384a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -236,8 +236,8 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 
 col = grid.column()
 col.prop(flow, "flow_behavior", expand=False)
-if flow.flow_behavior in {'INFLOW'}:
-col.prop(flow, "use_inflow", text="Use Inflow")
+if flow.flow_behavior in {'INFLOW', 'OUTFLOW'}:
+col.prop(flow, "use_inflow", text="Use Flow")
 
 col.prop(flow, "subframes", text="Sampling Substeps")

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a0fe22095e6] master: Fluid: Use maximum for initial velocity grid application

2020-04-22 Thread Sebastián Barschkis
Commit: a0fe22095e6d9b8b194c2cf6f9a7c7b419d7e61c
Author: Sebastián Barschkis
Date:   Wed Apr 22 15:00:52 2020 +0200
Branches: master
https://developer.blender.org/rBa0fe22095e6d9b8b194c2cf6f9a7c7b419d7e61c

Fluid: Use maximum for initial velocity grid application

Using MAX2 when writing intial velocities into the grid prevents overriding 
initial velocities when using multiple flow objects that are close to each 
other.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 4934ec570d3..a26feb2d06b 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3110,9 +3110,9 @@ static void update_flowsfluids(struct Depsgraph 
*depsgraph,
   levelset,
   emission_in);
   if (mfs->flags & FLUID_FLOW_INITVELOCITY) {
-velx_initial[d_index] = velocity_map[e_index * 3];
-vely_initial[d_index] = velocity_map[e_index * 3 + 1];
-velz_initial[d_index] = velocity_map[e_index * 3 + 2];
+velx_initial[d_index] = MAX2(velx_initial[d_index], 
velocity_map[e_index * 3]);
+vely_initial[d_index] = MAX2(vely_initial[d_index], 
velocity_map[e_index * 3 + 1]);
+velz_initial[d_index] = MAX2(velz_initial[d_index], 
velocity_map[e_index * 3 + 2]);
   }
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [8d5ae15040e] master: Fluid: Fixes for cache 'Replay' mode

2020-04-22 Thread Sebastián Barschkis
Commit: 8d5ae15040ed9aac4315facd997432bcb75c5b78
Author: Sebastián Barschkis
Date:   Wed Apr 22 14:58:41 2020 +0200
Branches: master
https://developer.blender.org/rB8d5ae15040ed9aac4315facd997432bcb75c5b78

Fluid: Fixes for cache 'Replay' mode

General fixes and improvements for the cache. Previous commits on fluids broke 
the 'Replay' cache a bit.

===

M   source/blender/blenkernel/intern/fluid.c
M   source/blender/blenloader/intern/readfile.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 3effb9c0bb0..4934ec570d3 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1149,7 +1149,6 @@ static void ensure_obstaclefields(FluidDomainSettings 
*mds)
 }
 
 static void update_obstacleflags(FluidDomainSettings *mds,
- Object *domain,
  Object **coll_ob_array,
  int coll_ob_array_len)
 {
@@ -1178,7 +1177,6 @@ static void update_obstacleflags(FluidDomainSettings *mds,
   }
   if (mes->flags & FLUID_EFFECTOR_NEEDS_UPDATE) {
 mes->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
-BKE_fluid_cache_free_all(mds, domain);
 mds->cache_flag |= FLUID_DOMAIN_OUTDATED_DATA;
   }
   if (mes->type == FLUID_EFFECTOR_TYPE_COLLISION) {
@@ -1341,7 +1339,7 @@ static void update_obstacles(Depsgraph *depsgraph,
   depsgraph, ob, mds->effector_group, , eModifierType_Fluid);
 
   /* Update all effector related flags and ensure that corresponding grids get 
initialized. */
-  update_obstacleflags(mds, ob, effecobjs, numeffecobjs);
+  update_obstacleflags(mds, effecobjs, numeffecobjs);
   ensure_obstaclefields(mds);
 
   /* Allocate effector map for each effector object. */
@@ -2637,10 +2635,7 @@ static void ensure_flowsfields(FluidDomainSettings *mds)
   }
 }
 
-static void update_flowsflags(FluidDomainSettings *mds,
-  Object *domain,
-  Object **flowobjs,
-  int numflowobj)
+static void update_flowsflags(FluidDomainSettings *mds, Object **flowobjs, int 
numflowobj)
 {
   int active_fields = mds->active_fields;
   uint flow_index;
@@ -2668,7 +2663,6 @@ static void update_flowsflags(FluidDomainSettings *mds,
   }
   if (mfs->flags & FLUID_FLOW_NEEDS_UPDATE) {
 mfs->flags &= ~FLUID_FLOW_NEEDS_UPDATE;
-BKE_fluid_cache_free_all(mds, domain);
 mds->cache_flag |= FLUID_DOMAIN_OUTDATED_DATA;
   }
   if (mfs->flags & FLUID_FLOW_INITVELOCITY) {
@@ -2910,7 +2904,7 @@ static void update_flowsfluids(struct Depsgraph 
*depsgraph,
   depsgraph, ob, mds->fluid_group, , eModifierType_Fluid);
 
   /* Update all flow related flags and ensure that corresponding grids get 
initialized. */
-  update_flowsflags(mds, ob, flowobjs, numflowobjs);
+  update_flowsflags(mds, flowobjs, numflowobjs);
   ensure_flowsfields(mds);
 
   /* Allocate emission map for each flow object. */
@@ -3092,8 +3086,9 @@ static void update_flowsfluids(struct Depsgraph 
*depsgraph,
 }
 /* Main inflow application. */
 else if (is_geometry || is_inflow) {
-  float *levelset = ((is_first_frame || is_resume) && is_static) ? 
phistatic_in :
-   
phi_in;
+  float *levelset = ((is_first_frame || is_resume) && is_static && 
!is_geometry) ?
+phistatic_in :
+phi_in;
   apply_inflow_fields(mfs,
   emission_map[e_index],
   distance_map[e_index],
@@ -3731,18 +3726,8 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
 return;
   }
 
-  bool bake_outdated = mds->cache_flag &
-   (FLUID_DOMAIN_OUTDATED_DATA | 
FLUID_DOMAIN_OUTDATED_NOISE |
-FLUID_DOMAIN_OUTDATED_MESH | 
FLUID_DOMAIN_OUTDATED_PARTICLES |
-FLUID_DOMAIN_OUTDATED_GUIDE);
-
-  /* Exit early if cache is outdated. */
-  if (bake_outdated) {
-return;
-  }
-
-  /* Reset fluid if no fluid present. */
-  if (!mds->fluid || mds->cache_flag & FLUID_DOMAIN_OUTDATED_DATA) {
+  /* Reset fluid if no fluid present. Also resets active fields. */
+  if (!mds->fluid) {
 BKE_fluid_modifier_reset_ex(mmd, false);
   }
 
@@ -3750,19 +3735,29 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   const char *relbase = modifier_path_relbase_from_global(ob);
   BLI_path_abs(mds->cache_directory, relbase);
 
+  /* Ensure that all flags are up to date before doi

[Bf-blender-cvs] [76c1a91cfa5] master: Fluid: Fix for inconsistent behavior with flow and effector objects

2020-04-19 Thread Sebastián Barschkis
Commit: 76c1a91cfa5a96d4804b90c8ab8d3a92ad8ddd8c
Author: Sebastián Barschkis
Date:   Sun Apr 19 20:15:57 2020 +0200
Branches: master
https://developer.blender.org/rB76c1a91cfa5a96d4804b90c8ab8d3a92ad8ddd8c

Fluid: Fix for inconsistent behavior with flow and effector objects

Fixes issue with flow and effector objects which were not being used after 
resuming a bake job.
This issue has been reported in T75729 and T75758.

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h
M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index 85cc04b4a52..7825ad14d7d 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -107,6 +107,7 @@ float *manta_get_phistatic_in(struct MANTA *fluid);
 float *manta_get_phiobs_in(struct MANTA *fluid);
 float *manta_get_phiobsstatic_in(struct MANTA *fluid);
 float *manta_get_phiout_in(struct MANTA *fluid);
+float *manta_get_phioutstatic_in(struct MANTA *fluid);
 
 /* Smoke functions */
 void manta_smoke_export_script(struct MANTA *smoke, struct FluidModifierData 
*mmd);
diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 539e3080c54..a56ce4c1f60 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -141,6 +141,7 @@ MANTA::MANTA(int *res, FluidModifierData *mmd) : 
mCurrentID(++solverID)
   mPhiIn = nullptr;
   mPhiStaticIn = nullptr;
   mPhiOutIn = nullptr;
+  mPhiOutStaticIn = nullptr;
   mPhi = nullptr;
 
   // Mesh
@@ -1926,6 +1927,7 @@ void MANTA::exportSmokeScript(FluidModifierData *mmd)
   bool obstacle = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE;
   bool guiding = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
   bool invel = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
+  bool outflow = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
 
   std::string manta_script;
 
@@ -1968,6 +1970,8 @@ void MANTA::exportSmokeScript(FluidModifierData *mmd)
 manta_script += fluid_alloc_obstacle;
   if (invel)
 manta_script += fluid_alloc_invel;
+  if (outflow)
+manta_script += fluid_alloc_outflow;
 
   // Noise field
   if (noise)
@@ -2032,6 +2036,7 @@ void MANTA::exportLiquidScript(FluidModifierData *mmd)
   bool fractions = mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS;
   bool guiding = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE;
   bool invel = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL;
+  bool outflow = mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW;
 
   std::string manta_script;
 
@@ -2070,6 +2075,8 @@ void MANTA::exportLiquidScript(FluidModifierData *mmd)
 manta_script += fluid_alloc_fractions;
   if (invel)
 manta_script += fluid_alloc_invel;
+  if (outflow)
+manta_script += fluid_alloc_outflow;
 
   // Domain init
   manta_script += header_gridinit + liquid_init_phi;
@@ -3119,6 +3126,8 @@ void MANTA::updatePointers()
 
   if (mUsingOutflow) {
 mPhiOutIn = (float *)pyObjectToPointer(callPythonFunction("phiOutIn" + 
solver_ext, func));
+mPhiOutStaticIn = (float *)pyObjectToPointer(
+callPythonFunction("phiOutSIn" + solver_ext, func));
   }
   if (mUsingObstacle) {
 mPhiObsIn = (float *)pyObjectToPointer(callPythonFunction("phiObsIn" + 
solver_ext, func));
@@ -3230,7 +3239,7 @@ bool MANTA::hasConfig(FluidModifierData *mmd, int framenr)
 
 bool MANTA::hasData(FluidModifierData *mmd, int framenr)
 {
-  std::string filename = (mUsingSmoke) ? FLUID_DOMAIN_FILE_DENSITY : 
FLUID_DOMAIN_FILE_PHI;
+  std::string filename = (mUsingSmoke) ? FLUID_DOMAIN_FILE_DENSITY : 
FLUID_DOMAIN_FILE_PP;
   std::string extension = getCacheFileEnding(mmd->domain->cache_data_format);
   return BLI_exists(getFile(mmd, FLUID_DOMAIN_DIR_DATA, filename, extension, 
framenr).c_str());
 }
diff --git a/intern/mantaflow/intern/MANTA_main.h 
b/intern/mantaflow/intern/MANTA_main.h
index caac63d8e39..21946431f28 100644
--- a/intern/mantaflow/intern/MANTA_main.h
+++ b/intern/mantaflow/intern/MANTA_main.h
@@ -405,6 +405,10 @@ struct MANTA {
   {
 return mPhiOutIn;
   }
+  inline float *getPhiOutStaticIn()
+  {
+return mPhiOutStaticIn;
+  }
   inline float *getPhi()
   {
 return mPhi;
@@ -844,6 +848,7 @@ struct MANTA {
   float *mPhiObsStaticIn;
   float *mPhiGuideIn;
   float *mPhiOutIn;
+  flo

[Bf-blender-cvs] [6c4a7e0ac34] master: Fluid: Added missing outflow object type to enable / disable flow flag

2020-04-19 Thread Sebastián Barschkis
Commit: 6c4a7e0ac341b05d8fc8e15ed8e645a4936da9ca
Author: Sebastián Barschkis
Date:   Sun Apr 19 19:43:05 2020 +0200
Branches: master
https://developer.blender.org/rB6c4a7e0ac341b05d8fc8e15ed8e645a4936da9ca

Fluid: Added missing outflow object type to enable / disable flow flag

There is no reason to not include outflow objects here too.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 960d2dff101..d6d2526384a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -236,8 +236,8 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 
 col = grid.column()
 col.prop(flow, "flow_behavior", expand=False)
-if flow.flow_behavior in {'INFLOW'}:
-col.prop(flow, "use_inflow", text="Use Inflow")
+if flow.flow_behavior in {'INFLOW', 'OUTFLOW'}:
+col.prop(flow, "use_inflow", text="Use Flow")
 
 col.prop(flow, "subframes", text="Sampling Substeps")

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a331d799007] master: Fluid: Fix for caches being released when file is loaded

2020-04-19 Thread Sebastián Barschkis
Commit: a331d79900749ca0a09e1349971039f6746ee3cf
Author: Sebastián Barschkis
Date:   Sun Apr 19 21:13:27 2020 +0200
Branches: master
https://developer.blender.org/rBa331d79900749ca0a09e1349971039f6746ee3cf

Fluid: Fix for caches being released when file is loaded

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 08b5b788afd..0f6b85b366b 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4163,6 +4163,12 @@ struct Mesh *BKE_fluid_modifier_do(
 mmd->domain->cache_flag &= ~FLUID_DOMAIN_OUTDATED_PARTICLES;
 mmd->domain->cache_flag &= ~FLUID_DOMAIN_OUTDATED_GUIDE;
   }
+  else if (mmd->type & MOD_FLUID_TYPE_FLOW && mmd->flow) {
+mmd->flow->flags &= ~FLUID_FLOW_NEEDS_UPDATE;
+  }
+  else if (mmd->type & MOD_FLUID_TYPE_EFFEC && mmd->effector) {
+mmd->effector->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
+  }
   if (!result) {
 result = BKE_mesh_copy_for_eval(me, false);
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0f6044610fa] master: Fluid: Cleanup in MANTA main class

2020-04-15 Thread Sebastián Barschkis
Commit: 0f6044610faa71db9050c41980c31cbd56eb2469
Author: Sebastián Barschkis
Date:   Wed Apr 15 14:03:22 2020 +0200
Branches: master
https://developer.blender.org/rB0f6044610faa71db9050c41980c31cbd56eb2469

Fluid: Cleanup in MANTA main class

More concise return types for cache import functions and general cleanup.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 79c8625ec48..539e3080c54 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -61,28 +61,29 @@ int MANTA::with_debug(0);
 MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID)
 {
   if (with_debug)
-std::cout << "MANTA: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", "
+std::cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << 
res[1] << ", "
   << res[2] << ")" << std::endl;
 
   mmd->domain->fluid = this;
 
   mUsingLiquid = (mmd->domain->type == FLUID_DOMAIN_TYPE_LIQUID);
   mUsingSmoke = (mmd->domain->type == FLUID_DOMAIN_TYPE_GAS);
-  mUsingHeat = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && 
mUsingSmoke;
-  mUsingFire = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && 
mUsingSmoke;
-  mUsingColors = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingNoise = (mmd->domain->flags & FLUID_DOMAIN_USE_NOISE) && mUsingSmoke;
   mUsingFractions = (mmd->domain->flags & FLUID_DOMAIN_USE_FRACTIONS) && 
mUsingLiquid;
+  mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
+  mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && 
mUsingLiquid;
+  mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE);
   mUsingDrops = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_SPRAY) && 
mUsingLiquid;
   mUsingBubbles = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_BUBBLE) 
&& mUsingLiquid;
   mUsingFloats = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_FOAM) && 
mUsingLiquid;
   mUsingTracers = (mmd->domain->particle_type & FLUID_DOMAIN_PARTICLE_TRACER) 
&& mUsingLiquid;
-  mUsingMesh = (mmd->domain->flags & FLUID_DOMAIN_USE_MESH) && mUsingLiquid;
-  mUsingMVel = (mmd->domain->flags & FLUID_DOMAIN_USE_SPEED_VECTORS) && 
mUsingLiquid;
+
+  mUsingHeat = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_HEAT) && 
mUsingSmoke;
+  mUsingFire = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_FIRE) && 
mUsingSmoke;
+  mUsingColors = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_COLORS) && 
mUsingSmoke;
   mUsingObstacle = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE);
   mUsingInvel = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_INVEL);
   mUsingOutflow = (mmd->domain->active_fields & FLUID_DOMAIN_ACTIVE_OUTFLOW);
-  mUsingGuiding = (mmd->domain->flags & FLUID_DOMAIN_USE_GUIDE);
 
   // Simulation constants
   mTempAmb = 0;  // TODO: Maybe use this later for buoyancy calculation
@@ -566,7 +567,7 @@ bool MANTA::runPythonString(std::vector 
commands)
 void MANTA::initializeMantaflow()
 {
   if (with_debug)
-std::cout << "Fluid: Initializing Mantaflow framework." << std::endl;
+std::cout << "Fluid: Initializing Mantaflow framework" << std::endl;
 
   std::string filename = "manta_scene_" + std::to_string(mCurrentID) + ".py";
   std::vector fill = std::vector();
@@ -581,7 +582,7 @@ void MANTA::initializeMantaflow()
 void MANTA::terminateMantaflow()
 {
   if (with_debug)
-std::cout << "Fluid: Releasing Mantaflow framework." << std::endl;
+std::cout << "Fluid: Releasing Mantaflow framework" << std::endl;
 
   PyGILState_STATE gilstate = PyGILState_Ensure();
   Pb::finalize();  // Namespace from Mantaflow (registry)
@@ -1078,8 +1079,7 @@ bool MANTA::updateFlipStructures(FluidModifierData *mmd, 
int framenr)
 assert(result == expected);
   }
 
-  mFlipFromFile = true;
-  return (result == expected);
+  return mFlipFromFile = (result == expected);
 }
 
 bool MANTA::updateMeshStructures(FluidModifierData *mmd, int framenr)
@@ -1126,8 +1126,7 @@ bool MANTA::updateMeshStructures(FluidModifierData *mmd, 
int framenr)

[Bf-blender-cvs] [d9db8f8b7c2] master: Fluid: Remove noise bake call from Python

2020-04-15 Thread Sebastián Barschkis
Commit: d9db8f8b7c20158ca2c3285636e5d2e5d2d7a2ba
Author: Sebastián Barschkis
Date:   Wed Apr 15 13:59:05 2020 +0200
Branches: master
https://developer.blender.org/rBd9db8f8b7c20158ca2c3285636e5d2e5d2d7a2ba

Fluid: Remove noise bake call from Python

Saving noise cache files is handled in fluid.c.

===

M   intern/mantaflow/intern/strings/fluid_script.h

===

diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index 0aad0546aea..e81a44109ef 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -527,7 +527,6 @@ def bake_noise_process_$ID$(framenr, format_data, 
format_noise, path_data, path_
 sn$ID$.timestep = frameLength_s$ID$ # no adaptive timestep for noise\n\
 \n\
 smoke_step_noise_$ID$(framenr)\n\
-smoke_save_noise_$ID$(path_noise, framenr, format_noise, resumable)\n\
 \n\
 def bake_noise_$ID$(path_data, path_noise, framenr, format_data, format_noise, 
resumable):\n\
 if not withMPBake or isWindows:\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d6de81eed6c] master: Fluid: Minor UI fix for diffusion panel

2020-04-15 Thread Sebastián Barschkis
Commit: d6de81eed6ca60205af9b8d8e86d506a4f0c181d
Author: Sebastián Barschkis
Date:   Wed Apr 15 13:49:41 2020 +0200
Branches: master
https://developer.blender.org/rBd6de81eed6ca60205af9b8d8e86d506a4f0c181d

Fluid: Minor UI fix for diffusion panel

Was missing active option.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 390b5de7d37..960d2dff101 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -988,6 +988,7 @@ class PHYSICS_PT_diffusion(PhysicButtonsPanel, Panel):
 layout.use_property_split = True
 
 domain = context.fluid.domain_settings
+layout.active = domain.use_diffusion
 
 is_baking_any = domain.is_cache_baking_any
 has_baked_any = domain.has_cache_baked_any

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [e21fdfc8e4c] master: Fix T75681: Mantaflow crash when trying to bake a cupcake: The CG solver diverged, residual norm > 1e30

2020-04-15 Thread Sebastián Barschkis
Commit: e21fdfc8e4c805b353e8e120acf0030aeb894beb
Author: Sebastián Barschkis
Date:   Wed Apr 15 13:56:47 2020 +0200
Branches: master
https://developer.blender.org/rBe21fdfc8e4c805b353e8e120acf0030aeb894beb

Fix T75681: Mantaflow crash when trying to bake a cupcake: The CG solver 
diverged, residual norm > 1e30

Ensures that there are no enclosed holes between an obstacle and the domain 
walls.

===

M   intern/mantaflow/intern/strings/liquid_script.h
M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index b0bf6f85914..34994f115d7 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -173,14 +173,14 @@ def liquid_adaptive_step_$ID$(framenr):\n\
 if using_obstacle_s$ID$:\n\
 mantaMsg('Initializing obstacle levelset')\n\
 phiObsIn_s$ID$.join(phiObsSIn_s$ID$) # Join static obstacle map\n\
-phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
 phiObs_s$ID$.join(phiObsIn_s$ID$)\n\
 \n\
 # Using boundaryWidth=2 to not search beginning from walls (just a 
performance optimization)\n\
 # Additional sanity check: fill holes in phiObs which can result after 
joining with phiObsIn\n\
-phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2 if 
using_fractions_s$ID$ else 1)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=3)\n\
 \n\
diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index 7a855ff2cb8..cb651eb40b3 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -279,14 +279,14 @@ def smoke_adaptive_step_$ID$(framenr):\n\
 if using_obstacle_s$ID$:\n\
 mantaMsg('Initializing obstacle levelset')\n\
 phiObsIn_s$ID$.join(phiObsSIn_s$ID$) # Join static obstacle map\n\
-phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObsIn_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObsIn_s$ID$, distance=3, inside=False)\n\
 phiObs_s$ID$.join(phiObsIn_s$ID$)\n\
 \n\
 # Using boundaryWidth=2 to not search beginning from walls (just a 
performance optimization)\n\
 # Additional sanity check: fill holes in phiObs which can result after 
joining with phiObsIn\n\
-phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=2)\n\
+phiObs_s$ID$.fillHoles(maxDepth=int(res_s$ID$), boundaryWidth=1)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=6, inside=True)\n\
 extrapolateLsSimple(phi=phiObs_s$ID$, distance=3, inside=False)\n\
 \n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7de86ad61fb] master: Fluid: Improved cache 'Replay' option

2020-04-15 Thread Sebastián Barschkis
Commit: 7de86ad61fb1135c9e18f6336b5b01600b381b06
Author: Sebastián Barschkis
Date:   Wed Apr 15 14:16:13 2020 +0200
Branches: master
https://developer.blender.org/rB7de86ad61fb1135c9e18f6336b5b01600b381b06

Fluid: Improved cache 'Replay' option

When using the 'Replay' cache mode the cache needs to be invalidated whenever 
simulation variables have been changed.
The invalidation will always only affect the according subcaches, e.g. when 
changing a mesh paramter only the mesh cache will be invalidated, the base 
cache will remain intact.
Before this change Blender always invalidated the entire cache.

===

M   source/blender/blenkernel/BKE_fluid.h
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesdna/DNA_fluid_types.h
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/source/blender/blenkernel/BKE_fluid.h 
b/source/blender/blenkernel/BKE_fluid.h
index e8b4c819c62..e06a1a9fb92 100644
--- a/source/blender/blenkernel/BKE_fluid.h
+++ b/source/blender/blenkernel/BKE_fluid.h
@@ -61,6 +61,7 @@ void BKE_fluid_reallocate_copy_fluid(struct 
FluidDomainSettings *mds,
  int o_max[3],
  int o_shift[3],
  int n_shift[3]);
+void BKE_fluid_cache_free_all(struct FluidDomainSettings *mds, struct Object 
*ob);
 void BKE_fluid_cache_free(struct FluidDomainSettings *mds, struct Object *ob, 
int cache_map);
 void BKE_fluid_cache_new_name_for_current_session(int maxlen, char *r_name);
 
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 8076cc0967b..c4dd674790b 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -334,6 +334,14 @@ void BKE_fluid_reallocate_copy_fluid(FluidDomainSettings 
*mds,
   manta_free(fluid_old);
 }
 
+void BKE_fluid_cache_free_all(FluidDomainSettings *mds, Object *ob)
+{
+  int cache_map = (FLUID_DOMAIN_OUTDATED_DATA | FLUID_DOMAIN_OUTDATED_NOISE |
+   FLUID_DOMAIN_OUTDATED_MESH | 
FLUID_DOMAIN_OUTDATED_PARTICLES |
+   FLUID_DOMAIN_OUTDATED_GUIDE);
+  BKE_fluid_cache_free(mds, ob, cache_map);
+}
+
 void BKE_fluid_cache_free(FluidDomainSettings *mds, Object *ob, int cache_map)
 {
   char temp_dir[FILE_MAX];
@@ -1130,7 +1138,18 @@ static void obstacles_from_mesh(Object *coll_ob,
   }
 }
 
+static void ensure_obstaclefields(FluidDomainSettings *mds)
+{
+  if (mds->active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE) {
+manta_ensure_obstacle(mds->fluid, mds->mmd);
+  }
+  if (mds->active_fields & FLUID_DOMAIN_ACTIVE_GUIDE) {
+manta_ensure_guiding(mds->fluid, mds->mmd);
+  }
+}
+
 static void update_obstacleflags(FluidDomainSettings *mds,
+ Object *domain,
  Object **coll_ob_array,
  int coll_ob_array_len)
 {
@@ -1157,6 +1176,11 @@ static void update_obstacleflags(FluidDomainSettings 
*mds,
   if (!mes) {
 break;
   }
+  if (mes->flags & FLUID_EFFECTOR_NEEDS_UPDATE) {
+mes->flags &= ~FLUID_EFFECTOR_NEEDS_UPDATE;
+BKE_fluid_cache_free_all(mds, domain);
+mds->cache_flag |= FLUID_DOMAIN_OUTDATED_DATA;
+  }
   if (mes->type == FLUID_EFFECTOR_TYPE_COLLISION) {
 active_fields |= FLUID_DOMAIN_ACTIVE_OBSTACLE;
   }
@@ -1165,13 +1189,6 @@ static void update_obstacleflags(FluidDomainSettings 
*mds,
   }
 }
   }
-  /* Finally, initialize new data fields if any */
-  if (active_fields & FLUID_DOMAIN_ACTIVE_OBSTACLE) {
-manta_ensure_obstacle(mds->fluid, mds->mmd);
-  }
-  if (active_fields & FLUID_DOMAIN_ACTIVE_GUIDE) {
-manta_ensure_guiding(mds->fluid, mds->mmd);
-  }
   mds->active_fields = active_fields;
 }
 
@@ -1193,7 +1210,8 @@ static void update_obstacles(Depsgraph *depsgraph,
   depsgraph, ob, mds->effector_group, , eModifierType_Fluid);
 
   /* Update all effector related flags and ensure that corresponding grids get 
initialized. */
-  update_obstacleflags(mds, effecobjs, numeffecobjs);
+  update_obstacleflags(mds, ob, effecobjs, numeffecobjs);
+  ensure_obstaclefields(mds);
 
   /* Initialize effector maps for each flow. */
   bb_maps = MEM_callocN(sizeof(struct FluidObjectBB) * numeffecobjs, 
"fluid_effector_bb_maps");
@@ -2573,21 +2591,49 @@ BLI_INLINE void apply_inflow_fields(FluidFlowSettings 
*mfs,
   }
 }
 
-static void update_flowsflags(FluidDomainSettings *mds, Object **flowobjs, int 
numflowobj)
+static void ensure_flowsfields(FluidDomainSettings *mds)
+{
+  if (mds->active_fields & FLUID_DOMAIN_ACTIVE_INVEL) {
+manta_ensure_invelocity(mds->fluid, mds->mmd);
+  }
+  if (mds->active_fields & FLUID_DO

[Bf-blender-cvs] [0b86943641e] master: Fix T74901: Smoke Simulation crashes on eevee and is not persistent on Cycles

2020-04-10 Thread Sebastián Barschkis
Commit: 0b86943641ec59d7f1a0799c0f709e4f23d619f8
Author: Sebastián Barschkis
Date:   Fri Apr 10 12:10:13 2020 +0200
Branches: master
https://developer.blender.org/rB0b86943641ec59d7f1a0799c0f709e4f23d619f8

Fix T74901: Smoke Simulation crashes on eevee and is not persistent on Cycles

Issue was introduced in 5260aaf3b1c8 (fix for T73921).

===

M   source/blender/draw/engines/eevee/eevee_lightcache.c

===

diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c 
b/source/blender/draw/engines/eevee/eevee_lightcache.c
index 9447c365c48..614c749b9aa 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -777,8 +777,6 @@ static void 
eevee_lightbake_delete_resources(EEVEE_LightBake *lbake)
   if (!lbake->resource_only) {
 BLI_mutex_unlock(lbake->mutex);
   }
-
-  EEVEE_volumes_free_smoke_textures();
 }
 
 /* Cache as in draw cache not light cache. */
@@ -1347,6 +1345,9 @@ void EEVEE_lightbake_job(void *custom_data, short *stop, 
short *do_update, float
   }
 
   eevee_lightbake_delete_resources(lbake);
+
+  /* Free GPU smoke textures and the smoke domain list correctly: See also 
T73921.*/
+  EEVEE_volumes_free_smoke_textures();
 }
 
 /* This is to update the world irradiance and reflection contribution from

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a6d8f6c0f30] master: Fluid: Fix unused variables

2020-04-09 Thread Sebastián Barschkis
Commit: a6d8f6c0f308edb74a2b56e784e49153e21c8680
Author: Sebastián Barschkis
Date:   Thu Apr 9 12:18:05 2020 +0200
Branches: master
https://developer.blender.org/rBa6d8f6c0f308edb74a2b56e784e49153e21c8680

Fluid: Fix unused variables

Unsed variables for fluid caching.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index e96f65751de..8076cc0967b 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3788,6 +3788,13 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
   prev_particles = manta_has_particles(mds->fluid, mmd, scene_framenr - 1);
   prev_guide = manta_has_guiding(mds->fluid, mmd, scene_framenr - 1, 
guide_parent);
 
+  /* Unused for now, but needed for proper caching. */
+  UNUSED_VARS(prev_guide);
+  UNUSED_VARS(next_noise);
+  UNUSED_VARS(next_mesh);
+  UNUSED_VARS(next_particles);
+  UNUSED_VARS(next_guide);
+
   bool with_gdomain;
   with_gdomain = (mds->guide_source == FLUID_DOMAIN_GUIDE_SRC_DOMAIN);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4a6f715421a] master: Fix T73552: Mantaflow - liquid particles show up in organized unrealistic structure

2020-04-08 Thread Sebastián Barschkis
Commit: 4a6f715421af0d6cc15dc9e7ab6f3f90438d0a3d
Author: Sebastián Barschkis
Date:   Wed Apr 8 18:29:11 2020 +0200
Branches: master
https://developer.blender.org/rB4a6f715421af0d6cc15dc9e7ab6f3f90438d0a3d

Fix T73552: Mantaflow - liquid particles show up in organized unrealistic 
structure

Issue was being caused by a particle offset which was random but the same for 
every particle.

===

M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp

===

diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index 6a26c480392..791dd001bbe 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit f3d32c45934fd08c40096fb3510e9cc403730977"
+#define MANTA_GIT_VERSION "commit 21303fab2eda588ec22988bf9e5762d2001c131f"
diff --git a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp 
b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
index 23f5e23d99d..a8913a218c1 100644
--- a/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
+++ b/extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp
@@ -525,7 +525,7 @@ struct knFlipSampleSecondaryParticlesMoreCylinders : public 
KernelBase {
 if (!(flags(i, j, k) & itype))
   return;
 
-RandomStream mRand(9832);
+static RandomStream mRand(9832);
 Real radius =
 0.25;  // diameter=0.5 => sampling with two cylinders in each 
dimension since cell size=1
 for (Real x = i - radius; x <= i + radius; x += 2 * radius) {
@@ -791,11 +791,9 @@ struct knFlipSampleSecondaryParticles : public KernelBase {
 const int n = KE * (k_ta * TA + k_wc * WC) * dt;  // number of secondary 
particles
 if (n == 0)
   return;
-RandomStream mRand(9832);
+static RandomStream mRand(9832);
 
-Vec3 xi = Vec3(i + mRand.getReal(),
-   j + mRand.getReal(),
-   k + mRand.getReal());  // randomized offset uniform in cell
+Vec3 xi = Vec3(i, j, k) + mRand.getVec3();  // randomized offset uniform 
in cell
 Vec3 vi = v.getInterpolated(xi);
 Vec3 dir = dt * vi;   // direction of movement 
of current particle
 Vec3 e1 = getNormalized(Vec3(dir.z, 0, -dir.x));  // perpendicular to dir

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [020d1e23aee] master: Fluid: Fix issue with mesh not being loaded

2020-04-08 Thread Sebastián Barschkis
Commit: 020d1e23aee934dfad5fabc4038362cb8adf6c2a
Author: Sebastián Barschkis
Date:   Wed Apr 8 16:25:00 2020 +0200
Branches: master
https://developer.blender.org/rB020d1e23aee934dfad5fabc4038362cb8adf6c2a

Fluid: Fix issue with mesh not being loaded

Fixed an issue that was likely introduced in a past cleanup.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 293abae1b3a..79c8625ec48 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -1098,12 +1098,14 @@ bool MANTA::updateMeshStructures(FluidModifierData 
*mmd, int framenr)
   int expected = 0; /* Expected number of read successes for this frame. */
 
   /* Ensure empty data structures at start. */
-  if (!mMeshNodes || !mMeshTriangles || !mMeshVelocities)
+  if (!mMeshNodes || !mMeshTriangles)
 return false;
 
   mMeshNodes->clear();
   mMeshTriangles->clear();
-  mMeshVelocities->clear();
+
+  if (mMeshVelocities)
+mMeshVelocities->clear();
 
   std::string mformat = getCacheFileEnding(mmd->domain->cache_mesh_format);
   std::string dformat = getCacheFileEnding(mmd->domain->cache_data_format);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ff2c67d7e8e] master: Fluid: Disable subframes when using adaptive time-steps in the first frame

2020-04-08 Thread Sebastián Barschkis
Commit: ff2c67d7e8ed334c482681e2342bf8cce0957546
Author: Sebastián Barschkis
Date:   Wed Apr 8 13:42:40 2020 +0200
Branches: master
https://developer.blender.org/rBff2c67d7e8ed334c482681e2342bf8cce0957546

Fluid: Disable subframes when using adaptive time-steps in the first frame

First frame should only produce inflow once and not compute the emission for 
the frame before the first frame. Problem became evident in T74062.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 985d0a79b23..e96f65751de 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1250,7 +1250,8 @@ static void update_obstacles(Depsgraph *depsgraph,
 
 /* Set scene time */
 /* Handle emission subframe */
-if (subframe < subframes || time_per_frame + dt + FLT_EPSILON < 
frame_length) {
+if ((subframe < subframes || time_per_frame + dt + FLT_EPSILON < 
frame_length) &&
+!is_first_frame) {
   scene->r.subframe = (time_per_frame + (subframe + 1.0f) * 
subframe_dt) / frame_length;
   scene->r.cfra = frame - 1;
 }
@@ -2763,7 +2764,8 @@ static void update_flowsfluids(struct Depsgraph 
*depsgraph,
 FluidObjectBB bb_temp = {NULL};
 
 /* Set scene time */
-if (subframe < subframes || time_per_frame + dt + FLT_EPSILON < 
frame_length) {
+if ((subframe < subframes || time_per_frame + dt + FLT_EPSILON < 
frame_length) &&
+!is_first_frame) {
   scene->r.subframe = (time_per_frame + (subframe + 1.0f) * 
subframe_dt) / frame_length;
   scene->r.cfra = frame - 1;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a1ddb633297] master: Fluid: Update Mantaflow source files

2020-04-08 Thread Sebastián Barschkis
Commit: a1ddb633297a603ed19a37340be5f27c1c439d36
Author: Sebastián Barschkis
Date:   Wed Apr 8 13:25:16 2020 +0200
Branches: master
https://developer.blender.org/rBa1ddb633297a603ed19a37340be5f27c1c439d36

Fluid: Update Mantaflow source files

Update includes new grid helper functions and some cleanups.

===

M   extern/mantaflow/preprocessed/gitinfo.h
M   extern/mantaflow/preprocessed/grid.cpp
M   extern/mantaflow/preprocessed/grid.h
M   extern/mantaflow/preprocessed/grid.h.reg.cpp
M   extern/mantaflow/preprocessed/plugin/secondaryparticles.cpp

===

diff --git a/extern/mantaflow/preprocessed/gitinfo.h 
b/extern/mantaflow/preprocessed/gitinfo.h
index 208d8008a7e..6a26c480392 100644
--- a/extern/mantaflow/preprocessed/gitinfo.h
+++ b/extern/mantaflow/preprocessed/gitinfo.h
@@ -1,3 +1,3 @@
 
 
-#define MANTA_GIT_VERSION "commit 5fbd3d04381b21afce4a593d1fe2d9bc7bef5424"
+#define MANTA_GIT_VERSION "commit f3d32c45934fd08c40096fb3510e9cc403730977"
diff --git a/extern/mantaflow/preprocessed/grid.cpp 
b/extern/mantaflow/preprocessed/grid.cpp
index f10052349d5..0ea3afb91f4 100644
--- a/extern/mantaflow/preprocessed/grid.cpp
+++ b/extern/mantaflow/preprocessed/grid.cpp
@@ -853,6 +853,147 @@ template struct knPermuteAxes : public 
KernelBase {
   int axis2;
 };
 
+struct knJoinVec : public KernelBase {
+  knJoinVec(Grid , const Grid , bool keepMax)
+  : KernelBase(, 0), a(a), b(b), keepMax(keepMax)
+  {
+runMessage();
+run();
+  }
+  inline void op(IndexInt idx, Grid , const Grid , bool 
keepMax) const
+  {
+Real a1 = normSquare(a[idx]);
+Real b1 = normSquare(b[idx]);
+a[idx] = (keepMax) ? max(a1, b1) : min(a1, b1);
+  }
+  inline Grid ()
+  {
+return a;
+  }
+  typedef Grid type0;
+  inline const Grid ()
+  {
+return b;
+  }
+  typedef Grid type1;
+  inline bool ()
+  {
+return keepMax;
+  }
+  typedef bool type2;
+  void runMessage()
+  {
+debMsg("Executing kernel knJoinVec ", 3);
+debMsg("Kernel range"
+   << " x " << maxX << " y " << maxY << " z " << minZ << " - " << 
maxZ << " ",
+   4);
+  };
+  void operator()(const tbb::blocked_range &__r) const
+  {
+for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
+  op(idx, a, b, keepMax);
+  }
+  void run()
+  {
+tbb::parallel_for(tbb::blocked_range(0, size), *this);
+  }
+  Grid 
+  const Grid 
+  bool keepMax;
+};
+struct knJoinInt : public KernelBase {
+  knJoinInt(Grid , const Grid , bool keepMax)
+  : KernelBase(, 0), a(a), b(b), keepMax(keepMax)
+  {
+runMessage();
+run();
+  }
+  inline void op(IndexInt idx, Grid , const Grid , bool keepMax) 
const
+  {
+a[idx] = (keepMax) ? max(a[idx], b[idx]) : min(a[idx], b[idx]);
+  }
+  inline Grid ()
+  {
+return a;
+  }
+  typedef Grid type0;
+  inline const Grid ()
+  {
+return b;
+  }
+  typedef Grid type1;
+  inline bool ()
+  {
+return keepMax;
+  }
+  typedef bool type2;
+  void runMessage()
+  {
+debMsg("Executing kernel knJoinInt ", 3);
+debMsg("Kernel range"
+   << " x " << maxX << " y " << maxY << " z " << minZ << " - " << 
maxZ << " ",
+   4);
+  };
+  void operator()(const tbb::blocked_range &__r) const
+  {
+for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
+  op(idx, a, b, keepMax);
+  }
+  void run()
+  {
+tbb::parallel_for(tbb::blocked_range(0, size), *this);
+  }
+  Grid 
+  const Grid 
+  bool keepMax;
+};
+struct knJoinReal : public KernelBase {
+  knJoinReal(Grid , const Grid , bool keepMax)
+  : KernelBase(, 0), a(a), b(b), keepMax(keepMax)
+  {
+runMessage();
+run();
+  }
+  inline void op(IndexInt idx, Grid , const Grid , bool 
keepMax) const
+  {
+a[idx] = (keepMax) ? max(a[idx], b[idx]) : min(a[idx], b[idx]);
+  }
+  inline Grid ()
+  {
+return a;
+  }
+  typedef Grid type0;
+  inline const Grid ()
+  {
+return b;
+  }
+  typedef Grid type1;
+  inline bool ()
+  {
+return keepMax;
+  }
+  typedef bool type2;
+  void runMessage()
+  {
+debMsg("Executing kernel knJoinReal ", 3);
+debMsg("Kernel range"
+   << " x " << maxX << " y " << maxY << " z " << minZ << " - " << 
maxZ << " ",
+   4);
+  };
+  void operator()(const tbb::blocked_range &__r) const
+  {
+for (IndexInt idx = __r.begin(); idx != (IndexInt)__r.end(); idx++)
+  op(idx, a, b, keepMax);
+  }
+  void run()
+  {
+tbb::parallel_for(tbb::blocked_range(0, 

[Bf-blender-cvs] [c2cb87f8976] master: Fluid: Fix problem with inconsistent noise when using multiple adaptive time-steps

2020-04-08 Thread Sebastián Barschkis
Commit: c2cb87f8976b813821a5166686d7625fbe384ba8
Author: Sebastián Barschkis
Date:   Wed Apr 8 13:27:12 2020 +0200
Branches: master
https://developer.blender.org/rBc2cb87f8976b813821a5166686d7625fbe384ba8

Fluid: Fix problem with inconsistent noise when using multiple adaptive 
time-steps

Problem was mentioned in T74062.

===

M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index 0f265fcb7ac..7a855ff2cb8 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -82,6 +82,7 @@ const std::string smoke_alloc =
 "\n\
 mantaMsg('Smoke alloc')\n\
 shadow_s$ID$ = s$ID$.create(RealGrid)\n\
+emission_s$ID$   = s$ID$.create(RealGrid)\n\
 emissionIn_s$ID$ = s$ID$.create(RealGrid)\n\
 density_s$ID$= s$ID$.create(RealGrid)\n\
 densityIn_s$ID$  = s$ID$.create(RealGrid)\n\
@@ -101,7 +102,7 @@ color_b_in_s$ID$ = None\n\
 \n\
 # Keep track of important objects in dict to load them later on\n\
 smoke_data_dict_final_s$ID$ = dict(density=density_s$ID$, 
shadow=shadow_s$ID$)\n\
-smoke_data_dict_resume_s$ID$ = dict(densityIn=densityIn_s$ID$, 
emissionIn=emissionIn_s$ID$)\n";
+smoke_data_dict_resume_s$ID$ = dict(densityIn=densityIn_s$ID$, 
emission=emission_s$ID$)\n";
 
 const std::string smoke_alloc_noise =
 "\n\
@@ -300,6 +301,9 @@ def smoke_adaptive_step_$ID$(framenr):\n\
 setObstacleFlags(flags=flags_s$ID$, phiObs=phiObs_s$ID$, 
phiOut=phiOut_s$ID$, phiIn=phiIn_s$ID$, boundaryWidth=1)\n\
 flags_s$ID$.fillGrid()\n\
 \n\
+# accumulate emission value per adaptive step for later use in noise 
computation\n\
+emission_s$ID$.join(emissionIn_s$ID$)\n\
+\n\
 applyEmission(flags=flags_s$ID$, target=density_s$ID$, 
source=densityIn_s$ID$, emissionTexture=emissionIn_s$ID$, 
type=FlagInflow|FlagOutflow)\n\
 if using_heat_s$ID$:\n\
 applyEmission(flags=flags_s$ID$, target=heat_s$ID$, 
source=heatIn_s$ID$, emissionTexture=emissionIn_s$ID$, 
type=FlagInflow|FlagOutflow)\n\
@@ -437,7 +441,7 @@ def smoke_step_noise_$ID$(framenr):\n\
 \n\
 # Interpolate emission grids and apply them to big noise grids\n\
 tmpIn_sn$ID$.copyFrom(densityIn_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=densityIn_s$ID$, target=tmpIn_sn$ID$)\n\
-emissionIn_sn$ID$.copyFrom(emissionIn_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=emissionIn_s$ID$, target=emissionIn_sn$ID$)\n\
+emissionIn_sn$ID$.copyFrom(emission_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=emission_s$ID$, target=emissionIn_sn$ID$)\n\
 \n\
 # Higher-res noise grid needs scaled emission values\n\
 tmpIn_sn$ID$.multConst(float(upres_sn$ID$))\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7cafdc57e06] master: Fluid: Manta clang-format update

2020-04-08 Thread Sebastián Barschkis
Commit: 7cafdc57e06d675061ec40cfaba03c2af1f58122
Author: Sebastián Barschkis
Date:   Wed Apr 8 13:20:18 2020 +0200
Branches: master
https://developer.blender.org/rB7cafdc57e06d675061ec40cfaba03c2af1f58122

Fluid: Manta clang-format update

Do not use sort-includes in Manta source files for now when applying 
clang-format. Too many conflicts.

===

M   extern/mantaflow/UPDATE.sh

===

diff --git a/extern/mantaflow/UPDATE.sh b/extern/mantaflow/UPDATE.sh
index 0db18d03094..3feb1ba9226 100644
--- a/extern/mantaflow/UPDATE.sh
+++ b/extern/mantaflow/UPDATE.sh
@@ -71,7 +71,7 @@ rm $BLENDER_INSTALLATION/blender/tmp/preprocessed/fileio/*.reg
 cd $BLENDER_INSTALLATION/blender/tmp/
 
 echo "Applying clang format to Mantaflow source files"
-find . -iname *.h -o -iname *.cpp | xargs clang-format --verbose -i -style=file
+find . -iname *.h -o -iname *.cpp | xargs clang-format --verbose -i 
-style=file -sort-includes=0
 find . -iname *.h -o -iname *.cpp | xargs dos2unix --verbose
 
 #  5) MOVE MANTAFLOW FILES TO EXTERN/ 


___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4a838321206] master: Fix T74828: Fluid: Crash with Fire/Smoke Noise

2020-04-07 Thread Sebastián Barschkis
Commit: 4a83832120647044908898a9afc5e54028d78617
Author: Sebastián Barschkis
Date:   Tue Apr 7 14:22:56 2020 +0200
Branches: master
https://developer.blender.org/rB4a83832120647044908898a9afc5e54028d78617

Fix T74828: Fluid: Crash with Fire/Smoke Noise

Issue was that the noise simulation was trying to bake with a minimized domain 
size (adaptive domain initializes domain with size (1,1,1)). Similarly to the 
base resolution bake, there should be no noise baking happening at those domain 
sizes - a domain at this size is considered empty.

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index 939f24fbeef..85cc04b4a52 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -39,6 +39,7 @@ void manta_ensure_invelocity(struct MANTA *fluid, struct 
FluidModifierData *mmd)
 void manta_ensure_outflow(struct MANTA *fluid, struct FluidModifierData *mmd);
 int manta_write_config(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_write_data(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+int manta_write_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_read_config(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_read_data(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_read_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 95487ff3bd0..293abae1b3a 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -1441,6 +1441,29 @@ bool MANTA::writeData(FluidModifierData *mmd, int 
framenr)
   return runPythonString(pythonCommands);
 }
 
+bool MANTA::writeNoise(FluidModifierData *mmd, int framenr)
+{
+  if (with_debug)
+std::cout << "MANTA::writeNoise()" << std::endl;
+
+  std::ostringstream ss;
+  std::vector pythonCommands;
+
+  std::string directory = getDirectory(mmd, FLUID_DOMAIN_DIR_NOISE);
+  std::string nformat = getCacheFileEnding(mmd->domain->cache_noise_format);
+
+  bool final_cache = (mmd->domain->cache_type == FLUID_DOMAIN_CACHE_FINAL);
+  std::string resumable_cache = (final_cache) ? "False" : "True";
+
+  if (mUsingSmoke && mUsingNoise) {
+ss.str("");
+ss << "smoke_save_noise_" << mCurrentID << "('" << 
escapeSlashes(directory) << "', " << framenr
+   << ", '" << nformat << "', " << resumable_cache << ")";
+pythonCommands.push_back(ss.str());
+  }
+  return runPythonString(pythonCommands);
+}
+
 bool MANTA::readConfiguration(FluidModifierData *mmd, int framenr)
 {
   if (with_debug)
diff --git a/intern/mantaflow/intern/MANTA_main.h 
b/intern/mantaflow/intern/MANTA_main.h
index f4699e857ff..caac63d8e39 100644
--- a/intern/mantaflow/intern/MANTA_main.h
+++ b/intern/mantaflow/intern/MANTA_main.h
@@ -79,7 +79,8 @@ struct MANTA {
   // Write cache
   bool writeConfiguration(FluidModifierData *mmd, int framenr);
   bool writeData(FluidModifierData *mmd, int framenr);
-  // write call for noise, mesh and particles were left in bake calls for now
+  bool writeNoise(FluidModifierData *mmd, int framenr);
+  // write calls for mesh and particles were left in bake calls for now
 
   // Read cache (via Manta save/load)
   bool readConfiguration(FluidModifierData *mmd, int framenr);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp 
b/intern/mantaflow/intern/manta_fluid_API.cpp
index 594f7a44e7f..b4582051c3c 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -80,6 +80,13 @@ int manta_write_data(MANTA *fluid, FluidModifierData *mmd, 
int framenr)
   return fluid->writeData(mmd, framenr);
 }
 
+int manta_write_noise(MANTA *fluid, FluidModifierData *mmd, int framenr)
+{
+  if (!fluid || !mmd)
+return 0;
+  return fluid->writeNoise(mmd, framenr);
+}
+
 int manta_read_config(MANTA *fluid, FluidModifierData *mmd, int framenr)
 {
   if (!fluid || !mmd)
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index cbb933725eb..985d0a79b23 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -3999,7 +3999,11 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierDa

[Bf-blender-cvs] [ea78f9922ef] master: Fluid: Fixed assertion error

2020-04-07 Thread Sebastián Barschkis
Commit: ea78f9922eff794858983cdb5bf3cf59e6b52b39
Author: Sebastián Barschkis
Date:   Tue Apr 7 14:13:05 2020 +0200
Branches: master
https://developer.blender.org/rBea78f9922eff794858983cdb5bf3cf59e6b52b39

Fluid: Fixed assertion error

Fix for new assertion statements that were introduced in bfdc42d9906a.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 54b728b734e..95487ff3bd0 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -1222,19 +1222,21 @@ bool MANTA::updateSmokeStructures(FluidModifierData 
*mmd, int framenr)
 
   if (mUsingColors) {
 file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_COLORR, 
dformat, framenr);
-expected += 3;
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mColorR, false);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_COLORG, 
dformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mColorG, false);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_COLORB, 
dformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mColorB, false);
   assert(result == expected);
@@ -1243,19 +1245,21 @@ bool MANTA::updateSmokeStructures(FluidModifierData 
*mmd, int framenr)
 
   if (mUsingFire) {
 file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_FLAME, 
dformat, framenr);
-expected += 3;
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mFlame, false);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_FUEL, 
dformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mFuel, false);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_REACT, 
dformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mReact, false);
   assert(result == expected);
@@ -1301,19 +1305,21 @@ bool MANTA::updateNoiseStructures(FluidModifierData 
*mmd, int framenr)
 
   if (mUsingColors) {
 file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_COLORRNOISE, 
nformat, framenr);
-expected += 3;
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mColorRHigh, true);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_COLORGNOISE, 
nformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mColorGHigh, true);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_COLORBNOISE, 
nformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mColorBHigh, true);
   assert(result == expected);
@@ -1322,19 +1328,21 @@ bool MANTA::updateNoiseStructures(FluidModifierData 
*mmd, int framenr)
 
   if (mUsingFire) {
 file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_FLAMENOISE, 
nformat, framenr);
-expected += 3;
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mFlameHigh, true);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_FUELNOISE, 
nformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mFuelHigh, true);
   assert(result == expected);
 }
 
 file = getFile(mmd, FLUID_DOMAIN_DIR_NOISE, FLUID_DOMAIN_FILE_REACTNOISE, 
nformat, framenr);
+expected += 1;
 if (BLI_exists(file.c_str())) {
   result += updateGridFromFile(file, mReactHigh, true);
   assert(result == expected);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [71a52bbe2a2] master: Fluid: Ensure correct velocities for noise bake

2020-04-06 Thread Sebastián Barschkis
Commit: 71a52bbe2a2edaac77d146b27502dddf986d3284
Author: Sebastián Barschkis
Date:   Mon Apr 6 17:48:18 2020 +0200
Branches: master
https://developer.blender.org/rB71a52bbe2a2edaac77d146b27502dddf986d3284

Fluid: Ensure correct velocities for noise bake

Make sure that noise uses the unaltered velocity grid. This is particularly 
important once external velocities get added to the velocity grid.

===

M   intern/mantaflow/intern/strings/smoke_script.h

===

diff --git a/intern/mantaflow/intern/strings/smoke_script.h 
b/intern/mantaflow/intern/strings/smoke_script.h
index fb2eaa9b441..0f265fcb7ac 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -329,6 +329,9 @@ const std::string smoke_step =
 def smoke_step_$ID$():\n\
 mantaMsg('Smoke step low')\n\
 \n\
+# save original state for later (used during noise creation)\n\
+velTmp_s$ID$.copyFrom(vel_s$ID$)\n\
+\n\
 if using_dissolve_s$ID$:\n\
 mantaMsg('Dissolving smoke')\n\
 dissolveSmoke(flags=flags_s$ID$, density=density_s$ID$, 
heat=heat_s$ID$, red=color_r_s$ID$, green=color_g_s$ID$, blue=color_b_s$ID$, 
speed=dissolveSpeed_s$ID$, logFalloff=using_logdissolve_s$ID$)\n\
@@ -422,36 +425,36 @@ def smoke_step_noise_$ID$(framenr):\n\
 mantaMsg('Interpolating grids')\n\
 # Join big obstacle levelset after initDomain() call as it overwrites 
everything in phiObs\n\
 if using_obstacle_s$ID$:\n\
-interpolateGrid(target=phiIn_sn$ID$, source=phiObsIn_s$ID$) # mis-use 
phiIn_sn\n\
+phiIn_sn$ID$.copyFrom(phiObsIn_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(target=phiIn_sn$ID$, source=phiObsIn_s$ID$) # mis-use 
phiIn_sn\n\
 phiObs_sn$ID$.join(phiIn_sn$ID$)\n\
 if using_outflow_s$ID$:\n\
-interpolateGrid(target=phiOut_sn$ID$, source=phiOut_s$ID$)\n\
-interpolateGrid(target=phiIn_sn$ID$, source=phiIn_s$ID$)\n\
-interpolateMACGrid(target=vel_sn$ID$, source=vel_s$ID$)\n\
+phiOut_sn$ID$.copyFrom(phiOut_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(target=phiOut_sn$ID$, source=phiOut_s$ID$)\n\
+phiIn_sn$ID$.copyFrom(phiIn_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(target=phiIn_sn$ID$, source=phiIn_s$ID$)\n\
+vel_sn$ID$.copyFrom(velTmp_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateMACGrid(target=vel_sn$ID$, source=velTmp_s$ID$)\n\
 \n\
 setObstacleFlags(flags=flags_sn$ID$, phiObs=phiObs_sn$ID$, 
phiOut=phiOut_sn$ID$, phiIn=phiIn_sn$ID$, boundaryWidth=1)\n\
 flags_sn$ID$.fillGrid()\n\
 \n\
 # Interpolate emission grids and apply them to big noise grids\n\
-interpolateGrid(source=densityIn_s$ID$, target=tmpIn_sn$ID$)\n\
-interpolateGrid(source=emissionIn_s$ID$, target=emissionIn_sn$ID$)\n\
+tmpIn_sn$ID$.copyFrom(densityIn_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=densityIn_s$ID$, target=tmpIn_sn$ID$)\n\
+emissionIn_sn$ID$.copyFrom(emissionIn_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=emissionIn_s$ID$, target=emissionIn_sn$ID$)\n\
 \n\
 # Higher-res noise grid needs scaled emission values\n\
 tmpIn_sn$ID$.multConst(float(upres_sn$ID$))\n\
 applyEmission(flags=flags_sn$ID$, target=density_sn$ID$, 
source=tmpIn_sn$ID$, emissionTexture=emissionIn_sn$ID$, 
type=FlagInflow|FlagOutflow)\n\
 \n\
 if using_colors_s$ID$:\n\
-interpolateGrid(source=color_r_in_s$ID$, target=tmpIn_sn$ID$)\n\
+tmpIn_sn$ID$.copyFrom(color_r_in_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=color_r_in_s$ID$, target=tmpIn_sn$ID$)\n\
 applyEmission(flags=flags_sn$ID$, target=color_r_sn$ID$, 
source=tmpIn_sn$ID$, emissionTexture=emissionIn_sn$ID$, 
type=FlagInflow|FlagOutflow)\n\
-interpolateGrid(source=color_g_in_s$ID$, target=tmpIn_sn$ID$)\n\
+tmpIn_sn$ID$.copyFrom(color_g_in_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=color_g_in_s$ID$, target=tmpIn_sn$ID$)\n\
 applyEmission(flags=flags_sn$ID$, target=color_g_sn$ID$, 
source=tmpIn_sn$ID$, emissionTexture=emissionIn_sn$ID$, 
type=FlagInflow|FlagOutflow)\n\
-interpolateGrid(source=color_b_in_s$ID$, target=tmpIn_sn$ID$)\n\
+tmpIn_sn$ID$.copyFrom(color_b_in_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=color_b_in_s$ID$, target=tmpIn_sn$ID$)\n\
 applyEmission(flags=flags_sn$ID$, target=color_b_sn$ID$, 
source=tmpIn_sn$ID$, emissionTexture=emissionIn_sn$ID$, 
type=FlagInflow|FlagOutflow)\n\
 \n\
 if using_fire_s$ID$:\n\
-interpolateGrid(source=fuelIn_s$ID$, target=tmpIn_sn$ID$)\n\
+tmpIn_sn$ID$.copyFrom(fuelIn_s$ID$) if upres_sn$ID$ <= 1 else 
interpolateGrid(source=fuelIn_s$ID$, target=tmpIn_sn$ID$)\n\
 applyEmission(flags=flags_sn$ID$, target=fuel_sn$ID$, 
source=tmpIn_sn$ID$, emissionTe

[Bf-blender-cvs] [bfdc42d9906] master: Fluid: Refactored MANTA class

2020-04-03 Thread Sebastián Barschkis
Commit: bfdc42d9906a08ecc8033eeb9fe267e0a7e5265b
Author: Sebastián Barschkis
Date:   Thu Apr 2 13:48:50 2020 +0200
Branches: master
https://developer.blender.org/rBbfdc42d9906a08ecc8033eeb9fe267e0a7e5265b

Fluid: Refactored MANTA class

Refactored the caching system so that return values are no longer ignored. The 
aim of this refactor was to make the caching more robust.

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index d14ab8d6dd3..3555e098caf 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -48,7 +48,6 @@
 
 #include "MEM_guardedalloc.h"
 
-std::atomic MANTA::mantaInitialized(false);
 std::atomic MANTA::solverID(0);
 int MANTA::with_debug(0);
 
@@ -523,6 +522,7 @@ MANTA::~MANTA()
   // Destruction string for Python
   std::string tmpString = "";
   std::vector pythonCommands;
+  bool result = false;
 
   tmpString += manta_import;
   tmpString += fluid_delete_all;
@@ -530,11 +530,15 @@ MANTA::~MANTA()
   // Leave out mmd argument in parseScript since only looking up IDs
   std::string finalString = parseScript(tmpString);
   pythonCommands.push_back(finalString);
-  runPythonString(pythonCommands);
+  result = runPythonString(pythonCommands);
+
+  assert(result);
+  (void)result;  // not needed in release
 }
 
-void MANTA::runPythonString(std::vector commands)
+bool MANTA::runPythonString(std::vector commands)
 {
+  int success = -1;
   PyGILState_STATE gilstate = PyGILState_Ensure();
   for (std::vector::iterator it = commands.begin(); it != 
commands.end(); ++it) {
 std::string command = *it;
@@ -546,19 +550,23 @@ void MANTA::runPythonString(std::vector 
commands)
 memcpy(buffer, command.data(), cmdLength);
 
 buffer[cmdLength] = '\0';
-PyRun_SimpleString(buffer);
+success = PyRun_SimpleString(buffer);
 delete[] buffer;
 #else
-PyRun_SimpleString(command.c_str());
+success = PyRun_SimpleString(command.c_str());
 #endif
   }
   PyGILState_Release(gilstate);
+
+  /* PyRun_SimpleString returns 0 on success, -1 when an error occurred. */
+  assert(success == 0);
+  return (success != -1);
 }
 
 void MANTA::initializeMantaflow()
 {
   if (with_debug)
-std::cout << "Initializing  Mantaflow" << std::endl;
+std::cout << "Fluid: Initializing Mantaflow framework." << std::endl;
 
   std::string filename = "manta_scene_" + std::to_string(mCurrentID) + ".py";
   std::vector fill = std::vector();
@@ -568,18 +576,16 @@ void MANTA::initializeMantaflow()
   PyGILState_STATE gilstate = PyGILState_Ensure();
   Pb::setup(filename, fill);  // Namespace from Mantaflow (registry)
   PyGILState_Release(gilstate);
-  mantaInitialized = true;
 }
 
 void MANTA::terminateMantaflow()
 {
   if (with_debug)
-std::cout << "Terminating Mantaflow" << std::endl;
+std::cout << "Fluid: Releasing Mantaflow framework." << std::endl;
 
   PyGILState_STATE gilstate = PyGILState_Ensure();
   Pb::finalize();  // Namespace from Mantaflow (registry)
   PyGILState_Release(gilstate);
-  mantaInitialized = false;
 }
 
 static std::string getCacheFileEnding(char cache_format)
@@ -599,8 +605,8 @@ static std::string getCacheFileEnding(char cache_format)
 case FLUID_DOMAIN_FILE_OBJECT:
   return ".obj";
 default:
-  if (MANTA::with_debug)
-std::cout << "Error: Could not find file extension" << std::endl;
+  std::cerr << "Fluid Error -- Could not find file extension. Using 
default file extension."
+<< std::endl;
   return ".uni";
   }
 }
@@ -618,8 +624,7 @@ std::string MANTA::getRealValue(const std::string , 
FluidModifierData *m
   }
 
   if (!mmd) {
-if (with_debug)
-  std::cout << "Invalid modifier data in getRealValue()" << std::endl;
+std::cerr << "Fluid Error -- Invalid modifier data." << std::endl;
 ss << "ERROR - INVALID MODIFIER DATA";
 return ss.str();
   }
@@ -994,7 +999,7 @@ std::string MANTA::getRealValue(const std::string , 
FluidModifierData *m
   else if (varName == "USING_DIFFUSION")
 ss << (mmd->domain->flags & FLUID_DOMAIN_USE_DIFFUSION ? "True" : "False");
   else
-std::cout << "ERROR: Unknown option: " << varName << std::endl;
+std::cerr << "Fluid Error -- Unknown option: " << varName << std::endl;
   return ss.str();
 }
 
@@ -1034,24 +1039,27 @@ std::string MANTA::parseScript(const std::string 
_string, FluidModifierDat
   

[Bf-blender-cvs] [70b061b4fdd] master: Fluid: Refactored caching in main Mantaflow class

2020-04-03 Thread Sebastián Barschkis
Commit: 70b061b4fdd487c971b12fd0f772767387ebc8f4
Author: Sebastián Barschkis
Date:   Fri Apr 3 16:38:38 2020 +0200
Branches: master
https://developer.blender.org/rB70b061b4fdd487c971b12fd0f772767387ebc8f4

Fluid: Refactored caching in main Mantaflow class

This refactor cleans up code for the Manta file IO. It also improves the cache 
'Replay' option.

===

M   intern/mantaflow/extern/manta_fluid_API.h
M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/MANTA_main.h
M   intern/mantaflow/intern/manta_fluid_API.cpp
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesdna/DNA_fluid_types.h

===

diff --git a/intern/mantaflow/extern/manta_fluid_API.h 
b/intern/mantaflow/extern/manta_fluid_API.h
index 48d42504994..939f24fbeef 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -62,6 +62,15 @@ int manta_bake_noise(struct MANTA *fluid, struct 
FluidModifierData *mmd, int fra
 int manta_bake_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
 int manta_bake_particles(struct MANTA *fluid, struct FluidModifierData *mmd, 
int framenr);
 int manta_bake_guiding(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+int manta_has_data(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+int manta_has_noise(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+int manta_has_mesh(struct MANTA *fluid, struct FluidModifierData *mmd, int 
framenr);
+int manta_has_particles(struct MANTA *fluid, struct FluidModifierData *mmd, 
int framenr);
+int manta_has_guiding(struct MANTA *fluid,
+  struct FluidModifierData *mmd,
+  int framenr,
+  bool domain);
+
 void manta_update_variables(struct MANTA *fluid, struct FluidModifierData 
*mmd);
 int manta_get_frame(struct MANTA *fluid);
 float manta_get_timestep(struct MANTA *fluid);
diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 3555e098caf..54b728b734e 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -595,19 +595,19 @@ static std::string getCacheFileEnding(char cache_format)
 
   switch (cache_format) {
 case FLUID_DOMAIN_FILE_UNI:
-  return ".uni";
+  return FLUID_DOMAIN_EXTENSION_UNI;
 case FLUID_DOMAIN_FILE_OPENVDB:
-  return ".vdb";
+  return FLUID_DOMAIN_EXTENSION_OPENVDB;
 case FLUID_DOMAIN_FILE_RAW:
-  return ".raw";
+  return FLUID_DOMAIN_EXTENSION_RAW;
 case FLUID_DOMAIN_FILE_BIN_OBJECT:
-  return ".bobj.gz";
+  return FLUID_DOMAIN_EXTENSION_BINOBJ;
 case FLUID_DOMAIN_FILE_OBJECT:
-  return ".obj";
+  return FLUID_DOMAIN_EXTENSION_OBJ;
 default:
   std::cerr << "Fluid Error -- Could not find file extension. Using 
default file extension."
 << std::endl;
-  return ".uni";
+  return FLUID_DOMAIN_EXTENSION_UNI;
   }
 }
 
@@ -1054,38 +1054,27 @@ bool MANTA::updateFlipStructures(FluidModifierData 
*mmd, int framenr)
   int result = 0;
   int expected = 0; /* Expected number of read successes for this frame. */
 
-  // Ensure empty data structures at start
-  if (mFlipParticleData)
-mFlipParticleData->clear();
-  if (mFlipParticleVelocity)
-mFlipParticleVelocity->clear();
+  /* Ensure empty data structures at start. */
+  if (!mFlipParticleData || !mFlipParticleVelocity)
+return false;
 
-  std::ostringstream ss;
-  char cacheDir[FILE_MAX], targetFile[FILE_MAX];
-  cacheDir[0] = '\0';
-  targetFile[0] = '\0';
+  mFlipParticleData->clear();
+  mFlipParticleVelocity->clear();
 
   std::string pformat = getCacheFileEnding(mmd->domain->cache_particle_format);
-  BLI_path_join(
-  cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, 
FLUID_DOMAIN_DIR_DATA, nullptr);
+  std::string file = getFile(
+  mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_PP, pformat.c_str(), 
framenr);
 
   expected += 1;
-  ss.str("");
-  ss << "pp_" << pformat;
-  BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str());
-  BLI_path_frame(targetFile, framenr, 0);
-  if (BLI_exists(targetFile)) {
-result += updateParticlesFromFile(targetFile, false, false);
+  if (BLI_exists(file.c_str())) {
+result += updateParticlesFromFile(file, false, false);
 assert(result == expected);
   }
 
+  file = getFile(mmd, FLUID_DOMAIN_DIR_DATA, FLUID_DOMAIN_FILE_PVEL, 
pformat.c_str(), framenr);
   expected += 1;
-  ss.str("");
-  ss << "pVel_" << pformat;
-  BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str());

[Bf-blender-cvs] [b74e3886171] master: Fix T75210: Frame range does not go down to 0 in the physics tab for mantaflow when clicking the left arrow

2020-03-31 Thread Sebastián Barschkis
Commit: b74e38861714be4aa36e2e10fbce8b3b21bb8adc
Author: Sebastián Barschkis
Date:   Tue Mar 31 12:18:03 2020 +0200
Branches: master
https://developer.blender.org/rBb74e38861714be4aa36e2e10fbce8b3b21bb8adc

Fix T75210: Frame range does not go down to 0 in the physics tab for mantaflow 
when clicking the left arrow

Added nore flexibility to cache frame range and ensured validity of frame range.

===

M   source/blender/blenkernel/BKE_fluid.h
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/source/blender/blenkernel/BKE_fluid.h 
b/source/blender/blenkernel/BKE_fluid.h
index 2c5742d3dc7..e8b4c819c62 100644
--- a/source/blender/blenkernel/BKE_fluid.h
+++ b/source/blender/blenkernel/BKE_fluid.h
@@ -75,6 +75,9 @@ void BKE_fluid_particle_system_create(struct Main *bmain,
   const int psys_type);
 void BKE_fluid_particle_system_destroy(struct Object *ob, const int 
particle_type);
 
+void BKE_fluid_cache_startframe_set(struct FluidDomainSettings *settings, int 
value);
+void BKE_fluid_cache_endframe_set(struct FluidDomainSettings *settings, int 
value);
+
 void BKE_fluid_cachetype_mesh_set(struct FluidDomainSettings *settings, int 
cache_mesh_format);
 void BKE_fluid_cachetype_data_set(struct FluidDomainSettings *settings, int 
cache_data_format);
 void BKE_fluid_cachetype_particle_set(struct FluidDomainSettings *settings,
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index b095e6dbeec..8ced4a06c02 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4471,6 +4471,16 @@ void BKE_fluid_particle_system_destroy(struct Object 
*ob, const int particle_typ
  * Use for versioning, even when fluids are disabled.
  * \{ */
 
+void BKE_fluid_cache_startframe_set(FluidDomainSettings *settings, int value)
+{
+  settings->cache_frame_start = (value > settings->cache_frame_end) ? 
settings->cache_frame_end : value;
+}
+
+void BKE_fluid_cache_endframe_set(FluidDomainSettings *settings, int value)
+{
+  settings->cache_frame_end = (value < settings->cache_frame_start) ? 
settings->cache_frame_start : value;
+}
+
 void BKE_fluid_cachetype_mesh_set(FluidDomainSettings *settings, int 
cache_mesh_format)
 {
   if (cache_mesh_format == settings->cache_mesh_format) {
diff --git a/source/blender/makesrna/intern/rna_fluid.c 
b/source/blender/makesrna/intern/rna_fluid.c
index 9410906595d..e087056e850 100644
--- a/source/blender/makesrna/intern/rna_fluid.c
+++ b/source/blender/makesrna/intern/rna_fluid.c
@@ -391,6 +391,18 @@ static void rna_Fluid_combined_export_update(Main *bmain, 
Scene *scene, PointerR
   }
 }
 
+static void rna_Fluid_cache_startframe_set(struct PointerRNA *ptr, int value)
+{
+  FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
+  BKE_fluid_cache_startframe_set(settings, value);
+}
+
+static void rna_Fluid_cache_endframe_set(struct PointerRNA *ptr, int value)
+{
+  FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
+  BKE_fluid_cache_endframe_set(settings, value);
+}
+
 static void rna_Fluid_cachetype_mesh_set(struct PointerRNA *ptr, int value)
 {
   FluidDomainSettings *settings = (FluidDomainSettings *)ptr->data;
@@ -1925,12 +1937,13 @@ static void rna_def_fluid_domain_settings(BlenderRNA 
*brna)
   prop = RNA_def_property(srna, "cache_frame_start", PROP_INT, PROP_TIME);
   RNA_def_property_int_sdna(prop, NULL, "cache_frame_start");
   RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
-  RNA_def_property_ui_range(prop, 1, MAXFRAME, 1, 1);
+  RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_startframe_set", 
NULL);
   RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation 
starts");
 
   prop = RNA_def_property(srna, "cache_frame_end", PROP_INT, PROP_TIME);
   RNA_def_property_int_sdna(prop, NULL, "cache_frame_end");
-  RNA_def_property_range(prop, 1, MAXFRAME);
+  RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
+  RNA_def_property_int_funcs(prop, NULL, "rna_Fluid_cache_endframe_set", NULL);
   RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops");
 
   prop = RNA_def_property(srna, "cache_frame_pause_data", PROP_INT, PROP_TIME);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1280f3c0ae9] master: Fluid: Optimization for mesh file loading

2020-03-30 Thread Sebastián Barschkis
Commit: 1280f3c0ae9622a4ca189f22b637ba919fbb6828
Author: Sebastián Barschkis
Date:   Mon Mar 30 17:32:22 2020 +0200
Branches: master
https://developer.blender.org/rB1280f3c0ae9622a4ca189f22b637ba919fbb6828

Fluid: Optimization for mesh file loading

Improved loading times for mesh files by reading bigger chunks of data from the 
disk at once.

===

M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 2b3a282d815..bf58e22938a 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -54,6 +54,10 @@ int MANTA::with_debug(0);
 
 /* Number of particles that the cache reads at once (with zlib). */
 #define PARTICLE_CHUNK 2
+/* Number of mesh nodes that the cache reads at once (with zlib). */
+#define NODE_CHUNK 2
+/* Number of mesh triangles that the cache reads at once (with zlib). */
+#define TRIANGLE_CHUNK 2
 
 MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID)
 {
@@ -2461,29 +2465,59 @@ void MANTA::updateMeshFromBobj(const char *filename)
 std::cout << "MANTA::updateMeshFromBobj()" << std::endl;
 
   gzFile gzf;
-  float fbuffer[3];
-  int ibuffer[3];
-  int numBuffer = 0;
 
   gzf = (gzFile)BLI_gzopen(filename, "rb1");  // do some compression
   if (!gzf)
 std::cerr << "updateMeshData: unable to open file: " << filename << 
std::endl;
 
+  int numBuffer = 0;
+
   // Num vertices
   gzread(gzf, , sizeof(int));
 
   if (with_debug)
 std::cout << "read mesh , num verts: " << numBuffer << " , in file: " << 
filename << std::endl;
 
+  int numChunks = (int)(ceil((float)numBuffer / NODE_CHUNK));
+  int readLen, readStart, readEnd, readBytes, k;
+
   if (numBuffer) {
 // Vertices
+int todoVertices = numBuffer;
+float *bufferVerts = (float *)MEM_malloc_arrayN(
+NODE_CHUNK, sizeof(float) * 3, "fluid_mesh_vertices");
+
 mMeshNodes->resize(numBuffer);
-for (std::vector::iterator it = mMeshNodes->begin(); it != 
mMeshNodes->end(); ++it) {
-  gzread(gzf, fbuffer, sizeof(float) * 3);
-  it->pos[0] = fbuffer[0];
-  it->pos[1] = fbuffer[1];
-  it->pos[2] = fbuffer[2];
+
+for (int i = 0; i < numChunks && todoVertices > 0; ++i) {
+  readLen = NODE_CHUNK;
+  if (todoVertices < NODE_CHUNK) {
+readLen = todoVertices;
+  }
+
+  readBytes = gzread(gzf, bufferVerts, readLen * sizeof(float) * 3);
+  if (!readBytes) {
+if (with_debug)
+  std::cerr << "error while reading vertices" << std::endl;
+MEM_freeN(bufferVerts);
+gzclose(gzf);
+return;
+  }
+
+  readStart = (numBuffer - todoVertices);
+  CLAMP(readStart, 0, numBuffer);
+  readEnd = readStart + readLen;
+  CLAMP(readEnd, 0, numBuffer);
+
+  k = 0;
+  for (std::vector::size_type j = readStart; j < readEnd; 
j++, k += 3) {
+mMeshNodes->at(j).pos[0] = bufferVerts[k];
+mMeshNodes->at(j).pos[1] = bufferVerts[k + 1];
+mMeshNodes->at(j).pos[2] = bufferVerts[k + 2];
+  }
+  todoVertices -= readLen;
 }
+MEM_freeN(bufferVerts);
   }
 
   // Num normals
@@ -2495,14 +2529,42 @@ void MANTA::updateMeshFromBobj(const char *filename)
 
   if (numBuffer) {
 // Normals
+int todoNormals = numBuffer;
+float *bufferNormals = (float *)MEM_malloc_arrayN(
+NODE_CHUNK, sizeof(float) * 3, "fluid_mesh_normals");
+
 if (!getNumVertices())
   mMeshNodes->resize(numBuffer);
-for (std::vector::iterator it = mMeshNodes->begin(); it != 
mMeshNodes->end(); ++it) {
-  gzread(gzf, fbuffer, sizeof(float) * 3);
-  it->normal[0] = fbuffer[0];
-  it->normal[1] = fbuffer[1];
-  it->normal[2] = fbuffer[2];
+
+for (int i = 0; i < numChunks && todoNormals > 0; ++i) {
+  readLen = NODE_CHUNK;
+  if (todoNormals < NODE_CHUNK) {
+readLen = todoNormals;
+  }
+
+  readBytes = gzread(gzf, bufferNormals, readLen * sizeof(float) * 3);
+  if (!readBytes) {
+if (with_debug)
+  std::cerr << "error while reading normals" << std::endl;
+MEM_freeN(bufferNormals);
+gzclose(gzf);
+return;
+  }
+
+  readStart = (numBuffer - todoNormals);
+  CLAMP(readStart, 0, numBuffer);
+  readEnd = readStart + readLen;
+  CLAMP(readEnd, 0, numBuffer);
+
+  k = 0;
+  for (std::vector::size_type j = readStart; j < readEnd; 
j++, k += 3) {
+mMeshNodes->at(j).normal[0] = bufferNormals[k];
+mMeshNodes->at(j).normal[1] = bufferNormals[k + 1];
+

[Bf-blender-cvs] [6f15bc3b52f] master: Fluid: Removed Empty Space option for liquid domains

2020-03-30 Thread Sebastián Barschkis
Commit: 6f15bc3b52fceaeec87f0c4afd89d763d39f42df
Author: Sebastián Barschkis
Date:   Mon Mar 30 17:34:16 2020 +0200
Branches: master
https://developer.blender.org/rB6f15bc3b52fceaeec87f0c4afd89d763d39f42df

Fluid: Removed Empty Space option for liquid domains

The option only makes sense for gas domains where there is some density.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index ba9e2110817..390b5de7d37 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -194,7 +194,8 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 col.prop(domain, "gravity", text="Gravity")
 
 col = flow.column()
-col.prop(domain, "clipping", text="Empty Space")
+if PhysicButtonsPanel.poll_gas_domain(context):
+col.prop(domain, "clipping", text="Empty Space")
 col.prop(domain, "delete_in_obstacle", text="Delete In Obstacle")
 
 if domain.cache_type == 'MODULAR':

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [7d59f84708f] master: Fluid: Optimization for liquid / secondary particle file loading

2020-03-29 Thread Sebastián Barschkis
Commit: 7d59f84708fc8a5587b4155cd14162529a4c9baf
Author: Sebastián Barschkis
Date:   Sun Mar 29 21:30:55 2020 +0200
Branches: master
https://developer.blender.org/rB7d59f84708fc8a5587b4155cd14162529a4c9baf

Fluid: Optimization for liquid / secondary particle file loading

Improved loading times for particles files by reading bigger chunks of data 
from the disk at once.

===

M   intern/mantaflow/CMakeLists.txt
M   intern/mantaflow/intern/MANTA_main.cpp

===

diff --git a/intern/mantaflow/CMakeLists.txt b/intern/mantaflow/CMakeLists.txt
index 5080f2d8cac..73bcc017c83 100644
--- a/intern/mantaflow/CMakeLists.txt
+++ b/intern/mantaflow/CMakeLists.txt
@@ -50,6 +50,7 @@ set(INC_SYS
   ../../extern/mantaflow/helper/util
   ../../extern/mantaflow/helper/pwrapper
   ../../extern/mantaflow/preprocessed
+  ../guardedalloc
   ${PYTHON_INCLUDE_DIRS}
   ${ZLIB_INCLUDE_DIRS}
 )
diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index c169d242583..2b3a282d815 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -21,10 +21,10 @@
  * \ingroup mantaflow
  */
 
-#include 
 #include 
-#include 
 #include 
+#include 
+#include 
 #include 
 
 #if OPENVDB == 1
@@ -32,24 +32,29 @@
 #endif
 
 #include "MANTA_main.h"
-#include "manta.h"
 #include "Python.h"
 #include "fluid_script.h"
-#include "smoke_script.h"
 #include "liquid_script.h"
+#include "manta.h"
+#include "smoke_script.h"
 
+#include "BLI_fileops.h"
 #include "BLI_path_util.h"
 #include "BLI_utildefines.h"
-#include "BLI_fileops.h"
 
-#include "DNA_scene_types.h"
-#include "DNA_modifier_types.h"
 #include "DNA_fluid_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_scene_types.h"
+
+#include "MEM_guardedalloc.h"
 
 std::atomic MANTA::mantaInitialized(false);
 std::atomic MANTA::solverID(0);
 int MANTA::with_debug(0);
 
+/* Number of particles that the cache reads at once (with zlib). */
+#define PARTICLE_CHUNK 2
+
 MANTA::MANTA(int *res, FluidModifierData *mmd) : mCurrentID(++solverID)
 {
   if (with_debug)
@@ -1052,8 +1057,6 @@ int MANTA::updateFlipStructures(FluidModifierData *mmd, 
int framenr)
   BLI_path_join(
   cacheDir, sizeof(cacheDir), mmd->domain->cache_directory, 
FLUID_DOMAIN_DIR_DATA, nullptr);
 
-  // TODO (sebbas): Use pp_xl and pVel_xl when using upres simulation?
-
   ss << "pp_" << pformat;
   BLI_join_dirfile(targetFile, sizeof(targetFile), cacheDir, ss.str().c_str());
   BLI_path_frame(targetFile, framenr, 0);
@@ -2703,18 +2706,17 @@ void MANTA::updateParticlesFromUni(const char 
*filename, bool isSecondarySys, bo
 std::cout << "MANTA::updateParticlesFromUni()" << std::endl;
 
   gzFile gzf;
-  float fbuffer[4];
   int ibuffer[4];
 
   gzf = (gzFile)BLI_gzopen(filename, "rb1");  // do some compression
   if (!gzf)
-std::cout << "updateParticlesFromUni: unable to open file" << std::endl;
+std::cerr << "updateParticlesFromUni: unable to open file" << std::endl;
 
   char ID[5] = {0, 0, 0, 0, 0};
   gzread(gzf, ID, 4);
 
   if (!strcmp(ID, "PB01")) {
-std::cout << "particle uni file format v01 not supported anymore" << 
std::endl;
+std::cerr << "particle uni file format v01 not supported anymore" << 
std::endl;
 gzclose(gzf);
 return;
   }
@@ -2757,48 +2759,128 @@ void MANTA::updateParticlesFromUni(const char 
*filename, bool isSecondarySys, bo
   }
   if (!ibuffer[0]) {  // Any particles present?
 if (with_debug)
-  std::cout << "no particles present yet" << std::endl;
+  std::cerr << "no particles present yet" << std::endl;
 gzclose(gzf);
 return;
   }
 
   numParticles = ibuffer[0];
 
+  const int numChunks = (int)(ceil((float)numParticles / PARTICLE_CHUNK));
+  int todoParticles, readLen, k;
+  int readStart, readEnd, readBytes;
+
   // Reading base particle system file v2
   if (!strcmp(ID, "PB02")) {
-dataPointer->resize(numParticles);
 MANTA::pData *bufferPData;
-for (std::vector::iterator it = dataPointer->begin(); it != 
dataPointer->end(); ++it) {
-  gzread(gzf, fbuffer, sizeof(float) * 3 + sizeof(int));
-  bufferPData = (MANTA::pData *)fbuffer;
-  it->pos[0] = bufferPData->pos[0];
-  it->pos[1] = bufferPData->pos[1];
-  it->pos[2] = bufferPData->pos[2];
-  it->flag = bufferPData->flag;
+todoParticles = numParticles;
+bufferPData = (MANTA::pData *)MEM_malloc_arrayN(
+PARTICLE_CHUNK, s

[Bf-blender-cvs] [b023c911185] master: Fluid: Use dynamic mode whenever active rigid bodies are in the scene

2020-03-29 Thread Sebastián Barschkis
Commit: b023c911185636293e928ef998f4c9cad2c15d9c
Author: Sebastián Barschkis
Date:   Sun Mar 29 18:51:18 2020 +0200
Branches: master
https://developer.blender.org/rBb023c911185636293e928ef998f4c9cad2c15d9c

Fluid: Use dynamic mode whenever active rigid bodies are in the scene

Required for collisions with moving rigid bodies. Otherwise the static 
optimization mode will be kept and the obstacles would be calculated only once 
at the beginning.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index b8d9718920e..b095e6dbeec 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -36,6 +36,7 @@
 #include "DNA_fluid_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
+#include "DNA_rigidbody_types.h"
 
 #include "BKE_effect.h"
 #include "BKE_fluid.h"
@@ -644,6 +645,11 @@ static bool is_static_object(Object *ob)
 }
   }
 
+  /* Active rigid body objects considered to be dynamic fluid objects. */
+  if (ob->rigidbody_object && ob->rigidbody_object->type == RBO_TYPE_ACTIVE) {
+return false;
+  }
+
   /* Finally, check if the object has animation data. If so, it is considered 
dynamic. */
   return !BKE_object_moves_in_time(ob, true);
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5cf66890197] master: Fluid: Removed obstacle levelset optimization

2020-03-26 Thread Sebastián Barschkis
Commit: 5cf66890197211b2a64cb30fc6ba746360e02ae0
Author: Sebastián Barschkis
Date:   Fri Mar 27 00:16:05 2020 +0100
Branches: master
https://developer.blender.org/rB5cf66890197211b2a64cb30fc6ba746360e02ae0

Fluid: Removed obstacle levelset optimization

Currently results in unstable particle behavior and incorrect meshing.

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index e9222fc7d93..b0bf6f85914 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -190,9 +190,6 @@ def liquid_adaptive_step_$ID$(framenr):\n\
 extrapolateLsSimple(phi=phiIn_s$ID$, distance=3)\n\
 phi_s$ID$.join(phiIn_s$ID$)\n\
 \n\
-if using_obstacle_s$ID$:\n\
-phi_s$ID$.subtract(o=phiObsIn_s$ID$, flags=flags_s$ID$, 
subtractType=FlagObstacle)\n\
-\n\
 if using_outflow_s$ID$:\n\
 phiOut_s$ID$.join(phiOutIn_s$ID$)\n\
 \n\
@@ -200,6 +197,10 @@ def liquid_adaptive_step_$ID$(framenr):\n\
 updateFractions(flags=flags_s$ID$, phiObs=phiObs_s$ID$, 
fractions=fractions_s$ID$, boundaryWidth=boundaryWidth_s$ID$, 
fracThreshold=fracThreshold_s$ID$)\n\
 setObstacleFlags(flags=flags_s$ID$, phiObs=phiObs_s$ID$, 
phiOut=phiOut_s$ID$, fractions=fractions_s$ID$, phiIn=phiIn_s$ID$)\n\
 \n\
+if using_obstacle_s$ID$:\n\
+# TODO (sebbas): Enable flags check again, currently produces unstable 
particle behavior\n\
+phi_s$ID$.subtract(o=phiObsIn_s$ID$) #, flags=flags_s$ID$, 
subtractType=FlagObstacle)\n\
+\n\
 # add initial velocity: set invel as source grid to ensure const vels in 
inflow region, sampling makes use of this\n\
 if using_invel_s$ID$:\n\
 extrapolateVec3Simple(vel=invelC_s$ID$, phi=phiIn_s$ID$, distance=6, 
inside=True)\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [04ab6777616] master: Fluid: Small fix for secondary particles

2020-03-25 Thread Sebastián Barschkis
Commit: 04ab677761649312354c4257753520f5df575e81
Author: Sebastián Barschkis
Date:   Wed Mar 25 13:46:47 2020 +0100
Branches: master
https://developer.blender.org/rB04ab677761649312354c4257753520f5df575e81

Fluid: Small fix for secondary particles

Small tweak to ensure index will not run out of bounds during secondary 
particle computation.

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index 9321cc15466..e9222fc7d93 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -361,7 +361,8 @@ def liquid_step_particles_$ID$():\n\
 interpolateGrid(target=phi_sp$ID$, source=phiTmp_s$ID$)\n\
 interpolateGrid(target=phiOut_sp$ID$, source=phiOut_s$ID$)\n\
 \n\
-setObstacleFlags(flags=flags_sp$ID$, phiObs=phiObs_sp$ID$, phiOut=None, 
phiIn=None) # phiIn not needed\n\
+# phiIn not needed, bwidth to 0 because we are omitting 
flags.initDomain()\n\
+setObstacleFlags(flags=flags_sp$ID$, phiObs=phiObs_sp$ID$, phiOut=None, 
phiIn=None, boundaryWidth=0)\n\
 flags_sp$ID$.updateFromLevelset(levelset=phi_sp$ID$)\n\
 \n\
 # Actual secondary particle simulation\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [cda81d5a4d3] master: Fluid: Enforce minimum thickness to planar flow / effector objects

2020-03-23 Thread Sebastián Barschkis
Commit: cda81d5a4d391a8a7b298eb1b6f2fdf1a0ed838a
Author: Sebastián Barschkis
Date:   Mon Mar 23 23:50:25 2020 +0100
Branches: master
https://developer.blender.org/rBcda81d5a4d391a8a7b298eb1b6f2fdf1a0ed838a

Fluid: Enforce minimum thickness to planar flow / effector objects

Planar object now have a thickness by default. This should make it more 
intuitive for users as there is no need to specify an object thickness.

===

M   intern/mantaflow/intern/strings/liquid_script.h
M   release/scripts/startup/bl_ui/properties_physics_fluid.py
M   source/blender/blenkernel/intern/fluid.c
M   source/blender/makesrna/intern/rna_fluid.c

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index 297c2a8ed6b..9321cc15466 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -361,7 +361,6 @@ def liquid_step_particles_$ID$():\n\
 interpolateGrid(target=phi_sp$ID$, source=phiTmp_s$ID$)\n\
 interpolateGrid(target=phiOut_sp$ID$, source=phiOut_s$ID$)\n\
 \n\
-flags_sp$ID$.initDomain(boundaryWidth=1 if using_fractions_s$ID$ else 0, 
phiWalls=phiObs_sp$ID$, outflow=boundConditions_s$ID$)\n\
 setObstacleFlags(flags=flags_sp$ID$, phiObs=phiObs_sp$ID$, phiOut=None, 
phiIn=None) # phiIn not needed\n\
 flags_sp$ID$.updateFromLevelset(levelset=phi_sp$ID$)\n\
 \n\
diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 8d8070bad7a..b5a19bdc8ca 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -194,6 +194,7 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 
 col = flow.column()
 col.prop(domain, "clipping", text="Empty Space")
+col.prop(domain, "delete_in_obstacle", text="Delete In Obstacle")
 
 if domain.cache_type == 'MODULAR':
 col.separator()
@@ -272,7 +273,6 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 
 col.prop(effector_settings, "use_effector", text="Use Effector")
 col.prop(effector_settings, "use_plane_init", text="Is Planar")
-col.prop(effector_settings, "delete_in_obstacle", text="Delete In 
Obstacle")
 
 if effector_settings.effector_type == 'GUIDE':
 col.prop(effector_settings, "velocity_factor", text="Velocity 
Factor")
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 58a1ae28d42..ae51c997a08 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -571,7 +571,7 @@ static void update_distances(int index,
  BVHTreeFromMesh *tree_data,
  const float ray_start[3],
  float surface_thickness,
- int use_plane_init);
+ bool use_plane_init);
 
 static int get_light(ViewLayer *view_layer, float *light)
 {
@@ -1717,16 +1717,25 @@ static void update_distances(int index,
  BVHTreeFromMesh *tree_data,
  const float ray_start[3],
  float surface_thickness,
- int use_plane_init)
+ bool use_plane_init)
 {
   float min_dist = PHI_MAX;
 
-  /* a) Planar initialization */
+  /* Planar initialization: Find nearest cells around mesh. */
   if (use_plane_init) {
 BVHTreeNearest nearest = {0};
 nearest.index = -1;
-nearest.dist_sq = surface_thickness *
-  surface_thickness; /* find_nearest uses squared distance 
*/
+/* Distance between two opposing vertices in a unit cube.
+ * I.e. the unit cube diagonal or sqrt(3).
+ * This value is our nearest neighbor search distance. */
+const float surface_distance = 1.732;
+nearest.dist_sq = surface_distance *
+  surface_distance; /* find_nearest uses squared distance. 
*/
+
+/* Subtract optional surface thickness value and virtually increase the 
object size. */
+if (surface_thickness) {
+  nearest.dist_sq += surface_thickness;
+}
 
 if (BLI_bvhtree_find_nearest(
 tree_data->tree, ray_start, , tree_data->nearest_callback, 
tree_data) != -1) {
@@ -1734,77 +1743,74 @@ static void update_distances(int index,
   sub_v3_v3v3(ray, ray_start, nearest.co);
   min_dist = len_v3(ray);
   min_dist = (-1.0f) * fabsf(min_dist);
-  distance_map[index] = min_dist;
 }
-return;
 

[Bf-blender-cvs] [e9629e3cfda] master: Fluid: Use different phi for levelset generation

2020-03-23 Thread Sebastián Barschkis
Commit: e9629e3cfdaf995bd76249595c5c2b7d81432e76
Author: Sebastián Barschkis
Date:   Mon Mar 23 23:44:37 2020 +0100
Branches: master
https://developer.blender.org/rBe9629e3cfdaf995bd76249595c5c2b7d81432e76

Fluid: Use different phi for levelset generation

Phi that is used for mesh should be the one that matches particles best.

===

M   intern/mantaflow/intern/strings/liquid_script.h

===

diff --git a/intern/mantaflow/intern/strings/liquid_script.h 
b/intern/mantaflow/intern/strings/liquid_script.h
index 2376d49aace..297c2a8ed6b 100644
--- a/intern/mantaflow/intern/strings/liquid_script.h
+++ b/intern/mantaflow/intern/strings/liquid_script.h
@@ -310,11 +310,11 @@ def liquid_step_mesh_$ID$():\n\
 \n\
 # no upres: just use the loaded grids\n\
 if upres_sm$ID$ <= 1:\n\
-phi_sm$ID$.copyFrom(phiTmp_s$ID$)\n\
+phi_sm$ID$.copyFrom(phi_s$ID$)\n\
 \n\
 # with upres: recreate grids\n\
 else:\n\
-interpolateGrid(target=phi_sm$ID$, source=phiTmp_s$ID$)\n\
+interpolateGrid(target=phi_sm$ID$, source=phi_s$ID$)\n\
 \n\
 # create surface\n\
 pp_sm$ID$.readParticles(pp_s$ID$)\n\

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0c571db4add] master: Fix T73988: Mantaflow fluid simulation - Particles for Spray, Foam and Bubbles are one frame ahead of Mesh

2020-03-22 Thread Sebastián Barschkis
Commit: 0c571db4add35ae78089cd8e88fa6f7a9125b123
Author: Sebastián Barschkis
Date:   Sun Mar 22 21:46:30 2020 +0100
Branches: master
https://developer.blender.org/rB0c571db4add35ae78089cd8e88fa6f7a9125b123

Fix T73988: Mantaflow fluid simulation - Particles for Spray, Foam and Bubbles 
are one frame ahead of Mesh

Fixes an issue with secondary particles being out of sync with the main 
simulation. Cleaned up the secondary particle code in general too (making sure 
that all solver attributes - timestep, framelength, etc. - are set correctly).

===

M   intern/mantaflow/intern/MANTA_main.cpp
M   intern/mantaflow/intern/strings/fluid_script.h
M   intern/mantaflow/intern/strings/liquid_script.h
M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/intern/mantaflow/intern/MANTA_main.cpp 
b/intern/mantaflow/intern/MANTA_main.cpp
index 5d35de7898f..c169d242583 100644
--- a/intern/mantaflow/intern/MANTA_main.cpp
+++ b/intern/mantaflow/intern/MANTA_main.cpp
@@ -837,6 +837,8 @@ std::string MANTA::getRealValue(const std::string , 
FluidModifierData *m
 ss << mmd->domain->flame_smoke_color[2];
   else if (varName == "CURRENT_FRAME")
 ss << mmd->time;
+  else if (varName == "START_FRAME")
+ss << mmd->domain->cache_frame_start;
   else if (varName == "END_FRAME")
 ss << mmd->domain->cache_frame_end;
   else if (varName == "CACHE_DATA_FORMAT")
diff --git a/intern/mantaflow/intern/strings/fluid_script.h 
b/intern/mantaflow/intern/strings/fluid_script.h
index c442dd56c09..0aad0546aea 100644
--- a/intern/mantaflow/intern/strings/fluid_script.h
+++ b/intern/mantaflow/intern/strings/fluid_script.h
@@ -123,6 +123,11 @@ cflCond_s$ID$  = $CFL$\n\
 timestepsMin_s$ID$ = $TIMESTEPS_MIN$\n\
 timestepsMax_s$ID$ = $TIMESTEPS_MAX$\n\
 \n\
+# Start and stop for simulation\n\
+current_frame_s$ID$ = $CURRENT_FRAME$\n\
+start_frame_s$ID$   = $START_FRAME$\n\
+end_frame_s$ID$ = $END_FRAME$\n\
+\n\
 # Fluid diffusion / viscosity\n\
 domainSize_s$ID$ = $FLUID_DOMAIN_SIZE$ # longest domain side in meters\n\
 viscosity_s$ID$ = $FLUID_VISCOSITY$ / (domainSize_s$ID$*domainSize_s$ID$) # 
kinematic viscosity in m^2/s\n\
@@ -208,6 +213,8 @@ def fluid_adapt_time_step_$ID$():\n\
 # time params are animatable\n\
 s$ID$.frameLength = frameLength_s$ID$\n\
 s$ID$.cfl = cflCond_s$ID$\n\
+s$ID$.timestepMin  = s$ID$.frameLength / max(1, timestepsMax_s$ID$)\n\
+s$ID$.timestepMax  = s$ID$.frameLength / max(1, timestepsMin_s$ID$)\n\
 \n\
 # ensure that vel grid is full (remember: adaptive domain can reallocate 
solver)\n\
 copyRealToVec3(sourceX=x_vel_s$ID$, sourceY=y_vel_s$ID$, 
sourceZ=z_vel_s$ID$, target=vel_s$ID$)\n\
@@ -225,7 +232,7 @@ const std::string fluid_alloc =
 mantaMsg('Fluid alloc data')\n\
 flags_s$ID$   = s$ID$.create(FlagGrid)\n\
 vel_s$ID$ = s$ID$.create(MACGrid)\n\
-velC_s$ID$= s$ID$.create(MACGrid)\n\
+velTmp_s$ID$  = s$ID$.create(MACGrid)\n\
 x_vel_s$ID$   = s$ID$.create(RealGrid)\n\
 y_vel_s$ID$   = s$ID$.create(RealGrid)\n\
 z_vel_s$ID$   = s$ID$.create(RealGrid)\n\
@@ -247,7 +254,7 @@ phiIn_s$ID$.setConst()\n\
 phiOut_s$ID$.setConst()\n\
 \n\
 # Keep track of important objects in dict to load them later on\n\
-fluid_data_dict_final_s$ID$  = dict(vel=vel_s$ID$)\n\
+fluid_data_dict_final_s$ID$  = dict(vel=vel_s$ID$, velTmp=velTmp_s$ID$)\n\
 fluid_data_dict_resume_s$ID$ = dict(phiObs=phiObs_s$ID$, phiIn=phiIn_s$ID$, 
phiOut=phiOut_s$ID$, flags=flags_s$ID$)\n";
 
 const std::string fluid_alloc_obstacle =
@@ -493,7 +500,8 @@ def bake_fluid_process_data_$ID$(framenr, format_data, 
format_particles, format_
 mantaMsg('Bake fluid data')\n\
 \n\
 s$ID$.frame = framenr\n\
-# Must not set 'timeTotal' here. Remember, this function is called from 
manta.c while-loop\n\
+s$ID$.frameLength = frameLength_s$ID$\n\
+s$ID$.timeTotal = timeTotal_s$ID$\n\
 \n\
 start_time = time.time()\n\
 if using_smoke_s$ID$:\n\
@@ -514,9 +522,9 @@ def bake_noise_process_$ID$(framenr, format_data, 
format_noise, path_data, path_
 mantaMsg('Bake fluid noise')\n\
 \n\
 sn$ID$.frame = framenr\n\
-sn$ID$.timeTotal = (framenr-1) * frameLength_s$ID$\n\
-sn$ID$.timestep  = dt0_s$ID$\n\
-mantaMsg('sn$ID$.timeTotal: ' + str(sn$ID$.timeTotal))\n\
+sn$ID$.frameLength = frameLength_s$ID$\n\
+sn$ID$.timeTotal = abs(framenr - start_frame_s$ID$) * frameLength_s$ID$\n\
+sn$ID$.timestep = frameLength_s$ID$ # no adaptive timestep for noise\n\
 \n\
 smoke_step_noise_$ID$(framenr)\n\
 smoke_save_noise_$ID$(path_noise, framenr, format_noise, resumable)\n\
@@ -533,8 +541,9 @@ def bake_mesh_process_$ID$(framenr, format_data, 
format_mesh, format_particles,
 ma

[Bf-blender-cvs] [3bab9b48687] master: Fix T74154: Mantaflow crash: Baking data for domain type fluid on a plane.

2020-03-20 Thread Sebastián Barschkis
Commit: 3bab9b486876ea3d44889e8b6c72cc70aced446f
Author: Sebastián Barschkis
Date:   Fri Mar 20 10:42:43 2020 +0100
Branches: master
https://developer.blender.org/rB3bab9b486876ea3d44889e8b6c72cc70aced446f

Fix T74154: Mantaflow crash: Baking data for domain type fluid on a plane.

Added sanity check to prevent bakes from being triggered when there is no fluid 
object present.

===

M   source/blender/blenkernel/BKE_fluid.h
M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/BKE_fluid.h 
b/source/blender/blenkernel/BKE_fluid.h
index 08bc20c60b5..2c5742d3dc7 100644
--- a/source/blender/blenkernel/BKE_fluid.h
+++ b/source/blender/blenkernel/BKE_fluid.h
@@ -52,7 +52,7 @@ void BKE_fluid_modifier_copy(const struct FluidModifierData 
*mmd,
  struct FluidModifierData *tmmd,
  const int flag);
 
-void BKE_fluid_reallocate_fluid(struct FluidDomainSettings *mds, int res[3], 
int free_old);
+bool BKE_fluid_reallocate_fluid(struct FluidDomainSettings *mds, int res[3], 
int free_old);
 void BKE_fluid_reallocate_copy_fluid(struct FluidDomainSettings *mds,
  int o_res[3],
  int n_res[3],
diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 89e0c7a4bf0..15f3fdf6a40 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -110,21 +110,23 @@ struct Scene;
 #  define ADD_IF_LOWER_NEG(a, b) (max_ff((a) + (b), min_ff((a), (b
 #  define ADD_IF_LOWER(a, b) (((b) > 0) ? ADD_IF_LOWER_POS((a), (b)) : 
ADD_IF_LOWER_NEG((a), (b)))
 
-void BKE_fluid_reallocate_fluid(FluidDomainSettings *mds, int res[3], int 
free_old)
+bool BKE_fluid_reallocate_fluid(FluidDomainSettings *mds, int res[3], int 
free_old)
 {
   if (free_old && mds->fluid) {
 manta_free(mds->fluid);
   }
   if (!min_iii(res[0], res[1], res[2])) {
 mds->fluid = NULL;
-return;
   }
+  else {
+mds->fluid = manta_init(res, mds->mmd);
 
-  mds->fluid = manta_init(res, mds->mmd);
+mds->res_noise[0] = res[0] * mds->noise_scale;
+mds->res_noise[1] = res[1] * mds->noise_scale;
+mds->res_noise[2] = res[2] * mds->noise_scale;
+  }
 
-  mds->res_noise[0] = res[0] * mds->noise_scale;
-  mds->res_noise[1] = res[1] * mds->noise_scale;
-  mds->res_noise[2] = res[2] * mds->noise_scale;
+  return (mds->fluid != NULL);
 }
 
 void BKE_fluid_reallocate_copy_fluid(FluidDomainSettings *mds,
@@ -538,12 +540,10 @@ static bool BKE_fluid_modifier_init(
 mds->time_per_frame = 0;
 mds->time_total = (scene_framenr - 1) * mds->frame_length;
 
-/* Allocate fluid. */
-BKE_fluid_reallocate_fluid(mds, mds->res, 0);
-
 mmd->time = scene_framenr;
 
-return true;
+/* Allocate fluid. */
+return BKE_fluid_reallocate_fluid(mds, mds->res, 0);
   }
   else if (mmd->type & MOD_FLUID_TYPE_FLOW) {
 if (!mmd->flow) {
@@ -3705,8 +3705,13 @@ static void 
BKE_fluid_modifier_processDomain(FluidModifierData *mmd,
* or if timeline gets reset to startframe */
   if (!mds->fluid) {
 BKE_fluid_modifier_reset_ex(mmd, false);
-BKE_fluid_modifier_init(mmd, depsgraph, ob, scene, me);
+
+/* Fluid domain init must not fail in order to continue modifier 
evaluation. */
+if (!BKE_fluid_modifier_init(mmd, depsgraph, ob, scene, me)) {
+  return;
+}
   }
+  BLI_assert(mds->fluid);
 
   /* Guiding parent res pointer needs initialization */
   guide_parent = mds->guide_parent;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [91c1759956d] master: Fluid: Cleaned up some parts of the fluid modifier UI

2020-03-19 Thread Sebastián Barschkis
Commit: 91c1759956d235c252e6f6220929b52de1a7da4b
Author: Sebastián Barschkis
Date:   Thu Mar 19 13:15:25 2020 +0100
Branches: master
https://developer.blender.org/rB91c1759956d235c252e6f6220929b52de1a7da4b

Fluid: Cleaned up some parts of the fluid modifier UI

Especially when expanding the UI panel horizontally, there were some problems 
with empty space.

===

M   release/scripts/startup/bl_ui/properties_physics_fluid.py

===

diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py 
b/release/scripts/startup/bl_ui/properties_physics_fluid.py
index 65992a4e4e9..8d8070bad7a 100644
--- a/release/scripts/startup/bl_ui/properties_physics_fluid.py
+++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py
@@ -173,7 +173,6 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 col = flow.column()
 col.enabled = not domain.has_cache_baked_guide
 col.prop(domain, "resolution_max", text="Resolution Divisions")
-col = flow.column()
 col.prop(domain, "time_scale", text="Time Scale")
 col.prop(domain, "cfl_condition", text="CFL Number")
 
@@ -192,6 +191,8 @@ class PHYSICS_PT_settings(PhysicButtonsPanel, Panel):
 sub.prop(domain, "gravity", text="Using Scene Gravity", 
icon='SCENE_DATA')
 else:
 col.prop(domain, "gravity", text="Gravity")
+
+col = flow.column()
 col.prop(domain, "clipping", text="Empty Space")
 
 if domain.cache_type == 'MODULAR':
@@ -421,14 +422,16 @@ class PHYSICS_PT_fire(PhysicButtonsPanel, Panel):
 
 col = flow.column()
 col.prop(domain, "burning_rate", text="Reaction Speed")
-col = flow.column(align=True)
-col.prop(domain, "flame_smoke", text="Flame Smoke")
-col.prop(domain, "flame_vorticity", text="Vorticity")
+row = col.row()
+sub = row.column(align=True)
+sub.prop(domain, "flame_smoke", text="Flame Smoke")
+sub.prop(domain, "flame_vorticity", text="Vorticity")
+
 col = flow.column(align=True)
 col.prop(domain, "flame_max_temp", text="Temperature Maximum")
 col.prop(domain, "flame_ignition", text="Minimum")
-col = flow.column()
-col.prop(domain, "flame_smoke_color", text="Flame Color")
+row = col.row()
+row.prop(domain, "flame_smoke_color", text="Flame Color")
 
 
 class PHYSICS_PT_liquid(PhysicButtonsPanel, Panel):
@@ -468,21 +471,23 @@ class PHYSICS_PT_liquid(PhysicButtonsPanel, Panel):
 col = flow.column()
 col.prop(domain, "simulation_method", expand=False)
 col.prop(domain, "flip_ratio", text="FLIP Ratio")
-col.prop(domain, "particle_radius", text="Particle Radius")
+row = col.row()
+sub = row.column(align=True)
+sub.prop(domain, "particle_radius", text="Particle Radius")
+sub.prop(domain, "particle_number", text="Sampling")
+sub.prop(domain, "particle_randomness", text="Randomness")
 
 col = flow.column()
-col.prop(domain, "particle_max", text="Particles Maximum")
-col.prop(domain, "particle_min", text="Minimum")
-
-col = flow.column()
-col.prop(domain, "particle_number", text="Particle Sampling")
+row = col.row()
+sub = row.column(align=True)
+sub.prop(domain, "particle_max", text="Particles Maximum")
+sub.prop(domain, "particle_min", text="Minimum")
 col.prop(domain, "particle_band_width", text="Narrow Band Width")
-col.prop(domain, "particle_randomness", text="Particle Randomness")
-
-col = flow.column()
-col.prop(domain, "use_fractions", text="Fractional Obstacles")
-col.active = domain.use_fractions
-col.prop(domain, "fractions_threshold", text="Obstacle-Fluid 
Threshold")
+row = col.row()
+sub = row.column(align=True)
+sub.prop(domain, "use_fractions", text="Fractional Obstacles")
+sub.active = domain.use_fractions
+sub.prop(domain, "fractions_threshold", text="Obstacle-Fluid 
Threshold")
 
 
 class PHYSICS_PT_flow_source(PhysicButtonsPanel, Panel):
@@ -1123,35 +1128,37 @@ class PHYSICS_PT_cache(PhysicButtonsP

[Bf-blender-cvs] [c8b4b4c0fa3] master: Fluid: Fixed issue with intial velocities in liquid domains

2020-03-18 Thread Sebastián Barschkis
Commit: c8b4b4c0fa3b1255a79b90393ee9f5ddb2ec35e9
Author: Sebastián Barschkis
Date:   Thu Mar 19 00:03:47 2020 +0100
Branches: master
https://developer.blender.org/rBc8b4b4c0fa3b1255a79b90393ee9f5ddb2ec35e9

Fluid: Fixed issue with intial velocities in liquid domains

The fix for T74762 (bf9c4af9bb74) introduced this issue. Initial velocities 
were not applied to liquids anymore.

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index dc872b933eb..edb3bc2cd4d 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1834,7 +1834,6 @@ static void sample_mesh(FluidFlowSettings *mfs,
   BVHTreeNearest nearest = {0};
 
   float volume_factor = 0.0f;
-  float emission_strength = 0.0f;
 
   hit.index = -1;
   hit.dist = PHI_MAX;
@@ -1849,6 +1848,10 @@ static void sample_mesh(FluidFlowSettings *mfs,
   bool is_gas_flow = (mfs->type == FLUID_FLOW_TYPE_SMOKE || mfs->type == 
FLUID_FLOW_TYPE_FIRE ||
   mfs->type == FLUID_FLOW_TYPE_SMOKEFIRE);
 
+  /* Emission strength for gases will be computed below.
+   * For liquids it's not needed. Just set to non zero value to allow initial 
velocity computation */
+  float emission_strength = (is_gas_flow) ? 0.0f : 1.0f;
+
   /* Emission inside the flow object. */
   if (is_gas_flow && mfs->volume_density) {
 if (BLI_bvhtree_ray_cast(tree_data->tree,

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [bf9c4af9bb7] master: Fix T74762: Mantaflow: Non emmiting flow source affects simulation

2020-03-17 Thread Sebastián Barschkis
Commit: bf9c4af9bb7436468eaa4fc954ab06c7369738d2
Author: Sebastián Barschkis
Date:   Tue Mar 17 18:20:08 2020 +0100
Branches: master
https://developer.blender.org/rBbf9c4af9bb7436468eaa4fc954ab06c7369738d2

Fix T74762: Mantaflow: Non emmiting flow source affects simulation

===

M   source/blender/blenkernel/intern/fluid.c

===

diff --git a/source/blender/blenkernel/intern/fluid.c 
b/source/blender/blenkernel/intern/fluid.c
index 797e03e015a..dc872b933eb 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1894,40 +1894,6 @@ static void sample_mesh(FluidFlowSettings *mfs,
 v3 = mloop[mlooptri[f_index].tri[2]].v;
 interp_weights_tri_v3(weights, mvert[v1].co, mvert[v2].co, mvert[v3].co, 
nearest.co);
 
-/* Initial velocity of flow object. */
-if (mfs->flags & FLUID_FLOW_INITVELOCITY && velocity_map) {
-  /* Apply normal directional velocity. */
-  if (mfs->vel_normal) {
-/* Interpolate vertex normal vectors to get nearest point normal. */
-normal_short_to_float_v3(n1, mvert[v1].no);
-normal_short_to_float_v3(n2, mvert[v2].no);
-normal_short_to_float_v3(n3, mvert[v3].no);
-interp_v3_v3v3v3(hit_normal, n1, n2, n3, weights);
-normalize_v3(hit_normal);
-
-/* Apply normal directional velocity. */
-velocity_map[index * 3] += hit_normal[0] * mfs->vel_normal * 0.25f;
-velocity_map[index * 3 + 1] += hit_normal[1] * mfs->vel_normal * 0.25f;
-velocity_map[index * 3 + 2] += hit_normal[2] * mfs->vel_normal * 0.25f;
-  }
-  /* Apply object velocity. */
-  if (has_velocity && mfs->vel_multi) {
-float hit_vel[3];
-interp_v3_v3v3v3(
-hit_vel, _vel[v1 * 3], _vel[v2 * 3], _vel[v3 * 3], 
weights);
-velocity_map[index * 3] += hit_vel[0] * mfs->vel_multi;
-velocity_map[index * 3 + 1] += hit_vel[1] * mfs->vel_multi;
-velocity_map[index * 3 + 2] += hit_vel[2] * mfs->vel_multi;
-#  ifdef DEBUG_PRINT
-/* Debugging: Print flow object velocities. */
-printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], 
hit_vel[1], hit_vel[2]);
-#  endif
-  }
-  velocity_map[index * 3] += mfs->vel_coord[0];
-  velocity_map[index * 3 + 1] += mfs->vel_coord[1];
-  velocity_map[index * 3 + 2] += mfs->vel_coord[2];
-}
-
 /* Compute emission strength for smoke flow. */
 if (is_gas_flow) {
   /* Emission from surface is based on UI configurable distance value. */
@@ -1977,6 +1943,40 @@ static void sample_mesh(FluidFlowSettings *mfs,
 emission_strength *= texres.tin;
   }
 }
+
+/* Initial velocity of flow object. Only compute velocity if emission is 
present. */
+if (mfs->flags & FLUID_FLOW_INITVELOCITY && velocity_map && 
emission_strength != 0.0) {
+  /* Apply normal directional velocity. */
+  if (mfs->vel_normal) {
+/* Interpolate vertex normal vectors to get nearest point normal. */
+normal_short_to_float_v3(n1, mvert[v1].no);
+normal_short_to_float_v3(n2, mvert[v2].no);
+normal_short_to_float_v3(n3, mvert[v3].no);
+interp_v3_v3v3v3(hit_normal, n1, n2, n3, weights);
+normalize_v3(hit_normal);
+
+/* Apply normal directional velocity. */
+velocity_map[index * 3] += hit_normal[0] * mfs->vel_normal * 0.25f;
+velocity_map[index * 3 + 1] += hit_normal[1] * mfs->vel_normal * 0.25f;
+velocity_map[index * 3 + 2] += hit_normal[2] * mfs->vel_normal * 0.25f;
+  }
+  /* Apply object velocity. */
+  if (has_velocity && mfs->vel_multi) {
+float hit_vel[3];
+interp_v3_v3v3v3(
+hit_vel, _vel[v1 * 3], _vel[v2 * 3], _vel[v3 * 3], 
weights);
+velocity_map[index * 3] += hit_vel[0] * mfs->vel_multi;
+velocity_map[index * 3 + 1] += hit_vel[1] * mfs->vel_multi;
+velocity_map[index * 3 + 2] += hit_vel[2] * mfs->vel_multi;
+#  ifdef DEBUG_PRINT
+/* Debugging: Print flow object velocities. */
+printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], 
hit_vel[1], hit_vel[2]);
+#  endif
+  }
+  velocity_map[index * 3] += mfs->vel_coord[0];
+  velocity_map[index * 3 + 1] += mfs->vel_coord[1];
+  velocity_map[index * 3 + 2] += mfs->vel_coord[2];
+}
   }
 
   /* Apply final influence value but also consider volume initialization 
factor. */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


  1   2   3   4   5   6   7   8   9   10   >