Fix T57070, T57389, and other bbox-related issues with meshes.

Thinks whole bbox code needs a complete rewrite, one can see a lot of
old history in it, it has way too many functions doing
nearly-the-same-thing(c), it spreads in very inconsistent ways across a
lot of files, ... But have no time for this right now, and would not be
a good idea with Beta comming up close anyway.

So for now going the simple and (hopefully) sane & safe way: forbid
object-level functions to affect data-level bbox. Mesh and curve ones
would generate bbox in obdata instead of object, for some reason (all
other obdata types only use object's bbox ever). That may have been
working in old ages, but with CoW and threaded depsgraph this is just
calling for piles of issues.
This commit is contained in:
Bastien Montagne 2018-11-25 17:16:11 +01:00
parent 5e5db7db89
commit 5f6fae9ad0
Notes: blender-bot 2023-02-14 05:14:10 +01:00
Referenced by issue #57389, Culling not working correctly when using array modifier
Referenced by issue #57070, 2.8 Crash in sculpting mode with tilling and Dyntopo
2 changed files with 24 additions and 12 deletions

View File

@ -325,16 +325,22 @@ void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3])
BoundBox *BKE_curve_boundbox_get(Object *ob)
{
Curve *cu = ob->data;
/* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
if (ob->bb == NULL || ob->bb->flag & BOUNDBOX_DIRTY) {
Curve *cu = ob->data;
float min[3], max[3];
if (ob->bb)
return ob->bb;
INIT_MINMAX(min, max);
BKE_curve_minmax(cu, true, min, max);
if (cu->bb == NULL || (cu->bb->flag & BOUNDBOX_DIRTY)) {
BKE_curve_texspace_calc(cu);
if (ob->bb == NULL) {
ob->bb = MEM_mallocN(sizeof(*ob->bb), __func__);
}
BKE_boundbox_init_from_minmax(ob->bb, min, max);
ob->bb->flag &= ~BOUNDBOX_DIRTY;
}
return cu->bb;
return ob->bb;
}
void BKE_curve_texspace_calc(Curve *cu)

View File

@ -914,16 +914,22 @@ void BKE_mesh_texspace_calc(Mesh *me)
BoundBox *BKE_mesh_boundbox_get(Object *ob)
{
Mesh *me = ob->data;
/* This is Object-level data access, DO NOT touch to Mesh's bb, would be totally thread-unsafe. */
if (ob->bb == NULL || ob->bb->flag & BOUNDBOX_DIRTY) {
Mesh *me = ob->data;
float min[3], max[3];
if (ob->bb)
return ob->bb;
INIT_MINMAX(min, max);
BKE_mesh_minmax(me, min, max);
if (me->bb == NULL || (me->bb->flag & BOUNDBOX_DIRTY)) {
BKE_mesh_texspace_calc(me);
if (ob->bb == NULL) {
ob->bb = MEM_mallocN(sizeof(*ob->bb), __func__);
}
BKE_boundbox_init_from_minmax(ob->bb, min, max);
ob->bb->flag &= ~BOUNDBOX_DIRTY;
}
return me->bb;
return ob->bb;
}
BoundBox *BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3])