[Bf-blender-cvs] [526e60d4f0b] master: Cleanup: remove underscore prefix from variable

Campbell Barton noreply at git.blender.org
Wed Oct 27 08:31:27 CEST 2021


Commit: 526e60d4f0b440e2e28e73620caa10920ab0732b
Author: Campbell Barton
Date:   Wed Oct 27 17:05:02 2021 +1100
Branches: master
https://developer.blender.org/rB526e60d4f0b440e2e28e73620caa10920ab0732b

Cleanup: remove underscore prefix from variable

Avoid using underscore prefix since these typically mean the variable
shouldn't be accessed directly (it may be accessed from a macro,
or memory on the stack which is assigned to a pointer).

In this case a more meaningful name can be used for the argument
that was shadowed.

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

M	source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
M	source/blender/editors/space_view3d/view3d_cursor_snap.c
M	source/blender/gpu/GPU_immediate_util.h
M	source/blender/gpu/intern/gpu_immediate_util.c

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

diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
index 07117c0153b..aed58e31798 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c
@@ -220,7 +220,7 @@ static void cage3d_draw_circle_wire(const float r[3],
   immUniform2fv("viewportSize", &viewport[2]);
   immUniform1f("lineWidth", line_width * U.pixelsize);
 
-  imm_draw_cube_wire_3d(pos, (float[3]){0}, r);
+  imm_draw_cube_wire_3d(pos, (const float[3]){0}, r);
 
 #if 0
   if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
diff --git a/source/blender/editors/space_view3d/view3d_cursor_snap.c b/source/blender/editors/space_view3d/view3d_cursor_snap.c
index 5db9dd5d0a7..937ac98acb8 100644
--- a/source/blender/editors/space_view3d/view3d_cursor_snap.c
+++ b/source/blender/editors/space_view3d/view3d_cursor_snap.c
@@ -372,7 +372,7 @@ static void cursor_box_draw(const float dimensions[3], uchar color[4])
 
   immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
   immUniformColor4ubv(color);
-  imm_draw_cube_corners_3d(pos_id, (float[3]){0.0f, 0.0f, dimensions[2]}, dimensions, 0.15f);
+  imm_draw_cube_corners_3d(pos_id, (const float[3]){0.0f, 0.0f, dimensions[2]}, dimensions, 0.15f);
   immUnbindProgram();
 
   GPU_line_smooth(false);
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index 793348ad8d2..0d3d39839b2 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -78,10 +78,10 @@ void imm_draw_box_checker_2d_ex(float x1,
                                 int checker_size);
 void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2);
 
-void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3]);
-void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3]);
+void imm_draw_cube_fill_3d(uint pos, const float center[3], const float aspect[3]);
+void imm_draw_cube_wire_3d(uint pos, const float center[3], const float aspect[3]);
 void imm_draw_cube_corners_3d(uint pos,
-                              const float co[3],
+                              const float center[3],
                               const float aspect[3],
                               const float factor);
 
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index aeed03080a3..032974db8d1 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -391,12 +391,12 @@ void imm_draw_box_checker_2d(float x1, float y1, float x2, float y2)
   imm_draw_box_checker_2d_ex(x1, y1, x2, y2, checker_primary, checker_secondary, checker_size);
 }
 
-void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3])
+void imm_draw_cube_fill_3d(uint pos, const float center[3], const float aspect[3])
 {
   float coords[ARRAY_SIZE(cube_coords)][3];
 
   for (int i = 0; i < ARRAY_SIZE(cube_coords); i++) {
-    madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect);
+    madd_v3_v3v3v3(coords[i], center, cube_coords[i], aspect);
   }
 
   immBegin(GPU_PRIM_TRIS, ARRAY_SIZE(cube_quad_index) * 3 * 2);
@@ -412,12 +412,12 @@ void imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3])
   immEnd();
 }
 
-void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3])
+void imm_draw_cube_wire_3d(uint pos, const float center[3], const float aspect[3])
 {
   float coords[ARRAY_SIZE(cube_coords)][3];
 
   for (int i = 0; i < ARRAY_SIZE(cube_coords); i++) {
-    madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect);
+    madd_v3_v3v3v3(coords[i], center, cube_coords[i], aspect);
   }
 
   immBegin(GPU_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 2);
@@ -429,31 +429,31 @@ void imm_draw_cube_wire_3d(uint pos, const float co[3], const float aspect[3])
 }
 
 void imm_draw_cube_corners_3d(uint pos,
-                              const float co[3],
+                              const float center[3],
                               const float aspect[3],
                               const float factor)
 {
   float coords[ARRAY_SIZE(cube_coords)][3];
 
   for (int i = 0; i < ARRAY_SIZE(cube_coords); i++) {
-    madd_v3_v3v3v3(coords[i], co, cube_coords[i], aspect);
+    madd_v3_v3v3v3(coords[i], center, cube_coords[i], aspect);
   }
 
   immBegin(GPU_PRIM_LINES, ARRAY_SIZE(cube_line_index) * 4);
   for (int i = 0; i < ARRAY_SIZE(cube_line_index); i++) {
-    float vec[3], _co[3];
+    float vec[3], co[3];
     sub_v3_v3v3(vec, coords[cube_line_index[i][1]], coords[cube_line_index[i][0]]);
     mul_v3_fl(vec, factor);
 
-    copy_v3_v3(_co, coords[cube_line_index[i][0]]);
-    immVertex3fv(pos, _co);
-    add_v3_v3(_co, vec);
-    immVertex3fv(pos, _co);
+    copy_v3_v3(co, coords[cube_line_index[i][0]]);
+    immVertex3fv(pos, co);
+    add_v3_v3(co, vec);
+    immVertex3fv(pos, co);
 
-    copy_v3_v3(_co, coords[cube_line_index[i][1]]);
-    immVertex3fv(pos, _co);
-    sub_v3_v3(_co, vec);
-    immVertex3fv(pos, _co);
+    copy_v3_v3(co, coords[cube_line_index[i][1]]);
+    immVertex3fv(pos, co);
+    sub_v3_v3(co, vec);
+    immVertex3fv(pos, co);
   }
   immEnd();
 }



More information about the Bf-blender-cvs mailing list