Naming constancy for 'imm' utility functions

- use 'imm_draw_' prefix for functions that draw.
- use '_3d' suffix for 3d functions, no suffix for 2d functions.
- use terms fill/wire (shorter than filled / lined).

Also add `imm_draw_circle_fill_3d` (only had wire version)
This commit is contained in:
Campbell Barton 2017-04-05 17:43:28 +10:00
parent bcd95dbdbb
commit 4dadb6d445
10 changed files with 46 additions and 31 deletions

View File

@ -478,7 +478,7 @@ static void sk_drawEdge(SK_Point *pt0, SK_Point *pt1, float size, float color[4]
angle = angle_normalized_v3v3(vec2, vec1);
gpuRotate3fv(angle * (float)(180.0 / M_PI) + 180.0f, axis);
imm_cylinder(pos, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
imm_draw_cylinder_fill_3d(pos, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
immUnbindProgram();
}
@ -506,7 +506,7 @@ static void sk_drawNormal(SK_Point *pt, float size, float height)
angle = angle_normalized_v3v3(vec2, pt->no);
gpuRotate3fv(angle * (float)(180.0 / M_PI), axis);
imm_cylinder(pos, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
imm_draw_cylinder_fill_3d(pos, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
immUnbindProgram();

View File

@ -1852,7 +1852,7 @@ static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr)
glEnable(GL_BLEND);
immUniformColor4ub(255, 100, 100, 20);
imm_draw_filled_circle(pos, x, y, p->radius, 40);
imm_draw_circle_fill(pos, x, y, p->radius, 40);
setlinestyle(6); /* TODO: handle line stipple in shader */

View File

@ -60,7 +60,8 @@ struct ColorManagedDisplaySettings;
void imm_draw_lined_circle(unsigned pos, float x, float y, float radius, int nsegments);
/* use this version when VertexFormat has a vec3 position */
void imm_draw_lined_circle_3D(unsigned pos, float x, float y, float radius, int nsegments);
void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float radius, int nsegments);
void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float radius, int nsegments);
/**
* Draw a filled circle with the given \a radius.
@ -72,7 +73,7 @@ void imm_draw_lined_circle_3D(unsigned pos, float x, float y, float radius, int
* \param radius The circle's radius.
* \param nsegments The number of segments to use in drawing (more = smoother).
*/
void imm_draw_filled_circle(unsigned pos, float x, float y, float radius, int nsegments);
void imm_draw_circle_fill(unsigned pos, float x, float y, float radius, int nsegments);
/**
* Draw a filled arc with the given inner and outer radius.
@ -89,7 +90,7 @@ void imm_draw_filled_circle(unsigned pos, float x, float y, float radius, int ns
* \param start: Specifies the starting angle, in degrees, of the disk portion.
* \param sweep: Specifies the sweep angle, in degrees, of the disk portion.
*/
void imm_draw_filled_disk_partial(
void imm_draw_disk_partial_fill(
unsigned pos, float x, float y,
float radius_inner, float radius_outer, int nsegments, float start, float sweep);
@ -105,7 +106,7 @@ void imm_draw_filled_disk_partial(
void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2);
/* use this version when VertexFormat has a vec3 position */
void imm_draw_line_box_3D(unsigned pos, float x1, float y1, float x2, float y2);
void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2);
/* Draw a standard checkerboard to indicate transparent backgrounds */
void imm_draw_checker_box(float x1, float y1, float x2, float y2);
@ -129,9 +130,10 @@ void imm_cpack(unsigned int x);
* \param slices Specifies the number of subdivisions around the z axis.
* \param stacks Specifies the number of subdivisions along the z axis.
*/
void imm_cylinder_nor(unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks);
void imm_cylinder_wire(unsigned int pos, float base, float top, float height, int slices, int stacks);
void imm_cylinder(unsigned int pos, float base, float top, float height, int slices, int stacks);
void imm_draw_cylinder_fill_normal_3d(
unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks);
void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks);
void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks);
/**
* Returns a float value as obtained by glGetFloatv.

View File

@ -2270,7 +2270,7 @@ static void ui_hsv_cursor(float x, float y)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3f(1.0f, 1.0f, 1.0f);
imm_draw_filled_circle(pos, x, y, 3.0f * U.pixelsize, 8);
imm_draw_circle_fill(pos, x, y, 3.0f * U.pixelsize, 8);
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);

View File

@ -97,7 +97,7 @@ void imm_draw_lined_circle(unsigned pos, float x, float y, float rad, int nsegme
imm_draw_circle(PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
}
void imm_draw_filled_circle(unsigned pos, float x, float y, float rad, int nsegments)
void imm_draw_circle_fill(unsigned pos, float x, float y, float rad, int nsegments)
{
imm_draw_circle(PRIM_TRIANGLE_FAN, pos, x, y, rad, nsegments);
}
@ -127,16 +127,18 @@ static void imm_draw_disk_partial(
/**
* Replacement for gluPartialDisk, (without 'loops' argument).
*/
void imm_draw_filled_disk_partial(
void imm_draw_disk_partial_fill(
unsigned pos, float x, float y,
float rad_inner, float rad_outer, int nsegments, float start, float sweep)
{
imm_draw_disk_partial(PRIM_TRIANGLE_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep);
}
void imm_draw_lined_circle_3D(unsigned pos, float x, float y, float rad, int nsegments)
static void imm_draw_circle_3D(
PrimitiveType prim_type, unsigned pos, float x, float y,
float rad, int nsegments)
{
immBegin(PRIM_LINE_LOOP, nsegments);
immBegin(prim_type, nsegments);
for (int i = 0; i < nsegments; ++i) {
float angle = 2 * M_PI * ((float)i / (float)nsegments);
immVertex3f(pos, x + rad * cosf(angle), y + rad * sinf(angle), 0.0f);
@ -144,6 +146,16 @@ void imm_draw_lined_circle_3D(unsigned pos, float x, float y, float rad, int nse
immEnd();
}
void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float rad, int nsegments)
{
imm_draw_circle_3D(PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
}
void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nsegments)
{
imm_draw_circle_3D(PRIM_TRIANGLE_FAN, pos, x, y, rad, nsegments);
}
void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
{
immBegin(PRIM_LINE_LOOP, 4);
@ -154,7 +166,7 @@ void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
immEnd();
}
void imm_draw_line_box_3D(unsigned pos, float x1, float y1, float x2, float y2)
void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2)
{
/* use this version when VertexFormat has a vec3 position */
immBegin(PRIM_LINE_LOOP, 4);
@ -186,7 +198,8 @@ void imm_cpack(unsigned int x)
(((x) >> 16) & 0xFF));
}
void imm_cylinder_nor(unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks)
void imm_draw_cylinder_fill_normal_3d(
unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks)
{
immBegin(GL_TRIANGLES, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
@ -237,7 +250,7 @@ void imm_cylinder_nor(unsigned int pos, unsigned int nor, float base, float top,
immEnd();
}
void imm_cylinder_wire(unsigned int pos, float base, float top, float height, int slices, int stacks)
void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
{
immBegin(GL_LINES, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {
@ -274,7 +287,7 @@ void imm_cylinder_wire(unsigned int pos, float base, float top, float height, in
immEnd();
}
void imm_cylinder(unsigned int pos, float base, float top, float height, int slices, int stacks)
void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
{
immBegin(GL_TRIANGLES, 6 * slices * stacks);
for (int i = 0; i < slices; ++i) {

View File

@ -462,7 +462,7 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4ub(0, 0, 0, 32);
imm_draw_filled_circle(pos, (float)x, (float)y, 20, 40);
imm_draw_circle_fill(pos, (float)x, (float)y, 20, 40);
immUniformColor4ub(255, 255, 255, 128);
imm_draw_lined_circle(pos, (float)x, (float)y, 20, 40);

View File

@ -1115,7 +1115,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
immUniform3fv("light", light_vec);
gpuTranslate3f(0.0f, 0.0f, head);
imm_cylinder_nor(pos, nor, size2, size1, length - head - tail, 16, 1);
imm_draw_cylinder_fill_normal_3d(pos, nor, size2, size1, length - head - tail, 16, 1);
immUnbindProgram();

View File

@ -1453,7 +1453,7 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
* previously it adjusted to always to show it but that seems
* confusing because it doesn't show the actual blend size */
if (blend != 0.0f && blend != z_abs) {
imm_draw_line_box_3D(pos, blend, -blend, -blend, blend);
imm_draw_line_box_3d(pos, blend, -blend, -blend, blend);
}
}
}
@ -1467,7 +1467,7 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
/* draw the circle at the end of the cone */
gpuTranslate3f(0.0f, 0.0f, x);
imm_draw_lined_circle_3D(pos, 0.0f, 0.0f, z_abs, 32);
imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, z_abs, 32);
/* draw the circle representing spotbl */
if (la->type == LA_SPOT) {
@ -1477,7 +1477,7 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
* previously it adjusted to always to show it but that seems
* confusing because it doesn't show the actual blend size */
if (blend != 0.0f && blend != z_abs) {
imm_draw_lined_circle_3D(pos, 0.0f, 0.0f, blend, 32);
imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, blend, 32);
}
}
}
@ -1563,9 +1563,9 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
else if (la->type == LA_AREA) {
setlinestyle(3);
if (la->area_shape == LA_AREA_SQUARE)
imm_draw_line_box_3D(pos, -la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
imm_draw_line_box_3d(pos, -la->area_size * 0.5f, -la->area_size * 0.5f, la->area_size * 0.5f, la->area_size * 0.5f);
else if (la->area_shape == LA_AREA_RECT)
imm_draw_line_box_3D(pos, -la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
imm_draw_line_box_3d(pos, -la->area_size * 0.5f, -la->area_sizey * 0.5f, la->area_size * 0.5f, la->area_sizey * 0.5f);
immBegin(GL_LINES, 2);
immVertex3f(pos, 0.0f, 0.0f, -circrad);
@ -8048,20 +8048,20 @@ static void imm_draw_bb(BoundBox *bb, char type, bool around_origin, const unsig
float radius = size[0] > size[1] ? size[0] : size[1];
gpuTranslate3f(cent[0], cent[1], cent[2] - size[2]);
gpuScale3f(radius, radius, 2.0f * size[2]);
imm_cylinder_wire(pos, 1.0f, 1.0f, 1.0f, 8, 1);
imm_draw_cylinder_wire_3d(pos, 1.0f, 1.0f, 1.0f, 8, 1);
}
else if (type == OB_BOUND_CONE) {
float radius = size[0] > size[1] ? size[0] : size[1];
gpuTranslate3f(cent[0], cent[1], cent[2] - size[2]);
gpuScale3f(radius, radius, 2.0f * size[2]);
imm_cylinder_wire(pos, 1.0f, 0.0f, 1.0f, 8, 1);
imm_draw_cylinder_wire_3d(pos, 1.0f, 0.0f, 1.0f, 8, 1);
}
else if (type == OB_BOUND_CAPSULE) {
float radius = size[0] > size[1] ? size[0] : size[1];
float length = size[2] > radius ? 2.0f * (size[2] - radius) : 0.0f;
gpuTranslate3f(cent[0], cent[1], cent[2] - length * 0.5f);
imm_cylinder_wire(pos, radius, radius, length, 8, 1);
imm_draw_cylinder_wire_3d(pos, radius, radius, length, 8, 1);
gpuRotateAxis(90, 'X');
gpuScaleUniform(radius);

View File

@ -296,7 +296,7 @@ static void wm_gesture_draw_circle(wmGesture *gt)
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor4f(1.0, 1.0, 1.0, 0.05);
imm_draw_filled_circle(pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
imm_draw_circle_fill(pos, (float)rect->xmin, (float)rect->ymin, (float)rect->xmax, 40);
immUnbindProgram();

View File

@ -3122,7 +3122,7 @@ static void radial_control_paint_tex(RadialControl *rc, float radius, float alph
/* flat color if no texture available */
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
immUniformColor3fvAlpha(col, alpha);
imm_draw_filled_circle(pos, 0.0f, 0.0f, radius, 40);
imm_draw_circle_fill(pos, 0.0f, 0.0f, radius, 40);
}
immUnbindProgram();