[Bf-blender-cvs] [901b0de] master: cleanup: C99
Mike Erwin
noreply at git.blender.org
Wed Dec 16 07:28:56 CET 2015
Commit: 901b0dea620a943a227ae2d7732cef0948777e7e
Author: Mike Erwin
Date: Wed Dec 16 01:24:15 2015 -0500
Branches: master
https://developer.blender.org/rB901b0dea620a943a227ae2d7732cef0948777e7e
cleanup: C99
- for loop scope
- tighter scope on local vars
- more bool
- more const
===================================================================
M source/blender/editors/include/ED_view3d.h
M source/blender/editors/space_view3d/drawobject.c
===================================================================
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index f325aba..d44c401 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -265,7 +265,7 @@ float ED_view3d_radius_to_dist(
const char persp, const bool use_aspect,
const float radius);
-void drawcircball(int mode, const float cent[3], float rad, float tmat[4][4]);
+void drawcircball(int mode, const float cent[3], float rad, const float tmat[4][4]);
/* backbuffer select and draw support */
void ED_view3d_backbuf_validate(struct ViewContext *vc);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index e03f817..681e64f 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -604,13 +604,12 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
Image *ima = ob->data;
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, ob->iuser, NULL);
- float scale, ofs_x, ofs_y, sca_x, sca_y;
- int ima_x, ima_y;
-
if (ibuf && (ibuf->rect == NULL) && (ibuf->rect_float != NULL)) {
IMB_rect_from_float(ibuf);
}
+ int ima_x, ima_y;
+
/* Get the buffer dimensions so we can fallback to fake ones */
if (ibuf && ibuf->rect) {
ima_x = ibuf->x;
@@ -621,35 +620,28 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
ima_y = 1;
}
+ float sca_x = 1.0f;
+ float sca_y = 1.0f;
+
/* Get the image aspect even if the buffer is invalid */
if (ima) {
if (ima->aspx > ima->aspy) {
- sca_x = 1.0f;
sca_y = ima->aspy / ima->aspx;
}
else if (ima->aspx < ima->aspy) {
sca_x = ima->aspx / ima->aspy;
- sca_y = 1.0f;
- }
- else {
- sca_x = 1.0f;
- sca_y = 1.0f;
}
}
- else {
- sca_x = 1.0f;
- sca_y = 1.0f;
- }
/* Calculate the scale center based on object's origin */
- ofs_x = ob->ima_ofs[0] * ima_x;
- ofs_y = ob->ima_ofs[1] * ima_y;
+ float ofs_x = ob->ima_ofs[0] * ima_x;
+ float ofs_y = ob->ima_ofs[1] * ima_y;
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
/* Calculate Image scale */
- scale = (ob->empty_drawsize / max_ff((float)ima_x * sca_x, (float)ima_y * sca_y));
+ float scale = ob->empty_drawsize / max_ff((float)ima_x * sca_x, (float)ima_y * sca_y);
/* Set the object scale */
glScalef(scale * sca_x, scale * sca_y, 1.0f);
@@ -659,7 +651,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
int zoomfilter = (U.gameflags & USER_DISABLE_MIPMAP ) ? GL_NEAREST : GL_LINEAR;
/* Setup GL params */
glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (use_clip) {
glEnable(GL_ALPHA_TEST);
@@ -693,7 +685,6 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
glVertex2f(ofs_x, ofs_y + ima_y);
glEnd();
-
/* Reset GL settings */
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
@@ -701,23 +692,22 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
BKE_image_release_ibuf(ima, ibuf, NULL);
}
-static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, float tmat[4][4])
+static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, const float tmat[4][4])
{
float vx[3], vy[3];
float *viter = (float *)verts;
- unsigned int a;
mul_v3_v3fl(vx, tmat[0], rad);
mul_v3_v3fl(vy, tmat[1], rad);
- for (a = 0; a < CIRCLE_RESOL; a++, viter += 3) {
+ for (unsigned int a = 0; a < CIRCLE_RESOL; a++, viter += 3) {
viter[0] = cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
viter[1] = cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
viter[2] = cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
}
}
-void drawcircball(int mode, const float cent[3], float rad, float tmat[4][4])
+void drawcircball(int mode, const float cent[3], float rad, const float tmat[4][4])
{
float verts[CIRCLE_RESOL][3];
@@ -744,7 +734,6 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3],
if (special_color) {
if (selstate == ACTIVE || selstate == SELECT) glColor4ub(0x88, 0xFF, 0xFF, 155);
-
else glColor4ub(0x55, 0xCC, 0xCC, 155);
}
else {
@@ -1084,8 +1073,6 @@ static void spotvolume(float lvec[3], float vvec[3], const float inp)
mul_m3_v3(mat2, lvec);
mul_m3_m3m3(mat2, mat1, mat4);
mul_m3_v3(mat2, vvec);
-
- return;
}
static void draw_spot_cone(Lamp *la, float x, float z)
@@ -1103,11 +1090,8 @@ static void draw_spot_cone(Lamp *la, float x, float z)
glVertex3f(z, z, 0);
}
else {
- float angle;
- int a;
-
- for (a = 0; a < 33; a++) {
- angle = a * M_PI * 2 / (33 - 1);
+ for (int a = 0; a < 33; a++) {
+ float angle = a * M_PI * 2 / (33 - 1);
glVertex3f(z * cosf(angle), z * sinf(angle), 0);
}
}
@@ -1765,13 +1749,12 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D
if (reconstruction->camnr) {
MovieReconstructedCamera *camera = reconstruction->cameras;
- int a = 0;
UI_ThemeColor(TH_CAMERA_PATH);
glLineWidth(2.0f);
glBegin(GL_LINE_STRIP);
- for (a = 0; a < reconstruction->camnr; a++, camera++) {
+ for (int a = 0; a < reconstruction->camnr; a++, camera++) {
glVertex3fv(camera->mat[3]);
}
glEnd();
@@ -1891,7 +1874,6 @@ static void drawcamera_stereo3d(
Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, const Camera *cam,
float vec[4][3], float drawsize, const float scale[3])
{
- int i;
float obmat[4][4];
float vec_lr[2][4][3];
const float fac = (cam->stereo.pivot == CAM_S3D_PIVOT_CENTER) ? 2.0f : 1.0f;
@@ -1908,7 +1890,7 @@ static void drawcamera_stereo3d(
glPushMatrix();
- for (i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
ob = BKE_camera_multiview_render(scene, ob, names[i]);
cam_lr[i] = ob->data;
@@ -1975,7 +1957,7 @@ static void drawcamera_stereo3d(
mid_v3_v3v3(axis_center, origin[0], origin[1]);
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
mid_v3_v3v3(world_plane[i], vec_lr[0][i], vec_lr[1][i]);
sub_v3_v3v3(local_plane[i], world_plane[i], axis_center);
}
@@ -1983,7 +1965,7 @@ static void drawcamera_stereo3d(
mid_v3_v3v3(screen_center, world_plane[0], world_plane[2]);
offset = cam->stereo.convergence_distance / len_v3v3(screen_center, axis_center);
- for (i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++) {
mul_v3_fl(local_plane[i], offset);
add_v3_v3(local_plane[i], axis_center);
}
@@ -2010,15 +1992,13 @@ static void drawcamera_stereo3d(
if (is_stereo3d_volume) {
float screen_center[3];
float near_plane[4][3], far_plane[4][3];
- float offset;
- int j;
- for (i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
mid_v3_v3v3(screen_center, vec_lr[i][0], vec_lr[i][2]);
- offset = len_v3v3(screen_center, origin[i]);
+ float offset = len_v3v3(screen_center, origin[i]);
- for (j = 0; j < 4; j++) {
+ for (int j = 0; j < 4; j++) {
sub_v3_v3v3(near_plane[j], vec_lr[i][j], origin[i]);
mul_v3_fl(near_plane[j], cam_lr[i]->clipsta / offset);
add_v3_v3(near_plane[j], origin[i]);
@@ -2066,8 +2046,6 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
Object *ob = base->object;
float tvec[3];
float vec[4][3], asp[2], shift[2], scale[3];
- int i;
- float drawsize;
MovieClip *clip = BKE_object_movieclip_get(scene, base->object, false);
const bool is_active = (ob == v3d->camera);
@@ -2120,6 +2098,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
scale[2] = 1.0f / len_v3(ob->obmat[2]);
}
+ float drawsize;
BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale,
asp, shift, &drawsize, vec);
@@ -2160,7 +2139,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base
/* draw an outline arrow for inactive cameras and filled
* for active cameras. We actually draw both outline+filled
* for active cameras so the wire can be seen side-on */
- for (i = 0; i < 2; i++) {
+ for (int i = 0; i < 2; i++) {
if (i == 0) glBegin(GL_LINE_LOOP);
else if (i == 1 && is_active) glBegin(GL_TRIANGLES);
else break;
@@ -2223,15 +2202,14 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
Object *UNUSED(ob), int UNUSED(flag))
{
float vec[3];
- int i, j;
glEnable(GL_BLEND);
- for (j = 0; j < 3; j++) {
+ for (int j = 0; j < 3; j++) {
vec[2] = 0.25f * j - 0.125f;
glBegin(GL_LINE_LOOP);
- for (i = 0; i < 16; i++) {
+ for (int i = 0; i < 16; i++) {
vec[0] = cosf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
vec[1] = sinf((float)M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f);
glVertex3fv(vec);
@@ -2239,11 +2217,11 @@ static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D
glEnd();
}
- for (j = 0; j < 4; j++) {
+ for (int j = 0; j < 4; j++) {
vec[0] = (((j + 1) % 2) * (j - 1)) * 0.5f;
vec[1] = ((j % 2) * (j - 2)) * 0.5f;
glBegin(GL_LINE_STRIP);
- for (i = 0; i < 3; i++) {
+ for (int i = 0; i < 3; i++) {
if (i == 1) {
vec[0] *= 0.5f;
vec[1] *= 0.5f;
@@ -2262,7 +2240,6 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short s
{
BPoint *bp = lt->def;
const float *co = dl ? dl->verts : NULL;
- int u, v, w;
const int color = sel ? TH_VERTEX_SELECT : TH_VERTEX;
UI_ThemeColor(color);
@@ -2270,11 +2247,11 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short s
glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
bglBegin(GL_POINTS);
- for (w = 0; w < lt->pntsw; w++) {
+ for (int w = 0; w < lt->pntsw; w++) {
int wxt = (w == 0 || w == lt->pntsw - 1);
- for (v = 0; v < lt->pntsv; v++) {
+ for (int v = 0; v < lt->pntsv; v++) {
int vxt = (v == 0 || v == lt->pntsv - 1);
- for (u = 0; u < lt->pntsu; u++, bp++, co += 3) {
+ for (int u = 0; u < lt->pntsu; u++, bp++, co += 3) {
int uxt = (u
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list