From f688e3cc3130e70e77f0bb050cd71cf1549c765c Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 1 Apr 2022 13:45:02 -0500 Subject: Cleanup: Use const for bounding boxes where possible --- source/blender/blenkernel/intern/object.cc | 18 +++++++++--------- source/blender/blenkernel/intern/rigidbody.c | 5 ++--- source/blender/draw/engines/eevee/eevee_shadows.c | 2 +- .../blender/draw/engines/eevee/eevee_shadows_cascade.c | 2 +- source/blender/draw/engines/eevee/eevee_volumes.c | 2 +- .../blender/draw/engines/gpencil/gpencil_cache_utils.c | 2 +- source/blender/draw/engines/overlay/overlay_extra.c | 7 +++---- source/blender/draw/engines/overlay/overlay_outline.c | 2 +- source/blender/draw/engines/select/select_draw_utils.c | 2 +- .../blender/draw/engines/workbench/workbench_shadow.c | 8 ++++---- source/blender/editors/sculpt_paint/sculpt.c | 2 +- source/blender/editors/space_view3d/space_view3d.c | 2 +- .../blender/editors/transform/transform_snap_object.cc | 4 ++-- .../gpencil_modifiers/intern/MOD_gpencilarray.c | 2 +- .../gpencil_modifiers/intern/lineart/lineart_cpu.c | 2 +- .../blender/io/alembic/exporter/abc_writer_abstract.cc | 2 +- source/blender/makesrna/intern/rna_object.c | 2 +- source/blender/makesrna/intern/rna_object_api.c | 2 +- .../blender/modifiers/intern/MOD_meshsequencecache.cc | 2 +- source/blender/render/intern/texture_pointdensity.c | 2 +- 20 files changed, 35 insertions(+), 37 deletions(-) diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 6c232fa8bd9..b37cf7db739 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -3705,7 +3705,7 @@ bool BKE_object_boundbox_calc_from_evaluated_geometry(Object *ob) void BKE_object_dimensions_get(Object *ob, float r_vec[3]) { - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { float scale[3]; @@ -3726,7 +3726,7 @@ void BKE_object_dimensions_set_ex(Object *ob, const float ob_scale_orig[3], const float ob_obmat_orig[4][4]) { - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { float len[3]; @@ -3767,19 +3767,19 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us case OB_CURVES_LEGACY: case OB_FONT: case OB_SURF: { - BoundBox bb = *BKE_curve_boundbox_get(ob); + const BoundBox bb = *BKE_curve_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; } case OB_MESH: { - BoundBox bb = *BKE_mesh_boundbox_get(ob); + const BoundBox bb = *BKE_mesh_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; } case OB_GPENCIL: { - BoundBox bb = *BKE_gpencil_boundbox_get(ob); + const BoundBox bb = *BKE_gpencil_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; @@ -3815,20 +3815,20 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us break; } case OB_CURVES: { - BoundBox bb = *BKE_curves_boundbox_get(ob); + const BoundBox bb = *BKE_curves_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; } case OB_POINTCLOUD: { - BoundBox bb = *BKE_pointcloud_boundbox_get(ob); + const BoundBox bb = *BKE_pointcloud_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; } case OB_VOLUME: { - BoundBox bb = *BKE_volume_boundbox_get(ob); + const BoundBox bb = *BKE_volume_boundbox_get(ob); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max); changed = true; break; @@ -3950,7 +3950,7 @@ bool BKE_object_minmax_dupli(Depsgraph *depsgraph, /* Do not modify the original boundbox. */ temp_ob.runtime.bb = nullptr; BKE_object_replace_data_on_shallow_copy(&temp_ob, dob->ob_data); - BoundBox *bb = BKE_object_boundbox_get(&temp_ob); + const BoundBox *bb = BKE_object_boundbox_get(&temp_ob); if (bb) { int i; diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index c21b525f628..60cc4ce83af 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -473,7 +473,6 @@ static rbCollisionShape *rigidbody_validate_sim_shape_helper(RigidBodyWorld *rbw { RigidBodyOb *rbo = ob->rigidbody_object; rbCollisionShape *new_shape = NULL; - BoundBox *bb = NULL; float size[3] = {1.0f, 1.0f, 1.0f}; float radius = 1.0f; float height = 1.0f; @@ -494,7 +493,7 @@ static rbCollisionShape *rigidbody_validate_sim_shape_helper(RigidBodyWorld *rbw */ /* XXX: all dimensions are auto-determined now... later can add stored settings for this */ /* get object dimensions without scaling */ - bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { size[0] = (bb->vec[4][0] - bb->vec[0][0]); size[1] = (bb->vec[2][1] - bb->vec[0][1]); @@ -1678,7 +1677,7 @@ static void rigidbody_update_sim_ob( if (mesh) { MVert *mvert = mesh->mvert; int totvert = mesh->totvert; - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); RB_shape_trimesh_update(rbo->shared->physics_shape, (float *)mvert, diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c index 29d98f6795d..9e571b1d15b 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows.c +++ b/source/blender/draw/engines/eevee/eevee_shadows.c @@ -147,7 +147,7 @@ void EEVEE_shadows_caster_register(EEVEE_ViewLayerData *sldata, Object *ob) } /* Update World AABB in frontbuffer. */ - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); float min[3], max[3]; INIT_MINMAX(min, max); for (int i = 0; i < 8; i++) { diff --git a/source/blender/draw/engines/eevee/eevee_shadows_cascade.c b/source/blender/draw/engines/eevee/eevee_shadows_cascade.c index 25939926cfa..536242f67d8 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows_cascade.c +++ b/source/blender/draw/engines/eevee/eevee_shadows_cascade.c @@ -311,7 +311,7 @@ static void eevee_shadow_cascade_setup(EEVEE_LightsInfo *linfo, if (c < 3) { dbg_col[c] = 1.0f; } - DRW_debug_bbox((BoundBox *)&corners, dbg_col); + DRW_debug_bbox((const BoundBox *)&corners, dbg_col); DRW_debug_sphere(center, csm_render->radius[c], dbg_col); #endif diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 6ef58c90e7a..7d210f15d8b 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -346,7 +346,7 @@ static bool eevee_volume_object_grids_init(Object *ob, ListBase *gpu_grids, DRWS if (multiple_transforms) { /* For multiple grids with different transform, we first transform from object space * to bounds, then for each individual grid from bounds to texture. */ - BoundBox *bb = BKE_volume_boundbox_get(ob); + const BoundBox *bb = BKE_volume_boundbox_get(ob); float bb_size[3]; sub_v3_v3v3(bb_size, bb->vec[6], bb->vec[0]); size_to_mat4(bounds_to_object, bb_size); diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index be35660a4d7..40ebd262df5 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -60,7 +60,7 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_PrivateData *pd, Object *ob) * strokes not aligned with the object axes. Maybe we could try to * compute the minimum axis of all strokes. But this would be more * computationally heavy and should go into the GPData evaluation. */ - BoundBox *bbox = BKE_object_boundbox_get(ob); + const BoundBox *bbox = BKE_object_boundbox_get(ob); /* Convert bbox to matrix */ float mat[4][4], size[3], center[3]; BKE_boundbox_calc_size_aabb(bbox, size); diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index 9953480e7fa..4f0bf0b8048 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -345,18 +345,17 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, bool around_origin) { float center[3], size[3], tmp[4][4], final_mat[4][4]; - BoundBox bb_local; if (ob->type == OB_MBALL && !BKE_mball_is_basis(ob)) { return; } - BoundBox *bb = BKE_object_boundbox_get(ob); - + const BoundBox *bb = BKE_object_boundbox_get(ob); + BoundBox bb_local; if (bb == NULL) { const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; + BKE_boundbox_init_from_minmax(&bb_local, min, max); bb = &bb_local; - BKE_boundbox_init_from_minmax(bb, min, max); } BKE_boundbox_calc_size_aabb(bb, size); diff --git a/source/blender/draw/engines/overlay/overlay_outline.c b/source/blender/draw/engines/overlay/overlay_outline.c index cb94008f53f..8010319e3fa 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.c +++ b/source/blender/draw/engines/overlay/overlay_outline.c @@ -32,7 +32,7 @@ static void gpencil_depth_plane(Object *ob, float r_plane[4]) * strokes not aligned with the object axes. Maybe we could try to * compute the minimum axis of all strokes. But this would be more * computationally heavy and should go into the GPData evaluation. */ - BoundBox *bbox = BKE_object_boundbox_get(ob); + const BoundBox *bbox = BKE_object_boundbox_get(ob); /* Convert bbox to matrix */ float mat[4][4], size[3], center[3]; BKE_boundbox_calc_size_aabb(bbox, size); diff --git a/source/blender/draw/engines/select/select_draw_utils.c b/source/blender/draw/engines/select/select_draw_utils.c index 7615b5bb39c..613b60f8829 100644 --- a/source/blender/draw/engines/select/select_draw_utils.c +++ b/source/blender/draw/engines/select/select_draw_utils.c @@ -31,7 +31,7 @@ void select_id_object_min_max(Object *obj, float r_min[3], float r_max[3]) { - BoundBox *bb; + const BoundBox *bb; BMEditMesh *em = BKE_editmesh_from_object(obj); if (em) { bb = BKE_editmesh_cage_boundbox_get(obj, em); diff --git a/source/blender/draw/engines/workbench/workbench_shadow.c b/source/blender/draw/engines/workbench/workbench_shadow.c index 432e571d74b..588c7240ab2 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.c +++ b/source/blender/draw/engines/workbench/workbench_shadow.c @@ -166,7 +166,7 @@ void workbench_shadow_cache_init(WORKBENCH_Data *data) } } -static BoundBox *workbench_shadow_object_shadow_bbox_get(WORKBENCH_PrivateData *wpd, +static const BoundBox *workbench_shadow_object_shadow_bbox_get(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed) { @@ -178,7 +178,7 @@ static BoundBox *workbench_shadow_object_shadow_bbox_get(WORKBENCH_PrivateData * INIT_MINMAX(oed->shadow_min, oed->shadow_max); /* From object space to shadow space */ - BoundBox *bbox = BKE_object_boundbox_get(ob); + const BoundBox *bbox = BKE_object_boundbox_get(ob); for (int i = 0; i < 8; i++) { float corner[3]; mul_v3_m4v3(corner, tmp_mat, bbox->vec[i]); @@ -203,7 +203,7 @@ static bool workbench_shadow_object_cast_visible_shadow(WORKBENCH_PrivateData *w Object *ob, WORKBENCH_ObjectData *oed) { - BoundBox *shadow_bbox = workbench_shadow_object_shadow_bbox_get(wpd, ob, oed); + const BoundBox *shadow_bbox = workbench_shadow_object_shadow_bbox_get(wpd, ob, oed); const DRWView *default_view = DRW_view_default_get(); return DRW_culling_box_test(default_view, shadow_bbox); } @@ -212,7 +212,7 @@ static float workbench_shadow_object_shadow_distance(WORKBENCH_PrivateData *wpd, Object *ob, WORKBENCH_ObjectData *oed) { - BoundBox *shadow_bbox = workbench_shadow_object_shadow_bbox_get(wpd, ob, oed); + const BoundBox *shadow_bbox = workbench_shadow_object_shadow_bbox_get(wpd, ob, oed); const int corners[4] = {0, 3, 4, 7}; float dist = 1e4f, dist_isect; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index be105a23a84..3644c3177d3 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3699,7 +3699,7 @@ static void do_tiled( SculptSession *ss = ob->sculpt; StrokeCache *cache = ss->cache; const float radius = cache->radius; - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); const float *bbMin = bb->vec[0]; const float *bbMax = bb->vec[6]; const float *step = sd->paint.tile_offset; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 2b613d0206e..3f2fbb97de1 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -702,7 +702,7 @@ static void view3d_ob_drop_matrix_from_snap(V3DSnapCursorState *snap_state, mat4_to_size(scale, ob->obmat); rescale_m4(obmat_final, scale); - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { float offset[3]; BKE_boundbox_calc_center_aabb(bb, offset); diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 3ef5056de85..21f3a42e278 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -718,7 +718,7 @@ static bool raycastMesh(SnapObjectContext *sctx, } /* Test BoundBox */ - BoundBox *bb = BKE_object_boundbox_get(ob_eval); + const BoundBox *bb = BKE_object_boundbox_get(ob_eval); if (bb) { /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ if (!isect_ray_aabb_v3_simple( @@ -1866,7 +1866,7 @@ static short snapArmature(SnapObjectContext *sctx, if (is_editmode == false) { /* Test BoundBox */ - BoundBox *bb = BKE_armature_boundbox_get(ob_eval); + const BoundBox *bb = BKE_armature_boundbox_get(ob_eval); if (bb && !snap_bound_box_check_dist(bb->vec[0], bb->vec[6], lpmat, diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c index fba83579ab1..1ceda0b334b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c @@ -132,7 +132,7 @@ static void generate_geometry(GpencilModifierData *md, /* Get bounbox for relative offset. */ float size[3] = {0.0f, 0.0f, 0.0f}; if (mmd->flag & GP_ARRAY_USE_RELATIVE) { - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; BKE_boundbox_init_from_minmax(bb, min, max); BKE_boundbox_calc_size_aabb(bb, size); diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index c28dfb082ba..08737c19eef 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -2095,7 +2095,7 @@ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], double shift_y, Object *use_ob) { - BoundBox *bb = BKE_object_boundbox_get(use_ob); + const BoundBox *bb = BKE_object_boundbox_get(use_ob); if (!bb) { /* For lights and empty stuff there will be no bbox. */ return false; diff --git a/source/blender/io/alembic/exporter/abc_writer_abstract.cc b/source/blender/io/alembic/exporter/abc_writer_abstract.cc index c277e5e2710..6c50583ad62 100644 --- a/source/blender/io/alembic/exporter/abc_writer_abstract.cc +++ b/source/blender/io/alembic/exporter/abc_writer_abstract.cc @@ -98,7 +98,7 @@ const Imath::Box3d &ABCAbstractWriter::bounding_box() const void ABCAbstractWriter::update_bounding_box(Object *object) { - BoundBox *bb = BKE_object_boundbox_get(object); + const BoundBox *bb = BKE_object_boundbox_get(object); if (!bb) { if (object->type != OB_CAMERA) { diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 3334022e202..e4495df36f1 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1971,7 +1971,7 @@ static void rna_Object_shaderfx_clear(Object *object, bContext *C) static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) { Object *ob = (Object *)ptr->owner_id; - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { memcpy(values, bb->vec, sizeof(bb->vec)); } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index ece1c5e5815..6967f78026a 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -594,7 +594,7 @@ static void rna_Object_ray_cast(Object *ob, } /* Test BoundBox first (efficiency) */ - BoundBox *bb = BKE_object_boundbox_get(ob); + const BoundBox *bb = BKE_object_boundbox_get(ob); float distmin; /* Needed for valid distance check from #isect_ray_aabb_v3_simple() call. */ diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.cc b/source/blender/modifiers/intern/MOD_meshsequencecache.cc index 1abe34ecc55..eadfdcf5baa 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.cc +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.cc @@ -106,7 +106,7 @@ static bool isDisabled(const struct Scene *UNUSED(scene), static Mesh *generate_bounding_box_mesh(Object *object, Mesh *org_mesh) { - BoundBox *bb = BKE_object_boundbox_get(object); + const BoundBox *bb = BKE_object_boundbox_get(object); Mesh *result = BKE_mesh_new_nomain_from_template(org_mesh, 8, 0, 0, 24, 6); MVert *mvert = result->mvert; diff --git a/source/blender/render/intern/texture_pointdensity.c b/source/blender/render/intern/texture_pointdensity.c index f81b43f4bb0..bb313d4962c 100644 --- a/source/blender/render/intern/texture_pointdensity.c +++ b/source/blender/render/intern/texture_pointdensity.c @@ -843,7 +843,7 @@ void RE_point_density_minmax(struct Depsgraph *depsgraph, } else { const float radius[3] = {pd->radius, pd->radius, pd->radius}; - BoundBox *bb = BKE_object_boundbox_get(object); + const BoundBox *bb = BKE_object_boundbox_get(object); if (bb != NULL) { BLI_assert((bb->flag & BOUNDBOX_DIRTY) == 0); -- cgit v1.2.3