diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-09-07 13:45:58 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-09-07 13:48:22 +0300 |
commit | bcc863993adfe019454d2da014528ac922fffd41 (patch) | |
tree | 53c09e1db00b815d45fb9e8f40f94f783bfac691 /source/blender/blenkernel/intern/particle.c | |
parent | 1263965f83b15e774ab83255030cf25768de5838 (diff) |
Fix T49273: Crash during access to dupli weights at launch time.
See commit's comments for details, but this boils down to: do not try to use
purely runtime cache data as a 'real' ID pointer in readcode, it's likely
doomed to fail in some cases, and is bad practice in any case!
Thix fix implies dupliweight's object will be invalid until first scene update
(i.e. first particles evaluation).
Diffstat (limited to 'source/blender/blenkernel/intern/particle.c')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index aecaf8537bb..907521c9677 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -318,16 +318,24 @@ void psys_check_group_weights(ParticleSettings *part) int current = 0; if (part->ren_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first) { - /* first remove all weights that don't have an object in the group */ + /* First try to find NULL objects from their index, + * and remove all weights that don't have an object in the group. */ dw = part->dupliweights.first; while (dw) { - if (!BKE_group_object_exists(part->dup_group, dw->ob)) { - tdw = dw->next; - BLI_freelinkN(&part->dupliweights, dw); - dw = tdw; + if (dw->ob == NULL || !BKE_group_object_exists(part->dup_group, dw->ob)) { + GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index); + if (go) { + dw->ob = go->ob; + } + else { + tdw = dw->next; + BLI_freelinkN(&part->dupliweights, dw); + dw = tdw; + } } - else + else { dw = dw->next; + } } /* then add objects in the group to new list */ |