Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/particle.c
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "BKE_anim.h" | #include "BKE_anim.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_boids.h" | #include "BKE_boids.h" | ||||
| #include "BKE_cloth.h" | #include "BKE_cloth.h" | ||||
| #include "BKE_collection.h" | |||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_effect.h" | #include "BKE_effect.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_group.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_displist.h" | #include "BKE_displist.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_library.h" | #include "BKE_library.h" | ||||
| ▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | else | ||||
| return (psys->pointcache->edit && psys->pointcache->edit->edited); | return (psys->pointcache->edit && psys->pointcache->edit->edited); | ||||
| } | } | ||||
| void psys_check_group_weights(ParticleSettings *part) | void psys_check_group_weights(ParticleSettings *part) | ||||
| { | { | ||||
| ParticleDupliWeight *dw, *tdw; | ParticleDupliWeight *dw, *tdw; | ||||
| int current = 0; | int current = 0; | ||||
| if (part->ren_as == PART_DRAW_GR && part->dup_group && part->dup_group->view_layer->object_bases.first) { | if (part->ren_as != PART_DRAW_GR || !part->dup_group) { | ||||
| BLI_freelistN(&part->dupliweights); | |||||
| return; | |||||
| } | |||||
| const ListBase dup_group_objects = BKE_collection_object_cache_get(part->dup_group); | |||||
| if (dup_group_objects.first) { | |||||
| /* First try to find NULL objects from their index, | /* First try to find NULL objects from their index, | ||||
| * and remove all weights that don't have an object in the group. */ | * and remove all weights that don't have an object in the group. */ | ||||
| dw = part->dupliweights.first; | dw = part->dupliweights.first; | ||||
| while (dw) { | while (dw) { | ||||
| if (dw->ob == NULL || !BKE_group_object_exists(part->dup_group, dw->ob)) { | if (dw->ob == NULL || !BKE_collection_has_object_recursive(part->dup_group, dw->ob)) { | ||||
| Base *base = BLI_findlink(&part->dup_group->view_layer->object_bases, dw->index); | Base *base = BLI_findlink(&dup_group_objects, dw->index); | ||||
| if (base != NULL) { | if (base != NULL) { | ||||
| dw->ob = base->object; | dw->ob = base->object; | ||||
| } | } | ||||
| else { | else { | ||||
| tdw = dw->next; | tdw = dw->next; | ||||
| BLI_freelinkN(&part->dupliweights, dw); | BLI_freelinkN(&part->dupliweights, dw); | ||||
| dw = tdw; | dw = tdw; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| dw = dw->next; | dw = dw->next; | ||||
| } | } | ||||
| } | } | ||||
| /* then add objects in the group to new list */ | /* then add objects in the group to new list */ | ||||
| FOREACH_GROUP_OBJECT_BEGIN(part->dup_group, object) | FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(part->dup_group, object) | ||||
| { | { | ||||
| dw = part->dupliweights.first; | dw = part->dupliweights.first; | ||||
| while (dw && dw->ob != object) { | while (dw && dw->ob != object) { | ||||
| dw = dw->next; | dw = dw->next; | ||||
| } | } | ||||
| if (!dw) { | if (!dw) { | ||||
| dw = MEM_callocN(sizeof(ParticleDupliWeight), "ParticleDupliWeight"); | dw = MEM_callocN(sizeof(ParticleDupliWeight), "ParticleDupliWeight"); | ||||
| dw->ob = object; | dw->ob = object; | ||||
| dw->count = 1; | dw->count = 1; | ||||
| BLI_addtail(&part->dupliweights, dw); | BLI_addtail(&part->dupliweights, dw); | ||||
| } | } | ||||
| } | } | ||||
| FOREACH_GROUP_OBJECT_END; | FOREACH_COLLECTION_OBJECT_RECURSIVE_END; | ||||
| dw = part->dupliweights.first; | dw = part->dupliweights.first; | ||||
| for (; dw; dw = dw->next) { | for (; dw; dw = dw->next) { | ||||
| if (dw->flag & PART_DUPLIW_CURRENT) { | if (dw->flag & PART_DUPLIW_CURRENT) { | ||||
| current = 1; | current = 1; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 3,870 Lines • Show Last 20 Lines | |||||