diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-11-25 19:16:11 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-11-25 20:49:57 +0300 |
commit | 5f6fae9ad0bdb4184fb430d533dbbdec9c3da67f (patch) | |
tree | 6462e37a074cf0eb6f99d0f167114f52a019d83d /source/blender/blenkernel/intern/mesh.c | |
parent | 5e5db7db896fa6ef31736ca2e42f344c494c2e92 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/mesh.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 0942cb071a3..432d1fbc85b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -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]) |