Fix T44268: Particles: too many virtual parents + non-100 display% = crash

Issue was caused by mismatched logic in counting child/parent particles in
job initialization and actual job execution. Confusion here came from mixed
usage of psys->renderdata and G.is_rendering.

We need to get rid of G.is_rendering and use eval_ctx if it's really needed,
but we also might just use psys->renderdata check since it's expected psys
to have this structure anyway.
This commit is contained in:
Sergey Sharybin 2015-04-07 13:50:11 +05:00
parent 98f4106694
commit 4b685e1b90
Notes: blender-bot 2023-02-14 09:16:46 +01:00
Referenced by commit c523e82e31, Particles: Fix for missing particles in render if they're disabled for viewport
Referenced by issue #44268, Particles: too many virtual parents + non-100 display% = crash
1 changed files with 5 additions and 3 deletions

View File

@ -286,7 +286,7 @@ bool psys_check_enabled(Object *ob, ParticleSystem *psys)
return 0;
psmd = psys_get_modifier(ob, psys);
if (psys->renderdata || G.is_rendering) {
if (psys->renderdata) {
if (!(psmd->modifier.mode & eModifierMode_Render))
return 0;
}
@ -1955,7 +1955,7 @@ void psys_find_parents(ParticleSimulationData *sim)
int from = PART_FROM_FACE;
totparent = (int)(totchild * part->parents * 0.3f);
if ((sim->psys->renderdata || G.is_rendering) && part->child_nbr && part->ren_child_nbr)
if (sim->psys->renderdata && part->child_nbr && part->ren_child_nbr)
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
/* hard limit, workaround for it being ignored above */
@ -2009,7 +2009,7 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, ParticleSi
if (totchild && part->childtype == PART_CHILD_FACES) {
totparent = (int)(totchild * part->parents * 0.3f);
if ((psys->renderdata || G.is_rendering) && part->child_nbr && part->ren_child_nbr)
if (psys->renderdata && part->child_nbr && part->ren_child_nbr)
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
/* part->parents could still be 0 so we can't test with totparent */
@ -2288,6 +2288,7 @@ static void psys_thread_create_path(ParticleTask *task, struct ChildParticle *cp
if (i >= ctx->totparent) {
pa = &psys->particles[cpa->parent];
/* this is now threadsafe, virtual parents are calculated before rest of children */
BLI_assert(cpa->parent < psys->totchildcache);
par = cache[cpa->parent];
}
}
@ -2335,6 +2336,7 @@ static void exec_child_path_cache(TaskPool *UNUSED(pool), void *taskdata, int UN
cpa = psys->child + task->begin;
for (i = task->begin; i < task->end; ++i, ++cpa) {
BLI_assert(i < psys->totchildcache);
psys_thread_create_path(task, cpa, cache[i], i);
}
}