From 5ce6ca05366e653cc576ac6beaed72d07c0e2e6c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 15 Feb 2018 10:27:39 +0100 Subject: [PATCH] Fix T54078: Adding subsurf prior to particle system breaks simple children vgroups and textures cpa->num points to a face index on BASE mesh, but get_child_modifier_parameters() expects index on a FINAL dm. So wrong index was used here. --- source/blender/blenkernel/intern/particle.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 723bb86cb47..87322b5fddc 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2306,7 +2306,19 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp /* get the original coordinates (orco) for texture usage */ cpa_from = part->from; - cpa_num = pa->num; + + /* + * NOTE: Should in theory be the same as: + cpa_num = psys_particle_dm_face_lookup( + ctx->sim.psmd->dm_final, + ctx->sim.psmd->dm_deformed, + pa->num, pa->fuv, + NULL); + */ + cpa_num = (ELEM(pa->num_dmcache, DMCACHE_ISCHILD, DMCACHE_NOTFOUND)) + ? pa->num + : pa->num_dmcache; + /* XXX hack to avoid messed up particle num and subsequent crash (#40733) */ if (cpa_num > ctx->sim.psmd->dm_final->getNumTessFaces(ctx->sim.psmd->dm_final)) cpa_num = 0;