[Bf-blender-cvs] [55fb6e70965] blender2.8: GPU_immediate_util: Add x, y radius to circle draw
Campbell Barton
noreply at git.blender.org
Wed Sep 13 19:46:32 CEST 2017
Commit: 55fb6e7096536a59ec306eb67889f8cf2f4e94bc
Author: Campbell Barton
Date: Thu Sep 14 01:36:23 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB55fb6e7096536a59ec306eb67889f8cf2f4e94bc
GPU_immediate_util: Add x,y radius to circle draw
A version of circle drawing for non 1:1 aspects
===================================================================
M source/blender/gpu/GPU_immediate_util.h
M source/blender/gpu/intern/gpu_immediate_util.c
===================================================================
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index e3a697fd229..31a90aa14b8 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -32,6 +32,9 @@ void imm_cpack(uint x);
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments);
void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int nsegments);
+void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments);
+void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float radius_x, float radius_y, int nsegments);
+
/* use this version when Gwn_VertFormat has a vec3 position */
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments);
void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments);
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index 4f68bbef4d7..5feb1c58cea 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -51,12 +51,13 @@ void imm_cpack(unsigned int x)
(((x) >> 16) & 0xFF));
}
-static void imm_draw_circle(Gwn_PrimType prim_type, const uint shdr_pos, float x, float y, float rad, int nsegments)
+static void imm_draw_circle(
+ Gwn_PrimType prim_type, const uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
{
immBegin(prim_type, nsegments);
for (int i = 0; i < nsegments; ++i) {
const float angle = (float)(2 * M_PI) * ((float)i / (float)nsegments);
- immVertex2f(shdr_pos, x + rad * cosf(angle), y + rad * sinf(angle));
+ immVertex2f(shdr_pos, x + (rad_x * cosf(angle)), y + (rad_y * sinf(angle)));
}
immEnd();
}
@@ -73,7 +74,7 @@ static void imm_draw_circle(Gwn_PrimType prim_type, const uint shdr_pos, float x
*/
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nsegments)
{
- imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad, nsegments);
+ imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad, rad, nsegments);
}
/**
@@ -88,7 +89,16 @@ void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float rad, int nse
*/
void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float rad, int nsegments)
{
- imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad, nsegments);
+ imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad, rad, nsegments);
+}
+
+void imm_draw_circle_wire_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
+{
+ imm_draw_circle(GWN_PRIM_LINE_LOOP, shdr_pos, x, y, rad_x, rad_y, nsegments);
+}
+void imm_draw_circle_fill_aspect_2d(uint shdr_pos, float x, float y, float rad_x, float rad_y, int nsegments)
+{
+ imm_draw_circle(GWN_PRIM_TRI_FAN, shdr_pos, x, y, rad_x, rad_y, nsegments);
}
/**
More information about the Bf-blender-cvs
mailing list