[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60672] trunk/blender/source: code cleanup : use const's for static arrays

Campbell Barton ideasman42 at gmail.com
Thu Oct 10 22:22:18 CEST 2013


Revision: 60672
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60672
Author:   campbellbarton
Date:     2013-10-10 20:22:17 +0000 (Thu, 10 Oct 2013)
Log Message:
-----------
code cleanup: use const's for static arrays

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
    trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c
    trunk/blender/source/blender/blenlib/intern/noise.c
    trunk/blender/source/blender/blenlib/intern/smallhash.c
    trunk/blender/source/blender/bmesh/operators/bmo_primitive.c
    trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp
    trunk/blender/source/blender/editors/curve/editcurve_add.c
    trunk/blender/source/blender/editors/space_view3d/drawarmature.c
    trunk/blender/source/blender/editors/transform/transform_ops.c
    trunk/blender/source/blender/imbuf/intern/indexer.c
    trunk/blender/source/blender/render/intern/source/imagetexture.c
    trunk/blender/source/blender/render/intern/source/pixelshading.c
    trunk/blender/source/blender/render/intern/source/rendercore.c
    trunk/blender/source/gameengine/Ketsji/KX_BlenderMaterial.cpp

Modified: trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/blenkernel/intern/dynamicpaint.c	2013-10-10 20:22:17 UTC (rev 60672)
@@ -98,12 +98,13 @@
 #endif
 
 /* precalculated gaussian factors for 5x super sampling	*/
-static float gaussianFactors[5] = {0.996849f,
-                                   0.596145f,
-                                   0.596145f,
-                                   0.596145f,
-                                   0.524141f};
-static float gaussianTotal = 3.309425f;
+static const float gaussianFactors[5] = {
+    0.996849f,
+    0.596145f,
+    0.596145f,
+    0.596145f,
+    0.524141f};
+static const float gaussianTotal = 3.309425f;
 
 /* UV Image neighboring pixel table x and y list */
 static int neighX[8] = {1, 1, 0, -1, -1, -1, 0, 1};

Modified: trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/blenlib/intern/BLI_kdopbvh.c	2013-10-10 20:22:17 UTC (rev 60672)
@@ -117,7 +117,7 @@
  * Notes: You can choose the tree type --> binary, quad, octree, choose below
  */
 
-static float KDOP_AXES[13][3] = {
+static const float KDOP_AXES[13][3] = {
 	{1.0, 0, 0}, {0, 1.0, 0}, {0, 0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0},
 	{1.0, -1.0, -1.0}, {1.0, 1.0, 0}, {1.0, 0, 1.0}, {0, 1.0, 1.0}, {1.0, -1.0, 0}, {1.0, 0, -1.0},
 	{0, 1.0, -1.0}

Modified: trunk/blender/source/blender/blenlib/intern/noise.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/noise.c	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/blenlib/intern/noise.c	2013-10-10 20:22:17 UTC (rev 60672)
@@ -50,7 +50,7 @@
 
 /* needed for voronoi */
 #define HASHPNT(x, y, z) hashpntf + 3 * hash[(hash[(hash[(z) & 255] + (y)) & 255] + (x)) & 255]
-static float hashpntf[768] = {
+static const float hashpntf[768] = {
 	0.536902, 0.020915, 0.501445, 0.216316, 0.517036, 0.822466, 0.965315,
 	0.377313, 0.678764, 0.744545, 0.097731, 0.396357, 0.247202, 0.520897,
 	0.613396, 0.542124, 0.146813, 0.255489, 0.810868, 0.638641, 0.980742,
@@ -163,7 +163,7 @@
 	0.114246, 0.905043, 0.713870, 0.555261, 0.951333
 };
 
-unsigned char hash[512] = {
+const unsigned char hash[512] = {
 	0xA2, 0xA0, 0x19, 0x3B, 0xF8, 0xEB, 0xAA, 0xEE, 0xF3, 0x1C, 0x67, 0x28, 0x1D, 0xED, 0x0,  0xDE, 0x95, 0x2E, 0xDC,
 	0x3F, 0x3A, 0x82, 0x35, 0x4D, 0x6C, 0xBA, 0x36, 0xD0, 0xF6, 0xC,  0x79, 0x32, 0xD1, 0x59, 0xF4, 0x8,  0x8B, 0x63,
 	0x89, 0x2F, 0xB8, 0xB4, 0x97, 0x83, 0xF2, 0x8F, 0x18, 0xC7, 0x51, 0x14, 0x65, 0x87, 0x48, 0x20, 0x42, 0xA8, 0x80,
@@ -194,7 +194,7 @@
 };
 
 
-float hashvectf[768] = {
+const float hashvectf[768] = {
 	0.33783, 0.715698, -0.611206, -0.944031, -0.326599, -0.045624, -0.101074, -0.416443, -0.903503, 0.799286, 0.49411,
 	-0.341949, -0.854645, 0.518036, 0.033936, 0.42514, -0.437866, -0.792114, -0.358948, 0.597046, 0.717377, -0.985413,
 	0.144714, 0.089294, -0.601776, -0.33728, -0.723907, -0.449921, 0.594513, 0.666382, 0.208313, -0.10791, 0.972076,
@@ -327,7 +327,8 @@
 /* Was BLI_hnoise(), removed noisesize, so other functions can call it without scaling. */
 static float orgBlenderNoise(float x, float y, float z)
 {
-	register float cn1, cn2, cn3, cn4, cn5, cn6, i, *h;
+	register float cn1, cn2, cn3, cn4, cn5, cn6, i;
+	register const float *h;
 	float fx, fy, fz, ox, oy, oz, jx, jy, jz;
 	float n = 0.5;
 	int ix, iy, iz, b00, b01, b10, b11, b20, b21;
@@ -504,7 +505,7 @@
 };
 
 
-static float g[512 + 2][3] = {
+static const float g[512 + 2][3] = {
 	{0.33783, 0.715698, -0.611206},
 	{-0.944031, -0.326599, -0.045624},
 	{-0.101074, -0.416443, -0.903503},
@@ -1034,7 +1035,8 @@
 static float noise3_perlin(float vec[3])
 {
 	int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
-	float rx0, rx1, ry0, ry1, rz0, rz1, *q, sx, sy, sz, a, b, c, d, t, u, v;
+	float rx0, rx1, ry0, ry1, rz0, rz1, sx, sy, sz, a, b, c, d, t, u, v;
+	const float *q;
 	register int i, j;
 
 
@@ -1227,7 +1229,7 @@
 void voronoi(float x, float y, float z, float *da, float *pa, float me, int dtype)
 {
 	int xx, yy, zz, xi, yi, zi;
-	float xd, yd, zd, d, *p;
+	float xd, yd, zd, d;
 
 	float (*distfunc)(float, float, float, float);
 	switch (dtype) {
@@ -1262,7 +1264,7 @@
 	for (xx = xi - 1; xx <= xi + 1; xx++) {
 		for (yy = yi - 1; yy <= yi + 1; yy++) {
 			for (zz = zi - 1; zz <= zi + 1; zz++) {
-				p = HASHPNT(xx, yy, zz);
+				const float *p = HASHPNT(xx, yy, zz);
 				xd = x - (p[0] + xx);
 				yd = y - (p[1] + yy);
 				zd = z - (p[2] + zz);
@@ -1416,7 +1418,7 @@
 	int xi = (int)(floor(x));
 	int yi = (int)(floor(y));
 	int zi = (int)(floor(z));
-	float *p = HASHPNT(xi, yi, zi);
+	const float *p = HASHPNT(xi, yi, zi);
 	ca[0] = p[0];
 	ca[1] = p[1];
 	ca[2] = p[2];

Modified: trunk/blender/source/blender/blenlib/intern/smallhash.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/smallhash.c	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/blenlib/intern/smallhash.c	2013-10-10 20:22:17 UTC (rev 60672)
@@ -55,7 +55,7 @@
 	((h) + (((hoff) = ((hoff) * 2) + 1), (hoff))) \
 	)
 
-extern unsigned int hashsizes[];
+extern const unsigned int hashsizes[];
 
 void BLI_smallhash_init(SmallHash *hash)
 {

Modified: trunk/blender/source/blender/bmesh/operators/bmo_primitive.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_primitive.c	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/bmesh/operators/bmo_primitive.c	2013-10-10 20:22:17 UTC (rev 60672)
@@ -36,7 +36,7 @@
 
 /* ************************ primitives ******************* */
 
-static float icovert[12][3] = {
+static const float icovert[12][3] = {
 	{0.0f, 0.0f, -200.0f},
 	{144.72f, -105.144f, -89.443f},
 	{-55.277f, -170.128, -89.443f},
@@ -51,7 +51,7 @@
 	{0.0f, 0.0f, 200.0f}
 };
 
-static short icoface[20][3] = {
+static const short icoface[20][3] = {
 	{0, 1, 2},
 	{1, 0, 5},
 	{0, 2, 3},
@@ -78,10 +78,10 @@
  * this hack is only used so that scons & mingw + split-sources hack works
  * ------------------------------- start copied code */
 /* these are not the monkeys you are looking for */
-static int monkeyo = 4;
-static int monkeynv = 271;
-static int monkeynf = 250;
-static signed char monkeyv[271][3] = {
+static const int monkeyo = 4;
+static const int monkeynv = 271;
+static const int monkeynf = 250;
+static const signed char monkeyv[271][3] = {
 	{-71, 21, 98}, {-63, 12, 88}, {-57, 7, 74}, {-82, -3, 79}, {-82, 4, 92},
 	{-82, 17, 100}, {-92, 21, 102}, {-101, 12, 95}, {-107, 7, 83},
 	{-117, 31, 84}, {-109, 31, 95}, {-96, 31, 102}, {-92, 42, 102},

Modified: trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp
===================================================================
--- trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/compositor/intern/COM_MemoryBuffer.cpp	2013-10-10 20:22:17 UTC (rev 60672)
@@ -179,7 +179,7 @@
 // table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
 // used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible
 #define EWA_MAXIDX 255
-static float EWA_WTS[EWA_MAXIDX + 1] = {
+static const float EWA_WTS[EWA_MAXIDX + 1] = {
 	1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f,
 	0.921178f, 0.912759f, 0.904405f, 0.896117f, 0.887893f, 0.879734f, 0.871638f, 0.863605f,
 	0.855636f, 0.847728f, 0.839883f, 0.832098f, 0.824375f, 0.816712f, 0.809108f, 0.801564f,

Modified: trunk/blender/source/blender/editors/curve/editcurve_add.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve_add.c	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/editors/curve/editcurve_add.c	2013-10-10 20:22:17 UTC (rev 60672)
@@ -58,7 +58,7 @@
 
 #include "curve_intern.h"
 
-static float nurbcircle[8][2] = {
+static const float nurbcircle[8][2] = {
 	{0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0,  1.0},
 	{0.0,  1.0}, { 1.0,  1.0}, { 1.0, 0.0}, { 1.0, -1.0}
 };

Modified: trunk/blender/source/blender/editors/space_view3d/drawarmature.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawarmature.c	2013-10-10 20:14:04 UTC (rev 60671)
+++ trunk/blender/source/blender/editors/space_view3d/drawarmature.c	2013-10-10 20:22:17 UTC (rev 60672)
@@ -304,7 +304,7 @@
 /* *************** Armature drawing, helper calls for parts ******************* */
 
 /* half the cube, in Y */
-static float cube[8][3] = {
+static const float cube[8][3] = {
 	{-1.0,  0.0, -1.0},
 	{-1.0,  0.0,  1.0},
 	{-1.0,  1.0,  1.0},
@@ -440,7 +440,7 @@
 	glCallList(displist);
 }
 
-static float bone_octahedral_verts[6][3] = {
+static const float bone_octahedral_verts[6][3] = {
 	{ 0.0f, 0.0f,  0.0f},
 	{ 0.1f, 0.1f,  0.1f},
 	{ 0.1f, 0.1f, -0.1f},
@@ -449,10 +449,10 @@
 	{ 0.0f, 1.0f,  0.0f}
 };
 
-static unsigned int bone_octahedral_wire_sides[8] = {0, 1, 5, 3, 0, 4, 5, 2};
-static unsigned int bone_octahedral_wire_square[8] = {1, 2, 3, 4, 1};
+static const unsigned int bone_octahedral_wire_sides[8] = {0, 1, 5, 3, 0, 4, 5, 2};
+static const unsigned int bone_octahedral_wire_square[8] = {1, 2, 3, 4, 1};
 
-static unsigned int bone_octahedral_solid_tris[8][3] = {
+static const unsigned int bone_octahedral_solid_tris[8][3] = {
 	{2, 1, 0}, /* bottom */
 	{3, 2, 0},
 	{4, 3, 0},
@@ -465,7 +465,7 @@
 };
 
 /* aligned with bone_octahedral_solid_tris */
-static float bone_octahedral_solid_normals[8][3] = {
+static const float bone_octahedral_solid_normals[8][3] = {
 	{ 0.70710683f, -0.70710683f,  0.00000000f},
 	{-0.00000000f, -0.70710683f, -0.70710683f},
 	{-0.70710683f, -0.70710683f,  0.00000000f},
@@ -599,7 +599,7 @@
 }
 
 /* 16 values of sin function (still same result!) */
-static float si[16] = {
+static const float si[16] = {
 	0.00000000f,
 	0.20129852f, 0.39435585f,
 	0.57126821f, 0.72479278f,

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list