diff options
author | Jacques Lucke <jacques@blender.org> | 2020-04-23 16:15:04 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-04-23 16:15:04 +0300 |
commit | 1fce2ea743846a3301cf254595fd5884dbfb4053 (patch) | |
tree | c85eb15338633785f6f613b790bde1e61073582b /source/blender/blenkernel | |
parent | 1c84cd81985abb76572fcedecc768fce1631129c (diff) | |
parent | 694c0547c21aa3a5087c0dd4323624358135f4ef (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/intern/fluid.c | 29 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 3 |
2 files changed, 23 insertions, 9 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index a26feb2d06b..d4f54daa773 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -489,23 +489,26 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *mds, static void manta_set_domain_gravity(Scene *scene, FluidDomainSettings *mds) { - float gravity[3] = {0.0f, 0.0f, -1.0f}; - float gravity_mag; + const float normalization_factor = 1.0f / 9.81f; /* Use global gravity if enabled. */ if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { + float gravity[3]; copy_v3_v3(gravity, scene->physics_settings.gravity); /* Map default value to 1.0. */ - mul_v3_fl(gravity, 1.0f / 9.810f); + mul_v3_fl(gravity, normalization_factor); /* Convert gravity to domain space. */ - gravity_mag = len_v3(gravity); + float gravity_mag = len_v3(gravity); mul_mat3_m4_v3(mds->imat, gravity); normalize_v3(gravity); mul_v3_fl(gravity, gravity_mag); copy_v3_v3(mds->gravity, gravity); } + else { + mul_v3_fl(mds->gravity, normalization_factor); + } mul_v3_fl(mds->gravity, mds->effector_weights->global_gravity); } @@ -3110,9 +3113,19 @@ static void update_flowsfluids(struct Depsgraph *depsgraph, levelset, emission_in); if (mfs->flags & FLUID_FLOW_INITVELOCITY) { - 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]); + /* Use the initial velocity from the inflow object with the highest velocity for + * now. */ + float vel_initial[3]; + vel_initial[0] = velx_initial[d_index]; + vel_initial[1] = vely_initial[d_index]; + vel_initial[2] = velz_initial[d_index]; + float vel_initial_strength = len_squared_v3(vel_initial); + float vel_map_strength = len_squared_v3(velocity_map + 3 * e_index); + if (vel_map_strength > vel_initial_strength) { + 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]; + } } } } @@ -4829,7 +4842,7 @@ void BKE_fluid_modifier_create_type_data(struct FluidModifierData *mmd) mmd->domain->flags = FLUID_DOMAIN_USE_DISSOLVE_LOG | FLUID_DOMAIN_USE_ADAPTIVE_TIME; mmd->domain->gravity[0] = 0.0f; mmd->domain->gravity[1] = 0.0f; - mmd->domain->gravity[2] = -1.0f; + mmd->domain->gravity[2] = -9.81f; mmd->domain->active_fields = 0; mmd->domain->type = FLUID_DOMAIN_TYPE_GAS; mmd->domain->boundary_width = 1; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 14b1ef7b87f..83f1dca4b8c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1258,7 +1258,8 @@ static void set_keyed_keys(ParticleSimulationData *sim) key = pa->keys + k; key->time = -1.0; /* use current time */ - psys_get_particle_state(&ksim, p % ksim.psys->totpart, key, 1); + const int p_ksim = (ksim.psys->totpart) ? p % ksim.psys->totpart : 0; + psys_get_particle_state(&ksim, p_ksim, key, 1); if (psys->flag & PSYS_KEYED_TIMING) { key->time = pa->time + pt->time; |