diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-08 15:26:29 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-05-09 11:34:45 +0300 |
commit | ca5c3f767cd029e9ce744f3e4ece74bf10b29c70 (patch) | |
tree | 12c71a3b0197e4f61f7d611fdf152fb2b2a08f44 /source/blender/draw/intern/draw_cache_impl_particles.c | |
parent | 0868ccae1383b7989de44ed45d7bb64145b4bf72 (diff) |
Draw manager: Move emit_from checks to interpolation functions
Keeps main function shorter.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_particles.c')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_particles.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index d50a45a9b3b..8a9ef096881 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -185,6 +185,13 @@ static void particle_calculate_parent_uvs(ParticleSystem *psys, /*const*/ MTFace **mtfaces, float (*r_uv)[2]) { + if (psmd == NULL) { + return; + } + const int emit_from = psmd->psys->part->from; + if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { + return; + } ParticleData *particle = &psys->particles[parent_index]; int num = particle->num_dmcache; if (num == DMCACHE_NOTFOUND) { @@ -211,6 +218,13 @@ static void particle_interpolate_children_uvs(ParticleSystem *psys, /*const*/ MTFace **mtfaces, float (*r_uv)[2]) { + if (psmd == NULL) { + return; + } + const int emit_from = psmd->psys->part->from; + if (!ELEM(emit_from, PART_FROM_FACE, PART_FROM_VOLUME)) { + return; + } ChildParticle *particle = &psys->child[child_index]; int num = particle->num; if (num != DMCACHE_NOTFOUND) { @@ -293,7 +307,6 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Modifi continue; } float tangent[3]; - int from = psmd ? psmd->psys->part->from : 0; float (*uv)[2] = NULL; if (psmd != NULL) { uv = MEM_callocN(sizeof(*uv) * num_uv_layers, "Particle UVs"); @@ -301,10 +314,8 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Modifi parent_uvs[i] = uv; } } - if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { - particle_calculate_parent_uvs( - psys, psmd, num_uv_layers, i, mtfaces, uv); - } + particle_calculate_parent_uvs( + psys, psmd, num_uv_layers, i, mtfaces, uv); for (int j = 0; j < path->segments; j++) { if (j == 0) { sub_v3_v3v3(tangent, path[j + 1].co, path[j].co); @@ -355,26 +366,21 @@ static void particle_batch_cache_ensure_pos_and_seg(ParticleSystem *psys, Modifi continue; } float tangent[3]; - int from = psmd ? psmd->psys->part->from : 0; float (*uv)[2] = NULL; if (!simple) { if (psmd != NULL) { uv = MEM_callocN(sizeof(*uv) * num_uv_layers, "Particle UVs"); } - if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { - particle_interpolate_children_uvs( - psys, psmd, num_uv_layers, i, mtfaces, uv); - } + particle_interpolate_children_uvs( + psys, psmd, num_uv_layers, i, mtfaces, uv); } else if (!parent_uvs[psys->child[i].parent]) { if (psmd != NULL) { uv = parent_uvs[psys->child[i].parent] = MEM_callocN(sizeof(*uv) * num_uv_layers, "Particle UVs"); } - if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { - const int parent_index = psys->child[i].parent; - particle_calculate_parent_uvs( - psys, psmd, num_uv_layers, parent_index, mtfaces, uv); - } + const int parent_index = psys->child[i].parent; + particle_calculate_parent_uvs( + psys, psmd, num_uv_layers, parent_index, mtfaces, uv); } for (int j = 0; j < path->segments; j++) { if (j == 0) { |