Fix T79651: Bounding box is wrong after duplicate object

The bounding box is not updated in the original object when the function is called using evaluated object and keeps wrong while the object is not edited or the file saved.

Reviewed By: mont29

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

Notes: Minor changes done in the patch following review comments.
This commit is contained in:
Antonio Vazquez 2020-09-14 15:26:17 +02:00
parent ec6d32b238
commit 6aeafacf86
Notes: blender-bot 2023-02-14 09:48:23 +01:00
Referenced by issue #79651, Grease Pencil: close shapes do Z-fighting (wrong overlapping) until stroke refreshment.
1 changed files with 13 additions and 0 deletions

View File

@ -185,6 +185,19 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob)
boundbox_gpencil(ob);
Object *ob_orig = (Object *)DEG_get_original_id(&ob->id);
/* Update orig object's boundbox with re-computed evaluated values. This function can be
* called with the evaluated object and need update the original object bound box data
* to keep both values synchronized. */
if ((ob_orig != NULL) && (ob != ob_orig)) {
if (ob_orig->runtime.bb == NULL) {
ob_orig->runtime.bb = MEM_callocN(sizeof(BoundBox), "GPencil boundbox");
}
for (int i = 0; i < 8; i++) {
copy_v3_v3(ob_orig->runtime.bb->vec[i], ob->runtime.bb->vec[i]);
}
}
return ob->runtime.bb;
}