[Bf-blender-cvs] [a13b1b18def] master: Fix T69702: crash using particles rendered as whole collection

Philipp Oeser noreply at git.blender.org
Tue Sep 10 15:42:51 CEST 2019


Commit: a13b1b18def05a2cc73ab05327412215da632389
Author: Philipp Oeser
Date:   Tue Sep 10 14:14:52 2019 +0200
Branches: master
https://developer.blender.org/rBa13b1b18def05a2cc73ab05327412215da632389

Fix T69702: crash using particles rendered as whole collection

This happened when the 'Whole Collection' option was enabled next to the
'Use Count' option. These two are exclusive but some code paths only
checked for 'Use Count'.

Reviewers: brecht

Maniphest Tasks: T69702

Differential Revision: https://developer.blender.org/D5741

===================================================================

M	source/blender/blenkernel/intern/object_dupli.c

===================================================================

diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index 7983fe54be5..8ffb99dd8ab 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -822,8 +822,10 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
     /* gather list of objects or single object */
     int totcollection = 0;
 
+    const bool use_whole_collection = part->draw & PART_DRAW_WHOLE_GR;
+    const bool use_collection_count = part->draw & PART_DRAW_COUNT_GR && !use_whole_collection;
     if (part->ren_as == PART_DRAW_GR) {
-      if (part->draw & PART_DRAW_COUNT_GR) {
+      if (use_collection_count) {
         psys_find_group_weights(part);
 
         for (dw = part->instance_weights.first; dw; dw = dw->next) {
@@ -848,7 +850,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
 
       oblist = MEM_callocN((size_t)totcollection * sizeof(Object *), "dupcollection object list");
 
-      if (part->draw & PART_DRAW_COUNT_GR) {
+      if (use_collection_count) {
         a = 0;
         for (dw = part->instance_weights.first; dw; dw = dw->next) {
           FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (
@@ -916,7 +918,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
         }
 
         /* for collections, pick the object based on settings */
-        if (part->draw & PART_DRAW_RAND_GR) {
+        if (part->draw & PART_DRAW_RAND_GR && !use_whole_collection) {
           b = BLI_rng_get_int(rng) % totcollection;
         }
         else {



More information about the Bf-blender-cvs mailing list