diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-02-17 04:24:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-02-17 04:52:53 +0300 |
commit | ae2b677dcb5a70f5f58e1da56b4fcf15b12ef851 (patch) | |
tree | 93dd1b8a40c6eed9ca8c6845f443f503c142c968 /source/blender/blenkernel/intern | |
parent | 0d86259fc8a34c7ae3543008adc16e35d185fdbd (diff) |
Cleanup: move object bounding-box into runtime struct
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mball.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object_update.c | 6 |
9 files changed, 50 insertions, 48 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 99474ce9bae..c4462c7d479 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2466,10 +2466,10 @@ static void boundbox_armature(Object *ob) BoundBox *bb; float min[3], max[3]; - if (ob->bb == NULL) { - ob->bb = MEM_callocN(sizeof(BoundBox), "Armature boundbox"); + if (ob->runtime.bb == NULL) { + ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "Armature boundbox"); } - bb = ob->bb; + bb = ob->runtime.bb; INIT_MINMAX(min, max); if (!minmax_armature(ob, min, max)) { @@ -2486,7 +2486,7 @@ BoundBox *BKE_armature_boundbox_get(Object *ob) { boundbox_armature(ob); - return ob->bb; + return ob->runtime.bb; } bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 3be101134ec..6f44dcdecc5 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -319,21 +319,21 @@ void BKE_curve_boundbox_calc(Curve *cu, float r_loc[3], float r_size[3]) BoundBox *BKE_curve_boundbox_get(Object *ob) { /* 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) { + if (ob->runtime.bb == NULL || ob->runtime.bb->flag & BOUNDBOX_DIRTY) { Curve *cu = ob->data; float min[3], max[3]; INIT_MINMAX(min, max); BKE_curve_minmax(cu, true, min, max); - if (ob->bb == NULL) { - ob->bb = MEM_mallocN(sizeof(*ob->bb), __func__); + if (ob->runtime.bb == NULL) { + ob->runtime.bb = MEM_mallocN(sizeof(*ob->runtime.bb), __func__); } - BKE_boundbox_init_from_minmax(ob->bb, min, max); - ob->bb->flag &= ~BOUNDBOX_DIRTY; + BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); + ob->runtime.bb->flag &= ~BOUNDBOX_DIRTY; } - return ob->bb; + return ob->runtime.bb; } void BKE_curve_texspace_calc(Curve *cu) diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 0f3a3192d75..19ddb59acee 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1894,8 +1894,8 @@ static void boundbox_displist_object(Object *ob) */ /* object's BB is calculated from final displist */ - if (ob->bb == NULL) - ob->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + if (ob->runtime.bb == NULL) + ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "boundbox"); if (ob->runtime.mesh_eval) { BKE_object_boundbox_calc_from_mesh(ob, ob->runtime.mesh_eval); @@ -1905,9 +1905,9 @@ static void boundbox_displist_object(Object *ob) INIT_MINMAX(min, max); BKE_displist_minmax(&ob->runtime.curve_cache->disp, min, max); - BKE_boundbox_init_from_minmax(ob->bb, min, max); + BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); - ob->bb->flag &= ~BOUNDBOX_DIRTY; + ob->runtime.bb->flag &= ~BOUNDBOX_DIRTY; } } } diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index d2ca18ef231..83c69ee657f 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1111,11 +1111,11 @@ static void boundbox_gpencil(Object *ob) bGPdata *gpd; float min[3], max[3]; - if (ob->bb == NULL) { - ob->bb = MEM_callocN(sizeof(BoundBox), "GPencil boundbox"); + if (ob->runtime.bb == NULL) { + ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "GPencil boundbox"); } - bb = ob->bb; + bb = ob->runtime.bb; gpd = ob->data; BKE_gpencil_data_minmax(NULL, gpd, min, max); @@ -1133,15 +1133,15 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob) return NULL; gpd = ob->data; - if ((ob->bb) && ((ob->bb->flag & BOUNDBOX_DIRTY) == 0) && + if ((ob->runtime.bb) && ((ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) && ((gpd->flag & GP_DATA_CACHE_IS_DIRTY) == 0)) { - return ob->bb; + return ob->runtime.bb; } boundbox_gpencil(ob); - return ob->bb; + return ob->runtime.bb; } /* ************************************************** */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 4a974267950..f11c1cb134f 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1089,11 +1089,11 @@ static void boundbox_lattice(Object *ob) Lattice *lt; float min[3], max[3]; - if (ob->bb == NULL) { - ob->bb = MEM_callocN(sizeof(BoundBox), "Lattice boundbox"); + if (ob->runtime.bb == NULL) { + ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "Lattice boundbox"); } - bb = ob->bb; + bb = ob->runtime.bb; lt = ob->data; INIT_MINMAX(min, max); @@ -1107,7 +1107,7 @@ BoundBox *BKE_lattice_boundbox_get(Object *ob) { boundbox_lattice(ob); - return ob->bb; + return ob->runtime.bb; } void BKE_lattice_minmax_dl(Object *ob, Lattice *lt, float min[3], float max[3]) diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 10825a36ea6..14878cdf494 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -186,8 +186,10 @@ void BKE_mball_texspace_calc(Object *ob) int tot; bool do_it = false; - if (ob->bb == NULL) ob->bb = MEM_callocN(sizeof(BoundBox), "mb boundbox"); - bb = ob->bb; + if (ob->runtime.bb == NULL) { + ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "mb boundbox"); + } + bb = ob->runtime.bb; /* Weird one, this. */ /* INIT_MINMAX(min, max); */ @@ -222,8 +224,8 @@ BoundBox *BKE_mball_boundbox_get(Object *ob) { BLI_assert(ob->type == OB_MBALL); - if (ob->bb != NULL && (ob->bb->flag & BOUNDBOX_DIRTY) == 0) { - return ob->bb; + if (ob->runtime.bb != NULL && (ob->runtime.bb->flag & BOUNDBOX_DIRTY) == 0) { + return ob->runtime.bb; } /* This should always only be called with evaluated objects, but currently RNA is a problem here... */ @@ -231,7 +233,7 @@ BoundBox *BKE_mball_boundbox_get(Object *ob) BKE_mball_texspace_calc(ob); } - return ob->bb; + return ob->runtime.bb; } float *BKE_mball_make_orco(Object *ob, ListBase *dispbase) @@ -243,7 +245,7 @@ float *BKE_mball_make_orco(Object *ob, ListBase *dispbase) int a; /* restore size and loc */ - bb = ob->bb; + bb = ob->runtime.bb; loc[0] = (bb->vec[0][0] + bb->vec[4][0]) / 2.0f; size[0] = bb->vec[4][0] - loc[0]; loc[1] = (bb->vec[0][1] + bb->vec[2][1]) / 2.0f; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 9a725be302c..780712c8e25 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -897,7 +897,7 @@ void BKE_mesh_texspace_calc(Mesh *me) BoundBox *BKE_mesh_boundbox_get(Object *ob) { /* 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) { + if (ob->runtime.bb == NULL || ob->runtime.bb->flag & BOUNDBOX_DIRTY) { Mesh *me = ob->data; float min[3], max[3]; @@ -907,14 +907,14 @@ BoundBox *BKE_mesh_boundbox_get(Object *ob) max[0] = max[1] = max[2] = 1.0f; } - if (ob->bb == NULL) { - ob->bb = MEM_mallocN(sizeof(*ob->bb), __func__); + if (ob->runtime.bb == NULL) { + ob->runtime.bb = MEM_mallocN(sizeof(*ob->runtime.bb), __func__); } - BKE_boundbox_init_from_minmax(ob->bb, min, max); - ob->bb->flag &= ~BOUNDBOX_DIRTY; + BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); + ob->runtime.bb->flag &= ~BOUNDBOX_DIRTY; } - return ob->bb; + return ob->runtime.bb; } BoundBox *BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 91ecc8dd74a..8a50a93487a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -449,9 +449,9 @@ void BKE_object_free_derived_caches(Object *ob) } } - if (ob->bb) { - MEM_freeN(ob->bb); - ob->bb = NULL; + if (ob->runtime.bb) { + MEM_freeN(ob->runtime.bb); + ob->runtime.bb = NULL; } object_update_from_subsurf_ccg(ob); @@ -565,7 +565,7 @@ void BKE_object_free(Object *ob) MEM_SAFE_FREE(ob->mat); MEM_SAFE_FREE(ob->matbits); MEM_SAFE_FREE(ob->iuser); - MEM_SAFE_FREE(ob->bb); + MEM_SAFE_FREE(ob->runtime.bb); BLI_freelistN(&ob->defbase); BLI_freelistN(&ob->fmaps); @@ -1342,7 +1342,7 @@ void BKE_object_copy_data(Main *bmain, Object *ob_dst, const Object *ob_src, con if (ob_src->iuser) ob_dst->iuser = MEM_dupallocN(ob_src->iuser); - if (ob_src->bb) ob_dst->bb = MEM_dupallocN(ob_src->bb); + if (ob_src->runtime.bb) ob_dst->runtime.bb = MEM_dupallocN(ob_src->runtime.bb); BLI_listbase_clear(&ob_dst->modifiers); @@ -2447,13 +2447,13 @@ void BKE_object_boundbox_calc_from_mesh(struct Object *ob, struct Mesh *me_eval) zero_v3(max); } - if (ob->bb == NULL) { - ob->bb = MEM_callocN(sizeof(BoundBox), "DM-BoundBox"); + if (ob->runtime.bb == NULL) { + ob->runtime.bb = MEM_callocN(sizeof(BoundBox), "DM-BoundBox"); } - BKE_boundbox_init_from_minmax(ob->bb, min, max); + BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max); - ob->bb->flag &= ~BOUNDBOX_DIRTY; + ob->runtime.bb->flag &= ~BOUNDBOX_DIRTY; } void BKE_object_dimensions_get(Object *ob, float vec[3]) diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c index 59068dc4cd5..78c1ca6419b 100644 --- a/source/blender/blenkernel/intern/object_update.c +++ b/source/blender/blenkernel/intern/object_update.c @@ -258,10 +258,10 @@ void BKE_object_eval_boundbox(Depsgraph *depsgraph, Object *object) Object *ob_orig = DEG_get_original_object(object); BoundBox *bb = BKE_object_boundbox_get(object); if (bb != NULL) { - if (ob_orig->bb == NULL) { - ob_orig->bb = MEM_mallocN(sizeof(*ob_orig->bb), __func__); + if (ob_orig->runtime.bb == NULL) { + ob_orig->runtime.bb = MEM_mallocN(sizeof(*ob_orig->runtime.bb), __func__); } - *ob_orig->bb = *bb; + *ob_orig->runtime.bb = *bb; } } |