diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 13:30:43 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-08-07 14:38:06 +0300 |
commit | 1b272a649b40e99dba4185167f6cee7cbece1942 (patch) | |
tree | 2785f52c566b36cbdcbf9355f698dc520ffbb482 /source/blender/blenkernel/intern/particle.c | |
parent | cfc6f9eb18e701f5be601b95c45004e8cf7fbc81 (diff) |
Cleanup: Blenkernel, Clang-Tidy else-after-return fixes
This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/blenkernel` module.
No functional changes.
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 180 |
1 files changed, 87 insertions, 93 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 1df5cda0ce5..44c24f5a4d1 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -512,9 +512,8 @@ bool psys_check_edited(ParticleSystem *psys) if (psys->part && psys->part->type == PART_HAIR) { return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited)); } - else { - return (psys->pointcache->edit && psys->pointcache->edit->edited); - } + + return (psys->pointcache->edit && psys->pointcache->edit->edited); } void psys_find_group_weights(ParticleSettings *part) @@ -1653,12 +1652,11 @@ int psys_particle_dm_face_lookup(Mesh *mesh_final, // printf("\tNO CD_ORIGSPACE, assuming not needed\n"); return findex_orig; } - else { - printf("\tNO CD_ORIGSPACE, error out of range\n"); - return DMCACHE_NOTFOUND; - } + + printf("\tNO CD_ORIGSPACE, error out of range\n"); + return DMCACHE_NOTFOUND; } - else if (findex_orig >= mesh_original->totface) { + if (findex_orig >= mesh_original->totface) { return DMCACHE_NOTFOUND; /* index not in the original mesh */ } @@ -2555,9 +2553,8 @@ static void psys_thread_create_path(ParticleTask *task, if (!needupdate) { return; } - else { - memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1)); - } + + memset(child_keys, 0, sizeof(*child_keys) * (ctx->segments + 1)); } /* get parent paths */ @@ -4666,10 +4663,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta psys_get_particle_on_path(sim, p, state, 1); return 1; } - else { - cpa = sim->psys->child + p - totpart; - pa = sim->psys->particles + cpa->parent; - } + + cpa = sim->psys->child + p - totpart; + pa = sim->psys->particles + cpa->parent; } else { pa = sim->psys->particles + p; @@ -4691,106 +4687,105 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta psys_get_particle_on_path(sim, p, state, 1); return 1; } - else { - if (cpa) { - float mat[4][4]; - ParticleKey *key1; - float t = (cfra - pa->time) / pa->lifetime; - float par_orco[3] = {0.0f, 0.0f, 0.0f}; - key1 = &pa->state; - offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); + if (cpa) { + float mat[4][4]; + ParticleKey *key1; + float t = (cfra - pa->time) / pa->lifetime; + float par_orco[3] = {0.0f, 0.0f, 0.0f}; - CLAMP(t, 0.0f, 1.0f); + key1 = &pa->state; + offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); - unit_m4(mat); - ParticleChildModifierContext modifier_ctx = {NULL}; - modifier_ctx.thread_ctx = NULL; - modifier_ctx.sim = sim; - modifier_ctx.ptex = NULL; - modifier_ctx.cpa = cpa; - modifier_ctx.orco = cpa->fuv; - modifier_ctx.par_co = key1->co; - modifier_ctx.par_vel = key1->vel; - modifier_ctx.par_rot = key1->rot; - modifier_ctx.par_orco = par_orco; - modifier_ctx.parent_keys = psys->childcache ? psys->childcache[p - totpart] : NULL; + CLAMP(t, 0.0f, 1.0f); - do_child_modifiers(&modifier_ctx, mat, state, t); + unit_m4(mat); + ParticleChildModifierContext modifier_ctx = {NULL}; + modifier_ctx.thread_ctx = NULL; + modifier_ctx.sim = sim; + modifier_ctx.ptex = NULL; + modifier_ctx.cpa = cpa; + modifier_ctx.orco = cpa->fuv; + modifier_ctx.par_co = key1->co; + modifier_ctx.par_vel = key1->vel; + modifier_ctx.par_rot = key1->rot; + modifier_ctx.par_orco = par_orco; + modifier_ctx.parent_keys = psys->childcache ? psys->childcache[p - totpart] : NULL; - if (psys->lattice_deform_data) { - BKE_lattice_deform_data_eval_co( - psys->lattice_deform_data, state->co, psys->lattice_strength); - } + do_child_modifiers(&modifier_ctx, mat, state, t); + + if (psys->lattice_deform_data) { + BKE_lattice_deform_data_eval_co( + psys->lattice_deform_data, state->co, psys->lattice_strength); + } + } + else { + if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) { + copy_particle_key(state, &pa->state, 1); + } + else if (pa->prev_state.time == cfra) { + copy_particle_key(state, &pa->prev_state, 1); } else { - if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) { - copy_particle_key(state, &pa->state, 1); - } - else if (pa->prev_state.time == cfra) { - copy_particle_key(state, &pa->prev_state, 1); - } - else { - float dfra, frs_sec = sim->scene->r.frs_sec; - /* let's interpolate to try to be as accurate as possible */ - if (pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) { - if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) { - /* prev_state is wrong so let's not use it, - * this can happen at frames 1, 0 or particle birth. */ - dfra = state->time - pa->state.time; + float dfra, frs_sec = sim->scene->r.frs_sec; + /* let's interpolate to try to be as accurate as possible */ + if (pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) { + if (pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) { + /* prev_state is wrong so let's not use it, + * this can happen at frames 1, 0 or particle birth. */ + dfra = state->time - pa->state.time; - copy_particle_key(state, &pa->state, 1); + copy_particle_key(state, &pa->state, 1); - madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); - } - else { - ParticleKey keys[4]; - float keytime; + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); + } + else { + ParticleKey keys[4]; + float keytime; - copy_particle_key(keys + 1, &pa->prev_state, 1); - copy_particle_key(keys + 2, &pa->state, 1); + copy_particle_key(keys + 1, &pa->prev_state, 1); + copy_particle_key(keys + 2, &pa->state, 1); - dfra = keys[2].time - keys[1].time; + dfra = keys[2].time - keys[1].time; - keytime = (state->time - keys[1].time) / dfra; + keytime = (state->time - keys[1].time) / dfra; - /* convert velocity to timestep size */ - mul_v3_fl(keys[1].vel, dfra * timestep); - mul_v3_fl(keys[2].vel, dfra * timestep); + /* convert velocity to timestep size */ + mul_v3_fl(keys[1].vel, dfra * timestep); + mul_v3_fl(keys[2].vel, dfra * timestep); - psys_interpolate_particle(-1, keys, keytime, state, 1); + psys_interpolate_particle(-1, keys, keytime, state, 1); - /* convert back to real velocity */ - mul_v3_fl(state->vel, 1.f / (dfra * timestep)); + /* convert back to real velocity */ + mul_v3_fl(state->vel, 1.f / (dfra * timestep)); - interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime); - interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime); - } + interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime); + interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime); } - else if (pa->state.time + 1.f >= state->time && pa->state.time - 1.f <= state->time) { - /* linear interpolation using only pa->state */ + } + else if (pa->state.time + 1.f >= state->time && pa->state.time - 1.f <= state->time) { + /* linear interpolation using only pa->state */ - dfra = state->time - pa->state.time; + dfra = state->time - pa->state.time; - copy_particle_key(state, &pa->state, 1); + copy_particle_key(state, &pa->state, 1); - madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); - } - else { - /* Extrapolating over big ranges is not accurate - * so let's just give something close to reasonable back. */ - copy_particle_key(state, &pa->state, 0); - } + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); } - - if (sim->psys->lattice_deform_data) { - BKE_lattice_deform_data_eval_co( - sim->psys->lattice_deform_data, state->co, psys->lattice_strength); + else { + /* Extrapolating over big ranges is not accurate + * so let's just give something close to reasonable back. */ + copy_particle_key(state, &pa->state, 0); } } - return 1; + if (sim->psys->lattice_deform_data) { + BKE_lattice_deform_data_eval_co( + sim->psys->lattice_deform_data, state->co, psys->lattice_strength); + } } + + return 1; } void psys_get_dupli_texture(ParticleSystem *psys, @@ -4844,9 +4839,8 @@ void psys_get_dupli_texture(ParticleSystem *psys, orco); return; } - else { - pa = psys->particles + cpa->pa[0]; - } + + pa = psys->particles + cpa->pa[0]; } if ((part->from == PART_FROM_FACE) && (psmd->mesh_final != NULL) && !is_grid) { |