Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object_dupli.c
| Show First 20 Lines • Show All 816 Lines • ▼ Show 20 Lines | if ((for_render || part->draw_as == PART_DRAW_REND) && | ||||
| RNG *rng = BLI_rng_new_srandom(31415926u + (unsigned int)psys->seed); | RNG *rng = BLI_rng_new_srandom(31415926u + (unsigned int)psys->seed); | ||||
| psys->lattice_deform_data = psys_create_lattice_deform_data(&sim); | psys->lattice_deform_data = psys_create_lattice_deform_data(&sim); | ||||
| /* gather list of objects or single object */ | /* gather list of objects or single object */ | ||||
| int totcollection = 0; | 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->ren_as == PART_DRAW_GR) { | ||||
| if (part->draw & PART_DRAW_COUNT_GR) { | if (use_collection_count) { | ||||
| psys_find_group_weights(part); | psys_find_group_weights(part); | ||||
| for (dw = part->instance_weights.first; dw; dw = dw->next) { | for (dw = part->instance_weights.first; dw; dw = dw->next) { | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( | ||||
| part->instance_collection, object, mode) { | part->instance_collection, object, mode) { | ||||
| if (dw->ob == object) { | if (dw->ob == object) { | ||||
| totcollection += dw->count; | totcollection += dw->count; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( | ||||
| part->instance_collection, object, mode) { | part->instance_collection, object, mode) { | ||||
| (void)object; | (void)object; | ||||
| totcollection++; | totcollection++; | ||||
| } | } | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END; | ||||
| } | } | ||||
| oblist = MEM_callocN((size_t)totcollection * sizeof(Object *), "dupcollection object list"); | oblist = MEM_callocN((size_t)totcollection * sizeof(Object *), "dupcollection object list"); | ||||
| if (part->draw & PART_DRAW_COUNT_GR) { | if (use_collection_count) { | ||||
| a = 0; | a = 0; | ||||
| for (dw = part->instance_weights.first; dw; dw = dw->next) { | for (dw = part->instance_weights.first; dw; dw = dw->next) { | ||||
| FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( | FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN ( | ||||
| part->instance_collection, object, mode) { | part->instance_collection, object, mode) { | ||||
| if (dw->ob == object) { | if (dw->ob == object) { | ||||
| for (b = 0; b < dw->count; b++, a++) { | for (b = 0; b < dw->count; b++, a++) { | ||||
| oblist[a] = dw->ob; | oblist[a] = dw->ob; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | for (pa = psys->particles; a < totpart + totchild; a++, pa++) { | ||||
| if (part->ren_as == PART_DRAW_GR) { | if (part->ren_as == PART_DRAW_GR) { | ||||
| /* prevent divide by zero below [#28336] */ | /* prevent divide by zero below [#28336] */ | ||||
| if (totcollection == 0) { | if (totcollection == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* for collections, pick the object based on settings */ | /* 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; | b = BLI_rng_get_int(rng) % totcollection; | ||||
| } | } | ||||
| else { | else { | ||||
| b = a % totcollection; | b = a % totcollection; | ||||
| } | } | ||||
| ob = oblist[b]; | ob = oblist[b]; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 205 Lines • Show Last 20 Lines | |||||