Fix (unreported) asserts in `make_object_duplilist_real()`.
Code would try to add multiple time the same key in `parent_gh` (for this ghash a lot of dupliobjects may generate same key). Was making the tool unusable in debug builds. Also optimise things a bit by avoiding creating parent_gh when only `use_base_parent` is set.
This commit is contained in:
parent
4e5d251ccb
commit
17fb504bcf
|
@ -1307,7 +1307,9 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
|
|||
|
||||
if (use_hierarchy || use_base_parent) {
|
||||
dupli_gh = BLI_ghash_ptr_new(__func__);
|
||||
parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
|
||||
if (use_hierarchy) {
|
||||
parent_gh = BLI_ghash_new(dupliobject_hash, dupliobject_cmp, __func__);
|
||||
}
|
||||
}
|
||||
|
||||
for (dob = lb->first; dob; dob = dob->next) {
|
||||
|
@ -1344,10 +1346,17 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
|
|||
copy_m4_m4(ob->obmat, dob->mat);
|
||||
BKE_object_apply_mat4(ob, ob->obmat, false, false);
|
||||
|
||||
if (dupli_gh)
|
||||
if (dupli_gh) {
|
||||
BLI_ghash_insert(dupli_gh, dob, ob);
|
||||
if (parent_gh)
|
||||
BLI_ghash_insert(parent_gh, dob, ob);
|
||||
}
|
||||
if (parent_gh) {
|
||||
void **val;
|
||||
/* Due to nature of hash/comparison of this ghash, a lot of duplis may be considered as 'the same',
|
||||
* this avoids trying to insert same key several time and raise asserts in debug builds... */
|
||||
if (!BLI_ghash_ensure_p(parent_gh, dob, &val)) {
|
||||
*val = ob;
|
||||
}
|
||||
}
|
||||
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue