Cleanup: confusing if statements & alignment

This commit is contained in:
Campbell Barton 2015-04-08 12:23:38 +10:00
parent ccfb9a96c3
commit 808ea6271a
7 changed files with 38 additions and 51 deletions

@ -714,7 +714,7 @@ GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_WindowWin32 *window
// zDelta /= WHEEL_DELTA; // zDelta /= WHEEL_DELTA;
// temporary fix below: microsoft now has added more precision, making the above division not work // temporary fix below: microsoft now has added more precision, making the above division not work
if (zDelta <= 0) zDelta = -1; else zDelta = 1; zDelta = (zDelta <= 0) ? -1 : 1;
// short xPos = (short) LOWORD(lParam); // horizontal position of pointer // short xPos = (short) LOWORD(lParam); // horizontal position of pointer
// short yPos = (short) HIWORD(lParam); // vertical position of pointer // short yPos = (short) HIWORD(lParam); // vertical position of pointer

@ -1161,29 +1161,24 @@ static void make_black_ibuf(ImBuf *ibuf)
} }
} }
static void multibuf(ImBuf *ibuf, float fmul) static void multibuf(ImBuf *ibuf, const float fmul)
{ {
char *rt; char *rt;
float *rt_float; float *rt_float;
int a, mul, icol; int a;
mul = (int)(256.0f * fmul);
rt = (char *)ibuf->rect; rt = (char *)ibuf->rect;
rt_float = ibuf->rect_float; rt_float = ibuf->rect_float;
if (rt) { if (rt) {
const int imul = (int)(256.0f * fmul);
a = ibuf->x * ibuf->y; a = ibuf->x * ibuf->y;
while (a--) { while (a--) {
rt[0] = min_ii((imul * rt[0]) >> 8, 255);
icol = (mul * rt[0]) >> 8; rt[1] = min_ii((imul * rt[1]) >> 8, 255);
if (icol > 254) rt[0] = 255; else rt[0] = icol; rt[2] = min_ii((imul * rt[2]) >> 8, 255);
icol = (mul * rt[1]) >> 8; rt[3] = min_ii((imul * rt[3]) >> 8, 255);
if (icol > 254) rt[1] = 255; else rt[1] = icol;
icol = (mul * rt[2]) >> 8;
if (icol > 254) rt[2] = 255; else rt[2] = icol;
icol = (mul * rt[3]) >> 8;
if (icol > 254) rt[3] = 255; else rt[3] = icol;
rt += 4; rt += 4;
} }

@ -795,22 +795,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
nr = me->totface; nr = me->totface;
tface = me->tface; tface = me->tface;
while (nr--) { while (nr--) {
cp = (char *)&tface->col[0]; int j;
if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2; for (j = 0; j < 4; j++) {
if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2; int k;
if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2; cp = ((char *)&tface->col[j]) + 1;
cp = (char *)&tface->col[1]; for (k = 0; k < 3; k++) {
if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2; cp[k] = (cp[k] > 126) ? 255 : cp[k] * 2;
if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2; }
if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2; }
cp = (char *)&tface->col[2];
if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2;
if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2;
if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2;
cp = (char *)&tface->col[3];
if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2;
if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2;
if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2;
tface++; tface++;
} }

@ -65,7 +65,7 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
if (isBreaked()) breaked = true; if (isBreaked()) breaked = true;
if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3); if (!breaked) FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
if (settings->iter & 1) ofs = 0.5f; else ofs = 0.f; ofs = (settings->iter & 1) ? 0.5f : 0.0f;
for (x = 0; x < (settings->iter * 4); x++) { for (x = 0; x < (settings->iter * 4); x++) {
y = x & 3; y = x & 3;
cm[x][0] = cm[x][1] = cm[x][2] = 1; cm[x][0] = cm[x][1] = cm[x][2] = 1;

@ -602,10 +602,10 @@ static void round_box_shade_col4_r(unsigned char r_col[4], const char col1[4], c
const int faci = FTOCHAR(fac); const int faci = FTOCHAR(fac);
const int facm = 255 - faci; const int facm = 255 - faci;
r_col[0] = (faci * col1[0] + facm * col2[0]) >> 8; r_col[0] = (faci * col1[0] + facm * col2[0]) / 256;
r_col[1] = (faci * col1[1] + facm * col2[1]) >> 8; r_col[1] = (faci * col1[1] + facm * col2[1]) / 256;
r_col[2] = (faci * col1[2] + facm * col2[2]) >> 8; r_col[2] = (faci * col1[2] + facm * col2[2]) / 256;
r_col[3] = (faci * col1[3] + facm * col2[3]) >> 8; r_col[3] = (faci * col1[3] + facm * col2[3]) / 256;
} }
static void widget_verts_to_triangle_strip(uiWidgetBase *wtb, const int totvert, float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2]) static void widget_verts_to_triangle_strip(uiWidgetBase *wtb, const int totvert, float triangle_strip[WIDGET_SIZE_MAX * 2 + 2][2])

@ -648,7 +648,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf)
wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255); wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, scope_gamma) * 255);
} }
for (x = 0; x <= 255; x++) { for (x = 0; x < 256; x++) {
vectorscope_put_cross(255, 0, 255 - x, tgt, w, h, 1); vectorscope_put_cross(255, 0, 255 - x, tgt, w, h, 1);
vectorscope_put_cross(255, x, 0, tgt, w, h, 1); vectorscope_put_cross(255, x, 0, tgt, w, h, 1);
vectorscope_put_cross(255 - x, 255, 0, tgt, w, h, 1); vectorscope_put_cross(255 - x, 255, 0, tgt, w, h, 1);

@ -2249,9 +2249,9 @@ static void do_merge_fullsample(Render *re, bNodeTree *ntree)
for (x = 0; x < re->rectx; x++, rf += 4, col += 4) { for (x = 0; x < re->rectx; x++, rf += 4, col += 4) {
/* clamping to 1.0 is needed for correct AA */ /* clamping to 1.0 is needed for correct AA */
if (col[0] < 0.0f) col[0] = 0.0f; else if (col[0] > 1.0f) col[0] = 1.0f; CLAMP(col[0], 0.0, 1.0f);
if (col[1] < 0.0f) col[1] = 0.0f; else if (col[1] > 1.0f) col[1] = 1.0f; CLAMP(col[1], 0.0, 1.0f);
if (col[2] < 0.0f) col[2] = 0.0f; else if (col[2] > 1.0f) col[2] = 1.0f; CLAMP(col[2], 0.0, 1.0f);
add_filt_fmask_coord(filt, col, rf, re->rectx, re->recty, x, y); add_filt_fmask_coord(filt, col, rf, re->rectx, re->recty, x, y);
} }