Code cleanup: const args and arrays

This commit is contained in:
2014-04-27 07:50:08 +10:00
parent 7ca74fc1c0
commit b6e967be63
30 changed files with 91 additions and 75 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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),

View File

@@ -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];

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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,

View File

@@ -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);

View File

@@ -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;

View File

@@ -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,

View File

@@ -1261,9 +1261,11 @@ void EDBM_mesh_reveal(BMEditMesh *em)
BM_EDGES_OF_MESH,
BM_FACES_OF_MESH};
int sels[3] = {(em->selectmode & SCE_SELECT_VERTEX),
(em->selectmode & SCE_SELECT_EDGE),
(em->selectmode & SCE_SELECT_FACE), };
const bool sels[3] = {
(em->selectmode & SCE_SELECT_VERTEX) != 0,
(em->selectmode & SCE_SELECT_EDGE) != 0,
(em->selectmode & SCE_SELECT_FACE) != 0,
};
int i;
/* Use tag flag to remember what was hidden before all is revealed.

View File

@@ -1053,9 +1053,9 @@ static void project_face_seams_init(const ProjPaintState *ps, const int face_ind
*
* This is used for finding a pixels location in screenspace for painting */
static void screen_px_from_ortho(
float uv[2],
float v1co[3], float v2co[3], float v3co[3], /* Screenspace coords */
float uv1co[2], float uv2co[2], float uv3co[2],
const float uv[2],
const float v1co[3], const float v2co[3], const float v3co[3], /* Screenspace coords */
const float uv1co[2], const float uv2co[2], const float uv3co[2],
float pixelScreenCo[4],
float w[3])
{
@@ -1066,9 +1066,9 @@ static void screen_px_from_ortho(
/* same as screen_px_from_ortho except we need to take into account
* the perspective W coord for each vert */
static void screen_px_from_persp(
float uv[2],
float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */
float uv1co[2], float uv2co[2], float uv3co[2],
const float uv[2],
const float v1co[4], const float v2co[4], const float v3co[4], /* screenspace coords */
const float uv1co[2], const float uv2co[2], const float uv3co[2],
float pixelScreenCo[4],
float w[3])
{
@@ -1101,9 +1101,9 @@ static void screen_px_from_persp(
/* same as screen_px_from_persp except we return ortho weights back to the caller.
* These weights will be used to determine correct interpolation of uvs in cloned uv layer */
static void screen_px_from_persp_ortho_weights(
float uv[2],
float v1co[4], float v2co[4], float v3co[4], /* screenspace coords */
float uv1co[2], float uv2co[2], float uv3co[2],
const float uv[2],
const float v1co[4], const float v2co[4], const float v3co[4], /* screenspace coords */
const float uv1co[2], const float uv2co[2], const float uv3co[2],
float pixelScreenCo[4],
float w[3])
{
@@ -1711,8 +1711,8 @@ static bool project_bucket_isect_circle(const float cent[2], const float radius_
static void rect_to_uvspace_ortho(
rctf *bucket_bounds,
float *v1coSS, float *v2coSS, float *v3coSS,
float *uv1co, float *uv2co, float *uv3co,
const float *v1coSS, const float *v2coSS, const float *v3coSS,
const float *uv1co, const float *uv2co, const float *uv3co,
float bucket_bounds_uv[4][2],
const int flip)
{
@@ -1744,8 +1744,8 @@ static void rect_to_uvspace_ortho(
/* same as above but use barycentric_weights_v2_persp */
static void rect_to_uvspace_persp(
rctf *bucket_bounds,
float *v1coSS, float *v2coSS, float *v3coSS,
float *uv1co, float *uv2co, float *uv3co,
const float *v1coSS, const float *v2coSS, const float *v3coSS,
const float *uv1co, const float *uv2co, const float *uv3co,
float bucket_bounds_uv[4][2],
const int flip
)
@@ -1821,7 +1821,7 @@ static void project_bucket_clip_face(
const bool is_ortho,
rctf *bucket_bounds,
float *v1coSS, float *v2coSS, float *v3coSS,
float *uv1co, float *uv2co, float *uv3co,
const float *uv1co, const float *uv2co, const float *uv3co,
float bucket_bounds_uv[8][2],
int *tot)
{

View File

@@ -1185,8 +1185,10 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA
bool found = false;
unsigned int index;
int mval[2] = {win->eventstate->x - vc.ar->winrct.xmin,
win->eventstate->y - vc.ar->winrct.ymin};
const int mval[2] = {
win->eventstate->x - vc.ar->winrct.xmin,
win->eventstate->y - vc.ar->winrct.ymin,
};
view3d_operator_needs_opengl(C);
ED_view3d_init_mats_rv3d(vc.obact, vc.rv3d);

View File

@@ -4012,7 +4012,7 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
{
SculptSession *ss = ob->sculpt;
StrokeCache *cache = ss->cache;
float mouse[2] = {
const float mouse[2] = {
cache->mouse[0],
cache->mouse[1]
};

View File

@@ -468,7 +468,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
}
static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
float marker_pos[2], int width, int height)
const float marker_pos[2], int width, int height)
{
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
bool show_search = false;
@@ -571,7 +571,7 @@ static void track_colors(MovieTrackingTrack *track, int act, float col[3], float
}
static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
float marker_pos[2], int width, int height, int act, int sel)
const float marker_pos[2], int width, int height, int act, int sel)
{
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
bool show_search = false;
@@ -785,7 +785,7 @@ static void draw_marker_slide_triangle(float x, float y, float dx, float dy, int
}
static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
float marker_pos[2], int outline, int sel, int act, int width, int height)
const float marker_pos[2], int outline, int sel, int act, int width, int height)
{
float dx, dy, patdx, patdy, searchdx, searchdy;
int tiny = sc->flag & SC_SHOW_TINY_MARKER;
@@ -898,7 +898,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
}
static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
float marker_pos[2], int act, int width, int height, float zoomx, float zoomy)
const float marker_pos[2], int act, int width, int height, float zoomx, float zoomy)
{
char str[128] = {0}, state[64] = {0};
float dx = 0.0f, dy = 0.0f, fontsize, pos[3];

View File

@@ -96,8 +96,10 @@ static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack
static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
{
static float colors[2][3] = {{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f}};
const float colors[2][3] = {
{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f},
};
float col[4];
copy_v3_v3(col, colors[coord]);

View File

@@ -473,7 +473,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
}
static int mouse_on_slide_zone(SpaceClip *sc, MovieTrackingMarker *marker,
int area, float co[2], float slide_zone[2],
int area, const float co[2], const float slide_zone[2],
float padding, int width, int height)
{
const float size = 12.0f;
@@ -504,7 +504,7 @@ static int mouse_on_slide_zone(SpaceClip *sc, MovieTrackingMarker *marker,
}
static int mouse_on_corner(SpaceClip *sc, MovieTrackingMarker *marker,
int area, float co[2], int corner, float padding,
int area, const float co[2], int corner, float padding,
int width, int height)
{
float min[2], max[2], crn[2];
@@ -573,7 +573,7 @@ static int get_mouse_pattern_corner(SpaceClip *sc, MovieTrackingMarker *marker,
}
static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
float co[2], int width, int height)
const float co[2], int width, int height)
{
float pos[2], dx, dy;
float pat_min[2], pat_max[2];

View File

@@ -587,14 +587,14 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node)
static void node_circle_draw(float x, float y, float size, const float col[4], int highlight)
{
/* 16 values of sin function */
static float si[16] = {
static 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] = {
static 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,

View File

@@ -1467,7 +1467,7 @@ static void bgl_sphere_project(float ax, float az)
static void draw_dof_ellipse(float ax, float az)
{
static float staticSine[16] = {
const float staticSine[16] = {
0.0f, 0.104528463268f, 0.207911690818f, 0.309016994375f,
0.406736643076f, 0.5f, 0.587785252292f, 0.669130606359f,
0.743144825477f, 0.809016994375f, 0.866025403784f,

View File

@@ -150,7 +150,7 @@ static void view3d_draw_clipping(RegionView3D *rv3d)
BoundBox *bb = rv3d->clipbb;
if (bb) {
static unsigned int clipping_index[6][4] = {
const unsigned int clipping_index[6][4] = {
{0, 1, 2, 3},
{0, 4, 5, 1},
{4, 7, 6, 5},

View File

@@ -621,7 +621,7 @@ static void viewops_data_create_ex(bContext *C, wmOperator *op, const wmEvent *e
negate_v3_v3(rv3d->ofs, dvec);
}
else {
float mval_ar_mid[2] = {
const float mval_ar_mid[2] = {
(float)vod->ar->winx / 2.0f,
(float)vod->ar->winy / 2.0f};

View File

@@ -282,9 +282,11 @@ static bool view3d_ruler_pick(RulerInfo *ruler_info, const float mval[2],
ruler_item_best = ruler_item;
{
float dist_points[3] = {len_squared_v2v2(co_ss[0], mval),
len_squared_v2v2(co_ss[1], mval),
len_squared_v2v2(co_ss[2], mval)};
const float dist_points[3] = {
len_squared_v2v2(co_ss[0], mval),
len_squared_v2v2(co_ss[1], mval),
len_squared_v2v2(co_ss[2], mval),
};
if (min_fff(UNPACK3(dist_points)) < RULER_PICK_DIST_SQ) {
co_index_best = min_axis_v3(dist_points);
}
@@ -301,8 +303,10 @@ static bool view3d_ruler_pick(RulerInfo *ruler_info, const float mval[2],
ruler_item_best = ruler_item;
{
float dist_points[2] = {len_squared_v2v2(co_ss[0], mval),
len_squared_v2v2(co_ss[2], mval)};
const float dist_points[2] = {
len_squared_v2v2(co_ss[0], mval),
len_squared_v2v2(co_ss[2], mval),
};
if (min_ff(UNPACK2(dist_points)) < RULER_PICK_DIST_SQ) {
co_index_best = (dist_points[0] < dist_points[1]) ? 0 : 2;
}

View File

@@ -1189,7 +1189,7 @@ static void draw_manipulator_rotate(
static void drawsolidcube(float size)
{
static float cube[8][3] = {
const float cube[8][3] = {
{-1.0, -1.0, -1.0},
{-1.0, -1.0, 1.0},
{-1.0, 1.0, 1.0},

View File

@@ -991,7 +991,7 @@ static bool uv_select_edgeloop_edge_tag_faces(BMEditMesh *em, UvMapVert *first1,
}
static int uv_select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit *hit,
float limit[2], const bool extend)
const float limit[2], const bool extend)
{
BMFace *efa;
BMIter iter, liter;

View File

@@ -1481,7 +1481,7 @@ static void gpu_color_from_mask_quad_copy(const CCGKey *key,
static void gpu_color_from_mask_quad_set(const CCGKey *key,
CCGElem *a, CCGElem *b,
CCGElem *c, CCGElem *d,
float diffuse_color[4])
const float diffuse_color[4])
{
float color = gpu_color_from_mask_quad(key, a, b, c, d);
glColor3f(diffuse_color[0] * color, diffuse_color[1] * color, diffuse_color[2] * color);

View File

@@ -674,7 +674,7 @@ struct scale_outpix_float {
};
static void shrink_picture_float(
float *src, float *dst, int src_width,
const float *src, float *dst, int src_width,
int src_height, int dst_width, int dst_height)
{
double ratiox = (double) (dst_width) / (double) (src_width);

View File

@@ -752,7 +752,7 @@ static EMat *build_edge_mats(const MVertSkin *vs,
* having any special cases for dealing with sharing a frame between
* two hulls.) */
static int calc_edge_subdivisions(const MVert *mvert, const MVertSkin *nodes,
const MEdge *e, int *degree)
const MEdge *e, const int *degree)
{
/* prevent memory errors [#38003] */
#define NUM_SUBDIVISIONS_MAX 128

View File

@@ -277,7 +277,7 @@ int wm_cursor_arrow_move(wmWindow *win, wmEvent *event)
void WM_cursor_time(wmWindow *win, int nr)
{
/* 10 8x8 digits */
static char number_bitmaps[10][8] = {
const char number_bitmaps[10][8] = {
{0, 56, 68, 68, 68, 68, 68, 56},
{0, 24, 16, 16, 16, 16, 16, 56},
{0, 60, 66, 32, 16, 8, 4, 126},