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.
This commit is contained in:
Sergey Sharybin 2018-02-15 10:27:39 +01:00
parent 67cec97387
commit 5ce6ca0536
Notes: blender-bot 2023-02-14 06:11:15 +01:00
Referenced by issue #54078, Adding subsurf prior to particle system breaks simple children vgroups and textures
1 changed files with 13 additions and 1 deletions

View File

@ -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;