[Bf-blender-cvs] [23506622a54] master: Gizmo: add central point to circular 2D cage

Weizhen Huang noreply at git.blender.org
Fri Feb 3 18:31:03 CET 2023


Commit: 23506622a5420e60701a237a61cdf5890fcd3f23
Author: Weizhen Huang
Date:   Fri Feb 3 18:30:51 2023 +0100
Branches: master
https://developer.blender.org/rB23506622a5420e60701a237a61cdf5890fcd3f23

Gizmo: add central point to circular 2D cage

===================================================================

M	source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
M	source/blender/gpu/GPU_immediate_util.h
M	source/blender/gpu/intern/gpu_immediate_util.c

===================================================================

diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
index 1b09d35c8b2..b1bf1a7b542 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c
@@ -590,6 +590,20 @@ static void cage2d_draw_rect_handles(const rctf *r,
   immUnbindProgram();
 }
 
+static void cage2d_draw_central_handle(const float color[3], const float margin[2])
+{
+  uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+
+  const float rad[2] = {margin[0] * 0.25f, margin[1] * 0.25f};
+
+  immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+  immUniformColor3fv(color);
+
+  imm_draw_circle_fill_aspect_3d(pos, 0.0f, 0.0f, rad[0], rad[1], CIRCLE_RESOL);
+
+  immUnbindProgram();
+}
+
 /** \} */
 
 static void gizmo_cage2d_draw_intern(wmGizmo *gz,
@@ -636,6 +650,8 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz,
       GPU_select_load_id(select_id | ED_GIZMO_CAGE2D_PART_SCALE);
       cage2d_draw_circle_wire(
           gz->color, size_real, 0.5f * (margin[0] + margin[1]), gz->line_width);
+
+      cage2d_draw_central_handle(gz->color, margin);
     }
     else {
       if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE) {
@@ -736,6 +752,8 @@ static void gizmo_cage2d_draw_intern(wmGizmo *gz,
       else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
         cage2d_draw_circle_wire(black, size_real, 0.0f, outline_line_width);
         cage2d_draw_circle_wire(color, size_real, 0.0f, gz->line_width);
+
+        cage2d_draw_central_handle(color, margin);
       }
       else {
         BLI_assert(0);
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index d12f950185b..d072f57ea27 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -76,6 +76,8 @@ void imm_draw_circle_wire_aspect_3d(
     uint pos, float x, float y, float radius_x, float radius_y, int nsegments);
 void imm_draw_circle_dashed_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);
+void imm_draw_circle_fill_aspect_3d(
+    uint pos, float x, float y, float radius_x, float radius_y, int nsegments);
 
 /**
  * Same as 'imm_draw_disk_partial_fill_2d', except it draws a wire arc.
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index b25fd04091a..14fb4dbc810 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -398,6 +398,12 @@ void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegm
   imm_draw_circle_3D(GPU_PRIM_TRI_FAN, pos, x, y, radius, radius, nsegments);
 }
 
+void imm_draw_circle_fill_aspect_3d(
+    uint pos, float x, float y, float radius_x, float radius_y, int nsegments)
+{
+  imm_draw_circle_3D(GPU_PRIM_TRI_FAN, pos, x, y, radius_x, radius_y, nsegments);
+}
+
 void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
 {
   /* NOTE(Metal/AMD): For small primitives, line list more efficient than line-strip. */



More information about the Bf-blender-cvs mailing list