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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSebastián Barschkis <sebbas@sebbas.org>2020-07-20 19:35:29 +0300
committerSebastián Barschkis <sebbas@sebbas.org>2020-07-20 19:35:52 +0300
commit62a819202e79ed41651a1e3d9b686a6363ef20cb (patch)
treead76c69c788833d1bd87c392ddad9e11ad579c76 /intern
parent7d85495ab9e0b27180ed06e14a19dd7640262bbc (diff)
Fluid: Refactored smoke noise system
This refactor is in response to reports in which the adaptive domain with noise caused a crash (e.g. T79009). It should also fix issues where the smoke appeared to be cut off when using the adaptive domain together with noise. It is also possible that some of these changes improve the lines issue from T74559.
Diffstat (limited to 'intern')
-rw-r--r--intern/mantaflow/extern/manta_fluid_API.h68
-rw-r--r--intern/mantaflow/intern/manta_fluid_API.cpp136
-rw-r--r--intern/mantaflow/intern/strings/smoke_script.h6
3 files changed, 65 insertions, 145 deletions
diff --git a/intern/mantaflow/extern/manta_fluid_API.h b/intern/mantaflow/extern/manta_fluid_API.h
index 1dbfc6bdd9c..3da1d8f53f0 100644
--- a/intern/mantaflow/extern/manta_fluid_API.h
+++ b/intern/mantaflow/extern/manta_fluid_API.h
@@ -111,46 +111,16 @@ float *manta_get_phioutstatic_in(struct MANTA *fluid);
/* Smoke functions */
void manta_smoke_export_script(struct MANTA *smoke, struct FluidModifierData *fmd);
-void manta_smoke_export(struct MANTA *smoke,
- float *dt,
- float *dx,
- float **dens,
- float **react,
- float **flame,
- float **fuel,
- float **heat,
- float **vx,
- float **vy,
- float **vz,
- float **r,
- float **g,
- float **b,
- int **flags,
- float **shadow);
-void manta_smoke_turbulence_export(struct MANTA *smoke,
- float **dens,
- float **react,
- float **flame,
- float **fuel,
- float **r,
- float **g,
- float **b,
- float **tcu,
- float **tcv,
- float **tcw,
- float **tcu2,
- float **tcv2,
- float **tcw2);
void manta_smoke_get_rgba(struct MANTA *smoke, float *data, int sequential);
-void manta_smoke_turbulence_get_rgba(struct MANTA *smoke, float *data, int sequential);
+void manta_noise_get_rgba(struct MANTA *smoke, float *data, int sequential);
void manta_smoke_get_rgba_fixed_color(struct MANTA *smoke,
float color[3],
float *data,
int sequential);
-void manta_smoke_turbulence_get_rgba_fixed_color(struct MANTA *smoke,
- float color[3],
- float *data,
- int sequential);
+void manta_noise_get_rgba_fixed_color(struct MANTA *smoke,
+ float color[3],
+ float *data,
+ int sequential);
void manta_smoke_ensure_heat(struct MANTA *smoke, struct FluidModifierData *fmd);
void manta_smoke_ensure_fire(struct MANTA *smoke, struct FluidModifierData *fmd);
void manta_smoke_ensure_colors(struct MANTA *smoke, struct FluidModifierData *fmd);
@@ -177,17 +147,23 @@ float *manta_smoke_get_emission_in(struct MANTA *smoke);
int manta_smoke_has_heat(struct MANTA *smoke);
int manta_smoke_has_fuel(struct MANTA *smoke);
int manta_smoke_has_colors(struct MANTA *smoke);
-float *manta_smoke_turbulence_get_density(struct MANTA *smoke);
-float *manta_smoke_turbulence_get_fuel(struct MANTA *smoke);
-float *manta_smoke_turbulence_get_react(struct MANTA *smoke);
-float *manta_smoke_turbulence_get_color_r(struct MANTA *smoke);
-float *manta_smoke_turbulence_get_color_g(struct MANTA *smoke);
-float *manta_smoke_turbulence_get_color_b(struct MANTA *smoke);
-float *manta_smoke_turbulence_get_flame(struct MANTA *smoke);
-int manta_smoke_turbulence_has_fuel(struct MANTA *smoke);
-int manta_smoke_turbulence_has_colors(struct MANTA *smoke);
-void manta_smoke_turbulence_get_res(struct MANTA *smoke, int *res);
-int manta_smoke_turbulence_get_cells(struct MANTA *smoke);
+float *manta_noise_get_density(struct MANTA *smoke);
+float *manta_noise_get_fuel(struct MANTA *smoke);
+float *manta_noise_get_react(struct MANTA *smoke);
+float *manta_noise_get_color_r(struct MANTA *smoke);
+float *manta_noise_get_color_g(struct MANTA *smoke);
+float *manta_noise_get_color_b(struct MANTA *smoke);
+float *manta_noise_get_texture_u(struct MANTA *smoke);
+float *manta_noise_get_texture_v(struct MANTA *smoke);
+float *manta_noise_get_texture_w(struct MANTA *smoke);
+float *manta_noise_get_texture_u2(struct MANTA *smoke);
+float *manta_noise_get_texture_v2(struct MANTA *smoke);
+float *manta_noise_get_texture_w2(struct MANTA *smoke);
+float *manta_noise_get_flame(struct MANTA *smoke);
+int manta_noise_has_fuel(struct MANTA *smoke);
+int manta_noise_has_colors(struct MANTA *smoke);
+void manta_noise_get_res(struct MANTA *smoke, int *res);
+int manta_noise_get_cells(struct MANTA *smoke);
/* Liquid functions */
void manta_liquid_export_script(struct MANTA *smoke, struct FluidModifierData *fmd);
diff --git a/intern/mantaflow/intern/manta_fluid_API.cpp b/intern/mantaflow/intern/manta_fluid_API.cpp
index 1db3da63ecc..60546bc1183 100644
--- a/intern/mantaflow/intern/manta_fluid_API.cpp
+++ b/intern/mantaflow/intern/manta_fluid_API.cpp
@@ -368,89 +368,6 @@ void manta_smoke_export_script(MANTA *smoke, FluidModifierData *fmd)
smoke->exportSmokeScript(fmd);
}
-void manta_smoke_export(MANTA *smoke,
- float *dt,
- float *dx,
- float **dens,
- float **react,
- float **flame,
- float **fuel,
- float **heat,
- float **vx,
- float **vy,
- float **vz,
- float **r,
- float **g,
- float **b,
- int **flags,
- float **shadow)
-{
- if (dens)
- *dens = smoke->getDensity();
- if (fuel)
- *fuel = smoke->getFuel();
- if (react)
- *react = smoke->getReact();
- if (flame)
- *flame = smoke->getFlame();
- if (heat)
- *heat = smoke->getHeat();
- *vx = smoke->getVelocityX();
- *vy = smoke->getVelocityY();
- *vz = smoke->getVelocityZ();
- if (r)
- *r = smoke->getColorR();
- if (g)
- *g = smoke->getColorG();
- if (b)
- *b = smoke->getColorB();
- *flags = smoke->getFlags();
- if (shadow)
- *shadow = smoke->getShadow();
- *dt = 1; // dummy value, not needed for smoke
- *dx = 1; // dummy value, not needed for smoke
-}
-
-void manta_smoke_turbulence_export(MANTA *smoke,
- float **dens,
- float **react,
- float **flame,
- float **fuel,
- float **r,
- float **g,
- float **b,
- float **tcu,
- float **tcv,
- float **tcw,
- float **tcu2,
- float **tcv2,
- float **tcw2)
-{
- if (!smoke && !(smoke->usingNoise()))
- return;
-
- *dens = smoke->getDensityHigh();
- if (fuel)
- *fuel = smoke->getFuelHigh();
- if (react)
- *react = smoke->getReactHigh();
- if (flame)
- *flame = smoke->getFlameHigh();
- if (r)
- *r = smoke->getColorRHigh();
- if (g)
- *g = smoke->getColorGHigh();
- if (b)
- *b = smoke->getColorBHigh();
- *tcu = smoke->getTextureU();
- *tcv = smoke->getTextureV();
- *tcw = smoke->getTextureW();
-
- *tcu2 = smoke->getTextureU2();
- *tcv2 = smoke->getTextureV2();
- *tcw2 = smoke->getTextureW2();
-}
-
static void get_rgba(
float *r, float *g, float *b, float *a, int total_cells, float *data, int sequential)
{
@@ -484,7 +401,7 @@ void manta_smoke_get_rgba(MANTA *smoke, float *data, int sequential)
sequential);
}
-void manta_smoke_turbulence_get_rgba(MANTA *smoke, float *data, int sequential)
+void manta_noise_get_rgba(MANTA *smoke, float *data, int sequential)
{
get_rgba(smoke->getColorRHigh(),
smoke->getColorGHigh(),
@@ -519,10 +436,7 @@ void manta_smoke_get_rgba_fixed_color(MANTA *smoke, float color[3], float *data,
get_rgba_fixed_color(color, smoke->getTotalCells(), data, sequential);
}
-void manta_smoke_turbulence_get_rgba_fixed_color(MANTA *smoke,
- float color[3],
- float *data,
- int sequential)
+void manta_noise_get_rgba_fixed_color(MANTA *smoke, float color[3], float *data, int sequential)
{
get_rgba_fixed_color(color, smoke->getTotalCellsHigh(), data, sequential);
}
@@ -647,45 +561,69 @@ int manta_smoke_has_colors(MANTA *smoke)
return (smoke->getColorR() && smoke->getColorG() && smoke->getColorB()) ? 1 : 0;
}
-float *manta_smoke_turbulence_get_density(MANTA *smoke)
+float *manta_noise_get_density(MANTA *smoke)
{
return (smoke && smoke->usingNoise()) ? smoke->getDensityHigh() : nullptr;
}
-float *manta_smoke_turbulence_get_fuel(MANTA *smoke)
+float *manta_noise_get_fuel(MANTA *smoke)
{
return (smoke && smoke->usingNoise()) ? smoke->getFuelHigh() : nullptr;
}
-float *manta_smoke_turbulence_get_react(MANTA *smoke)
+float *manta_noise_get_react(MANTA *smoke)
{
return (smoke && smoke->usingNoise()) ? smoke->getReactHigh() : nullptr;
}
-float *manta_smoke_turbulence_get_color_r(MANTA *smoke)
+float *manta_noise_get_color_r(MANTA *smoke)
{
return (smoke && smoke->usingNoise()) ? smoke->getColorRHigh() : nullptr;
}
-float *manta_smoke_turbulence_get_color_g(MANTA *smoke)
+float *manta_noise_get_color_g(MANTA *smoke)
{
return (smoke && smoke->usingNoise()) ? smoke->getColorGHigh() : nullptr;
}
-float *manta_smoke_turbulence_get_color_b(MANTA *smoke)
+float *manta_noise_get_color_b(MANTA *smoke)
{
return (smoke && smoke->usingNoise()) ? smoke->getColorBHigh() : nullptr;
}
-float *manta_smoke_turbulence_get_flame(MANTA *smoke)
+float *manta_noise_get_flame(MANTA *smoke)
{
return (smoke && smoke->usingNoise()) ? smoke->getFlameHigh() : nullptr;
}
+float *manta_noise_get_texture_u(MANTA *smoke)
+{
+ return (smoke && smoke->usingNoise()) ? smoke->getTextureU() : nullptr;
+}
+float *manta_noise_get_texture_v(MANTA *smoke)
+{
+ return (smoke && smoke->usingNoise()) ? smoke->getTextureV() : nullptr;
+}
+float *manta_noise_get_texture_w(MANTA *smoke)
+{
+ return (smoke && smoke->usingNoise()) ? smoke->getTextureW() : nullptr;
+}
+float *manta_noise_get_texture_u2(MANTA *smoke)
+{
+ return (smoke && smoke->usingNoise()) ? smoke->getTextureU2() : nullptr;
+}
+float *manta_noise_get_texture_v2(MANTA *smoke)
+{
+ return (smoke && smoke->usingNoise()) ? smoke->getTextureV2() : nullptr;
+}
+float *manta_noise_get_texture_w2(MANTA *smoke)
+{
+ return (smoke && smoke->usingNoise()) ? smoke->getTextureW2() : nullptr;
+}
-int manta_smoke_turbulence_has_fuel(MANTA *smoke)
+int manta_noise_has_fuel(MANTA *smoke)
{
return (smoke->getFuelHigh()) ? 1 : 0;
}
-int manta_smoke_turbulence_has_colors(MANTA *smoke)
+int manta_noise_has_colors(MANTA *smoke)
{
return (smoke->getColorRHigh() && smoke->getColorGHigh() && smoke->getColorBHigh()) ? 1 : 0;
}
-void manta_smoke_turbulence_get_res(MANTA *smoke, int *res)
+void manta_noise_get_res(MANTA *smoke, int *res)
{
if (smoke && smoke->usingNoise()) {
res[0] = smoke->getResXHigh();
@@ -693,7 +631,7 @@ void manta_smoke_turbulence_get_res(MANTA *smoke, int *res)
res[2] = smoke->getResZHigh();
}
}
-int manta_smoke_turbulence_get_cells(MANTA *smoke)
+int manta_noise_get_cells(MANTA *smoke)
{
int total_cells_high = smoke->getResXHigh() * smoke->getResYHigh() * smoke->getResZHigh();
return (smoke && smoke->usingNoise()) ? total_cells_high : 0;
diff --git a/intern/mantaflow/intern/strings/smoke_script.h b/intern/mantaflow/intern/strings/smoke_script.h
index 612d01b85ef..332aa2342ee 100644
--- a/intern/mantaflow/intern/strings/smoke_script.h
+++ b/intern/mantaflow/intern/strings/smoke_script.h
@@ -100,6 +100,9 @@ color_r_in_s$ID$ = None\n\
color_g_in_s$ID$ = None\n\
color_b_in_s$ID$ = None\n\
\n\
+# Set some initial values\n\
+shadow_s$ID$.setConst(-1)\n\
+\n\
# Keep track of important objects in dict to load them later on\n\
smoke_data_dict_final_s$ID$ = { 'density' : density_s$ID$, 'shadow' : shadow_s$ID$ }\n\
smoke_data_dict_resume_s$ID$ = { 'densityIn' : densityIn_s$ID$, 'emission' : emission_s$ID$ }\n";
@@ -490,6 +493,9 @@ def step_noise_$ID$():\n\
advectSemiLagrange(flags=flags_s$ID$, vel=vel_s$ID$, grid=uvGrid1_s$ID$, order=2)\n\
updateUvWeight(resetTime=sn$ID$.timestep*10.0 , index=1, numUvs=uvs_s$ID$, uv=uvGrid1_s$ID$, offset=uvs_offset_s$ID$)\n\
\n\
+ if not domainClosed_s$ID$ or using_outflow_s$ID$:\n\
+ resetOutflow(flags=flags_sn$ID$, real=density_sn$ID$)\n\
+ \n\
mantaMsg('Energy')\n\
computeEnergy(flags=flags_s$ID$, vel=vel_s$ID$, energy=energy_s$ID$)\n\
\n\