Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-04-03 08:20:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-04-03 08:25:43 +0300
commitd1e55be96e89c262262d5e79fef70ef3fc12fd6c (patch)
tree00c17bb450e93fd8bbd5c0152acdfdd16e7d0046 /source/blender/editors/screen/glutil.c
parenteba09b1520c06df304bc353e93d7220b4e83b755 (diff)
Add gluPartialDisk replacement (imm_draw_filled_circle_partial)
Needed for custom-manipulators branch but generally useful.
Diffstat (limited to 'source/blender/editors/screen/glutil.c')
-rw-r--r--source/blender/editors/screen/glutil.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index c66268beb9f..a613537100b 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -103,6 +103,38 @@ void imm_draw_filled_circle(unsigned pos, float x, float y, float rad, int nsegm
imm_draw_circle(PRIM_TRIANGLE_FAN, pos, x, y, rad, nsegments);
}
+/**
+ * \note We could have `imm_draw_lined_circle_partial` but currently there is no need.
+ */
+static void imm_draw_circle_partial(
+ PrimitiveType prim_type, unsigned pos, float x, float y,
+ float rad_inner, float rad_outer, int nsegments, float start, float sweep)
+{
+ /* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */
+ const float angle_start = -(DEG2RADF(start)) + (M_PI / 2);
+ const float angle_end = -(DEG2RADF(sweep) - angle_start);
+ nsegments += 1;
+ immBegin(prim_type, nsegments * 2);
+ for (int i = 0; i < nsegments; ++i) {
+ const float angle = interpf(angle_start, angle_end, ((float)i / (float)(nsegments - 1)));
+ const float angle_sin = sinf(angle);
+ const float angle_cos = cosf(angle);
+ immVertex2f(pos, x + rad_inner * angle_cos, y + rad_inner * angle_sin);
+ immVertex2f(pos, x + rad_outer * angle_cos, y + rad_outer * angle_sin);
+ }
+ immEnd();
+}
+
+/**
+ * Replacement for gluPartialDisk, (without 'loops' argument).
+ */
+void imm_draw_filled_circle_partial(
+ unsigned pos, float x, float y,
+ float rad_inner, float rad_outer, int nsegments, float start, float sweep)
+{
+ imm_draw_circle_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)
{
immBegin(PRIM_LINE_LOOP, nsegments);