Cleanup: Use const for bounding boxes where possible

This commit is contained in:
2022-04-01 13:45:02 -05:00
parent 999f6526b1
commit f688e3cc31
20 changed files with 35 additions and 37 deletions

View File

@@ -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]) 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) { if (bb) {
float scale[3]; float scale[3];
@@ -3726,7 +3726,7 @@ void BKE_object_dimensions_set_ex(Object *ob,
const float ob_scale_orig[3], const float ob_scale_orig[3],
const float ob_obmat_orig[4][4]) const float ob_obmat_orig[4][4])
{ {
BoundBox *bb = BKE_object_boundbox_get(ob); const BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) { if (bb) {
float len[3]; 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_CURVES_LEGACY:
case OB_FONT: case OB_FONT:
case OB_SURF: { 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); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max);
changed = true; changed = true;
break; break;
} }
case OB_MESH: { 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); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max);
changed = true; changed = true;
break; break;
} }
case OB_GPENCIL: { 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); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max);
changed = true; changed = true;
break; break;
@@ -3815,20 +3815,20 @@ void BKE_object_minmax(Object *ob, float r_min[3], float r_max[3], const bool us
break; break;
} }
case OB_CURVES: { 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); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max);
changed = true; changed = true;
break; break;
} }
case OB_POINTCLOUD: { 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); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max);
changed = true; changed = true;
break; break;
} }
case OB_VOLUME: { 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); BKE_boundbox_minmax(&bb, ob->obmat, r_min, r_max);
changed = true; changed = true;
break; break;
@@ -3950,7 +3950,7 @@ bool BKE_object_minmax_dupli(Depsgraph *depsgraph,
/* Do not modify the original boundbox. */ /* Do not modify the original boundbox. */
temp_ob.runtime.bb = nullptr; temp_ob.runtime.bb = nullptr;
BKE_object_replace_data_on_shallow_copy(&temp_ob, dob->ob_data); 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) { if (bb) {
int i; int i;

View File

@@ -473,7 +473,6 @@ static rbCollisionShape *rigidbody_validate_sim_shape_helper(RigidBodyWorld *rbw
{ {
RigidBodyOb *rbo = ob->rigidbody_object; RigidBodyOb *rbo = ob->rigidbody_object;
rbCollisionShape *new_shape = NULL; rbCollisionShape *new_shape = NULL;
BoundBox *bb = NULL;
float size[3] = {1.0f, 1.0f, 1.0f}; float size[3] = {1.0f, 1.0f, 1.0f};
float radius = 1.0f; float radius = 1.0f;
float height = 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 */ /* XXX: all dimensions are auto-determined now... later can add stored settings for this */
/* get object dimensions without scaling */ /* get object dimensions without scaling */
bb = BKE_object_boundbox_get(ob); const BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) { if (bb) {
size[0] = (bb->vec[4][0] - bb->vec[0][0]); size[0] = (bb->vec[4][0] - bb->vec[0][0]);
size[1] = (bb->vec[2][1] - bb->vec[0][1]); size[1] = (bb->vec[2][1] - bb->vec[0][1]);
@@ -1678,7 +1677,7 @@ static void rigidbody_update_sim_ob(
if (mesh) { if (mesh) {
MVert *mvert = mesh->mvert; MVert *mvert = mesh->mvert;
int totvert = mesh->totvert; 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, RB_shape_trimesh_update(rbo->shared->physics_shape,
(float *)mvert, (float *)mvert,

View File

@@ -147,7 +147,7 @@ void EEVEE_shadows_caster_register(EEVEE_ViewLayerData *sldata, Object *ob)
} }
/* Update World AABB in frontbuffer. */ /* 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]; float min[3], max[3];
INIT_MINMAX(min, max); INIT_MINMAX(min, max);
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {

View File

@@ -311,7 +311,7 @@ static void eevee_shadow_cascade_setup(EEVEE_LightsInfo *linfo,
if (c < 3) { if (c < 3) {
dbg_col[c] = 1.0f; 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); DRW_debug_sphere(center, csm_render->radius[c], dbg_col);
#endif #endif

View File

@@ -346,7 +346,7 @@ static bool eevee_volume_object_grids_init(Object *ob, ListBase *gpu_grids, DRWS
if (multiple_transforms) { if (multiple_transforms) {
/* For multiple grids with different transform, we first transform from object space /* For multiple grids with different transform, we first transform from object space
* to bounds, then for each individual grid from bounds to texture. */ * 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]; float bb_size[3];
sub_v3_v3v3(bb_size, bb->vec[6], bb->vec[0]); sub_v3_v3v3(bb_size, bb->vec[6], bb->vec[0]);
size_to_mat4(bounds_to_object, bb_size); size_to_mat4(bounds_to_object, bb_size);

View File

@@ -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 * strokes not aligned with the object axes. Maybe we could try to
* compute the minimum axis of all strokes. But this would be more * compute the minimum axis of all strokes. But this would be more
* computationally heavy and should go into the GPData evaluation. */ * 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 */ /* Convert bbox to matrix */
float mat[4][4], size[3], center[3]; float mat[4][4], size[3], center[3];
BKE_boundbox_calc_size_aabb(bbox, size); BKE_boundbox_calc_size_aabb(bbox, size);

View File

@@ -345,18 +345,17 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb,
bool around_origin) bool around_origin)
{ {
float center[3], size[3], tmp[4][4], final_mat[4][4]; 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)) { if (ob->type == OB_MBALL && !BKE_mball_is_basis(ob)) {
return; return;
} }
BoundBox *bb = BKE_object_boundbox_get(ob); const BoundBox *bb = BKE_object_boundbox_get(ob);
BoundBox bb_local;
if (bb == NULL) { if (bb == NULL) {
const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; 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; bb = &bb_local;
BKE_boundbox_init_from_minmax(bb, min, max);
} }
BKE_boundbox_calc_size_aabb(bb, size); BKE_boundbox_calc_size_aabb(bb, size);

View File

@@ -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 * strokes not aligned with the object axes. Maybe we could try to
* compute the minimum axis of all strokes. But this would be more * compute the minimum axis of all strokes. But this would be more
* computationally heavy and should go into the GPData evaluation. */ * 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 */ /* Convert bbox to matrix */
float mat[4][4], size[3], center[3]; float mat[4][4], size[3], center[3];
BKE_boundbox_calc_size_aabb(bbox, size); BKE_boundbox_calc_size_aabb(bbox, size);

View File

@@ -31,7 +31,7 @@
void select_id_object_min_max(Object *obj, float r_min[3], float r_max[3]) 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); BMEditMesh *em = BKE_editmesh_from_object(obj);
if (em) { if (em) {
bb = BKE_editmesh_cage_boundbox_get(obj, em); bb = BKE_editmesh_cage_boundbox_get(obj, em);

View File

@@ -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, Object *ob,
WORKBENCH_ObjectData *oed) 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); INIT_MINMAX(oed->shadow_min, oed->shadow_max);
/* From object space to shadow space */ /* 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++) { for (int i = 0; i < 8; i++) {
float corner[3]; float corner[3];
mul_v3_m4v3(corner, tmp_mat, bbox->vec[i]); 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, Object *ob,
WORKBENCH_ObjectData *oed) 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(); const DRWView *default_view = DRW_view_default_get();
return DRW_culling_box_test(default_view, shadow_bbox); 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, Object *ob,
WORKBENCH_ObjectData *oed) 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}; const int corners[4] = {0, 3, 4, 7};
float dist = 1e4f, dist_isect; float dist = 1e4f, dist_isect;

View File

@@ -3699,7 +3699,7 @@ static void do_tiled(
SculptSession *ss = ob->sculpt; SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache; StrokeCache *cache = ss->cache;
const float radius = cache->radius; 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 *bbMin = bb->vec[0];
const float *bbMax = bb->vec[6]; const float *bbMax = bb->vec[6];
const float *step = sd->paint.tile_offset; const float *step = sd->paint.tile_offset;

View File

@@ -702,7 +702,7 @@ static void view3d_ob_drop_matrix_from_snap(V3DSnapCursorState *snap_state,
mat4_to_size(scale, ob->obmat); mat4_to_size(scale, ob->obmat);
rescale_m4(obmat_final, scale); rescale_m4(obmat_final, scale);
BoundBox *bb = BKE_object_boundbox_get(ob); const BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) { if (bb) {
float offset[3]; float offset[3];
BKE_boundbox_calc_center_aabb(bb, offset); BKE_boundbox_calc_center_aabb(bb, offset);

View File

@@ -718,7 +718,7 @@ static bool raycastMesh(SnapObjectContext *sctx,
} }
/* Test BoundBox */ /* Test BoundBox */
BoundBox *bb = BKE_object_boundbox_get(ob_eval); const BoundBox *bb = BKE_object_boundbox_get(ob_eval);
if (bb) { if (bb) {
/* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */
if (!isect_ray_aabb_v3_simple( if (!isect_ray_aabb_v3_simple(
@@ -1866,7 +1866,7 @@ static short snapArmature(SnapObjectContext *sctx,
if (is_editmode == false) { if (is_editmode == false) {
/* Test BoundBox */ /* 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], if (bb && !snap_bound_box_check_dist(bb->vec[0],
bb->vec[6], bb->vec[6],
lpmat, lpmat,

View File

@@ -132,7 +132,7 @@ static void generate_geometry(GpencilModifierData *md,
/* Get bounbox for relative offset. */ /* Get bounbox for relative offset. */
float size[3] = {0.0f, 0.0f, 0.0f}; float size[3] = {0.0f, 0.0f, 0.0f};
if (mmd->flag & GP_ARRAY_USE_RELATIVE) { 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}; 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_init_from_minmax(bb, min, max);
BKE_boundbox_calc_size_aabb(bb, size); BKE_boundbox_calc_size_aabb(bb, size);

View File

@@ -2095,7 +2095,7 @@ static bool lineart_geometry_check_visible(double (*model_view_proj)[4],
double shift_y, double shift_y,
Object *use_ob) Object *use_ob)
{ {
BoundBox *bb = BKE_object_boundbox_get(use_ob); const BoundBox *bb = BKE_object_boundbox_get(use_ob);
if (!bb) { if (!bb) {
/* For lights and empty stuff there will be no bbox. */ /* For lights and empty stuff there will be no bbox. */
return false; return false;

View File

@@ -98,7 +98,7 @@ const Imath::Box3d &ABCAbstractWriter::bounding_box() const
void ABCAbstractWriter::update_bounding_box(Object *object) 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 (!bb) {
if (object->type != OB_CAMERA) { if (object->type != OB_CAMERA) {

View File

@@ -1971,7 +1971,7 @@ static void rna_Object_shaderfx_clear(Object *object, bContext *C)
static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) static void rna_Object_boundbox_get(PointerRNA *ptr, float *values)
{ {
Object *ob = (Object *)ptr->owner_id; Object *ob = (Object *)ptr->owner_id;
BoundBox *bb = BKE_object_boundbox_get(ob); const BoundBox *bb = BKE_object_boundbox_get(ob);
if (bb) { if (bb) {
memcpy(values, bb->vec, sizeof(bb->vec)); memcpy(values, bb->vec, sizeof(bb->vec));
} }

View File

@@ -594,7 +594,7 @@ static void rna_Object_ray_cast(Object *ob,
} }
/* Test BoundBox first (efficiency) */ /* Test BoundBox first (efficiency) */
BoundBox *bb = BKE_object_boundbox_get(ob); const BoundBox *bb = BKE_object_boundbox_get(ob);
float distmin; float distmin;
/* Needed for valid distance check from #isect_ray_aabb_v3_simple() call. */ /* Needed for valid distance check from #isect_ray_aabb_v3_simple() call. */

View File

@@ -106,7 +106,7 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
static Mesh *generate_bounding_box_mesh(Object *object, Mesh *org_mesh) 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); Mesh *result = BKE_mesh_new_nomain_from_template(org_mesh, 8, 0, 0, 24, 6);
MVert *mvert = result->mvert; MVert *mvert = result->mvert;

View File

@@ -843,7 +843,7 @@ void RE_point_density_minmax(struct Depsgraph *depsgraph,
} }
else { else {
const float radius[3] = {pd->radius, pd->radius, pd->radius}; 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) { if (bb != NULL) {
BLI_assert((bb->flag & BOUNDBOX_DIRTY) == 0); BLI_assert((bb->flag & BOUNDBOX_DIRTY) == 0);