Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-17 04:24:08 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-17 04:52:53 +0300
commitae2b677dcb5a70f5f58e1da56b4fcf15b12ef851 (patch)
tree93dd1b8a40c6eed9ca8c6845f443f503c142c968 /source
parent0d86259fc8a34c7ae3543008adc16e35d185fdbd (diff)
Cleanup: move object bounding-box into runtime struct
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/armature.c8
-rw-r--r--source/blender/blenkernel/intern/curve.c12
-rw-r--r--source/blender/blenkernel/intern/displist.c8
-rw-r--r--source/blender/blenkernel/intern/gpencil.c12
-rw-r--r--source/blender/blenkernel/intern/lattice.c8
-rw-r--r--source/blender/blenkernel/intern/mball.c14
-rw-r--r--source/blender/blenkernel/intern/mesh.c12
-rw-r--r--source/blender/blenkernel/intern/object.c18
-rw-r--r--source/blender/blenkernel/intern/object_update.c6
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc2
-rw-r--r--source/blender/editors/object/object_transform.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c4
-rw-r--r--source/blender/makesdna/DNA_object_types.h18
15 files changed, 68 insertions, 66 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;
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index fcd745eeb1f..186bf613de5 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5654,7 +5654,7 @@ static void direct_link_object(FileData *fd, Object *ob)
BKE_object_empty_draw_type_set(ob, ob->empty_drawtype);
}
- ob->bb = NULL;
+ ob->runtime.bb = NULL;
ob->derivedDeform = NULL;
ob->derivedFinal = NULL;
BKE_object_runtime_reset(ob);
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
index 32212b0e1c1..597cc8cd2ef 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
@@ -885,7 +885,7 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
ListBase *gpumaterial_ptr = NULL;
DrawDataList drawdata_backup;
DrawDataList *drawdata_ptr = NULL;
- ObjectRuntimeBackup object_runtime_backup = {{NULL}};
+ ObjectRuntimeBackup object_runtime_backup = {{0}};
if (check_datablock_expanded(id_cow)) {
switch (id_type) {
case ID_MA:
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 24abafe7d0f..201e8a8ea16 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -1011,7 +1011,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Curve *cu = ob->data;
- if (ob->bb == NULL && (centermode != ORIGIN_TO_CURSOR)) {
+ if (ob->runtime.bb == NULL && (centermode != ORIGIN_TO_CURSOR)) {
/* do nothing*/
}
else {
@@ -1020,8 +1020,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
else {
/* extra 0.5 is the height o above line */
- cent[0] = 0.5f * (ob->bb->vec[4][0] + ob->bb->vec[0][0]);
- cent[1] = 0.5f * (ob->bb->vec[0][1] + ob->bb->vec[2][1]);
+ cent[0] = 0.5f * (ob->runtime.bb->vec[4][0] + ob->runtime.bb->vec[0][0]);
+ cent[1] = 0.5f * (ob->runtime.bb->vec[0][1] + ob->runtime.bb->vec[2][1]);
}
cent[2] = 0.0f;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index cf580e093fd..b84798581a0 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5045,11 +5045,11 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
/* Copy the PBVH bounding box into the object's bounding box */
void sculpt_update_object_bounding_box(Object *ob)
{
- if (ob->bb) {
+ if (ob->runtime.bb) {
float bb_min[3], bb_max[3];
BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max);
- BKE_boundbox_init_from_minmax(ob->bb, bb_min, bb_max);
+ BKE_boundbox_init_from_minmax(ob->runtime.bb, bb_min, bb_max);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 6994b048698..aaf1d8a01a3 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -295,10 +295,10 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
/* use the boundbox if we can */
Object *ob_eval = base_eval->object;
- if (ob_eval->bb && !(ob_eval->bb->flag & BOUNDBOX_DIRTY)) {
+ if (ob_eval->runtime.bb && !(ob_eval->runtime.bb->flag & BOUNDBOX_DIRTY)) {
float cent[3];
- BKE_boundbox_calc_center_aabb(ob_eval->bb, cent);
+ BKE_boundbox_calc_center_aabb(ob_eval->runtime.bb, cent);
mul_m4_v3(ob_eval->obmat, cent);
add_v3_v3(select_center, cent);
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index f951b7273c9..b79009e9d1d 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -122,6 +122,15 @@ struct ObjectBBoneDeform;
/* Not saved in file! */
typedef struct Object_Runtime {
/**
+ * The custom data layer mask that was last used
+ * to calculate mesh_eval and mesh_deform_eval.
+ */
+ uint64_t last_data_mask;
+
+ /** Axis aligned boundbox (in localspace). */
+ struct BoundBox *bb;
+
+ /**
* Original mesh pointer, before object->data was changed to point
* to mesh_eval.
* Is assigned by dependency graph's copy-on-write evaluation.
@@ -138,7 +147,6 @@ typedef struct Object_Runtime {
*/
struct Mesh *mesh_deform_eval;
-
/** Runtime evaluated curve-specific data, not stored in the file. */
struct CurveCache *curve_cache;
@@ -147,12 +155,6 @@ typedef struct Object_Runtime {
struct ObjectBBoneDeform *cached_bbone_deformation;
- /**
- * The custom data layer mask that was last used
- * to calculate mesh_eval and mesh_deform_eval.
- */
- uint64_t last_data_mask;
-
/** Did last modifier stack generation need mapping support? */
char last_need_mapping;
char pad[7];
@@ -179,8 +181,6 @@ typedef struct Object {
/** Old animation system, deprecated for 2.5. */
struct Ipo *ipo DNA_DEPRECATED;
/* struct Path *path; */
- /** Axis aligned boundbox (in localspace). */
- struct BoundBox *bb;
struct bAction *action DNA_DEPRECATED; // XXX deprecated... old animation system
struct bAction *poselib;
/** Pose data, armature objects only. */