[Bf-blender-cvs] [f701c6344d4] fluid-mantaflow: Merge branch 'smokeTypes' into smokeC
Sebastián Barschkis
noreply at git.blender.org
Sat Apr 6 22:13:44 CEST 2019
Commit: f701c6344d425cb63283ccfe5f7b02d4b54a78ec
Author: Sebastián Barschkis
Date: Tue Mar 26 21:05:16 2019 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rBf701c6344d425cb63283ccfe5f7b02d4b54a78ec
Merge branch 'smokeTypes' into smokeC
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/smoke.c
index b231c1ed47c,82acc272c6b..28e5de86714
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@@ -98,15 -84,17 +84,19 @@@
//#define DEBUG_TIME
#ifdef DEBUG_TIME
- # include "PIL_time.h"
+ # include "PIL_time.h"
#endif
-#include "smoke_API.h"
+#ifdef WITH_MANTA
+# include "manta_fluid_API.h"
+#endif
-#ifdef WITH_SMOKE
+#ifdef WITH_MANTA
+ #include "BLI_task.h"
+ #include "BLI_kdtree.h"
+ #include "BLI_voxel.h"
+
static ThreadMutex object_update_lock = BLI_MUTEX_INITIALIZER;
struct Mesh;
@@@ -121,38 -109,71 +111,38 @@@ struct SmokeModifierData
#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)))
-#else /* WITH_SMOKE */
+#else /* WITH_MANTA */
/* Stubs to use when smoke is disabled */
-struct WTURBULENCE *smoke_turbulence_init(int *UNUSED(res), int UNUSED(amplify), int UNUSED(noisetype), const char *UNUSED(noisefile_path), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
-//struct FLUID_3D *smoke_init(int *UNUSED(res), float *UNUSED(dx), float *UNUSED(dtdef), int UNUSED(use_heat), int UNUSED(use_fire), int UNUSED(use_colors)) { return NULL; }
-void smoke_free(struct FLUID_3D *UNUSED(fluid)) {}
-float *smoke_get_density(struct FLUID_3D *UNUSED(fluid)) { return NULL; }
-void smoke_turbulence_free(struct WTURBULENCE *UNUSED(wt)) {}
-void smoke_initWaveletBlenderRNA(struct WTURBULENCE *UNUSED(wt), float *UNUSED(strength)) {}
-void smoke_initBlenderRNA(struct FLUID_3D *UNUSED(fluid), float *UNUSED(alpha), float *UNUSED(beta), float *UNUSED(dt_factor), float *UNUSED(vorticity),
- int *UNUSED(border_colli), float *UNUSED(burning_rate), float *UNUSED(flame_smoke), float *UNUSED(flame_smoke_color),
- float *UNUSED(flame_vorticity), float *UNUSED(flame_ignition_temp), float *UNUSED(flame_max_temp)) {}
+void fluid_free(struct FLUID *UNUSED(fluid));
+float *smoke_get_density(struct FLUID *UNUSED(fluid));
+
+void fluid_free(struct FLUID *UNUSED(fluid)) {}
+float *smoke_get_density(struct FLUID *UNUSED(fluid)) { return NULL; }
struct Mesh *smokeModifier_do(SmokeModifierData *UNUSED(smd), Depsgraph *UNUSED(depsgraph), Scene *UNUSED(scene), Object *UNUSED(ob), Mesh *UNUSED(me)) { return NULL; }
- float smoke_get_velocity_at(struct Object *UNUSED(ob), float UNUSED(position[3]), float UNUSED(velocity[3])) { return 0.0f; }
+ float BKE_smoke_get_velocity_at(struct Object *UNUSED(ob), float UNUSED(position[3]), float UNUSED(velocity[3])) { return 0.0f; }
-#endif /* WITH_SMOKE */
+#endif /* WITH_MANTA */
-#ifdef WITH_SMOKE
+#ifdef WITH_MANTA
- void smoke_reallocate_fluid(SmokeDomainSettings *sds, int res[3], int free_old)
-void BKE_smoke_reallocate_fluid(SmokeDomainSettings *sds, float dx, int res[3], int free_old)
++void BKE_smoke_reallocate_fluid(SmokeDomainSettings *sds, int res[3], int free_old)
{
- int use_heat = (sds->active_fields & SM_ACTIVE_HEAT);
- int use_fire = (sds->active_fields & SM_ACTIVE_FIRE);
- int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
-
if (free_old && sds->fluid)
- smoke_free(sds->fluid);
+ fluid_free(sds->fluid);
if (!min_iii(res[0], res[1], res[2])) {
sds->fluid = NULL;
return;
}
- sds->fluid = smoke_init(res, dx, DT_DEFAULT, use_heat, use_fire, use_colors);
- smoke_initBlenderRNA(sds->fluid, &(sds->alpha), &(sds->beta), &(sds->time_scale), &(sds->vorticity), &(sds->border_collisions),
- &(sds->burning_rate), &(sds->flame_smoke), sds->flame_smoke_color, &(sds->flame_vorticity), &(sds->flame_ignition), &(sds->flame_max_temp));
- /* reallocate shadow buffer */
- if (sds->shadow)
- MEM_freeN(sds->shadow);
- sds->shadow = MEM_callocN(sizeof(float) * res[0] * res[1] * res[2], "SmokeDomainShadow");
+ sds->fluid = fluid_init(res, sds->smd);
}
- void smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, int res[3])
-void BKE_smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, float dx, int res[3], int free_old)
++void BKE_smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, int res[3])
{
- int use_fire = (sds->active_fields & (SM_ACTIVE_HEAT | SM_ACTIVE_FIRE));
- int use_colors = (sds->active_fields & SM_ACTIVE_COLORS);
-
- if (free_old && sds->wt)
- smoke_turbulence_free(sds->wt);
- if (!min_iii(res[0], res[1], res[2])) {
- sds->wt = NULL;
- return;
- }
-
- /* smoke_turbulence_init uses non-threadsafe functions from fftw3 lib (like fftw_plan & co). */
- BLI_thread_lock(LOCK_FFTW);
-
- sds->wt = smoke_turbulence_init(res, sds->amplify + 1, sds->noise, BKE_tempdir_session(), use_fire, use_colors);
-
- BLI_thread_unlock(LOCK_FFTW);
-
- sds->res_wt[0] = res[0] * (sds->amplify + 1);
- sds->res_wt[1] = res[1] * (sds->amplify + 1);
- sds->res_wt[2] = res[2] * (sds->amplify + 1);
- sds->dx_wt = dx / (sds->amplify + 1);
- smoke_initWaveletBlenderRNA(sds->wt, &(sds->strength));
+ sds->res_noise[0] = res[0] * sds->noise_scale;
+ sds->res_noise[1] = res[1] * sds->noise_scale;
+ sds->res_noise[2] = res[2] * sds->noise_scale;
}
/* convert global position to domain cell space */
@@@ -291,26 -286,25 +281,26 @@@ static int smokeModifier_init(SmokeModi
res[0] = res[1] = res[2] = 1; /* use minimum res for adaptive init */
}
else {
- VECCOPY(res, sds->base_res);
+ copy_v3_v3_int(res, sds->base_res);
}
- VECCOPY(sds->res, res);
+ copy_v3_v3_int(sds->res, res);
sds->total_cells = sds->res[0] * sds->res[1] * sds->res[2];
sds->res_min[0] = sds->res_min[1] = sds->res_min[2] = 0;
- VECCOPY(sds->res_max, res);
+ copy_v3_v3_int(sds->res_max, res);
+ /* set time, dt = 0.1 is at 25fps */
+ float fps = scene->r.frs_sec / scene->r.frs_sec_base;
+ sds->dt = DT_DEFAULT * (25.0f / fps);
+
/* allocate fluid */
- smoke_reallocate_fluid(sds, sds->res, 0);
- BKE_smoke_reallocate_fluid(sds, sds->dx, sds->res, 0);
++ BKE_smoke_reallocate_fluid(sds, sds->res, 0);
smd->time = scene_framenr;
/* allocate highres fluid */
- if (sds->flags & MOD_SMOKE_HIGHRES) {
- BKE_smoke_reallocate_highres_fluid(sds, sds->dx, sds->res, 0);
+ if (sds->flags & FLUID_DOMAIN_USE_NOISE) {
- smoke_reallocate_highres_fluid(sds, sds->res);
++ BKE_smoke_reallocate_highres_fluid(sds, sds->res);
}
- /* allocate shadow buffer */
- if (!sds->shadow)
- sds->shadow = MEM_callocN(sizeof(float) * sds->res[0] * sds->res[1] * sds->res[2], "SmokeDomainShadow");
return 1;
}
@@@ -735,120 -649,30 +725,121 @@@ void smokeModifier_copy(const struct Sm
tsds->flame_max_temp = sds->flame_max_temp;
copy_v3_v3(tsds->flame_smoke_color, sds->flame_smoke_color);
- MEM_freeN(tsds->effector_weights);
- tsds->effector_weights = MEM_dupallocN(sds->effector_weights);
- tsds->openvdb_comp = sds->openvdb_comp;
- tsds->data_depth = sds->data_depth;
- tsds->cache_file_format = sds->cache_file_format;
+ /* noise options */
+ tsds->noise_strength = sds->noise_strength;
+ tsds->noise_pos_scale = sds->noise_pos_scale;
+ tsds->noise_time_anim = sds->noise_time_anim;
+ tsds->noise_scale = sds->noise_scale;
+ tsds->noise_type = sds->noise_type;
+
+ /* liquid domain options */
+ tsds->particle_randomness = sds->particle_randomness;
+ tsds->particle_number = sds->particle_number;
+ tsds->particle_minimum = sds->particle_minimum;
+ tsds->particle_maximum = sds->particle_maximum;
+ tsds->particle_radius = sds->particle_radius;
+ tsds->particle_band_width = sds->particle_band_width;
+
+ /* diffusion options*/
+ tsds->surface_tension = sds->surface_tension;
+ tsds->viscosity_base = sds->viscosity_base;
+ tsds->viscosity_exponent = sds->viscosity_exponent;
+ tsds->domain_size = sds->domain_size;
+
+ /* mesh options */
+ if (sds->mesh_velocities) {
+ tsds->mesh_velocities = MEM_dupallocN(sds->mesh_velocities);
+ }
+ tsds->mesh_concave_upper = sds->mesh_concave_upper;
+ tsds->mesh_concave_lower = sds->mesh_concave_lower;
+ tsds->mesh_smoothen_pos = sds->mesh_smoothen_pos;
+ tsds->mesh_smoothen_neg = sds->mesh_smoothen_neg;
+ tsds->mesh_scale = sds->mesh_scale;
+ tsds->totvert = sds->totvert;
+ tsds->mesh_generator = sds->mesh_generator;
+
+ /* secondary particle options */
+ tsds->sndparticle_k_b = sds->sndparticle_k_b;
+ tsds->sndparticle_k_d = sds->sndparticle_k_d;
+ tsds->sndparticle_k_ta = sds->sndparticle_k_ta;
+ tsds->sndparticle_k_wc = sds->sndparticle_k_wc;
+ tsds->sndparticle_l_max = sds->sndparticle_l_max;
+ tsds->sndparticle_l_min = sds->sndparticle_l_min;
+ tsds->sndparticle_tau_max_k = sds->sndparticle_tau_max_k;
+ tsds->sndparticle_tau_max_ta = sds->sndparticle_tau_max_ta;
+ tsds->sndparticle_tau_max_wc = sds->sndparticle_tau_max_wc;
+ tsds->sndparticle_tau_min_k = sds->sndparticle_tau_min_k;
+ tsds->sndparticle_tau_min_ta = sds->sndparticle_tau_min_ta;
+ tsds->sndparticle_tau_min_wc = sds->sndparticle_tau_min_wc;
+ tsds->sndparticle_boundary = sds->sndparticle_boundary;
+ tsds->sndparticle_combined_export = sds->sndparticle_combined_export;
+ tsds->sndparticle_potential_radius = sds->sndparticle_potential_radius;
+ tsds->sndparticle_update_radius = sds->sndparticle_update_radius;
+ tsds->particle_type = sds->particle_type;
+ tsds->particle_scale = sds->particle_scale;
+
+ /* fluid guiding options */
+ tsds->guiding_parent = sds->guiding_parent;
+ tsds->guiding_alpha = sds->guiding_alpha;
+ tsds->guiding_beta = sds->guiding_beta;
+ tsds->guiding_vel_factor = sds->guiding_vel_factor;
+ tsds->guide_res = sds->guide_res;
+ tsds->guiding_source = sds->guiding_source;
+
+ /* cache options */
+ tsds->cache_frame_start = sds->cache_frame_start;
+ tsds->cache_frame_end = sds->cache_frame_end;
+ tsds->cache_frame_pause_data = sds->cache_frame_pause_data;
+ tsds->cache_frame_pause_noise = sds->cache_frame_pause_noise;
+ tsds->cache_frame_pause_mesh = sds->cache_frame_pause_mesh;
+ tsds->cache_frame_pause_particles = sds->cache_frame_pause_parti
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list