[Bf-blender-cvs] [b6e967b] master: Code cleanup: const args and arrays

Campbell Barton noreply at git.blender.org
Sun Apr 27 00:58:03 CEST 2014


Commit: b6e967be636d0e1bae842b2c52c76fd867a4784a
Author: Campbell Barton
Date:   Sun Apr 27 07:50:08 2014 +1000
https://developer.blender.org/rBb6e967be636d0e1bae842b2c52c76fd867a4784a

Code cleanup: const args and arrays

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

M	source/blender/blenkernel/intern/dynamicpaint.c
M	source/blender/blenkernel/intern/implicit.c
M	source/blender/blenkernel/intern/tracking_solver.c
M	source/blender/blenlib/intern/math_geom.c
M	source/blender/bmesh/intern/bmesh_interp.c
M	source/blender/bmesh/intern/bmesh_walkers_impl.c
M	source/blender/editors/armature/armature_skinning.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_eyedropper.c
M	source/blender/editors/interface/view2d_ops.c
M	source/blender/editors/mesh/editmesh_loopcut.c
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/editors/space_clip/clip_graph_draw.c
M	source/blender/editors/space_clip/tracking_ops.c
M	source/blender/editors/space_node/node_draw.c
M	source/blender/editors/space_view3d/drawarmature.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_ruler.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/uvedit/uvedit_ops.c
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/imbuf/intern/scaling.c
M	source/blender/modifiers/intern/MOD_skin.c
M	source/blender/windowmanager/intern/wm_cursors.c

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

diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index e14282b..682a429 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -2235,11 +2235,13 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh
 int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface)
 {
 	/* Antialias jitter point relative coords	*/
-	float jitter5sample[10] =  {0.0f, 0.0f,
-		                        -0.2f, -0.4f,
-		                        0.2f, 0.4f,
-		                        0.4f, -0.2f,
-		                        -0.4f, 0.3f};
+	const float jitter5sample[10] =  {
+		    0.0f, 0.0f,
+		    -0.2f, -0.4f,
+		    0.2f, 0.4f,
+		    0.4f, -0.2f,
+		    -0.4f, 0.3f,
+	};
 	int ty;
 	int w, h;
 	int numOfFaces;
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index cceb792..bf70e0d 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1400,7 +1400,7 @@ static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n)
 	n[2] = n1[0]*n2[1]-n1[1]*n2[0];
 }
 
-static float calculateVertexWindForce(float wind[3], float vertexnormal[3])  
+static float calculateVertexWindForce(const float wind[3], const float vertexnormal[3])
 {
 	return dot_v3v3(wind, vertexnormal);
 }
diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c
index 9ab1643..056220e 100644
--- a/source/blender/blenkernel/intern/tracking_solver.c
+++ b/source/blender/blenkernel/intern/tracking_solver.c
@@ -535,7 +535,7 @@ bool BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieT
 }
 
 static void tracking_scale_reconstruction(ListBase *tracksbase, MovieTrackingReconstruction *reconstruction,
-                                          float scale[3])
+                                          const float scale[3])
 {
 	MovieTrackingTrack *track;
 	int i;
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 5638d8e..36b26f9 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2357,7 +2357,7 @@ void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const flo
 #endif
 
 		/* inline mean_value_half_tan four times here */
-		float t[4] = {
+		const float t[4] = {
 			MEAN_VALUE_HALF_TAN_V2(area, 0, 1),
 			MEAN_VALUE_HALF_TAN_V2(area, 1, 2),
 			MEAN_VALUE_HALF_TAN_V2(area, 2, 3),
diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c
index 1a1b399..a4e9106 100644
--- a/source/blender/bmesh/intern/bmesh_interp.c
+++ b/source/blender/bmesh/intern/bmesh_interp.c
@@ -295,8 +295,9 @@ static float quad_coord(const float aa[3], const float bb[3], const float cc[3],
 	return f1;
 }
 
-static int quad_co(float *x, float *y, float v1[3], float v2[3], float v3[3], float v4[3],
-                   float p[3], float n[3])
+static int quad_co(float *x, float *y,
+                   const float v1[3], const float v2[3], const float v3[3], const float v4[3],
+                   const float p[3], const float n[3])
 {
 	float projverts[5][3], n2[3];
 	float dprojverts[4][3], origin[3] = {0.0f, 0.0f, 0.0f};
@@ -384,8 +385,8 @@ static bool mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float p[3], float *x, floa
 	return 1;
 }
 
-static float bm_loop_flip_equotion(float mat[2][2], float b[2], float target_axis_x[3], float target_axis_y[3],
-                                   float coord[3], int i, int j)
+static float bm_loop_flip_equotion(float mat[2][2], float b[2], const float target_axis_x[3], const float target_axis_y[3],
+                                   const float coord[3], int i, int j)
 {
 	mat[0][0] = target_axis_x[i];
 	mat[0][1] = target_axis_y[i];
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index d530980..70b9023 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -471,8 +471,10 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data)
 	BMwLoopWalker *lwalk = NULL, owalk, *owalk_pt;
 	BMEdge *e = data;
 	BMVert *v;
-	int vert_edge_count[2] = {BM_vert_edge_count_nonwire(e->v1),
-	                          BM_vert_edge_count_nonwire(e->v2)};
+	const int vert_edge_count[2] = {
+	    BM_vert_edge_count_nonwire(e->v1),
+	    BM_vert_edge_count_nonwire(e->v2),
+	};
 
 	v = e->v1;
 
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 560af2d..e898e60 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -191,7 +191,7 @@ static void add_vgroups__mapFunc(void *userData, int index, const float co[3],
 
 static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist,
                                     bDeformGroup **dgrouplist, bDeformGroup **dgroupflip,
-                                    float (*root)[3], float (*tip)[3], int *selected, float scale)
+                                    float (*root)[3], float (*tip)[3], const int *selected, float scale)
 {
 	/* Create vertex group weights from envelopes */
 
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a4597b6..6e65cbb 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -475,7 +475,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s,
 
 /* draw a set of strokes */
 static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag,
-                            short debug, short lthick, float color[4])
+                            short debug, short lthick, const float color[4])
 {
 	bGPDstroke *gps;
 	
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 57e0892..6f9189c 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -456,7 +456,7 @@ static void draw_scope_end(const rctf *rect, GLint *scissor)
 }
 
 static void histogram_draw_one(float r, float g, float b, float alpha,
-                               float x, float y, float w, float h, float *data, int res, const bool is_line)
+                               float x, float y, float w, float h, const float *data, int res, const bool is_line)
 {
 	int i;
 	
@@ -1612,14 +1612,14 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol
 	static const float size = 5.0f;
 	
 	/* 16 values of sin function */
-	static float si[16] = {
+	const float si[16] = {
 	    0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
 	    0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
 	    -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
 	    -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
 	};
 	/* 16 values of cos function */
-	static float co[16] = {
+	const float co[16] = {
 	    1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
 	    -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
 	    -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index 0af902b..5b7915e 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -476,8 +476,9 @@ static void datadropper_id_sample_pt(bContext *C, DataDropper *ddr, int mx, int
 			if (sa->spacetype == SPACE_VIEW3D) {
 				ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
 				if (ar && BLI_rcti_isect_pt(&ar->winrct, mx, my)) {
-					int mval[2] = {mx - ar->winrct.xmin,
-					               my - ar->winrct.ymin};
+					const int mval[2] = {
+					    mx - ar->winrct.xmin,
+					    my - ar->winrct.ymin};
 					Base *base;
 
 					CTX_wm_area_set(C, sa);
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index fe3190a..af43a10 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1348,14 +1348,14 @@ struct SmoothView2DStore {
  */
 static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
 {
-	float size_a[2] = {BLI_rctf_size_x(rect_a),
-	                   BLI_rctf_size_y(rect_a)};
-	float size_b[2] = {BLI_rctf_size_x(rect_b),
-	                   BLI_rctf_size_y(rect_b)};
-	float cent_a[2] = {BLI_rctf_cent_x(rect_a),
-	                   BLI_rctf_cent_y(rect_a)};
-	float cent_b[2] = {BLI_rctf_cent_x(rect_b),
-	                   BLI_rctf_cent_y(rect_b)};
+	const float size_a[2] = {BLI_rctf_size_x(rect_a),
+	                         BLI_rctf_size_y(rect_a)};
+	const float size_b[2] = {BLI_rctf_size_x(rect_b),
+	                         BLI_rctf_size_y(rect_b)};
+	const float cent_a[2] = {BLI_rctf_cent_x(rect_a),
+	                         BLI_rctf_cent_y(rect_a)};
+	const float cent_b[2] = {BLI_rctf_cent_x(rect_b),
+	                         BLI_rctf_cent_y(rect_b)};
 
 	float fac_max = 0.0f;
 	float tfac;
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index 9a02a97..e52ec8d 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -493,7 +493,7 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event)
 	{
 		Scene *scene = CTX_data_scene(C);
 		ToolSettings *settings = scene->toolsettings;
-		int mesh_select_mode[3] = {
+		const int mesh_select_mode[3] = {
 		    (settings->selectmode & SCE_SELECT_VERTEX) != 0,
 		    (settings->selectmode & SCE_SELECT_EDGE)   != 0,
 		    (settings->selectmode & SCE_SELECT_FACE)   != 0,
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/so

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list