[Bf-blender-cvs] [63b0377e961] fluid-mantaflow: Mantaflow: Fixed issues raised in part 8 of the review (D3857)
Sebastián Barschkis
noreply at git.blender.org
Wed Dec 11 10:07:21 CET 2019
Commit: 63b0377e9619d69d31949550e2e9f9514ce07513
Author: Sebastián Barschkis
Date: Wed Dec 11 10:07:14 2019 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB63b0377e9619d69d31949550e2e9f9514ce07513
Mantaflow: Fixed issues raised in part 8 of the review (D3857)
===================================================================
M source/blender/blenkernel/intern/manta.c
M source/blender/blenkernel/intern/particle_system.c
===================================================================
diff --git a/source/blender/blenkernel/intern/manta.c b/source/blender/blenkernel/intern/manta.c
index 26a6bc9f22e..172e7121358 100644
--- a/source/blender/blenkernel/intern/manta.c
+++ b/source/blender/blenkernel/intern/manta.c
@@ -1310,8 +1310,10 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata,
data->velocityZ[index] += (data->mcs->type == FLUID_EFFECTOR_TYPE_GUIDE) ?
hit_vel[2] * data->mcs->vel_multi :
hit_vel[2];
- // printf("adding effector object vel: [%f, %f, %f], dx is: %f\n", hit_vel[0],
- // hit_vel[1], hit_vel[2], mds->dx);
+#if 0
+ /* 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);
+#endif
}
}
}
@@ -1579,9 +1581,10 @@ static void update_obstacles(Depsgraph *depsgraph,
scene->r.subframe = 0.0f;
scene->r.cfra = frame;
}
- // printf("effector: frame: %d // scene current frame: %d // scene current subframe: %f\n",
- // frame, scene->r.cfra, scene->r.subframe);
-
+#if 0
+ /* Debugging: Print subframe information. */
+ printf("effector: frame: %d // scene current frame: %d // scene current subframe: %f\n", frame, scene->r.cfra, scene->r.subframe);
+#endif
/* TODO (sebbas): Using BKE_scene_frame_get(scene) instead of new DEG_get_ctime(depsgraph) as
* subframes dont work with the latter yet */
BKE_object_modifier_update_subframe(
@@ -2400,7 +2403,10 @@ static void sample_mesh(MantaFlowSettings *mfs,
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;
- // printf("adding flow object vel: [%f, %f, %f]\n", hit_vel[0], hit_vel[1], hit_vel[2]);
+#if 0
+ /* 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];
@@ -3291,9 +3297,10 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
}
/* Sanity check: subframe portion must be between 0 and 1 */
CLAMP(scene->r.subframe, 0.0f, 1.0f);
- // printf("flow: frame (is first: %d): %d // scene current frame: %d // scene current
- // subframe: %f\n", is_first_frame, frame, scene->r.cfra, scene->r.subframe);
-
+#if 0
+ /* Debugging: Print subframe information. */
+ printf("flow: frame (is first: %d): %d // scene current frame: %d // scene current subframe: %f\n", is_first_frame, frame, scene->r.cfra, scene->r.subframe);
+#endif
/* Update frame time, this is considering current subframe fraction
* BLI_mutex_lock() called in manta_step(), so safe to update subframe here
* TODO (sebbas): Using BKE_scene_frame_get(scene) instead of new DEG_get_ctime(depsgraph)
@@ -3338,9 +3345,10 @@ static void update_flowsfluids(struct Depsgraph *depsgraph,
}
}
}
-
- // printf("flow: frame: %d // time per frame: %f // frame length: %f // dt: %f\n", frame,
- // time_per_frame, frame_length, dt);
+#if 0
+ /* Debugging: Print time information. */
+ printf("flow: frame: %d // time per frame: %f // frame length: %f // dt: %f\n", frame, time_per_frame, frame_length, dt);
+#endif
/* Adjust domain size if needed. Only do this once for every frame */
if (mds->type == FLUID_DOMAIN_TYPE_GAS && mds->flags & FLUID_DOMAIN_USE_ADAPTIVE_DOMAIN) {
@@ -3669,7 +3677,10 @@ static Mesh *createLiquidGeometry(MantaDomainSettings *mds, Mesh *orgmesh, Objec
num_normals = manta_liquid_get_num_normals(mds->fluid);
num_faces = manta_liquid_get_num_triangles(mds->fluid);
- // printf("num_verts: %d, num_normals: %d, num_faces: %d\n", num_verts, num_normals, num_faces);
+#if 0
+ /* Debugging: Print number of vertices, normals, and faces. */
+ printf("num_verts: %d, num_normals: %d, num_faces: %d\n", num_verts, num_normals, num_faces);
+#endif
if (!num_verts || !num_faces) {
return NULL;
@@ -3715,9 +3726,10 @@ static Mesh *createLiquidGeometry(MantaDomainSettings *mds, Mesh *orgmesh, Objec
mverts->co[0] *= max_size / fabsf(ob->scale[0]);
mverts->co[1] *= max_size / fabsf(ob->scale[1]);
mverts->co[2] *= max_size / fabsf(ob->scale[2]);
-
- // printf("mverts->co[0]: %f, mverts->co[1]: %f, mverts->co[2]: %f\n", mverts->co[0],
- // mverts->co[1], mverts->co[2]);
+#if 0
+ /* Debugging: Print coordinates of vertices. */
+ printf("mverts->co[0]: %f, mverts->co[1]: %f, mverts->co[2]: %f\n", mverts->co[0], mverts->co[1], mverts->co[2]);
+#endif
}
// Normals
@@ -3729,8 +3741,10 @@ static Mesh *createLiquidGeometry(MantaDomainSettings *mds, Mesh *orgmesh, Objec
no[2] = manta_liquid_get_normal_z_at(mds->fluid, i);
normal_float_to_short_v3(no_s, no);
-
- // printf("no_s[0]: %d, no_s[1]: %d, no_s[2]: %d\n", no_s[0], no_s[1], no_s[2]);
+#if 0
+ /* Debugging: Print coordinates of normals. */
+ printf("no_s[0]: %d, no_s[1]: %d, no_s[2]: %d\n", no_s[0], no_s[1], no_s[2]);
+#endif
}
// Triangles
@@ -3745,9 +3759,10 @@ static Mesh *createLiquidGeometry(MantaDomainSettings *mds, Mesh *orgmesh, Objec
mloops[0].v = manta_liquid_get_triangle_x_at(mds->fluid, i);
mloops[1].v = manta_liquid_get_triangle_y_at(mds->fluid, i);
mloops[2].v = manta_liquid_get_triangle_z_at(mds->fluid, i);
-
- // printf("mloops[0].v: %d, mloops[1].v: %d, mloops[2].v: %d\n", mloops[0].v, mloops[1].v,
- // mloops[2].v);
+#if 0
+ /* Debugging: Print mesh faces. */
+ printf("mloops[0].v: %d, mloops[1].v: %d, mloops[2].v: %d\n", mloops[0].v, mloops[1].v, mloops[2].v);
+#endif
}
BKE_mesh_ensure_normals(me);
@@ -3778,9 +3793,10 @@ static Mesh *createLiquidGeometry(MantaDomainSettings *mds, Mesh *orgmesh, Objec
velarray[i].vel[0] = manta_liquid_get_vertvel_x_at(mds->fluid, i) * (mds->dx / time_mult);
velarray[i].vel[1] = manta_liquid_get_vertvel_y_at(mds->fluid, i) * (mds->dx / time_mult);
velarray[i].vel[2] = manta_liquid_get_vertvel_z_at(mds->fluid, i) * (mds->dx / time_mult);
-
- // printf("velarray[%d].vel[0]: %f, velarray[%d].vel[1]: %f, velarray[%d].vel[2]: %f\n", i,
- // velarray[i].vel[0], i, velarray[i].vel[1], i, velarray[i].vel[2]);
+#if 0
+ /* Debugging: Print velocities of vertices. */
+ printf("velarray[%d].vel[0]: %f, velarray[%d].vel[1]: %f, velarray[%d].vel[2]: %f\n", i, velarray[i].vel[0], i, velarray[i].vel[1], i, velarray[i].vel[2]);
+#endif
}
return me;
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index ce34fea7981..2378cc058da 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -578,13 +578,13 @@ static void initialize_particle_texture(ParticleSimulationData *sim, ParticleDat
psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
- if (part->type & PART_EMITTER) {
+ if (part->type == PART_EMITTER) {
if (ptex.exist < psys_frand(psys, p + 125)) {
pa->flag |= PARS_UNEXIST;
}
pa->time = part->sta + (part->end - part->sta) * ptex.time;
}
- if (part->type & PART_HAIR) {
+ if (part->type == PART_HAIR) {
if (ptex.exist < psys_frand(psys, p + 125)) {
pa->flag |= PARS_UNEXIST;
}
@@ -4164,8 +4164,9 @@ static void particles_manta_step(ParticleSimulationData *sim,
int upres = 1;
char debugStrBuffer[256];
float tmp[3] = {0}, tmp2[3] = {0};
+ RNG *rng;
- /* Helper variables for scaling */
+ /* Helper variables for scaling. */
float min[3], max[3], size[3], cell_size_scaled[3], max_size;
/* Sanity check: parts also enabled in fluid domain? */
@@ -4186,7 +4187,7 @@ static void particles_manta_step(ParticleSimulationData *sim,
return;
}
- /* Count particle amount. tottypepart only important for snd particles */
+ /* Count particle amount. tottypepart is only important for snd particles. */
if (part->type & PART_MANTA_FLIP) {
tottypepart = totpart = manta_liquid_get_num_flip_particles(mds->fluid);
}
@@ -4194,7 +4195,7 @@ static void particles_manta_step(ParticleSimulationData *sim,
(PART_MANTA_SPRAY | PART_MANTA_BUBBLE | PART_MANTA_FOAM | PART_MANTA_TRACER)) {
totpart = manta_liquid_get_num_snd_particles(mds->fluid);
- /* tottypepart is the amount of particles of a snd particle type */
+ /* tottypepart is the amount of particles of a snd particle type. */
for (p = 0; p < totpart; p++) {
flagActivePart = manta_liquid_get_snd_particle_flag_at(mds->fluid, p);
if ((part->type & PART_MANTA_SPRAY) && (flagActivePart & PARTICLE_TYPE_SPRAY))
@@ -4207,7 +4208,7 @@ static void particles_manta_step(ParticleSimulationData *sim,
tottypepart++;
}
}
- /* Sanity check: no particles present */
+ /* Sanity check: no particles present. */
if (!totpart || !tottypepart)
return;
@@ -4218,22 +4219,22 @@ static void particles_manta_step(ParticleSimulationData *sim,
part->sta = part->end = 1.0f;
part->lifetime = sim->scene->r.efra + 1;
- /* Allocate particles */
+ /* Allocate particles. */
realloc_particles(sim, part->totpart);
- /* Randomness when choosing which particles to display */
- srand(123456789); // set seed
+ /* Set some randomness when choosing which particles to display. */
+ rng = BLI_rng_new(0);
double r, dispProb = (double)part->disp / 100.0;
- /* Loop over *all* particles. Will break out of loop before tottypepart amount exceeded */
+ /* Loop over *all* particles. Will break out of loop before tottypepart amount exceeded. */
for (p = 0, pa = psys->particles; p < totpart; p++) {
- /* Apply some randomness and determine whic
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list