Fix T51524: Instantiated Hair Object which has dupligroup children and hidden orig objects of group crash at render.

Note that this is speculative fix, actually precisely understanding what
happens in this code is... not easy.
This commit is contained in:
Bastien Montagne 2017-05-19 19:33:52 +02:00
parent 8d4aff31ce
commit b6f5e8d9a1
Notes: blender-bot 2023-02-14 06:58:04 +01:00
Referenced by issue #51524, Instantiated Hair Object which has dupligroup children and hidden orig objects of group crash at render
1 changed files with 8 additions and 1 deletions

View File

@ -4701,6 +4701,12 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
if (ob->particlesystem.first) {
psysindex= 1;
for (psys=ob->particlesystem.first; psys; psys=psys->next, psysindex++) {
/* It seems that we may generate psys->renderdata recursively in some nasty intricated cases of
* several levels of bupliobject (see T51524).
* For now, basic rule is, do not restore psys if it was already in 'render state'.
* Another, more robust solution could be to add some reference counting to that renderdata... */
const bool psys_has_renderdata = (psys->renderdata != NULL);
if (!psys_check_enabled(ob, psys, G.is_rendering))
continue;
@ -4712,8 +4718,9 @@ static void add_render_object(Render *re, Object *ob, Object *par, DupliObject *
if (dob)
psys->flag |= PSYS_USE_IMAT;
init_render_object_data(re, obr, timeoffset);
if (!(re->r.scemode & R_VIEWPORT_PREVIEW))
if (!(re->r.scemode & R_VIEWPORT_PREVIEW) && !psys_has_renderdata) {
psys_render_restore(ob, psys);
}
psys->flag &= ~PSYS_USE_IMAT;
/* only add instance for objects that have not been used for dupli */