[Bf-blender-cvs] [5387d33e5f9] master: Cleanup: Further use of const for object bounding boxes

Hans Goudey noreply at git.blender.org
Sat Apr 2 01:30:22 CEST 2022


Commit: 5387d33e5f954c4cecdb7ffd3d1042d8632d6c15
Author: Hans Goudey
Date:   Fri Apr 1 18:30:09 2022 -0500
Branches: master
https://developer.blender.org/rB5387d33e5f954c4cecdb7ffd3d1042d8632d6c15

Cleanup: Further use of const for object bounding boxes

Also solves two warnings from the previous similar commit,
f688e3cc3130e70e77f0bb0. The change to the grease pencil
modifier is quite suspicious, but doesn't change the behavior,
which was already broken.

===================================================================

M	intern/rigidbody/RBI_api.h
M	intern/rigidbody/rb_bullet_api.cpp
M	source/blender/blenkernel/BKE_object.h
M	source/blender/blenkernel/intern/object.cc
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/draw/intern/draw_manager_data.c
M	source/blender/editors/object/object_remesh.cc
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/transform/transform_snap_object.cc
M	source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c

===================================================================

diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 4065240a704..791a4a6ac05 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -246,8 +246,8 @@ void RB_shape_trimesh_update(rbCollisionShape *shape,
                              float *vertices,
                              int num_verts,
                              int vert_stride,
-                             float min[3],
-                             float max[3]);
+                             const float min[3],
+                             const float max[3]);
 
 /* ********************************** */
 /* Constraints */
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index 88b146384e1..ac8026be41b 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -802,8 +802,8 @@ void RB_shape_trimesh_update(rbCollisionShape *shape,
                              float *vertices,
                              int num_verts,
                              int vert_stride,
-                             float min[3],
-                             float max[3])
+                             const float min[3],
+                             const float max[3])
 {
   if (shape->mesh == NULL || num_verts != shape->mesh->num_vertices) {
     return;
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 2d60ce87e23..a90b9b12030 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -337,7 +337,7 @@ void BKE_boundbox_minmax(const struct BoundBox *bb,
                          float r_min[3],
                          float r_max[3]);
 
-struct BoundBox *BKE_object_boundbox_get(struct Object *ob);
+const struct BoundBox *BKE_object_boundbox_get(struct Object *ob);
 void BKE_object_dimensions_get(struct Object *ob, float r_vec[3]);
 /**
  * The original scale and object matrix can be passed in so any difference
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc
index 62c6a6aab98..c00a403d5e9 100644
--- a/source/blender/blenkernel/intern/object.cc
+++ b/source/blender/blenkernel/intern/object.cc
@@ -3587,7 +3587,7 @@ void BKE_boundbox_minmax(const BoundBox *bb,
   }
 }
 
-BoundBox *BKE_object_boundbox_get(Object *ob)
+const BoundBox *BKE_object_boundbox_get(Object *ob)
 {
   BoundBox *bb = nullptr;
 
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 3bc2139ca0c..fbbd429f58a 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -243,7 +243,7 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
 /** Bounding box from evaluated geometry. */
 static void object_sync_boundbox_to_original(Object *object_orig, Object *object_eval)
 {
-  BoundBox *bb = object_eval->runtime.bb;
+  const BoundBox *bb = object_eval->runtime.bb;
   if (!bb || (bb->flag & BOUNDBOX_DIRTY)) {
     BKE_object_boundbox_calc_from_evaluated_geometry(object_eval);
   }
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index f7d7c77969e..8c7cd6d1648 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -614,7 +614,7 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
   drw_call_calc_orco(ob, ob_infos->orcotexfac);
   /* Random float value. */
   uint random = (DST.dupli_source) ?
-                     DST.dupli_source->random_id :
+                    DST.dupli_source->random_id :
                      /* TODO(fclem): this is rather costly to do at runtime. Maybe we can
                       * put it in ob->runtime and make depsgraph ensure it is up to date. */
                      BLI_hash_int_2d(BLI_hash_string(ob->id.name + 2), 0);
@@ -638,7 +638,7 @@ static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, Object *ob)
 
 static void drw_call_culling_init(DRWCullingState *cull, Object *ob)
 {
-  BoundBox *bbox;
+  const BoundBox *bbox;
   if (ob != NULL && (bbox = BKE_object_boundbox_get(ob))) {
     float corner[3];
     /* Get BoundSphere center and radius from the BoundBox. */
diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc
index 2e495ac6147..966df0668ca 100644
--- a/source/blender/editors/object/object_remesh.cc
+++ b/source/blender/editors/object/object_remesh.cc
@@ -459,7 +459,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev
   op->customdata = cd;
 
   /* Select the front facing face of the mesh bounding box. */
-  BoundBox *bb = BKE_mesh_boundbox_get(cd->active_object);
+  const BoundBox *bb = BKE_mesh_boundbox_get(cd->active_object);
 
   /* Indices of the Bounding Box faces. */
   const int BB_faces[6][4] = {
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 37bc8b462aa..861da185975 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -1039,7 +1039,7 @@ static void cursor_draw_tiling_preview(const uint gpuattr,
                                        Object *ob,
                                        const float radius)
 {
-  BoundBox *bb = BKE_object_boundbox_get(ob);
+  const BoundBox *bb = BKE_object_boundbox_get(ob);
   float orgLoc[3], location[3];
   int tile_pass = 0;
   int start[3];
diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc
index 21f3a42e278..e879ca2b163 100644
--- a/source/blender/editors/transform/transform_snap_object.cc
+++ b/source/blender/editors/transform/transform_snap_object.cc
@@ -2349,7 +2349,7 @@ static short snapMesh(SnapObjectContext *sctx,
   float dist_px_sq = square_f(*dist_px);
 
   /* Test BoundBox */
-  BoundBox *bb = BKE_object_boundbox_get(ob_eval);
+  const BoundBox *bb = BKE_object_boundbox_get(ob_eval);
   if (bb &&
       !snap_bound_box_check_dist(
           bb->vec[0], bb->vec[6], lpmat, sctx->runtime.win_size, sctx->runtime.mval, dist_px_sq)) {
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index 1ceda0b334b..f3669673094 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
@@ -132,10 +132,10 @@ 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) {
-    const BoundBox *bb = BKE_object_boundbox_get(ob);
+    BoundBox bb;
     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);
+    BKE_boundbox_init_from_minmax(&bb, min, max);
+    BKE_boundbox_calc_size_aabb(&bb, size);
     mul_v3_fl(size, 2.0f);
     /* Need a minimum size (for flat drawings). */
     CLAMP3_MIN(size, 0.01f);



More information about the Bf-blender-cvs mailing list