Fix T45563: Crash rendering hair dupli's
authorCampbell Barton <ideasman42@gmail.com>
Mon, 27 Jul 2015 00:02:41 +0000 (10:02 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 27 Jul 2015 00:04:20 +0000 (10:04 +1000)
source/blender/render/intern/source/convertblender.c

index e51ff91450e905b54aa863e0b79dea854c6ec9f7..703cc4bddd99a7930b11c4143ba1bc8197ff2fa9 100644 (file)
@@ -5005,7 +5005,9 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
                                dupli_render_particle_set(re, ob, timeoffset, 0, 1);
                                duplilist = object_duplilist(re->eval_ctx, re->scene, ob);
                                duplilist_apply_data = duplilist_apply(ob, NULL, duplilist);
-                               dupli_render_particle_set(re, ob, timeoffset, 0, 0);
+                               /* postpone 'dupli_render_particle_set', since RE_addRenderInstance reads
+                                * index values from 'dob->persistent_id[0]', referencing 'psys->child' which
+                                * may be smaller once the particle system is restored, see: T45563. */
 
                                for (dob= duplilist->first, i = 0; dob; dob= dob->next, ++i) {
                                        DupliExtraData *dob_extra = &duplilist_apply_data->extra[i];
@@ -5098,6 +5100,9 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
                                        if (re->test_break(re->tbh)) break;
                                }
 
+                               /* restore particle system */
+                               dupli_render_particle_set(re, ob, timeoffset, 0, false);
+
                                if (duplilist_apply_data) {
                                        duplilist_restore(duplilist, duplilist_apply_data);
                                        duplilist_free_apply_data(duplilist_apply_data);