[Bf-blender-cvs] [8b13cf5667b] master: Cleanup: move 'imm_drawcircball' to 'gpu_immediate_util.c'

Germano Cavalcante noreply at git.blender.org
Fri Nov 12 20:30:17 CET 2021


Commit: 8b13cf5667bf6976ad8705941a0e7f81841cb8d9
Author: Germano Cavalcante
Date:   Fri Nov 12 16:15:21 2021 -0300
Branches: master
https://developer.blender.org/rB8b13cf5667bf6976ad8705941a0e7f81841cb8d9

Cleanup: move 'imm_drawcircball' to 'gpu_immediate_util.c'

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

M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/gpu/GPU_immediate_util.h
M	source/blender/gpu/intern/gpu_immediate_util.c

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

diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 0d07e39e3ab..008ad5b3203 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -588,8 +588,6 @@ float ED_view3d_radius_to_dist(const struct View3D *v3d,
                                const bool use_aspect,
                                const float radius);
 
-void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], unsigned int pos);
-
 /* Back-buffer select and draw support. */
 void ED_view3d_backbuf_depth_validate(struct ViewContext *vc);
 int ED_view3d_backbuf_sample_size_clamp(struct ARegion *region, const float dist);
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 6b9da431510..48f39f835c5 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -48,58 +48,6 @@
 
 #include "view3d_intern.h" /* bad level include */
 
-/* OpenGL Circle Drawing - Tables for Optimized Drawing Speed */
-/* 32 values of sin function (still same result!) */
-#define CIRCLE_RESOL 32
-
-static const float sinval[CIRCLE_RESOL] = {
-    0.00000000,  0.20129852,  0.39435585,  0.57126821,  0.72479278,  0.84864425,  0.93775213,
-    0.98846832,  0.99871650,  0.96807711,  0.89780453,  0.79077573,  0.65137248,  0.48530196,
-    0.29936312,  0.10116832,  -0.10116832, -0.29936312, -0.48530196, -0.65137248, -0.79077573,
-    -0.89780453, -0.96807711, -0.99871650, -0.98846832, -0.93775213, -0.84864425, -0.72479278,
-    -0.57126821, -0.39435585, -0.20129852, 0.00000000,
-};
-
-/* 32 values of cos function (still same result!) */
-static const float cosval[CIRCLE_RESOL] = {
-    1.00000000,  0.97952994,  0.91895781,  0.82076344,  0.68896691,  0.52896401,  0.34730525,
-    0.15142777,  -0.05064916, -0.25065253, -0.44039415, -0.61210598, -0.75875812, -0.87434661,
-    -0.95413925, -0.99486932, -0.99486932, -0.95413925, -0.87434661, -0.75875812, -0.61210598,
-    -0.44039415, -0.25065253, -0.05064916, 0.15142777,  0.34730525,  0.52896401,  0.68896691,
-    0.82076344,  0.91895781,  0.97952994,  1.00000000,
-};
-
-static void circball_array_fill(const float verts[CIRCLE_RESOL][3],
-                                const float cent[3],
-                                float rad,
-                                const float tmat[4][4])
-{
-  float vx[3], vy[3];
-  float *viter = (float *)verts;
-
-  mul_v3_v3fl(vx, tmat[0], rad);
-  mul_v3_v3fl(vy, tmat[1], rad);
-
-  for (uint a = 0; a < CIRCLE_RESOL; a++, viter += 3) {
-    viter[0] = cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
-    viter[1] = cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
-    viter[2] = cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
-  }
-}
-
-void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], uint pos)
-{
-  float verts[CIRCLE_RESOL][3];
-
-  circball_array_fill(verts, cent, rad, tmat);
-
-  immBegin(GPU_PRIM_LINE_LOOP, CIRCLE_RESOL);
-  for (int i = 0; i < CIRCLE_RESOL; i++) {
-    immVertex3fv(pos, verts[i]);
-  }
-  immEnd();
-}
-
 #ifdef VIEW3D_CAMERA_BORDER_HACK
 uchar view3d_camera_border_hack_col[3];
 bool view3d_camera_border_hack_test = false;
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
index 0d3d39839b2..047c3d3da00 100644
--- a/source/blender/gpu/GPU_immediate_util.h
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -92,6 +92,7 @@ void imm_draw_cylinder_wire_3d(
 void imm_draw_cylinder_fill_3d(
     uint pos, float base, float top, float height, int slices, int stacks);
 
+void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], uint pos);
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
index 032974db8d1..df18b89bd67 100644
--- a/source/blender/gpu/intern/gpu_immediate_util.c
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -602,3 +602,55 @@ void imm_draw_cylinder_fill_3d(
   }
   immEnd();
 }
+
+/* Circle Drawing - Tables for Optimized Drawing Speed */
+#define CIRCLE_RESOL 32
+
+static void circball_array_fill(const float verts[CIRCLE_RESOL][3],
+                                const float cent[3],
+                                float rad,
+                                const float tmat[4][4])
+{
+  /* 32 values of sin function (still same result!) */
+  const float sinval[CIRCLE_RESOL] = {
+      0.00000000,  0.20129852,  0.39435585,  0.57126821,  0.72479278,  0.84864425,  0.93775213,
+      0.98846832,  0.99871650,  0.96807711,  0.89780453,  0.79077573,  0.65137248,  0.48530196,
+      0.29936312,  0.10116832,  -0.10116832, -0.29936312, -0.48530196, -0.65137248, -0.79077573,
+      -0.89780453, -0.96807711, -0.99871650, -0.98846832, -0.93775213, -0.84864425, -0.72479278,
+      -0.57126821, -0.39435585, -0.20129852, 0.00000000,
+  };
+
+  /* 32 values of cos function (still same result!) */
+  const float cosval[CIRCLE_RESOL] = {
+      1.00000000,  0.97952994,  0.91895781,  0.82076344,  0.68896691,  0.52896401,  0.34730525,
+      0.15142777,  -0.05064916, -0.25065253, -0.44039415, -0.61210598, -0.75875812, -0.87434661,
+      -0.95413925, -0.99486932, -0.99486932, -0.95413925, -0.87434661, -0.75875812, -0.61210598,
+      -0.44039415, -0.25065253, -0.05064916, 0.15142777,  0.34730525,  0.52896401,  0.68896691,
+      0.82076344,  0.91895781,  0.97952994,  1.00000000,
+  };
+
+  float vx[3], vy[3];
+  float *viter = (float *)verts;
+
+  mul_v3_v3fl(vx, tmat[0], rad);
+  mul_v3_v3fl(vy, tmat[1], rad);
+
+  for (uint a = 0; a < CIRCLE_RESOL; a++, viter += 3) {
+    viter[0] = cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0];
+    viter[1] = cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1];
+    viter[2] = cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2];
+  }
+}
+
+void imm_drawcircball(const float cent[3], float rad, const float tmat[4][4], uint pos)
+{
+  float verts[CIRCLE_RESOL][3];
+
+  circball_array_fill(verts, cent, rad, tmat);
+
+  immBegin(GPU_PRIM_LINE_LOOP, CIRCLE_RESOL);
+  for (int i = 0; i < CIRCLE_RESOL; i++) {
+    immVertex3fv(pos, verts[i]);
+  }
+  immEnd();
+}



More information about the Bf-blender-cvs mailing list