[Bf-blender-cvs] [39b86a989da] master: Cleanup: use const arrays

Campbell Barton noreply at git.blender.org
Thu Mar 4 07:44:02 CET 2021


Commit: 39b86a989da5053ae5d6628834e5b78a16e6dffa
Author: Campbell Barton
Date:   Thu Mar 4 16:57:30 2021 +1100
Branches: master
https://developer.blender.org/rB39b86a989da5053ae5d6628834e5b78a16e6dffa

Cleanup: use const arrays

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

M	source/blender/blenkernel/intern/studiolight.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/mesh/editmesh_knife.c
M	source/blender/editors/transform/transform_constraints.c
M	source/blender/gpu/intern/gpu_immediate.cc
M	source/blender/python/gpu/gpu_py_offscreen.c

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

diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c
index 5bffcd4d9e7..4cc2d101b02 100644
--- a/source/blender/blenkernel/intern/studiolight.c
+++ b/source/blender/blenkernel/intern/studiolight.c
@@ -514,7 +514,7 @@ static void studiolight_create_matcap_gputexture(StudioLightImage *sli)
   ImBuf *ibuf = sli->ibuf;
   float *gpu_matcap_3components = MEM_callocN(sizeof(float[3]) * ibuf->x * ibuf->y, __func__);
 
-  float(*offset4)[4] = (float(*)[4])ibuf->rect_float;
+  const float(*offset4)[4] = (const float(*)[4])ibuf->rect_float;
   float(*offset3)[3] = (float(*)[3])gpu_matcap_3components;
   for (int i = 0; i < ibuf->x * ibuf->y; i++, offset4++, offset3++) {
     copy_v3_v3(*offset3, *offset4);
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index d10cdc207c2..40cfcaea883 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -120,7 +120,7 @@ void UI_draw_roundbox_4fv_ex(const rctf *rect,
   };
   GPUBatch *batch = ui_batch_roundbox_widget_get();
   GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
-  GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float(*)[4]) & widget_params);
+  GPU_batch_uniform_4fv_array(batch, "parameters", 11, (const float(*)[4]) & widget_params);
   GPU_blend(GPU_BLEND_ALPHA);
   GPU_batch_draw(batch);
   GPU_blend(GPU_BLEND_NONE);
@@ -2376,7 +2376,7 @@ void ui_draw_dropshadow(
 
   GPUBatch *batch = ui_batch_roundbox_shadow_get();
   GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW);
-  GPU_batch_uniform_4fv_array(batch, "parameters", 4, (float(*)[4]) & widget_params);
+  GPU_batch_uniform_4fv_array(batch, "parameters", 4, (const float(*)[4]) & widget_params);
   GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility);
   GPU_batch_draw(batch);
 
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 0fa5999976b..06b87dd857f 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1180,7 +1180,7 @@ void UI_widgetbase_draw_cache_flush(void)
     /* draw single */
     GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
     GPU_batch_uniform_4fv_array(
-        batch, "parameters", MAX_WIDGET_PARAMETERS, (float(*)[4])g_widget_base_batch.params);
+        batch, "parameters", MAX_WIDGET_PARAMETERS, (const float(*)[4])g_widget_base_batch.params);
     GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
     GPU_batch_draw(batch);
   }
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index 1f894ec0f1d..b5ec3f388a0 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -966,7 +966,7 @@ static void knifetool_draw_angle_snapping(const KnifeTool_OpData *kcd)
   float planes[4][4];
 
   planes_from_projmat(
-      (float(*)[4])kcd->projmat, planes[2], planes[0], planes[3], planes[1], NULL, NULL);
+      (const float(*)[4])kcd->projmat, planes[2], planes[0], planes[3], planes[1], NULL, NULL);
 
   /* ray-cast all planes */
   {
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 43cbcb0aba4..2037981e655 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -550,7 +550,7 @@ static void applyObjectConstraintSize(TransInfo *t,
 }
 
 static void constraints_rotation_impl(TransInfo *t,
-                                      float axismtx[3][3],
+                                      const float axismtx[3][3],
                                       float r_vec[3],
                                       float *r_angle)
 {
@@ -621,7 +621,7 @@ static void applyObjectConstraintRot(
 {
   if (t->con.mode & CON_APPLY) {
     float tmp_axismtx[3][3];
-    float(*axismtx)[3];
+    const float(*axismtx)[3];
 
     /* on setup call, use first object */
     if (td == NULL) {
diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc
index e56dcd16528..062741a6270 100644
--- a/source/blender/gpu/intern/gpu_immediate.cc
+++ b/source/blender/gpu/intern/gpu_immediate.cc
@@ -606,7 +606,7 @@ void immUniform4fv(const char *name, const float data[4])
 /* Note array index is not supported for name (i.e: "array[0]"). */
 void immUniformArray4fv(const char *name, const float *data, int count)
 {
-  GPU_shader_uniform_4fv_array(imm->shader, name, count, (float(*)[4])data);
+  GPU_shader_uniform_4fv_array(imm->shader, name, count, (const float(*)[4])data);
 }
 
 void immUniformMatrix4fv(const char *name, const float data[4][4])
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index 9d5671ff702..dff4b169f9a 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -336,8 +336,8 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar
                            region,
                            GPU_offscreen_width(self->ofs),
                            GPU_offscreen_height(self->ofs),
-                           (float(*)[4])py_mat_view->matrix,
-                           (float(*)[4])py_mat_projection->matrix,
+                           (const float(*)[4])py_mat_view->matrix,
+                           (const float(*)[4])py_mat_projection->matrix,
                            true,
                            true,
                            "",



More information about the Bf-blender-cvs mailing list