Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_draw.c
| Show First 20 Lines • Show All 1,633 Lines • ▼ Show 20 Lines | static void ui_draw_but_curve_grid(uint pos, const rcti *rect, float zoomx, float zoomy, float offsx, float offsy, float step) | ||||
| if (fy > rect->ymin) { | if (fy > rect->ymin) { | ||||
| fy -= dy * (floorf(fy - rect->ymin)); | fy -= dy * (floorf(fy - rect->ymin)); | ||||
| } | } | ||||
| float line_count = ( | float line_count = ( | ||||
| floorf((rect->xmax - fx) / dx) + 1.0f + | floorf((rect->xmax - fx) / dx) + 1.0f + | ||||
| floorf((rect->ymax - fy) / dy) + 1.0f); | floorf((rect->ymax - fy) / dy) + 1.0f); | ||||
| if (line_count > 0) { | |||||
fclem: Code style: it's better to return early than creating indentation blocks if possible.
It does… | |||||
| immBegin(GPU_PRIM_LINES, (int)line_count * 2); | immBegin(GPU_PRIM_LINES, (int)line_count * 2); | ||||
| while (fx < rect->xmax) { | while (fx <= rect->xmax) { | ||||
| immVertex2f(pos, fx, rect->ymin); | immVertex2f(pos, fx, rect->ymin); | ||||
| immVertex2f(pos, fx, rect->ymax); | immVertex2f(pos, fx, rect->ymax); | ||||
| fx += dx; | fx += dx; | ||||
| } | } | ||||
| while (fy < rect->ymax) { | while (fy <= rect->ymax) { | ||||
| immVertex2f(pos, rect->xmin, fy); | immVertex2f(pos, rect->xmin, fy); | ||||
| immVertex2f(pos, rect->xmax, fy); | immVertex2f(pos, rect->xmax, fy); | ||||
| fy += dy; | fy += dy; | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| } | |||||
| } | } | ||||
| static void gl_shaded_color_get(const uchar color[3], int shade, uchar r_color[3]) | static void gl_shaded_color_get(const uchar color[3], int shade, uchar r_color[3]) | ||||
| { | { | ||||
| r_color[0] = color[0] - shade > 0 ? color[0] - shade : 0; | r_color[0] = color[0] - shade > 0 ? color[0] - shade : 0; | ||||
| r_color[1] = color[1] - shade > 0 ? color[1] - shade : 0; | r_color[1] = color[1] - shade > 0 ? color[1] - shade : 0; | ||||
| r_color[2] = color[2] - shade > 0 ? color[2] - shade : 0; | r_color[2] = color[2] - shade > 0 ? color[2] - shade : 0; | ||||
| ▲ Show 20 Lines • Show All 651 Lines • Show Last 20 Lines | |||||
Code style: it's better to return early than creating indentation blocks if possible.
It does not make a huge diff here in this case but better get used to it.