Blender  V2.93
draw_cache.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "DNA_curve_types.h"
22 #include "DNA_hair_types.h"
23 #include "DNA_lattice_types.h"
24 #include "DNA_mesh_types.h"
25 #include "DNA_meta_types.h"
26 #include "DNA_modifier_types.h"
27 #include "DNA_object_types.h"
28 #include "DNA_particle_types.h"
29 #include "DNA_pointcloud_types.h"
30 #include "DNA_scene_types.h"
31 #include "DNA_volume_types.h"
32 
33 #include "UI_resources.h"
34 
35 #include "BLI_math.h"
36 #include "BLI_utildefines.h"
37 
38 #include "BKE_object.h"
39 #include "BKE_paint.h"
40 
41 #include "GPU_batch.h"
42 #include "GPU_batch_utils.h"
43 
44 #include "MEM_guardedalloc.h"
45 
46 #include "draw_cache.h"
47 #include "draw_cache_impl.h"
48 #include "draw_manager.h"
49 
50 #define VCLASS_LIGHT_AREA_SHAPE (1 << 0)
51 #define VCLASS_LIGHT_SPOT_SHAPE (1 << 1)
52 #define VCLASS_LIGHT_SPOT_BLEND (1 << 2)
53 #define VCLASS_LIGHT_SPOT_CONE (1 << 3)
54 #define VCLASS_LIGHT_DIST (1 << 4)
55 
56 #define VCLASS_CAMERA_FRAME (1 << 5)
57 #define VCLASS_CAMERA_DIST (1 << 6)
58 #define VCLASS_CAMERA_VOLUME (1 << 7)
59 
60 #define VCLASS_SCREENSPACE (1 << 8)
61 #define VCLASS_SCREENALIGNED (1 << 9)
62 
63 #define VCLASS_EMPTY_SCALED (1 << 10)
64 #define VCLASS_EMPTY_AXES (1 << 11)
65 #define VCLASS_EMPTY_AXES_NAME (1 << 12)
66 #define VCLASS_EMPTY_AXES_SHADOW (1 << 13)
67 #define VCLASS_EMPTY_SIZE (1 << 14)
68 
69 /* Sphere shape resolution */
70 /* Low */
71 #define DRW_SPHERE_SHAPE_LATITUDE_LOW 32
72 #define DRW_SPHERE_SHAPE_LONGITUDE_LOW 24
73 /* Medium */
74 #define DRW_SPHERE_SHAPE_LATITUDE_MEDIUM 64
75 #define DRW_SPHERE_SHAPE_LONGITUDE_MEDIUM 48
76 /* High */
77 #define DRW_SPHERE_SHAPE_LATITUDE_HIGH 80
78 #define DRW_SPHERE_SHAPE_LONGITUDE_HIGH 60
79 
80 typedef struct Vert {
81  float pos[3];
82  int class;
83 } Vert;
84 
85 typedef struct VertShaded {
86  float pos[3];
87  int class;
88  float nor[3];
90 
91 /* Batch's only (free'd as an array) */
92 static struct DRWShapeCache {
154 } SHC = {NULL};
155 
157 {
158  uint i = sizeof(SHC) / sizeof(GPUBatch *);
159  GPUBatch **batch = (GPUBatch **)&SHC;
160  while (i--) {
162  batch++;
163  }
164 }
165 
166 /* -------------------------------------------------------------------- */
171 {
172  if (!SHC.drw_procedural_verts) {
173  /* TODO(fclem): get rid of this dummy VBO. */
174  GPUVertFormat format = {0};
177  GPU_vertbuf_data_alloc(vbo, 1);
178 
180  }
181  return SHC.drw_procedural_verts;
182 }
183 
185 {
186  if (!SHC.drw_procedural_lines) {
187  /* TODO(fclem): get rid of this dummy VBO. */
188  GPUVertFormat format = {0};
191  GPU_vertbuf_data_alloc(vbo, 1);
192 
194  }
195  return SHC.drw_procedural_lines;
196 }
197 
199 {
200  if (!SHC.drw_procedural_tris) {
201  /* TODO(fclem): get rid of this dummy VBO. */
202  GPUVertFormat format = {0};
205  GPU_vertbuf_data_alloc(vbo, 1);
206 
208  }
209  return SHC.drw_procedural_tris;
210 }
211 
214 /* -------------------------------------------------------------------- */
219 {
220  GPUVertFormat format = {0};
223  return format;
224 }
225 
227  uint pos_id,
228  uint n1_id,
229  uint n2_id,
230  uint *v_idx,
231  const float co1[3],
232  const float co2[3],
233  const float n1[3],
234  const float n2[3])
235 {
236  GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
237  GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
238  GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1);
239 
240  GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
241  GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
242  GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2);
243 }
244 
245 #if 0 /* UNUSED */
246 static void add_lat_lon_vert(GPUVertBuf *vbo,
247  uint pos_id,
248  uint nor_id,
249  uint *v_idx,
250  const float rad,
251  const float lat,
252  const float lon)
253 {
254  float pos[3], nor[3];
255  nor[0] = sinf(lat) * cosf(lon);
256  nor[1] = cosf(lat);
257  nor[2] = sinf(lat) * sinf(lon);
258  mul_v3_v3fl(pos, nor, rad);
259 
260  GPU_vertbuf_attr_set(vbo, nor_id, *v_idx, nor);
261  GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos);
262 }
263 
264 static GPUVertBuf *fill_arrows_vbo(const float scale)
265 {
266  /* Position Only 3D format */
267  static GPUVertFormat format = {0};
268  static struct {
269  uint pos;
270  } attr_id;
271  if (format.attr_len == 0) {
273  }
274 
275  /* Line */
277  GPU_vertbuf_data_alloc(vbo, 6 * 3);
278 
279  float v1[3] = {0.0, 0.0, 0.0};
280  float v2[3] = {0.0, 0.0, 0.0};
281  float vtmp1[3], vtmp2[3];
282 
283  for (int axis = 0; axis < 3; axis++) {
284  const int arrow_axis = (axis == 0) ? 1 : 0;
285 
286  v2[axis] = 1.0f;
287  mul_v3_v3fl(vtmp1, v1, scale);
288  mul_v3_v3fl(vtmp2, v2, scale);
289  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1);
290  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2);
291 
292  v1[axis] = 0.85f;
293  v1[arrow_axis] = -0.08f;
294  mul_v3_v3fl(vtmp1, v1, scale);
295  mul_v3_v3fl(vtmp2, v2, scale);
296  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1);
297  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2);
298 
299  v1[arrow_axis] = 0.08f;
300  mul_v3_v3fl(vtmp1, v1, scale);
301  mul_v3_v3fl(vtmp2, v2, scale);
302  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1);
303  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2);
304 
305  /* reset v1 & v2 to zero */
306  v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f;
307  }
308 
309  return vbo;
310 }
311 #endif /* UNUSED */
312 
313 static GPUVertBuf *sphere_wire_vbo(const float rad, int flag)
314 {
315 #define NSEGMENTS 32
316  /* Position Only 3D format */
318 
320  GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3);
321 
322  int v = 0;
323  /* a single ring of vertices */
324  float p[NSEGMENTS][2];
325  for (int i = 0; i < NSEGMENTS; i++) {
326  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
327  p[i][0] = rad * cosf(angle);
328  p[i][1] = rad * sinf(angle);
329  }
330 
331  for (int axis = 0; axis < 3; axis++) {
332  for (int i = 0; i < NSEGMENTS; i++) {
333  for (int j = 0; j < 2; j++) {
334  float cv[2];
335 
336  cv[0] = p[(i + j) % NSEGMENTS][0];
337  cv[1] = p[(i + j) % NSEGMENTS][1];
338 
339  if (axis == 0) {
340  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], 0.0f}, flag});
341  }
342  else if (axis == 1) {
343  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
344  }
345  else {
346  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, cv[0], cv[1]}, flag});
347  }
348  }
349  }
350  }
351 
352  return vbo;
353 #undef NSEGMENTS
354 }
355 
356 /* Quads */
357 /* Use this one for rendering fullscreen passes. For 3D objects use DRW_cache_quad_get(). */
359 {
360  if (!SHC.drw_fullscreen_quad) {
361  /* Use a triangle instead of a real quad */
362  /* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */
363  const float pos[3][2] = {{-1.0f, -1.0f}, {3.0f, -1.0f}, {-1.0f, 3.0f}};
364  const float uvs[3][2] = {{0.0f, 0.0f}, {2.0f, 0.0f}, {0.0f, 2.0f}};
365 
366  /* Position Only 2D format */
367  static GPUVertFormat format = {0};
368  static struct {
369  uint pos, uvs;
370  } attr_id;
371  if (format.attr_len == 0) {
374  GPU_vertformat_alias_add(&format, "texCoord");
375  GPU_vertformat_alias_add(&format, "orco"); /* Fix driver bug (see T70004) */
376  }
377 
379  GPU_vertbuf_data_alloc(vbo, 3);
380 
381  for (int i = 0; i < 3; i++) {
382  GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
383  GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
384  }
385 
387  }
388  return SHC.drw_fullscreen_quad;
389 }
390 
391 /* Just a regular quad with 4 vertices. */
393 {
394  if (!SHC.drw_quad) {
396 
398  GPU_vertbuf_data_alloc(vbo, 4);
399 
400  int v = 0;
401  int flag = VCLASS_EMPTY_SCALED;
402  const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
403  for (int a = 0; a < 4; a++) {
404  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a][0], p[a][1], 0.0f}, flag});
405  }
406 
408  }
409  return SHC.drw_quad;
410 }
411 
412 /* Just a regular quad with 4 vertices - wires. */
414 {
415  if (!SHC.drw_quad_wires) {
417 
419  GPU_vertbuf_data_alloc(vbo, 5);
420 
421  int v = 0;
422  int flag = VCLASS_EMPTY_SCALED;
423  const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
424  for (int a = 0; a < 5; a++) {
425  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a % 4][0], p[a % 4][1], 0.0f}, flag});
426  }
427 
429  }
430  return SHC.drw_quad_wires;
431 }
432 
433 /* Grid */
435 {
436  if (!SHC.drw_grid) {
437  /* Position Only 2D format */
438  static GPUVertFormat format = {0};
439  static struct {
440  uint pos;
441  } attr_id;
442  if (format.attr_len == 0) {
444  }
445 
447  GPU_vertbuf_data_alloc(vbo, 8 * 8 * 2 * 3);
448 
449  uint v_idx = 0;
450  for (int i = 0; i < 8; i++) {
451  for (int j = 0; j < 8; j++) {
452  float pos0[2] = {(float)i / 8.0f, (float)j / 8.0f};
453  float pos1[2] = {(float)(i + 1) / 8.0f, (float)j / 8.0f};
454  float pos2[2] = {(float)i / 8.0f, (float)(j + 1) / 8.0f};
455  float pos3[2] = {(float)(i + 1) / 8.0f, (float)(j + 1) / 8.0f};
456 
457  madd_v2_v2v2fl(pos0, (float[2]){-1.0f, -1.0f}, pos0, 2.0f);
458  madd_v2_v2v2fl(pos1, (float[2]){-1.0f, -1.0f}, pos1, 2.0f);
459  madd_v2_v2v2fl(pos2, (float[2]){-1.0f, -1.0f}, pos2, 2.0f);
460  madd_v2_v2v2fl(pos3, (float[2]){-1.0f, -1.0f}, pos3, 2.0f);
461 
462  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos0);
463  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos1);
464  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos2);
465 
466  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos2);
467  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos1);
468  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos3);
469  }
470  }
471 
473  }
474  return SHC.drw_grid;
475 }
476 
477 /* Sphere */
478 static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lon)
479 {
480  float x = sinf(lat) * cosf(lon);
481  float y = cosf(lat);
482  float z = sinf(lat) * sinf(lon);
483  GPU_vertbuf_vert_set(vbo, *v_ofs, &(VertShaded){{x, y, z}, VCLASS_EMPTY_SCALED, {x, y, z}});
484  (*v_ofs)++;
485 }
486 
488 {
489  BLI_assert(level_of_detail >= DRW_LOD_LOW && level_of_detail < DRW_LOD_MAX);
490 
491  if (!SHC.drw_sphere_lod[level_of_detail]) {
492  int lat_res;
493  int lon_res;
494 
495  switch (level_of_detail) {
496  case DRW_LOD_LOW:
499  break;
500  case DRW_LOD_MEDIUM:
503  break;
504  case DRW_LOD_HIGH:
507  break;
508  default:
509  return NULL;
510  }
511 
514 
516  int v_len = (lat_res - 1) * lon_res * 6;
517  GPU_vertbuf_data_alloc(vbo, v_len);
518 
519  const float lon_inc = 2 * M_PI / lon_res;
520  const float lat_inc = M_PI / lat_res;
521  float lon, lat;
522 
523  int v = 0;
524  lon = 0.0f;
525  for (int i = 0; i < lon_res; i++, lon += lon_inc) {
526  lat = 0.0f;
527  for (int j = 0; j < lat_res; j++, lat += lat_inc) {
528  if (j != lat_res - 1) { /* Pole */
529  sphere_lat_lon_vert(vbo, &v, lat + lat_inc, lon + lon_inc);
530  sphere_lat_lon_vert(vbo, &v, lat + lat_inc, lon);
531  sphere_lat_lon_vert(vbo, &v, lat, lon);
532  }
533  if (j != 0) { /* Pole */
534  sphere_lat_lon_vert(vbo, &v, lat, lon + lon_inc);
535  sphere_lat_lon_vert(vbo, &v, lat + lat_inc, lon + lon_inc);
536  sphere_lat_lon_vert(vbo, &v, lat, lon);
537  }
538  }
539  }
540 
541  SHC.drw_sphere_lod[level_of_detail] = GPU_batch_create_ex(
543  }
544  return SHC.drw_sphere_lod[level_of_detail];
545 }
546 
549 /* -------------------------------------------------------------------- */
553 static void circle_verts(
554  GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
555 {
556  for (int a = 0; a < segments; a++) {
557  for (int b = 0; b < 2; b++) {
558  float angle = (2.0f * M_PI * (a + b)) / segments;
559  float s = sinf(angle) * radius;
560  float c = cosf(angle) * radius;
561  int v = *vert_idx;
562  *vert_idx = v + 1;
563  GPU_vertbuf_vert_set(vbo, v, &(Vert){{s, c, z}, flag});
564  }
565  }
566 }
567 
569  GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
570 {
571  for (int a = 0; a < segments * 2; a += 2) {
572  for (int b = 0; b < 2; b++) {
573  float angle = (2.0f * M_PI * (a + b)) / (segments * 2);
574  float s = sinf(angle) * radius;
575  float c = cosf(angle) * radius;
576  int v = *vert_idx;
577  *vert_idx = v + 1;
578  GPU_vertbuf_vert_set(vbo, v, &(Vert){{s, c, z}, flag});
579  }
580  }
581 }
582 
583 /* XXX TODO move that 1 unit cube to more common/generic place? */
584 static const float bone_box_verts[8][3] = {
585  {1.0f, 0.0f, 1.0f},
586  {1.0f, 0.0f, -1.0f},
587  {-1.0f, 0.0f, -1.0f},
588  {-1.0f, 0.0f, 1.0f},
589  {1.0f, 1.0f, 1.0f},
590  {1.0f, 1.0f, -1.0f},
591  {-1.0f, 1.0f, -1.0f},
592  {-1.0f, 1.0f, 1.0f},
593 };
594 
595 static const float bone_box_smooth_normals[8][3] = {
596  {M_SQRT3, -M_SQRT3, M_SQRT3},
597  {M_SQRT3, -M_SQRT3, -M_SQRT3},
598  {-M_SQRT3, -M_SQRT3, -M_SQRT3},
599  {-M_SQRT3, -M_SQRT3, M_SQRT3},
600  {M_SQRT3, M_SQRT3, M_SQRT3},
601  {M_SQRT3, M_SQRT3, -M_SQRT3},
602  {-M_SQRT3, M_SQRT3, -M_SQRT3},
603  {-M_SQRT3, M_SQRT3, M_SQRT3},
604 };
605 
606 static const uint bone_box_wire[24] = {
607  0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7,
608 };
609 
610 #if 0 /* UNUSED */
611 /* aligned with bone_octahedral_wire
612  * Contains adjacent normal index */
613 static const uint bone_box_wire_adjacent_face[24] = {
614  0, 2, 0, 4, 1, 6, 1, 8, 3, 10, 5, 10, 7, 11, 9, 11, 3, 8, 2, 5, 4, 7, 6, 9,
615 };
616 #endif
617 
618 static const uint bone_box_solid_tris[12][3] = {
619  {0, 2, 1}, /* bottom */
620  {0, 3, 2},
621 
622  {0, 1, 5}, /* sides */
623  {0, 5, 4},
624 
625  {1, 2, 6},
626  {1, 6, 5},
627 
628  {2, 3, 7},
629  {2, 7, 6},
630 
631  {3, 0, 4},
632  {3, 4, 7},
633 
634  {4, 5, 6}, /* top */
635  {4, 6, 7},
636 };
637 
642 static const uint bone_box_wire_lines_adjacency[12][4] = {
643  {4, 2, 0, 11},
644  {0, 1, 2, 8},
645  {2, 4, 1, 14},
646  {1, 0, 4, 20}, /* bottom */
647  {0, 8, 11, 14},
648  {2, 14, 8, 20},
649  {1, 20, 14, 11},
650  {4, 11, 20, 8}, /* top */
651  {20, 0, 11, 2},
652  {11, 2, 8, 1},
653  {8, 1, 14, 4},
654  {14, 4, 20, 0}, /* sides */
655 };
656 
657 #if 0 /* UNUSED */
658 static const uint bone_box_solid_tris_adjacency[12][6] = {
659  {0, 5, 1, 14, 2, 8},
660  {3, 26, 4, 20, 5, 1},
661 
662  {6, 2, 7, 16, 8, 11},
663  {9, 7, 10, 32, 11, 24},
664 
665  {12, 0, 13, 22, 14, 17},
666  {15, 13, 16, 30, 17, 6},
667 
668  {18, 3, 19, 28, 20, 23},
669  {21, 19, 22, 33, 23, 12},
670 
671  {24, 4, 25, 10, 26, 29},
672  {27, 25, 28, 34, 29, 18},
673 
674  {30, 9, 31, 15, 32, 35},
675  {33, 31, 34, 21, 35, 27},
676 };
677 #endif
678 
679 /* aligned with bone_box_solid_tris */
680 static const float bone_box_solid_normals[12][3] = {
681  {0.0f, -1.0f, 0.0f},
682  {0.0f, -1.0f, 0.0f},
683 
684  {1.0f, 0.0f, 0.0f},
685  {1.0f, 0.0f, 0.0f},
686 
687  {0.0f, 0.0f, -1.0f},
688  {0.0f, 0.0f, -1.0f},
689 
690  {-1.0f, 0.0f, 0.0f},
691  {-1.0f, 0.0f, 0.0f},
692 
693  {0.0f, 0.0f, 1.0f},
694  {0.0f, 0.0f, 1.0f},
695 
696  {0.0f, 1.0f, 0.0f},
697  {0.0f, 1.0f, 0.0f},
698 };
699 
701 {
702  if (!SHC.drw_cube) {
704 
705  const int tri_len = ARRAY_SIZE(bone_box_solid_tris);
706  const int vert_len = ARRAY_SIZE(bone_box_verts);
707 
709  GPU_vertbuf_data_alloc(vbo, vert_len);
710 
711  GPUIndexBufBuilder elb;
712  GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len);
713 
714  int v = 0;
715  for (int i = 0; i < vert_len; i++) {
716  float x = bone_box_verts[i][0];
717  float y = bone_box_verts[i][1] * 2.0f - 1.0f;
718  float z = bone_box_verts[i][2];
719  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED});
720  }
721 
722  for (int i = 0; i < tri_len; i++) {
723  const uint *tri_indices = bone_box_solid_tris[i];
724  GPU_indexbuf_add_tri_verts(&elb, tri_indices[0], tri_indices[1], tri_indices[2]);
725  }
726 
729  }
730  return SHC.drw_cube;
731 }
732 
734 {
735 #define CIRCLE_RESOL 64
736  if (!SHC.drw_circle) {
738 
741 
742  int v = 0;
743  for (int a = 0; a < CIRCLE_RESOL + 1; a++) {
744  float x = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
745  float z = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
746  float y = 0.0f;
747  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED});
748  }
749 
751  }
752  return SHC.drw_circle;
753 #undef CIRCLE_RESOL
754 }
755 
757 {
758  if (!SHC.drw_normal_arrow) {
759  GPUVertFormat format = {0};
761 
763  GPU_vertbuf_data_alloc(vbo, 2);
764 
765  /* TODO real arrow. For now, it's a line positioned in the vertex shader. */
766 
768  }
769  return SHC.drw_normal_arrow;
770 }
771 
772 /* -------------------------------------------------------------------- */
780 {
782  GPUVertFormat format = {0};
785  GPU_vertbuf_data_alloc(vbo, 4);
786 
789  }
791 }
792 
795 /* -------------------------------------------------------------------- */
800 {
801  switch (ob->type) {
802  case OB_MESH:
803  return DRW_cache_mesh_all_edges_get(ob);
804 
805  /* TODO, should match 'DRW_cache_object_surface_get' */
806  default:
807  return NULL;
808  }
809 }
810 
812 {
813  switch (ob->type) {
814  case OB_MESH:
815  return DRW_cache_mesh_edge_detection_get(ob, r_is_manifold);
816  case OB_CURVE:
817  return DRW_cache_curve_edge_detection_get(ob, r_is_manifold);
818  case OB_SURF:
819  return DRW_cache_surf_edge_detection_get(ob, r_is_manifold);
820  case OB_FONT:
821  return DRW_cache_text_edge_detection_get(ob, r_is_manifold);
822  case OB_MBALL:
823  return DRW_cache_mball_edge_detection_get(ob, r_is_manifold);
824  case OB_HAIR:
825  return NULL;
826  case OB_POINTCLOUD:
827  return NULL;
828  case OB_VOLUME:
829  return NULL;
830  default:
831  return NULL;
832  }
833 }
834 
836 {
837  switch (ob->type) {
838  case OB_MESH:
840  case OB_CURVE:
842  case OB_SURF:
844  case OB_FONT:
846  case OB_MBALL:
848  case OB_HAIR:
849  return NULL;
850  case OB_POINTCLOUD:
852  case OB_VOLUME:
854  case OB_GPENCIL: {
856  }
857  default:
858  return NULL;
859  }
860 }
861 
863 {
864  switch (ob->type) {
865  case OB_MESH:
867  case OB_CURVE:
869  case OB_SURF:
871  case OB_FONT:
873  case OB_MBALL:
874  return NULL;
875  case OB_HAIR:
876  return NULL;
877  case OB_POINTCLOUD:
878  return NULL;
879  case OB_VOLUME:
880  return NULL;
881  default:
882  return NULL;
883  }
884 }
885 
887 {
888  switch (ob->type) {
889  case OB_MESH:
890  return DRW_cache_mesh_surface_get(ob);
891  case OB_CURVE:
892  return DRW_cache_curve_surface_get(ob);
893  case OB_SURF:
894  return DRW_cache_surf_surface_get(ob);
895  case OB_FONT:
896  return DRW_cache_text_surface_get(ob);
897  case OB_MBALL:
898  return DRW_cache_mball_surface_get(ob);
899  case OB_HAIR:
900  return NULL;
901  case OB_POINTCLOUD:
903  case OB_VOLUME:
904  return NULL;
905  default:
906  return NULL;
907  }
908 }
909 
910 /* Returns the vertbuf used by shaded surface batch. */
912 {
914  short type = (me != NULL) ? OB_MESH : ob->type;
915 
916  switch (type) {
917  case OB_MESH:
918  return DRW_mesh_batch_cache_pos_vertbuf_get((me != NULL) ? me : ob->data);
919  case OB_CURVE:
920  case OB_SURF:
921  case OB_FONT:
923  case OB_MBALL:
925  case OB_HAIR:
926  return NULL;
927  case OB_POINTCLOUD:
928  return NULL;
929  case OB_VOLUME:
930  return NULL;
931  default:
932  return NULL;
933  }
934 }
935 
937 {
938  short type = ob->type;
939 
941  if (me != NULL && type != OB_POINTCLOUD) {
942  /* Some object types (e.g. curves) can have a Curve in ob->data, but will be rendered as mesh.
943  * For point clouds this never happens. Ideally this check would happen at another level and we
944  * would just have to care about ob->data here. */
945  type = OB_MESH;
946  }
947 
948  switch (type) {
949  case OB_MESH:
950  return DRW_mesh_material_count_get((me != NULL) ? me : ob->data);
951  case OB_CURVE:
952  case OB_SURF:
953  case OB_FONT:
955  case OB_MBALL:
957  case OB_HAIR:
958  return DRW_hair_material_count_get(ob->data);
959  case OB_POINTCLOUD:
961  case OB_VOLUME:
963  default:
964  BLI_assert(0);
965  return 0;
966  }
967 }
968 
970  struct GPUMaterial **gpumat_array,
971  uint gpumat_array_len)
972 {
973  switch (ob->type) {
974  case OB_MESH:
975  return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
976  case OB_CURVE:
977  return DRW_cache_curve_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
978  case OB_SURF:
979  return DRW_cache_surf_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
980  case OB_FONT:
981  return DRW_cache_text_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
982  case OB_MBALL:
983  return DRW_cache_mball_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
984  case OB_HAIR:
985  return NULL;
986  case OB_POINTCLOUD:
987  return DRW_cache_pointcloud_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
988  case OB_VOLUME:
989  return NULL;
990  default:
991  return NULL;
992  }
993 }
994 
997 /* -------------------------------------------------------------------- */
1002 {
1003  if (!SHC.drw_plain_axes) {
1005 
1007  GPU_vertbuf_data_alloc(vbo, 6);
1008 
1009  int v = 0;
1010  int flag = VCLASS_EMPTY_SCALED;
1011  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, -1.0f, 0.0f}, flag});
1012  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 1.0f, 0.0f}, flag});
1013  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{-1.0f, 0.0f, 0.0f}, flag});
1014  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{1.0f, 0.0f, 0.0f}, flag});
1015  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, -1.0f}, flag});
1016  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 1.0f}, flag});
1017 
1019  }
1020  return SHC.drw_plain_axes;
1021 }
1022 
1024 {
1025  if (!SHC.drw_empty_cube) {
1029 
1030  int v = 0;
1031  for (int i = 0; i < ARRAY_SIZE(bone_box_wire); i++) {
1032  float x = bone_box_verts[bone_box_wire[i]][0];
1033  float y = bone_box_verts[bone_box_wire[i]][1] * 2.0 - 1.0f;
1034  float z = bone_box_verts[bone_box_wire[i]][2];
1035  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED});
1036  }
1037 
1039  }
1040  return SHC.drw_empty_cube;
1041 }
1042 
1044 {
1045  if (!SHC.drw_single_arrow) {
1048  GPU_vertbuf_data_alloc(vbo, 4 * 2 * 2 + 2);
1049 
1050  int v = 0;
1051  int flag = VCLASS_EMPTY_SCALED;
1052  float p[3][3] = {{0}};
1053  p[0][2] = 1.0f;
1054  p[1][0] = 0.035f;
1055  p[1][1] = 0.035f;
1056  p[2][0] = -0.035f;
1057  p[2][1] = 0.035f;
1058  p[1][2] = p[2][2] = 0.75f;
1059  for (int sides = 0; sides < 4; sides++) {
1060  if (sides % 2 == 1) {
1061  p[1][0] = -p[1][0];
1062  p[2][1] = -p[2][1];
1063  }
1064  else {
1065  p[1][1] = -p[1][1];
1066  p[2][0] = -p[2][0];
1067  }
1068  for (int i = 0, a = 1; i < 2; i++, a++) {
1069  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[i][0], p[i][1], p[i][2]}, flag});
1070  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a][0], p[a][1], p[a][2]}, flag});
1071  }
1072  }
1073  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0}, flag});
1074  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.75f}, flag});
1075 
1077  }
1078  return SHC.drw_single_arrow;
1079 }
1080 
1082 {
1083  if (!SHC.drw_empty_sphere) {
1086  }
1087  return SHC.drw_empty_sphere;
1088 }
1089 
1091 {
1092 #define NSEGMENTS 8
1093  if (!SHC.drw_empty_cone) {
1097 
1098  int v = 0;
1099  int flag = VCLASS_EMPTY_SCALED;
1100  /* a single ring of vertices */
1101  float p[NSEGMENTS][2];
1102  for (int i = 0; i < NSEGMENTS; i++) {
1103  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
1104  p[i][0] = cosf(angle);
1105  p[i][1] = sinf(angle);
1106  }
1107  for (int i = 0; i < NSEGMENTS; i++) {
1108  float cv[2];
1109  cv[0] = p[(i) % NSEGMENTS][0];
1110  cv[1] = p[(i) % NSEGMENTS][1];
1111 
1112  /* cone sides */
1113  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
1114  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 2.0f, 0.0f}, flag});
1115 
1116  /* end ring */
1117  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
1118  cv[0] = p[(i + 1) % NSEGMENTS][0];
1119  cv[1] = p[(i + 1) % NSEGMENTS][1];
1120  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
1121  }
1122 
1124  }
1125  return SHC.drw_empty_cone;
1126 #undef NSEGMENTS
1127 }
1128 
1130 {
1131 #define NSEGMENTS 12
1132  if (!SHC.drw_empty_cylinder) {
1136 
1137  /* a single ring of vertices */
1138  int v = 0;
1139  int flag = VCLASS_EMPTY_SCALED;
1140  float p[NSEGMENTS][2];
1141  for (int i = 0; i < NSEGMENTS; i++) {
1142  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
1143  p[i][0] = cosf(angle);
1144  p[i][1] = sinf(angle);
1145  }
1146  for (int i = 0; i < NSEGMENTS; i++) {
1147  float cv[2], pv[2];
1148  cv[0] = p[(i) % NSEGMENTS][0];
1149  cv[1] = p[(i) % NSEGMENTS][1];
1150  pv[0] = p[(i + 1) % NSEGMENTS][0];
1151  pv[1] = p[(i + 1) % NSEGMENTS][1];
1152 
1153  /* cylinder sides */
1154  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], -1.0f}, flag});
1155  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], 1.0f}, flag});
1156  /* top ring */
1157  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], 1.0f}, flag});
1158  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{pv[0], pv[1], 1.0f}, flag});
1159  /* bottom ring */
1160  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], -1.0f}, flag});
1161  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{pv[0], pv[1], -1.0f}, flag});
1162  }
1163 
1165  }
1166  return SHC.drw_empty_cylinder;
1167 #undef NSEGMENTS
1168 }
1169 
1171 {
1172  if (!SHC.drw_empty_capsule_body) {
1173  const float pos[8][3] = {
1174  {1.0f, 0.0f, 1.0f},
1175  {1.0f, 0.0f, 0.0f},
1176  {0.0f, 1.0f, 1.0f},
1177  {0.0f, 1.0f, 0.0f},
1178  {-1.0f, 0.0f, 1.0f},
1179  {-1.0f, 0.0f, 0.0f},
1180  {0.0f, -1.0f, 1.0f},
1181  {0.0f, -1.0f, 0.0f},
1182  };
1183 
1184  /* Position Only 3D format */
1185  static GPUVertFormat format = {0};
1186  static struct {
1187  uint pos;
1188  } attr_id;
1189  if (format.attr_len == 0) {
1191  }
1192 
1194  GPU_vertbuf_data_alloc(vbo, 8);
1195  GPU_vertbuf_attr_fill(vbo, attr_id.pos, pos);
1196 
1199  }
1200  return SHC.drw_empty_capsule_body;
1201 }
1202 
1204 {
1205 #define NSEGMENTS 24 /* Must be multiple of 2. */
1206  if (!SHC.drw_empty_capsule_cap) {
1207  /* a single ring of vertices */
1208  float p[NSEGMENTS][2];
1209  for (int i = 0; i < NSEGMENTS; i++) {
1210  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
1211  p[i][0] = cosf(angle);
1212  p[i][1] = sinf(angle);
1213  }
1214 
1215  /* Position Only 3D format */
1216  static GPUVertFormat format = {0};
1217  static struct {
1218  uint pos;
1219  } attr_id;
1220  if (format.attr_len == 0) {
1222  }
1223 
1225  GPU_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2);
1226 
1227  /* Base circle */
1228  int vidx = 0;
1229  for (int i = 0; i < NSEGMENTS; i++) {
1230  float v[3] = {0.0f, 0.0f, 0.0f};
1231  copy_v2_v2(v, p[(i) % NSEGMENTS]);
1232  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1233  copy_v2_v2(v, p[(i + 1) % NSEGMENTS]);
1234  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1235  }
1236 
1237  for (int i = 0; i < NSEGMENTS / 2; i++) {
1238  float v[3] = {0.0f, 0.0f, 0.0f};
1239  int ci = i % NSEGMENTS;
1240  int pi = (i + 1) % NSEGMENTS;
1241  /* Y half circle */
1242  copy_v3_fl3(v, p[ci][0], 0.0f, p[ci][1]);
1243  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1244  copy_v3_fl3(v, p[pi][0], 0.0f, p[pi][1]);
1245  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1246  /* X half circle */
1247  copy_v3_fl3(v, 0.0f, p[ci][0], p[ci][1]);
1248  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1249  copy_v3_fl3(v, 0.0f, p[pi][0], p[pi][1]);
1250  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1251  }
1252 
1254  }
1255  return SHC.drw_empty_capsule_cap;
1256 #undef NSEGMENTS
1257 }
1258 
1259 /* Force Field */
1261 {
1262 #define CIRCLE_RESOL 32
1263  if (!SHC.drw_field_wind) {
1265 
1266  int v_len = 2 * (CIRCLE_RESOL * 4);
1268  GPU_vertbuf_data_alloc(vbo, v_len);
1269 
1270  int v = 0;
1271  int flag = VCLASS_EMPTY_SIZE;
1272  for (int i = 0; i < 4; i++) {
1273  float z = 0.05f * (float)i;
1274  circle_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
1275  }
1276 
1278  }
1279  return SHC.drw_field_wind;
1280 #undef CIRCLE_RESOL
1281 }
1282 
1284 {
1285 #define CIRCLE_RESOL 32
1286  if (!SHC.drw_field_force) {
1288 
1289  int v_len = 2 * (CIRCLE_RESOL * 3);
1291  GPU_vertbuf_data_alloc(vbo, v_len);
1292 
1293  int v = 0;
1295  for (int i = 0; i < 3; i++) {
1296  float radius = 1.0f + 0.5f * i;
1297  circle_verts(vbo, &v, CIRCLE_RESOL, radius, 0.0f, flag);
1298  }
1299 
1301  }
1302  return SHC.drw_field_force;
1303 #undef CIRCLE_RESOL
1304 }
1305 
1307 {
1308 #define SPIRAL_RESOL 32
1309  if (!SHC.drw_field_vortex) {
1311 
1312  int v_len = SPIRAL_RESOL * 2 + 1;
1314  GPU_vertbuf_data_alloc(vbo, v_len);
1315 
1316  int v = 0;
1317  int flag = VCLASS_EMPTY_SIZE;
1318  for (int a = SPIRAL_RESOL; a > -1; a--) {
1319  float r = a / (float)SPIRAL_RESOL;
1320  float angle = (2.0f * M_PI * a) / SPIRAL_RESOL;
1321  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle) * r, cosf(angle) * r, 0.0f}, flag});
1322  }
1323  for (int a = 1; a <= SPIRAL_RESOL; a++) {
1324  float r = a / (float)SPIRAL_RESOL;
1325  float angle = (2.0f * M_PI * a) / SPIRAL_RESOL;
1326  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle) * -r, cosf(angle) * -r, 0.0f}, flag});
1327  }
1328 
1330  }
1331  return SHC.drw_field_vortex;
1332 #undef SPIRAL_RESOL
1333 }
1334 
1335 /* Screen-aligned circle. */
1337 {
1338 #define CIRCLE_RESOL 32
1339  if (!SHC.drw_field_curve) {
1341 
1342  int v_len = 2 * (CIRCLE_RESOL);
1344  GPU_vertbuf_data_alloc(vbo, v_len);
1345 
1346  int v = 0;
1348  circle_verts(vbo, &v, CIRCLE_RESOL, 1.0f, 0.0f, flag);
1349 
1351  }
1352  return SHC.drw_field_curve;
1353 #undef CIRCLE_RESOL
1354 }
1355 
1357 {
1358 #define CIRCLE_RESOL 32
1359 #define SIDE_STIPPLE 32
1360  if (!SHC.drw_field_tube_limit) {
1362 
1363  int v_len = 2 * (CIRCLE_RESOL * 2 + 4 * SIDE_STIPPLE / 2);
1365  GPU_vertbuf_data_alloc(vbo, v_len);
1366 
1367  int v = 0;
1368  int flag = VCLASS_EMPTY_SIZE;
1369  /* Caps */
1370  for (int i = 0; i < 2; i++) {
1371  float z = i * 2.0f - 1.0f;
1372  circle_dashed_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
1373  }
1374  /* Side Edges */
1375  for (int a = 0; a < 4; a++) {
1376  float angle = (2.0f * M_PI * a) / 4.0f;
1377  for (int i = 0; i < SIDE_STIPPLE; i++) {
1378  float z = (i / (float)SIDE_STIPPLE) * 2.0f - 1.0f;
1379  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle), cosf(angle), z}, flag});
1380  }
1381  }
1382 
1384  }
1385  return SHC.drw_field_tube_limit;
1386 #undef SIDE_STIPPLE
1387 #undef CIRCLE_RESOL
1388 }
1389 
1391 {
1392 #define CIRCLE_RESOL 32
1393 #define SIDE_STIPPLE 32
1394  if (!SHC.drw_field_cone_limit) {
1396 
1397  int v_len = 2 * (CIRCLE_RESOL * 2 + 4 * SIDE_STIPPLE / 2);
1399  GPU_vertbuf_data_alloc(vbo, v_len);
1400 
1401  int v = 0;
1402  int flag = VCLASS_EMPTY_SIZE;
1403  /* Caps */
1404  for (int i = 0; i < 2; i++) {
1405  float z = i * 2.0f - 1.0f;
1406  circle_dashed_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
1407  }
1408  /* Side Edges */
1409  for (int a = 0; a < 4; a++) {
1410  float angle = (2.0f * M_PI * a) / 4.0f;
1411  for (int i = 0; i < SIDE_STIPPLE; i++) {
1412  float z = (i / (float)SIDE_STIPPLE) * 2.0f - 1.0f;
1413  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle) * z, cosf(angle) * z, z}, flag});
1414  }
1415  }
1416 
1418  }
1419  return SHC.drw_field_cone_limit;
1420 #undef SIDE_STIPPLE
1421 #undef CIRCLE_RESOL
1422 }
1423 
1424 /* Screen-aligned dashed circle */
1426 {
1427 #define CIRCLE_RESOL 32
1428  if (!SHC.drw_field_sphere_limit) {
1430 
1431  int v_len = 2 * CIRCLE_RESOL;
1433  GPU_vertbuf_data_alloc(vbo, v_len);
1434 
1435  int v = 0;
1437  circle_dashed_verts(vbo, &v, CIRCLE_RESOL, 1.0f, 0.0f, flag);
1438 
1441  }
1442  return SHC.drw_field_sphere_limit;
1443 #undef CIRCLE_RESOL
1444 }
1445 
1448 /* -------------------------------------------------------------------- */
1452 #define DIAMOND_NSEGMENTS 4
1453 #define INNER_NSEGMENTS 8
1454 #define OUTER_NSEGMENTS 10
1455 #define CIRCLE_NSEGMENTS 32
1456 
1457 static float light_distance_z_get(char axis, const bool start)
1458 {
1459  switch (axis) {
1460  case 'x': /* - X */
1461  return start ? 0.4f : 0.3f;
1462  case 'X': /* + X */
1463  return start ? 0.6f : 0.7f;
1464  case 'y': /* - Y */
1465  return start ? 1.4f : 1.3f;
1466  case 'Y': /* + Y */
1467  return start ? 1.6f : 1.7f;
1468  case 'z': /* - Z */
1469  return start ? 2.4f : 2.3f;
1470  case 'Z': /* + Z */
1471  return start ? 2.6f : 2.7f;
1472  }
1473  return 0.0;
1474 }
1475 
1477 {
1478  if (!SHC.drw_ground_line) {
1480 
1481  int v_len = 2 * (1 + DIAMOND_NSEGMENTS);
1483  GPU_vertbuf_data_alloc(vbo, v_len);
1484 
1485  int v = 0;
1486  /* Ground Point */
1487  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.35f, 0.0f, 0);
1488  /* Ground Line */
1489  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 1.0}, 0});
1490  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 0.0}, 0});
1491 
1493  }
1494  return SHC.drw_ground_line;
1495 }
1496 
1498 {
1499  if (!SHC.drw_light_point_lines) {
1501 
1504  GPU_vertbuf_data_alloc(vbo, v_len);
1505 
1506  const float r = 9.0f;
1507  int v = 0;
1508  /* Light Icon */
1509  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1510  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1511  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1512  /* Light area */
1514  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1515 
1517  }
1518  return SHC.drw_light_point_lines;
1519 }
1520 
1522 {
1523  if (!SHC.drw_light_sun_lines) {
1525 
1526  int v_len = 2 * (DIAMOND_NSEGMENTS + INNER_NSEGMENTS + OUTER_NSEGMENTS + 8 * 2 + 1);
1528  GPU_vertbuf_data_alloc(vbo, v_len);
1529 
1530  const float r = 9.0f;
1531  int v = 0;
1532  /* Light Icon */
1533  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1534  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1535  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1536  /* Sun Rays */
1537  for (int a = 0; a < 8; a++) {
1538  float angle = (2.0f * M_PI * a) / 8.0f;
1539  float s = sinf(angle) * r;
1540  float c = cosf(angle) * r;
1541  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 1.6f, c * 1.6f, 0.0f}, VCLASS_SCREENSPACE});
1542  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 1.9f, c * 1.9f, 0.0f}, VCLASS_SCREENSPACE});
1543  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 2.2f, c * 2.2f, 0.0f}, VCLASS_SCREENSPACE});
1544  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 2.5f, c * 2.5f, 0.0f}, VCLASS_SCREENSPACE});
1545  }
1546  /* Direction Line */
1547  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 0.0}, 0});
1548  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, -20.0}, 0}); /* Good default. */
1549 
1551  }
1552  return SHC.drw_light_sun_lines;
1553 }
1554 
1556 {
1557  if (!SHC.drw_light_spot_lines) {
1559 
1560  int v_len = 2 * (DIAMOND_NSEGMENTS * 3 + INNER_NSEGMENTS + OUTER_NSEGMENTS +
1561  CIRCLE_NSEGMENTS * 4 + 1);
1563  GPU_vertbuf_data_alloc(vbo, v_len);
1564 
1565  const float r = 9.0f;
1566  int v = 0;
1567  /* Light Icon */
1568  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1569  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1570  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1571  /* Light area */
1573  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1574  /* Cone cap */
1575  flag = VCLASS_LIGHT_SPOT_SHAPE;
1576  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1578  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1579  /* Cone silhouette */
1581  for (int a = 0; a < CIRCLE_NSEGMENTS; a++) {
1582  float angle = (2.0f * M_PI * a) / CIRCLE_NSEGMENTS;
1583  float s = sinf(angle);
1584  float c = cosf(angle);
1585  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0f}, 0});
1586  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s, c, -1.0f}, flag});
1587  }
1588  /* Direction Line */
1589  float zsta = light_distance_z_get('z', true);
1590  float zend = light_distance_z_get('z', false);
1591  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zsta}, VCLASS_LIGHT_DIST});
1592  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zend}, VCLASS_LIGHT_DIST});
1595 
1597  }
1598  return SHC.drw_light_spot_lines;
1599 }
1600 
1602 {
1603  if (!SHC.drw_light_spot_volume) {
1605 
1606  int v_len = CIRCLE_NSEGMENTS + 1 + 1;
1608  GPU_vertbuf_data_alloc(vbo, v_len);
1609 
1610  int v = 0;
1611  /* Cone apex */
1612  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0f}, 0});
1613  /* Cone silhouette */
1614  int flag = VCLASS_LIGHT_SPOT_SHAPE;
1615  for (int a = 0; a < CIRCLE_NSEGMENTS + 1; a++) {
1616  float angle = (2.0f * M_PI * a) / CIRCLE_NSEGMENTS;
1617  float s = sinf(-angle);
1618  float c = cosf(-angle);
1619  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s, c, -1.0f}, flag});
1620  }
1621 
1624  }
1625  return SHC.drw_light_spot_volume;
1626 }
1627 
1629 {
1632 
1633  int v_len = 2 *
1636  GPU_vertbuf_data_alloc(vbo, v_len);
1637 
1638  const float r = 9.0f;
1639  int v = 0;
1640  /* Light Icon */
1641  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1642  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1643  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1644  /* Light area */
1646  /* Direction Line */
1647  float zsta = light_distance_z_get('z', true);
1648  float zend = light_distance_z_get('z', false);
1649  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zsta}, VCLASS_LIGHT_DIST});
1650  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zend}, VCLASS_LIGHT_DIST});
1653 
1656  }
1658 }
1659 
1661 {
1664 
1666  int v_len = 2 * (DIAMOND_NSEGMENTS * 3 + INNER_NSEGMENTS + OUTER_NSEGMENTS + 4 + 1);
1667  GPU_vertbuf_data_alloc(vbo, v_len);
1668 
1669  const float r = 9.0f;
1670  int v = 0;
1671  /* Light Icon */
1672  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1673  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1674  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1675  /* Light area */
1676  int flag = VCLASS_LIGHT_AREA_SHAPE;
1677  for (int a = 0; a < 4; a++) {
1678  for (int b = 0; b < 2; b++) {
1679  const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
1680  float x = p[(a + b) % 4][0];
1681  float y = p[(a + b) % 4][1];
1682  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x * 0.5f, y * 0.5f, 0.0f}, flag});
1683  }
1684  }
1685  /* Direction Line */
1686  float zsta = light_distance_z_get('z', true);
1687  float zend = light_distance_z_get('z', false);
1688  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zsta}, VCLASS_LIGHT_DIST});
1689  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zend}, VCLASS_LIGHT_DIST});
1692 
1695  }
1697 }
1698 
1699 #undef CIRCLE_NSEGMENTS
1700 #undef OUTER_NSEGMENTS
1701 #undef INNER_NSEGMENTS
1702 
1705 /* -------------------------------------------------------------------- */
1710 {
1711  if (!SHC.drw_speaker) {
1712  float v[3];
1713  const int segments = 16;
1714  int vidx = 0;
1715 
1716  /* Position Only 3D format */
1717  static GPUVertFormat format = {0};
1718  static struct {
1719  uint pos;
1720  } attr_id;
1721  if (format.attr_len == 0) {
1723  }
1724 
1726  GPU_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4);
1727 
1728  for (int j = 0; j < 3; j++) {
1729  float z = 0.25f * j - 0.125f;
1730  float r = (j == 0 ? 0.5f : 0.25f);
1731 
1732  copy_v3_fl3(v, r, 0.0f, z);
1733  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1734  for (int i = 1; i < segments; i++) {
1735  float x = cosf(2.0f * (float)M_PI * i / segments) * r;
1736  float y = sinf(2.0f * (float)M_PI * i / segments) * r;
1737  copy_v3_fl3(v, x, y, z);
1738  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1739  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1740  }
1741  copy_v3_fl3(v, r, 0.0f, z);
1742  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1743  }
1744 
1745  for (int j = 0; j < 4; j++) {
1746  float x = (((j + 1) % 2) * (j - 1)) * 0.5f;
1747  float y = ((j % 2) * (j - 2)) * 0.5f;
1748  for (int i = 0; i < 3; i++) {
1749  if (i == 1) {
1750  x *= 0.5f;
1751  y *= 0.5f;
1752  }
1753 
1754  float z = 0.25f * i - 0.125f;
1755  copy_v3_fl3(v, x, y, z);
1756  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1757  if (i == 1) {
1758  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1759  }
1760  }
1761  }
1762 
1764  }
1765  return SHC.drw_speaker;
1766 }
1767 
1770 /* -------------------------------------------------------------------- */
1775 {
1776  if (!SHC.drw_lightprobe_cube) {
1778 
1779  int v_len = (6 + 3 + (1 + 2 * DIAMOND_NSEGMENTS) * 6) * 2;
1781  GPU_vertbuf_data_alloc(vbo, v_len);
1782 
1783  const float r = 14.0f;
1784  int v = 0;
1785  int flag = VCLASS_SCREENSPACE;
1786  /* Icon */
1787  const float sin_pi_3 = 0.86602540378f;
1788  const float cos_pi_3 = 0.5f;
1789  const float p[7][2] = {
1790  {0.0f, 1.0f},
1791  {sin_pi_3, cos_pi_3},
1792  {sin_pi_3, -cos_pi_3},
1793  {0.0f, -1.0f},
1794  {-sin_pi_3, -cos_pi_3},
1795  {-sin_pi_3, cos_pi_3},
1796  {0.0f, 0.0f},
1797  };
1798  for (int i = 0; i < 6; i++) {
1799  float t1[2], t2[2];
1800  copy_v2_v2(t1, p[i]);
1801  copy_v2_v2(t2, p[(i + 1) % 6]);
1802  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag});
1803  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag});
1804  }
1805  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[1][0] * r, p[1][1] * r, 0.0f}, flag});
1806  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1807  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[5][0] * r, p[5][1] * r, 0.0f}, flag});
1808  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1809  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[3][0] * r, p[3][1] * r, 0.0f}, flag});
1810  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1811  /* Direction Lines */
1813  for (int i = 0; i < 6; i++) {
1814  char axes[] = "zZyYxX";
1815  float zsta = light_distance_z_get(axes[i], true);
1816  float zend = light_distance_z_get(axes[i], false);
1817  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zsta}, flag});
1818  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zend}, flag});
1819  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zsta, flag);
1820  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zend, flag);
1821  }
1822 
1824  }
1825  return SHC.drw_lightprobe_cube;
1826 }
1827 
1829 {
1830  if (!SHC.drw_lightprobe_grid) {
1832 
1833  int v_len = (6 * 2 + 3 + (1 + 2 * DIAMOND_NSEGMENTS) * 6) * 2;
1835  GPU_vertbuf_data_alloc(vbo, v_len);
1836 
1837  const float r = 14.0f;
1838  int v = 0;
1839  int flag = VCLASS_SCREENSPACE;
1840  /* Icon */
1841  const float sin_pi_3 = 0.86602540378f;
1842  const float cos_pi_3 = 0.5f;
1843  const float p[7][2] = {
1844  {0.0f, 1.0f},
1845  {sin_pi_3, cos_pi_3},
1846  {sin_pi_3, -cos_pi_3},
1847  {0.0f, -1.0f},
1848  {-sin_pi_3, -cos_pi_3},
1849  {-sin_pi_3, cos_pi_3},
1850  {0.0f, 0.0f},
1851  };
1852  for (int i = 0; i < 6; i++) {
1853  float t1[2], t2[2], tr[2];
1854  copy_v2_v2(t1, p[i]);
1855  copy_v2_v2(t2, p[(i + 1) % 6]);
1856  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag});
1857  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag});
1858  /* Internal wires. */
1859  for (int j = 1; j < 2; j++) {
1860  mul_v2_v2fl(tr, p[(i / 2) * 2 + 1], -0.5f * j);
1861  add_v2_v2v2(t1, p[i], tr);
1862  add_v2_v2v2(t2, p[(i + 1) % 6], tr);
1863  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag});
1864  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag});
1865  }
1866  }
1867  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[1][0] * r, p[1][1] * r, 0.0f}, flag});
1868  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1869  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[5][0] * r, p[5][1] * r, 0.0f}, flag});
1870  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1871  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[3][0] * r, p[3][1] * r, 0.0f}, flag});
1872  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1873  /* Direction Lines */
1875  for (int i = 0; i < 6; i++) {
1876  char axes[] = "zZyYxX";
1877  float zsta = light_distance_z_get(axes[i], true);
1878  float zend = light_distance_z_get(axes[i], false);
1879  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zsta}, flag});
1880  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zend}, flag});
1881  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zsta, flag);
1882  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zend, flag);
1883  }
1884 
1886  }
1887  return SHC.drw_lightprobe_grid;
1888 }
1889 
1891 {
1892  if (!SHC.drw_lightprobe_planar) {
1894 
1895  int v_len = 2 * 4;
1897  GPU_vertbuf_data_alloc(vbo, v_len);
1898 
1899  const float r = 20.0f;
1900  int v = 0;
1901  /* Icon */
1902  const float sin_pi_3 = 0.86602540378f;
1903  const float p[4][2] = {
1904  {0.0f, 0.5f},
1905  {sin_pi_3, 0.0f},
1906  {0.0f, -0.5f},
1907  {-sin_pi_3, 0.0f},
1908  };
1909  for (int i = 0; i < 4; i++) {
1910  for (int a = 0; a < 2; a++) {
1911  float x = p[(i + a) % 4][0] * r;
1912  float y = p[(i + a) % 4][1] * r;
1913  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 0.0}, VCLASS_SCREENSPACE});
1914  }
1915  }
1916 
1918  }
1919  return SHC.drw_lightprobe_planar;
1920 }
1921 
1924 /* -------------------------------------------------------------------- */
1928 static const float bone_octahedral_verts[6][3] = {
1929  {0.0f, 0.0f, 0.0f},
1930  {0.1f, 0.1f, 0.1f},
1931  {0.1f, 0.1f, -0.1f},
1932  {-0.1f, 0.1f, -0.1f},
1933  {-0.1f, 0.1f, 0.1f},
1934  {0.0f, 1.0f, 0.0f},
1935 };
1936 
1937 static const float bone_octahedral_smooth_normals[6][3] = {
1938  {0.0f, -1.0f, 0.0f},
1939 #if 0 /* creates problems for outlines when scaled */
1940  {0.943608f * M_SQRT1_2, -0.331048f, 0.943608f * M_SQRT1_2},
1941  {0.943608f * M_SQRT1_2, -0.331048f, -0.943608f * M_SQRT1_2},
1942  {-0.943608f * M_SQRT1_2, -0.331048f, -0.943608f * M_SQRT1_2},
1943  {-0.943608f * M_SQRT1_2, -0.331048f, 0.943608f * M_SQRT1_2},
1944 #else
1945  {M_SQRT1_2, 0.0f, M_SQRT1_2},
1946  {M_SQRT1_2, 0.0f, -M_SQRT1_2},
1947  {-M_SQRT1_2, 0.0f, -M_SQRT1_2},
1948  {-M_SQRT1_2, 0.0f, M_SQRT1_2},
1949 #endif
1950  {0.0f, 1.0f, 0.0f},
1951 };
1952 
1953 #if 0 /* UNUSED */
1954 
1955 static const uint bone_octahedral_wire[24] = {
1956  0, 1, 1, 5, 5, 3, 3, 0, 0, 4, 4, 5, 5, 2, 2, 0, 1, 2, 2, 3, 3, 4, 4, 1,
1957 };
1958 
1959 /* aligned with bone_octahedral_wire
1960  * Contains adjacent normal index */
1961 static const uint bone_octahedral_wire_adjacent_face[24] = {
1962  0, 3, 4, 7, 5, 6, 1, 2, 2, 3, 6, 7, 4, 5, 0, 1, 0, 4, 1, 5, 2, 6, 3, 7,
1963 };
1964 #endif
1965 
1966 static const uint bone_octahedral_solid_tris[8][3] = {
1967  {2, 1, 0}, /* bottom */
1968  {3, 2, 0},
1969  {4, 3, 0},
1970  {1, 4, 0},
1971 
1972  {5, 1, 2}, /* top */
1973  {5, 2, 3},
1974  {5, 3, 4},
1975  {5, 4, 1},
1976 };
1977 
1990  {0, 1, 2, 6},
1991  {0, 12, 1, 6},
1992  {0, 3, 12, 6},
1993  {0, 2, 3, 6},
1994  {1, 6, 2, 3},
1995  {1, 12, 6, 3},
1996  {1, 0, 12, 3},
1997  {1, 2, 0, 3},
1998  {2, 0, 1, 12},
1999  {2, 3, 0, 12},
2000  {2, 6, 3, 12},
2001  {2, 1, 6, 12},
2002 };
2003 
2004 #if 0 /* UNUSED */
2005 static const uint bone_octahedral_solid_tris_adjacency[8][6] = {
2006  {0, 12, 1, 10, 2, 3},
2007  {3, 15, 4, 1, 5, 6},
2008  {6, 18, 7, 4, 8, 9},
2009  {9, 21, 10, 7, 11, 0},
2010 
2011  {12, 22, 13, 2, 14, 17},
2012  {15, 13, 16, 5, 17, 20},
2013  {18, 16, 19, 8, 20, 23},
2014  {21, 19, 22, 11, 23, 14},
2015 };
2016 #endif
2017 
2018 /* aligned with bone_octahedral_solid_tris */
2019 static const float bone_octahedral_solid_normals[8][3] = {
2020  {M_SQRT1_2, -M_SQRT1_2, 0.00000000f},
2021  {-0.00000000f, -M_SQRT1_2, -M_SQRT1_2},
2022  {-M_SQRT1_2, -M_SQRT1_2, 0.00000000f},
2023  {0.00000000f, -M_SQRT1_2, M_SQRT1_2},
2024  {0.99388373f, 0.11043154f, -0.00000000f},
2025  {0.00000000f, 0.11043154f, -0.99388373f},
2026  {-0.99388373f, 0.11043154f, 0.00000000f},
2027  {0.00000000f, 0.11043154f, 0.99388373f},
2028 };
2029 
2031 {
2032  if (!SHC.drw_bone_octahedral) {
2033  uint v_idx = 0;
2034 
2035  static GPUVertFormat format = {0};
2036  static struct {
2037  uint pos, nor, snor;
2038  } attr_id;
2039  if (format.attr_len == 0) {
2043  }
2044 
2045  /* Vertices */
2047  GPU_vertbuf_data_alloc(vbo, 24);
2048 
2049  for (int i = 0; i < 8; i++) {
2050  for (int j = 0; j < 3; j++) {
2053  attr_id.snor,
2054  v_idx,
2057  vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]);
2058  }
2059  }
2060 
2062  }
2063  return SHC.drw_bone_octahedral;
2064 }
2065 
2067 {
2069  GPUIndexBufBuilder elb;
2070  GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 24);
2071 
2072  for (int i = 0; i < 12; i++) {
2078  }
2079 
2080  /* HACK Reuse vertex buffer. */
2081  GPUBatch *pos_nor_batch = DRW_cache_bone_octahedral_get();
2082 
2084  pos_nor_batch->verts[0],
2085  GPU_indexbuf_build(&elb),
2087  }
2089 }
2090 
2092 {
2093  if (!SHC.drw_bone_box) {
2094  uint v_idx = 0;
2095 
2096  static GPUVertFormat format = {0};
2097  static struct {
2098  uint pos, nor, snor;
2099  } attr_id;
2100  if (format.attr_len == 0) {
2104  }
2105 
2106  /* Vertices */
2108  GPU_vertbuf_data_alloc(vbo, 36);
2109 
2110  for (int i = 0; i < 12; i++) {
2111  for (int j = 0; j < 3; j++) {
2114  vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]);
2116  }
2117  }
2118 
2120  }
2121  return SHC.drw_bone_box;
2122 }
2123 
2125 {
2126  if (!SHC.drw_bone_box_wire) {
2127  GPUIndexBufBuilder elb;
2128  GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 36);
2129 
2130  for (int i = 0; i < 12; i++) {
2136  }
2137 
2138  /* HACK Reuse vertex buffer. */
2139  GPUBatch *pos_nor_batch = DRW_cache_bone_box_get();
2140 
2142  pos_nor_batch->verts[0],
2143  GPU_indexbuf_build(&elb),
2145  }
2146  return SHC.drw_bone_box_wire;
2147 }
2148 
2149 /* Helpers for envelope bone's solid sphere-with-hidden-equatorial-cylinder.
2150  * Note that here we only encode head/tail in forth component of the vector. */
2151 static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3])
2152 {
2153  r_nor[0] = sinf(lat) * cosf(lon);
2154  r_nor[1] = sinf(lat) * sinf(lon);
2155  r_nor[2] = cosf(lat);
2156 }
2157 
2159 {
2160  if (!SHC.drw_bone_envelope) {
2161  const int lon_res = 24;
2162  const int lat_res = 24;
2163  const float lon_inc = 2.0f * M_PI / lon_res;
2164  const float lat_inc = M_PI / lat_res;
2165  uint v_idx = 0;
2166 
2167  static GPUVertFormat format = {0};
2168  static struct {
2169  uint pos;
2170  } attr_id;
2171  if (format.attr_len == 0) {
2173  }
2174 
2175  /* Vertices */
2177  GPU_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1);
2178 
2179  float lon = 0.0f;
2180  for (int i = 0; i < lon_res; i++, lon += lon_inc) {
2181  float lat = 0.0f;
2182  float co1[3], co2[3];
2183 
2184  /* Note: the poles are duplicated on purpose, to restart the strip. */
2185 
2186  /* 1st sphere */
2187  for (int j = 0; j < lat_res; j++, lat += lat_inc) {
2188  benv_lat_lon_to_co(lat, lon, co1);
2189  benv_lat_lon_to_co(lat, lon + lon_inc, co2);
2190 
2191  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
2192  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
2193  }
2194 
2195  /* Closing the loop */
2196  benv_lat_lon_to_co(M_PI, lon, co1);
2197  benv_lat_lon_to_co(M_PI, lon + lon_inc, co2);
2198 
2199  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
2200  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
2201  }
2202 
2204  }
2205  return SHC.drw_bone_envelope;
2206 }
2207 
2209 {
2211 #define CIRCLE_RESOL 64
2212  float v0[2], v1[2], v2[2];
2213  const float radius = 1.0f;
2214 
2215  /* Position Only 2D format */
2216  static GPUVertFormat format = {0};
2217  static struct {
2218  uint pos0, pos1, pos2;
2219  } attr_id;
2220  if (format.attr_len == 0) {
2224  }
2225 
2228 
2229  v0[0] = radius * sinf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL));
2230  v0[1] = radius * cosf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL));
2231  v1[0] = radius * sinf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL));
2232  v1[1] = radius * cosf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL));
2233 
2234  /* Output 4 verts for each position. See shader for explanation. */
2235  uint v = 0;
2236  for (int a = 0; a <= CIRCLE_RESOL; a++) {
2237  v2[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2238  v2[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2239  GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
2240  GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
2241  GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
2242  copy_v2_v2(v0, v1);
2243  copy_v2_v2(v1, v2);
2244  }
2245 
2248 #undef CIRCLE_RESOL
2249  }
2251 }
2252 
2254 {
2255  if (!SHC.drw_bone_point) {
2256 #if 0 /* old style geometry sphere */
2257  const int lon_res = 16;
2258  const int lat_res = 8;
2259  const float rad = 0.05f;
2260  const float lon_inc = 2 * M_PI / lon_res;
2261  const float lat_inc = M_PI / lat_res;
2262  uint v_idx = 0;
2263 
2264  static GPUVertFormat format = {0};
2265  static struct {
2266  uint pos, nor;
2267  } attr_id;
2268  if (format.attr_len == 0) {
2271  }
2272 
2273  /* Vertices */
2275  GPU_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6);
2276 
2277  float lon = 0.0f;
2278  for (int i = 0; i < lon_res; i++, lon += lon_inc) {
2279  float lat = 0.0f;
2280  for (int j = 0; j < lat_res; j++, lat += lat_inc) {
2281  if (j != lat_res - 1) { /* Pole */
2282  add_lat_lon_vert(
2283  vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
2284  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon);
2285  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
2286  }
2287 
2288  if (j != 0) { /* Pole */
2289  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon + lon_inc);
2290  add_lat_lon_vert(
2291  vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
2292  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
2293  }
2294  }
2295  }
2296 
2298 #else
2299 # define CIRCLE_RESOL 64
2300  float v[2];
2301  const float radius = 0.05f;
2302 
2303  /* Position Only 2D format */
2304  static GPUVertFormat format = {0};
2305  static struct {
2306  uint pos;
2307  } attr_id;
2308  if (format.attr_len == 0) {
2310  }
2311 
2314 
2315  for (int a = 0; a < CIRCLE_RESOL; a++) {
2316  v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2317  v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2318  GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v);
2319  }
2320 
2322 # undef CIRCLE_RESOL
2323 #endif
2324  }
2325  return SHC.drw_bone_point;
2326 }
2327 
2329 {
2330  if (!SHC.drw_bone_point_wire) {
2331 #if 0 /* old style geometry sphere */
2332  GPUVertBuf *vbo = sphere_wire_vbo(0.05f);
2334 #else
2335 # define CIRCLE_RESOL 64
2336  const float radius = 0.05f;
2337 
2338  /* Position Only 2D format */
2339  static GPUVertFormat format = {0};
2340  static struct {
2341  uint pos;
2342  } attr_id;
2343  if (format.attr_len == 0) {
2345  }
2346 
2349 
2350  uint v = 0;
2351  for (int a = 0; a <= CIRCLE_RESOL; a++) {
2352  float pos[2];
2353  pos[0] = radius * sinf((2.0f * M_PI * a) / CIRCLE_RESOL);
2354  pos[1] = radius * cosf((2.0f * M_PI * a) / CIRCLE_RESOL);
2355  GPU_vertbuf_attr_set(vbo, attr_id.pos, v++, pos);
2356  }
2357 
2360 # undef CIRCLE_RESOL
2361 #endif
2362  }
2363  return SHC.drw_bone_point_wire;
2364 }
2365 
2366 /* keep in sync with armature_stick_vert.glsl */
2367 #define COL_WIRE (1 << 0)
2368 #define COL_HEAD (1 << 1)
2369 #define COL_TAIL (1 << 2)
2370 #define COL_BONE (1 << 3)
2371 
2372 #define POS_HEAD (1 << 4)
2373 #define POS_TAIL (1 << 5)
2374 #define POS_BONE (1 << 6)
2375 
2377 {
2378  if (!SHC.drw_bone_stick) {
2379 #define CIRCLE_RESOL 12
2380  uint v = 0;
2381  uint flag;
2382  const float radius = 2.0f; /* head/tail radius */
2383  float pos[2];
2384 
2385  /* Position Only 2D format */
2386  static GPUVertFormat format = {0};
2387  static struct {
2388  uint pos, flag;
2389  } attr_id;
2390  if (format.attr_len == 0) {
2393  }
2394 
2395  const uint vcount = (CIRCLE_RESOL + 1) * 2 + 6;
2396 
2398  GPU_vertbuf_data_alloc(vbo, vcount);
2399 
2400  GPUIndexBufBuilder elb;
2401  GPU_indexbuf_init_ex(&elb, GPU_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount);
2402 
2403  /* head/tail points */
2404  for (int i = 0; i < 2; i++) {
2405  /* center vertex */
2406  copy_v2_fl(pos, 0.0f);
2407  flag = (i == 0) ? POS_HEAD : POS_TAIL;
2408  flag |= (i == 0) ? COL_HEAD : COL_TAIL;
2409  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
2410  GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
2412  /* circle vertices */
2413  flag |= COL_WIRE;
2414  for (int a = 0; a < CIRCLE_RESOL; a++) {
2415  pos[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2416  pos[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2417  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
2418  GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
2420  }
2421  /* Close the circle */
2423 
2425  }
2426 
2427  /* Bone rectangle */
2428  pos[0] = 0.0f;
2429  for (int i = 0; i < 6; i++) {
2430  pos[1] = (ELEM(i, 0, 3)) ? 0.0f : ((i < 3) ? 1.0f : -1.0f);
2431  flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) | ((i == 0 || i == 3) ? 0 : COL_WIRE) |
2432  COL_BONE | POS_BONE;
2433  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
2434  GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
2436  }
2437 
2439  vbo,
2440  GPU_indexbuf_build(&elb),
2442 #undef CIRCLE_RESOL
2443  }
2444  return SHC.drw_bone_stick;
2445 }
2446 
2447 #define S_X 0.0215f
2448 #define S_Y 0.025f
2449 static float x_axis_name[4][2] = {
2450  {0.9f * S_X, 1.0f * S_Y},
2451  {-1.0f * S_X, -1.0f * S_Y},
2452  {-0.9f * S_X, 1.0f * S_Y},
2453  {1.0f * S_X, -1.0f * S_Y},
2454 };
2455 #define X_LEN (sizeof(x_axis_name) / (sizeof(float[2])))
2456 #undef S_X
2457 #undef S_Y
2458 
2459 #define S_X 0.0175f
2460 #define S_Y 0.025f
2461 static float y_axis_name[6][2] = {
2462  {-1.0f * S_X, 1.0f * S_Y},
2463  {0.0f * S_X, -0.1f * S_Y},
2464  {1.0f * S_X, 1.0f * S_Y},
2465  {0.0f * S_X, -0.1f * S_Y},
2466  {0.0f * S_X, -0.1f * S_Y},
2467  {0.0f * S_X, -1.0f * S_Y},
2468 };
2469 #define Y_LEN (sizeof(y_axis_name) / (sizeof(float[2])))
2470 #undef S_X
2471 #undef S_Y
2472 
2473 #define S_X 0.02f
2474 #define S_Y 0.025f
2475 static float z_axis_name[10][2] = {
2476  {-0.95f * S_X, 1.00f * S_Y},
2477  {0.95f * S_X, 1.00f * S_Y},
2478  {0.95f * S_X, 1.00f * S_Y},
2479  {0.95f * S_X, 0.90f * S_Y},
2480  {0.95f * S_X, 0.90f * S_Y},
2481  {-1.00f * S_X, -0.90f * S_Y},
2482  {-1.00f * S_X, -0.90f * S_Y},
2483  {-1.00f * S_X, -1.00f * S_Y},
2484  {-1.00f * S_X, -1.00f * S_Y},
2485  {1.00f * S_X, -1.00f * S_Y},
2486 };
2487 #define Z_LEN (sizeof(z_axis_name) / (sizeof(float[2])))
2488 #undef S_X
2489 #undef S_Y
2490 
2491 #define S_X 0.007f
2492 #define S_Y 0.007f
2493 static float axis_marker[8][2] = {
2494 #if 0 /* square */
2495  {-1.0f * S_X, 1.0f * S_Y},
2496  {1.0f * S_X, 1.0f * S_Y},
2497  {1.0f * S_X, 1.0f * S_Y},
2498  {1.0f * S_X, -1.0f * S_Y},
2499  {1.0f * S_X, -1.0f * S_Y},
2500  {-1.0f * S_X, -1.0f * S_Y},
2501  {-1.0f * S_X, -1.0f * S_Y},
2502  {-1.0f * S_X, 1.0f * S_Y}
2503 #else /* diamond */
2504  {-S_X, 0.0f},
2505  {0.0f, S_Y},
2506  {0.0f, S_Y},
2507  {S_X, 0.0f},
2508  {S_X, 0.0f},
2509  {0.0f, -S_Y},
2510  {0.0f, -S_Y},
2511  {-S_X, 0.0f}
2512 #endif
2513 };
2514 #define MARKER_LEN (sizeof(axis_marker) / (sizeof(float[2])))
2515 #define MARKER_FILL_LAYER 6
2516 #undef S_X
2517 #undef S_Y
2518 
2520 {
2521  if (!SHC.drw_bone_arrows) {
2524  int v_len = (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 + (X_LEN + Y_LEN + Z_LEN);
2525  GPU_vertbuf_data_alloc(vbo, v_len);
2526 
2527  int v = 0;
2528  for (int axis = 0; axis < 3; axis++) {
2530  /* Vertex layout is XY screen position and axis in Z.
2531  * Fractional part of Z is a positive offset at axis unit position.*/
2532  float p[3] = {0.0f, 0.0f, axis};
2533  /* center to axis line */
2534  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0f}, 0});
2535  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[0], p[1], p[2]}, flag});
2536  /* Axis end marker */
2537  for (int j = 1; j < MARKER_FILL_LAYER + 1; j++) {
2538  for (int i = 0; i < MARKER_LEN; i++) {
2539  mul_v2_v2fl(p, axis_marker[i], 4.0f * j / (float)MARKER_FILL_LAYER);
2540  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[0], p[1], p[2]}, flag});
2541  }
2542  }
2543  /* Axis name */
2545  int axis_v_len[] = {X_LEN, Y_LEN, Z_LEN};
2546  float(*axis_v)[2] = (axis == 0) ? x_axis_name : ((axis == 1) ? y_axis_name : z_axis_name);
2547  p[2] = axis + 0.25f;
2548  for (int i = 0; i < axis_v_len[axis]; i++) {
2549  mul_v2_v2fl(p, axis_v[i], 4.0f);
2550  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[0], p[1], p[2]}, flag});
2551  }
2552  }
2553 
2555  }
2556  return SHC.drw_bone_arrows;
2557 }
2558 
2559 static const float staticSine[16] = {
2560  0.0f,
2561  0.104528463268f,
2562  0.207911690818f,
2563  0.309016994375f,
2564  0.406736643076f,
2565  0.5f,
2566  0.587785252292f,
2567  0.669130606359f,
2568  0.743144825477f,
2569  0.809016994375f,
2570  0.866025403784f,
2571  0.913545457643f,
2572  0.951056516295f,
2573  0.978147600734f,
2574  0.994521895368f,
2575  1.0f,
2576 };
2577 
2578 #define set_vert(a, b, quarter) \
2579  { \
2580  copy_v2_fl2(pos, (quarter % 2 == 0) ? -(a) : (a), (quarter < 2) ? -(b) : (b)); \
2581  GPU_vertbuf_attr_set(vbo, attr_id.pos, v++, pos); \
2582  } \
2583  ((void)0)
2584 
2586 {
2587  if (!SHC.drw_bone_dof_sphere) {
2588  int i, j, q, n = ARRAY_SIZE(staticSine);
2589  float x, z, px, pz, pos[2];
2590 
2591  /* Position Only 3D format */
2592  static GPUVertFormat format = {0};
2593  static struct {
2594  uint pos;
2595  } attr_id;
2596  if (format.attr_len == 0) {
2598  }
2599 
2601  GPU_vertbuf_data_alloc(vbo, n * n * 6 * 4);
2602 
2603  uint v = 0;
2604  for (q = 0; q < 4; q++) {
2605  pz = 0.0f;
2606  for (i = 1; i < n; i++) {
2607  z = staticSine[i];
2608  px = 0.0f;
2609  for (j = 1; j <= (n - i); j++) {
2610  x = staticSine[j];
2611  if (j == n - i) {
2612  set_vert(px, z, q);
2613  set_vert(px, pz, q);
2614  set_vert(x, pz, q);
2615  }
2616  else {
2617  set_vert(x, z, q);
2618  set_vert(x, pz, q);
2619  set_vert(px, z, q);
2620 
2621  set_vert(x, pz, q);
2622  set_vert(px, pz, q);
2623  set_vert(px, z, q);
2624  }
2625  px = x;
2626  }
2627  pz = z;
2628  }
2629  }
2630  /* TODO allocate right count from the beginning. */
2631  GPU_vertbuf_data_resize(vbo, v);
2632 
2634  }
2635  return SHC.drw_bone_dof_sphere;
2636 }
2637 
2639 {
2640  if (!SHC.drw_bone_dof_lines) {
2641  int i, n = ARRAY_SIZE(staticSine);
2642  float pos[2];
2643 
2644  /* Position Only 3D format */
2645  static GPUVertFormat format = {0};
2646  static struct {
2647  uint pos;
2648  } attr_id;
2649  if (format.attr_len == 0) {
2651  }
2652 
2654  GPU_vertbuf_data_alloc(vbo, n * 4);
2655 
2656  uint v = 0;
2657  for (i = 0; i < n * 4; i++) {
2658  float a = (1.0f - (i / (float)(n * 4))) * 2.0f * M_PI;
2659  float x = cosf(a);
2660  float y = sinf(a);
2661  set_vert(x, y, 0);
2662  }
2663 
2666  }
2667  return SHC.drw_bone_dof_lines;
2668 }
2669 
2670 #undef set_vert
2671 
2674 /* -------------------------------------------------------------------- */
2679 {
2680  if (!SHC.drw_camera_frame) {
2682 
2683  const int v_len = 2 * (4 + 4);
2685  GPU_vertbuf_data_alloc(vbo, v_len);
2686 
2687  int v = 0;
2688  const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
2689  /* Frame */
2690  for (int a = 0; a < 4; a++) {
2691  for (int b = 0; b < 2; b++) {
2692  float x = p[(a + b) % 4][0];
2693  float y = p[(a + b) % 4][1];
2694  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 1.0f}, VCLASS_CAMERA_FRAME});
2695  }
2696  }
2697  /* Wires to origin. */
2698  for (int a = 0; a < 4; a++) {
2699  float x = p[a][0];
2700  float y = p[a][1];
2701  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 1.0f}, VCLASS_CAMERA_FRAME});
2702  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 0.0f}, VCLASS_CAMERA_FRAME});
2703  }
2704 
2706  }
2707  return SHC.drw_camera_frame;
2708 }
2709 
2711 {
2712  if (!SHC.drw_camera_volume) {
2714 
2715  const int v_len = ARRAY_SIZE(bone_box_solid_tris) * 3;
2717  GPU_vertbuf_data_alloc(vbo, v_len);
2718 
2719  int v = 0;
2721  for (int i = 0; i < ARRAY_SIZE(bone_box_solid_tris); i++) {
2722  for (int a = 0; a < 3; a++) {
2723  float x = bone_box_verts[bone_box_solid_tris[i][a]][2];
2724  float y = bone_box_verts[bone_box_solid_tris[i][a]][0];
2725  float z = bone_box_verts[bone_box_solid_tris[i][a]][1];
2726  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, flag});
2727  }
2728  }
2729 
2731  }
2732  return SHC.drw_camera_volume;
2733 }
2734 
2736 {
2737  if (!SHC.drw_camera_volume_wire) {
2739 
2740  const int v_len = ARRAY_SIZE(bone_box_wire);
2742  GPU_vertbuf_data_alloc(vbo, v_len);
2743 
2744  int v = 0;
2746  for (int i = 0; i < ARRAY_SIZE(bone_box_wire); i++) {
2747  float x = bone_box_verts[bone_box_wire[i]][2];
2748  float y = bone_box_verts[bone_box_wire[i]][0];
2749  float z = bone_box_verts[bone_box_wire[i]][1];
2750  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, flag});
2751  }
2752 
2755  }
2756  return SHC.drw_camera_volume_wire;
2757 }
2758 
2760 {
2761  if (!SHC.drw_camera_tria_wire) {
2763 
2764  const int v_len = 2 * 3;
2766  GPU_vertbuf_data_alloc(vbo, v_len);
2767 
2768  int v = 0;
2769  const float p[3][2] = {{-1.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}};
2770  for (int a = 0; a < 3; a++) {
2771  for (int b = 0; b < 2; b++) {
2772  float x = p[(a + b) % 3][0];
2773  float y = p[(a + b) % 3][1];
2774  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 1.0f}, VCLASS_CAMERA_FRAME});
2775  }
2776  }
2777 
2779  }
2780  return SHC.drw_camera_tria_wire;
2781 }
2782 
2784 {
2785  if (!SHC.drw_camera_tria) {
2787 
2788  const int v_len = 3;
2790  GPU_vertbuf_data_alloc(vbo, v_len);
2791 
2792  int v = 0;
2793  /* Use camera frame position */
2794  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{-1.0f, 1.0f, 1.0f}, VCLASS_CAMERA_FRAME});
2795  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{1.0f, 1.0f, 1.0f}, VCLASS_CAMERA_FRAME});
2796  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 1.0f}, VCLASS_CAMERA_FRAME});
2797 
2799  }
2800  return SHC.drw_camera_tria;
2801 }
2802 
2804 {
2805  if (!SHC.drw_camera_distances) {
2807 
2808  const int v_len = 2 * (1 + DIAMOND_NSEGMENTS * 2 + 2);
2810  GPU_vertbuf_data_alloc(vbo, v_len);
2811 
2812  int v = 0;
2813  /* Direction Line */
2814  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 0.0}, VCLASS_CAMERA_DIST});
2815  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 1.0}, VCLASS_CAMERA_DIST});
2818  /* Focus cross */
2819  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{1.0, 0.0, 2.0}, VCLASS_CAMERA_DIST});
2820  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{-1.0, 0.0, 2.0}, VCLASS_CAMERA_DIST});
2821  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 1.0, 2.0}, VCLASS_CAMERA_DIST});
2822  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, -1.0, 2.0}, VCLASS_CAMERA_DIST});
2823 
2825  }
2826  return SHC.drw_camera_distances;
2827 }
2828 
2831 /* -------------------------------------------------------------------- */
2836 {
2837  BLI_assert(ob->type == OB_MESH);
2839 }
2840 
2842 {
2843  BLI_assert(ob->type == OB_MESH);
2845 }
2846 
2848 {
2849  BLI_assert(ob->type == OB_MESH);
2851 }
2852 
2854 {
2855  BLI_assert(ob->type == OB_MESH);
2856  return DRW_mesh_batch_cache_get_edge_detection(ob->data, r_is_manifold);
2857 }
2858 
2860 {
2861  BLI_assert(ob->type == OB_MESH);
2863 }
2864 
2866 {
2867  BLI_assert(ob->type == OB_MESH);
2869 }
2870 
2871 /* Return list of batches with length equal to max(1, totcol). */
2873  struct GPUMaterial **gpumat_array,
2874  uint gpumat_array_len)
2875 {
2876  BLI_assert(ob->type == OB_MESH);
2877  return DRW_mesh_batch_cache_get_surface_shaded(ob->data, gpumat_array, gpumat_array_len);
2878 }
2879 
2880 /* Return list of batches with length equal to max(1, totcol). */
2882 {
2883  BLI_assert(ob->type == OB_MESH);
2885 }
2886 
2888 {
2889  BLI_assert(ob->type == OB_MESH);
2891 }
2892 
2894 {
2895  BLI_assert(ob->type == OB_MESH);
2897 }
2898 
2900 {
2901  BLI_assert(ob->type == OB_MESH);
2903 }
2904 
2906 {
2907  BLI_assert(ob->type == OB_MESH);
2909 }
2910 
2912 {
2913  BLI_assert(ob->type == OB_MESH);
2915 }
2916 
2918 {
2919  BLI_assert(ob->type == OB_MESH);
2921 }
2922 
2925 /* -------------------------------------------------------------------- */
2930 {
2931  BLI_assert(ob->type == OB_CURVE);
2932 
2933  struct Curve *cu = ob->data;
2934  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
2935  if (mesh_eval != NULL) {
2936  return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
2937  }
2938 
2940 }
2941 
2943 {
2944  BLI_assert(ob->type == OB_CURVE);
2945 
2946  struct Curve *cu = ob->data;
2948 }
2949 
2951 {
2953 
2954  struct Curve *cu = ob->data;
2956 }
2957 
2959 {
2961 
2962  struct Curve *cu = ob->data;
2964 }
2965 
2967 {
2968  BLI_assert(ob->type == OB_CURVE);
2969 
2970  struct Curve *cu = ob->data;
2971  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
2972  if (mesh_eval != NULL) {
2973  return DRW_mesh_batch_cache_get_surface(mesh_eval);
2974  }
2975 
2977 }
2978 
2980 {
2981  BLI_assert(ob->type == OB_CURVE);
2982 
2983  struct Curve *cu = ob->data;
2984  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
2985  if (mesh_eval != NULL) {
2986  return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
2987  }
2988 
2989  /* TODO */
2990  UNUSED_VARS(cu);
2991  return NULL;
2992 }
2993 
2995 {
2996  BLI_assert(ob->type == OB_CURVE);
2997 
2998  struct Curve *cu = ob->data;
2999  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3000  if (mesh_eval != NULL) {
3001  return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
3002  }
3003 
3005 }
3006 
3008 {
3009  BLI_assert(ob->type == OB_CURVE);
3010  struct Curve *cu = ob->data;
3011  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3012  if (mesh_eval != NULL) {
3013  return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
3014  }
3015 
3016  return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
3017 }
3018 
3019 /* Return list of batches */
3021  struct GPUMaterial **gpumat_array,
3022  uint gpumat_array_len)
3023 {
3024  BLI_assert(ob->type == OB_CURVE);
3025 
3026  struct Curve *cu = ob->data;
3027  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3028  if (mesh_eval != NULL) {
3029  return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
3030  }
3031 
3032  return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
3033 }
3034 
3037 /* -------------------------------------------------------------------- */
3042 {
3043  BLI_assert(ob->type == OB_MBALL);
3045 }
3046 
3048 {
3049  BLI_assert(ob->type == OB_MBALL);
3050  return DRW_metaball_batch_cache_get_edge_detection(ob, r_is_manifold);
3051 }
3052 
3054 {
3055  BLI_assert(ob->type == OB_MBALL);
3057 }
3058 
3060  struct GPUMaterial **gpumat_array,
3061  uint gpumat_array_len)
3062 {
3063  BLI_assert(ob->type == OB_MBALL);
3064  MetaBall *mb = ob->data;
3065  return DRW_metaball_batch_cache_get_surface_shaded(ob, mb, gpumat_array, gpumat_array_len);
3066 }
3067 
3070 /* -------------------------------------------------------------------- */
3075 {
3076  BLI_assert(ob->type == OB_FONT);
3077  struct Curve *cu = ob->data;
3078  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3079  const bool has_surface = (cu->flag & (CU_FRONT | CU_BACK)) || cu->ext1 != 0.0f ||
3080  cu->ext2 != 0.0f;
3081  if (!has_surface) {
3082  return NULL;
3083  }
3084  if (mesh_eval != NULL) {
3085  return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
3086  }
3087 
3089 }
3090 
3092 {
3093  BLI_assert(ob->type == OB_FONT);
3094  struct Curve *cu = ob->data;
3095  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3096  if (cu->editfont && (cu->flag & CU_FAST)) {
3097  return NULL;
3098  }
3099  if (mesh_eval != NULL) {
3100  return DRW_mesh_batch_cache_get_surface(mesh_eval);
3101  }
3102 
3104 }
3105 
3107 {
3108  BLI_assert(ob->type == OB_FONT);
3109  struct Curve *cu = ob->data;
3110  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3111  if (cu->editfont && (cu->flag & CU_FAST)) {
3112  return NULL;
3113  }
3114  if (mesh_eval != NULL) {
3115  return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
3116  }
3117 
3118  return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
3119 }
3120 
3122 {
3123  BLI_assert(ob->type == OB_FONT);
3124  struct Curve *cu = ob->data;
3125  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3126  if (cu->editfont && (cu->flag & CU_FAST)) {
3127  return NULL;
3128  }
3129  if (mesh_eval != NULL) {
3130  return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
3131  }
3132 
3134 }
3135 
3137 {
3138  BLI_assert(ob->type == OB_FONT);
3139  struct Curve *cu = ob->data;
3140  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3141  if (cu->editfont && (cu->flag & CU_FAST)) {
3142  return NULL;
3143  }
3144  if (mesh_eval != NULL) {
3145  return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
3146  }
3147 
3149 }
3150 
3152  struct GPUMaterial **gpumat_array,
3153  uint gpumat_array_len)
3154 {
3155  BLI_assert(ob->type == OB_FONT);
3156  struct Curve *cu = ob->data;
3157  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3158  if (cu->editfont && (cu->flag & CU_FAST)) {
3159  return NULL;
3160  }
3161  if (mesh_eval != NULL) {
3162  return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
3163  }
3164 
3165  return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
3166 }
3167 
3170 /* -------------------------------------------------------------------- */
3175 {
3176  BLI_assert(ob->type == OB_SURF);
3177 
3178  struct Curve *cu = ob->data;
3179  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3180  if (mesh_eval != NULL) {
3181  return DRW_mesh_batch_cache_get_surface(mesh_eval);
3182  }
3183 
3185 }
3186 
3188 {
3189  BLI_assert(ob->type == OB_SURF);
3190 
3191  struct Curve *cu = ob->data;
3192  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3193  if (mesh_eval != NULL) {
3194  return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
3195  }
3196 
3198 }
3199 
3201 {
3202  BLI_assert(ob->type == OB_SURF);
3203 
3204  struct Curve *cu = ob->data;
3205  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3206  if (mesh_eval != NULL) {
3207  return DRW_mesh_batch_cache_get_wireframes_face(mesh_eval);
3208  }
3209 
3211 }
3212 
3214 {
3215  BLI_assert(ob->type == OB_SURF);
3216  struct Curve *cu = ob->data;
3217  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3218  if (mesh_eval != NULL) {
3219  return DRW_mesh_batch_cache_get_edge_detection(mesh_eval, r_is_manifold);
3220  }
3221 
3222  return DRW_curve_batch_cache_get_edge_detection(cu, r_is_manifold);
3223 }
3224 
3226 {
3227  BLI_assert(ob->type == OB_SURF);
3228 
3229  struct Curve *cu = ob->data;
3230  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3231  if (mesh_eval != NULL) {
3232  return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
3233  }
3234 
3235  /* TODO */
3236  UNUSED_VARS(cu);
3237  return NULL;
3238 }
3239 
3240 /* Return list of batches */
3242  struct GPUMaterial **gpumat_array,
3243  uint gpumat_array_len)
3244 {
3245  BLI_assert(ob->type == OB_SURF);
3246 
3247  struct Curve *cu = ob->data;
3248  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3249  if (mesh_eval != NULL) {
3250  return DRW_mesh_batch_cache_get_surface_shaded(mesh_eval, gpumat_array, gpumat_array_len);
3251  }
3252 
3253  return DRW_curve_batch_cache_get_surface_shaded(cu, gpumat_array, gpumat_array_len);
3254 }
3255 
3258 /* -------------------------------------------------------------------- */
3263 {
3264  BLI_assert(ob->type == OB_LATTICE);
3265 
3266  struct Lattice *lt = ob->data;
3268 }
3269 
3271 {
3272  BLI_assert(ob->type == OB_LATTICE);
3273 
3274  Lattice *lt = ob->data;
3275  int actdef = -1;
3276 
3277  if (use_weight && ob->defbase.first && lt->editlatt->latt->dvert) {
3278  actdef = ob->actdef - 1;
3279  }
3280 
3281  return DRW_lattice_batch_cache_get_all_edges(lt, use_weight, actdef);
3282 }
3283 
3285 {
3286  BLI_assert(ob->type == OB_LATTICE);
3287 
3288  struct Lattice *lt = ob->data;
3290 }
3291 
3294 /* -------------------------------------------------------------------- */
3299 {
3300  BLI_assert(object->type == OB_POINTCLOUD);
3301  return DRW_pointcloud_batch_cache_get_dots(object);
3302 }
3303 
3305 {
3306  BLI_assert(object->type == OB_POINTCLOUD);
3308 }
3309 
3310 /* -------------------------------------------------------------------- */
3315 {
3316  BLI_assert(ob->type == OB_VOLUME);
3318 }
3319 
3321 {
3322  BLI_assert(ob->type == OB_VOLUME);
3324 }
3325 
3328 /* -------------------------------------------------------------------- */
3333 {
3334  return DRW_particles_batch_cache_get_hair(object, psys, md);
3335 }
3336 
3338 {
3339  return DRW_particles_batch_cache_get_dots(object, psys);
3340 }
3341 
3343  ParticleSystem *psys,
3344  struct PTCacheEdit *edit,
3345  bool use_weight)
3346 {
3347  return DRW_particles_batch_cache_get_edit_strands(object, psys, edit, use_weight);
3348 }
3349 
3351  ParticleSystem *psys,
3352  struct PTCacheEdit *edit)
3353 {
3354  return DRW_particles_batch_cache_get_edit_inner_points(object, psys, edit);
3355 }
3356 
3358  ParticleSystem *psys,
3359  struct PTCacheEdit *edit)
3360 {
3361  return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit);
3362 }
3363 
3365 {
3366  switch (type) {
3367  case PART_DRAW_CROSS:
3368  if (!SHC.drw_particle_cross) {
3371  GPU_vertbuf_data_alloc(vbo, 6);
3372 
3373  int v = 0;
3374  int flag = 0;
3375  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, -1.0f, 0.0f}, flag});
3376  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 1.0f, 0.0f}, flag});
3377  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{-1.0f, 0.0f, 0.0f}, flag});
3378  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{1.0f, 0.0f, 0.0f}, flag});
3379  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, -1.0f}, flag});
3380  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 1.0f}, flag});
3381 
3384  }
3385 
3386  return SHC.drw_particle_cross;
3387  case PART_DRAW_AXIS:
3388  if (!SHC.drw_particle_axis) {
3391  GPU_vertbuf_data_alloc(vbo, 6);
3392 
3393  int v = 0;
3394  int flag = VCLASS_EMPTY_AXES;
3395  /* Set minimum to 0.001f so we can easily normalize to get the color. */
3396  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0001f, 0.0f}, flag});
3397  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 2.0f, 0.0f}, flag});
3398  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0001f, 0.0f, 0.0f}, flag});
3399  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{2.0f, 0.0f, 0.0f}, flag});
3400  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0001f}, flag});
3401  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 2.0f}, flag});
3402 
3404  }
3405 
3406  return SHC.drw_particle_axis;
3407  case PART_DRAW_CIRC:
3408 #define CIRCLE_RESOL 32
3409  if (!SHC.drw_particle_circle) {
3413 
3414  int v = 0;
3415  int flag = VCLASS_SCREENALIGNED;
3416  for (int a = 0; a <= CIRCLE_RESOL; a++) {
3417  float angle = (2.0f * M_PI * a) / CIRCLE_RESOL;
3418  float x = sinf(angle);
3419  float y = cosf(angle);
3420  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 0.0f}, flag});
3421  }
3422 
3425  }
3426 
3427  return SHC.drw_particle_circle;
3428 #undef CIRCLE_RESOL
3429  default:
3430  BLI_assert(false);
3431  break;
3432  }
3433 
3434  return NULL;
3435 }
3436 
3437 /* 3D cursor */
3438 GPUBatch *DRW_cache_cursor_get(bool crosshair_lines)
3439 {
3440  GPUBatch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle;
3441 
3442  if (*drw_cursor == NULL) {
3443  const float f5 = 0.25f;
3444  const float f10 = 0.5f;
3445  const float f20 = 1.0f;
3446 
3447  const int segments = 16;
3448  const int vert_len = segments + 8;
3449  const int index_len = vert_len + 5;
3450 
3451  const uchar red[3] = {255, 0, 0};
3452  const uchar white[3] = {255, 255, 255};
3453 
3454  static GPUVertFormat format = {0};
3455  static struct {
3456  uint pos, color;
3457  } attr_id;
3458  if (format.attr_len == 0) {
3462  }
3463 
3464  GPUIndexBufBuilder elb;
3465  GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len);
3466 
3468  GPU_vertbuf_data_alloc(vbo, vert_len);
3469 
3470  int v = 0;
3471  for (int i = 0; i < segments; i++) {
3472  float angle = (float)(2 * M_PI) * ((float)i / (float)segments);
3473  float x = f10 * cosf(angle);
3474  float y = f10 * sinf(angle);
3475 
3476  GPU_vertbuf_attr_set(vbo, attr_id.color, v, (i % 2 == 0) ? red : white);
3477 
3478  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y});
3480  }
3482 
3483  if (crosshair_lines) {
3484  uchar crosshair_color[3];
3485  UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
3486 
3488 
3489  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0});
3490  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3492  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0});
3493  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3495 
3497 
3498  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0});
3499  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3501  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0});
3502  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3504 
3506 
3507  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20});
3508  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3510  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5});
3511  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3513 
3515 
3516  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5});
3517  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3519  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20});
3520  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3522  }
3523 
3524  GPUIndexBuf *ibo = GPU_indexbuf_build(&elb);
3525 
3526  *drw_cursor = GPU_batch_create_ex(
3528  }
3529  return *drw_cursor;
3530 }
3531 
3534 /* -------------------------------------------------------------------- */
3539 {
3540  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3541  switch (ob->type) {
3542  case OB_MESH:
3544  break;
3545  case OB_CURVE:
3546  case OB_FONT:
3547  case OB_SURF:
3548  if (mesh_eval != NULL) {
3549  DRW_mesh_batch_cache_validate(mesh_eval);
3550  }
3552  break;
3553  case OB_MBALL:
3555  break;
3556  case OB_LATTICE:
3558  break;
3559  case OB_HAIR:
3561  break;
3562  case OB_POINTCLOUD:
3564  break;
3565  case OB_VOLUME:
3567  break;
3568  default:
3569  break;
3570  }
3571 }
3572 
3574 {
3575  const DRWContextState *draw_ctx = DRW_context_state_get();
3576  const Scene *scene = draw_ctx->scene;
3577  const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
3578  draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
3579  const bool is_paint_mode = ELEM(
3581 
3582  const bool use_hide = ((ob->type == OB_MESH) &&
3583  ((is_paint_mode && (ob == draw_ctx->obact) &&
3585  ((mode == CTX_MODE_EDIT_MESH) && DRW_object_is_in_edit_mode(ob))));
3586 
3587  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3588  switch (ob->type) {
3589  case OB_MESH:
3591  DST.task_graph, ob, (Mesh *)ob->data, scene, is_paint_mode, use_hide);
3592  break;
3593  case OB_CURVE:
3594  case OB_FONT:
3595  case OB_SURF:
3596  if (mesh_eval) {
3598  DST.task_graph, ob, mesh_eval, scene, is_paint_mode, use_hide);
3599  }
3601  break;
3602  /* TODO all cases */
3603  default:
3604  break;
3605  }
3606 }
3607 
3609 {
3611 }
3612 
3613 void DRW_batch_cache_free_old(Object *ob, int ctime)
3614 {
3615  struct Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob);
3616 
3617  switch (ob->type) {
3618  case OB_MESH:
3619  DRW_mesh_batch_cache_free_old((Mesh *)ob->data, ctime);
3620  break;
3621  case OB_CURVE:
3622  case OB_FONT:
3623  case OB_SURF:
3624  if (mesh_eval) {
3625  DRW_mesh_batch_cache_free_old(mesh_eval, ctime);
3626  }
3627  break;
3628  /* TODO all cases */
3629  default:
3630  break;
3631  }
3632 }
3633 
typedef float(TangentPoint)[2]
eContextObjectMode
Definition: BKE_context.h:114
@ CTX_MODE_PAINT_TEXTURE
Definition: BKE_context.h:126
@ CTX_MODE_SCULPT
Definition: BKE_context.h:123
@ CTX_MODE_EDIT_MESH
Definition: BKE_context.h:115
@ CTX_MODE_PAINT_VERTEX
Definition: BKE_context.h:125
@ CTX_MODE_PAINT_WEIGHT
Definition: BKE_context.h:124
enum eContextObjectMode CTX_data_mode_enum_ex(const struct Object *obedit, const struct Object *ob, const eObjectMode object_mode)
General operations, lookup, etc. for blender objects.
struct Mesh * BKE_object_get_evaluated_mesh(struct Object *object)
Definition: object.c:4459
#define BLI_assert(a)
Definition: BLI_assert.h:58
bool BLI_gset_add(GSet *gs, void *key)
Definition: BLI_ghash.c:1160
#define M_SQRT3
Definition: BLI_math_base.h:53
#define M_SQRT1_2
Definition: BLI_math_base.h:50
#define M_PI
Definition: BLI_math_base.h:38
MINLINE void madd_v2_v2v2fl(float r[2], const float a[2], const float b[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
MINLINE void copy_v2_fl(float r[2], float f)
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED_FUNCTION(x)
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define ELEM(...)
@ CU_FAST
@ CU_FRONT
@ CU_BACK
Object is a sort of wrapper for general info.
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_MESH
@ OB_POINTCLOUD
@ OB_HAIR
@ OB_VOLUME
@ OB_CURVE
@ OB_GPENCIL
#define PART_DRAW_AXIS
#define PART_DRAW_CROSS
#define PART_DRAW_CIRC
GPUBatch
Definition: GPU_batch.h:93
#define GPU_BATCH_DISCARD_SAFE(batch)
Definition: GPU_batch.h:199
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
Definition: gpu_batch.cc:60
@ GPU_BATCH_OWNS_INDEX
Definition: GPU_batch.h:54
@ GPU_BATCH_OWNS_VBO
Definition: GPU_batch.h:45
struct GPUIndexBuf GPUIndexBuf
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *)
GPUIndexBuf * GPU_indexbuf_build(GPUIndexBufBuilder *)
void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *, uint v)
void GPU_indexbuf_add_line_adj_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3, uint v4)
void GPU_indexbuf_init_ex(GPUIndexBufBuilder *, GPUPrimType, uint index_len, uint vertex_len)
void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
@ GPU_PRIM_TRI_FAN
Definition: GPU_primitive.h:41
@ GPU_PRIM_LINE_LOOP
Definition: GPU_primitive.h:39
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:35
@ GPU_PRIM_LINES_ADJ
Definition: GPU_primitive.h:43
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:38
@ GPU_PRIM_TRI_STRIP
Definition: GPU_primitive.h:40
@ GPU_PRIM_TRIS
Definition: GPU_primitive.h:37
void GPU_vertbuf_vert_set(GPUVertBuf *verts, uint v_idx, const void *data)
#define GPU_vertbuf_create_with_format(format)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void GPU_vertbuf_attr_fill(GPUVertBuf *, uint a_idx, const void *data)
void GPU_vertbuf_attr_set(GPUVertBuf *, uint a_idx, uint v_idx, const void *data)
void GPU_vertbuf_data_resize(GPUVertBuf *, uint v_len)
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
@ GPU_FETCH_INT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias)
@ GPU_COMP_F32
@ GPU_COMP_I32
@ GPU_COMP_U32
@ GPU_COMP_U8
Read Guarded memory(de)allocation.
@ TH_VIEW_OVERLAY
Definition: UI_resources.h:343
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
Definition: resources.c:1350
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
Scene scene
struct VertShaded VertShaded
GPUBatch * DRW_cache_text_face_wireframe_get(Object *ob)
Definition: draw_cache.c:3136
#define DRW_SPHERE_SHAPE_LONGITUDE_HIGH
Definition: draw_cache.c:78
GPUBatch * DRW_cache_mesh_face_wireframe_get(Object *ob)
Definition: draw_cache.c:2911
GPUBatch * DRW_cache_camera_frame_get(void)
Definition: draw_cache.c:2678
GPUBatch * DRW_cache_empty_capsule_body_get(void)
Definition: draw_cache.c:1170
GPUBatch * DRW_cache_curve_edge_normal_get(Object *ob)
Definition: draw_cache.c:2942
#define VCLASS_LIGHT_AREA_SHAPE
Definition: draw_cache.c:50
GPUBatch * DRW_cache_groundline_get(void)
Definition: draw_cache.c:1476
GPUBatch * DRW_cache_curve_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:3007
GPUBatch * DRW_cache_circle_get(void)
Definition: draw_cache.c:733
#define set_vert(a, b, quarter)
Definition: draw_cache.c:2578
static struct DRWShapeCache SHC
GPUBatch * DRW_cache_plain_axes_get(void)
Definition: draw_cache.c:1001
GPUBatch * DRW_cache_empty_sphere_get(void)
Definition: draw_cache.c:1081
GPUVertBuf * DRW_cache_object_pos_vertbuf_get(Object *ob)
Definition: draw_cache.c:911
GPUBatch * DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
Definition: draw_cache.c:2899
static const float bone_box_solid_normals[12][3]
Definition: draw_cache.c:680
static GPUVertBuf * sphere_wire_vbo(const float rad, int flag)
Definition: draw_cache.c:313
GPUBatch ** DRW_cache_mball_surface_shaded_get(Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:3059
GPUBatch * DRW_cache_bone_octahedral_wire_get(void)
Definition: draw_cache.c:2066
GPUBatch * DRW_cache_quad_get(void)
Definition: draw_cache.c:392
GPUBatch * DRW_cache_particles_get_edit_inner_points(Object *object, ParticleSystem *psys, struct PTCacheEdit *edit)
Definition: draw_cache.c:3350
GPUBatch * DRW_cache_object_all_edges_get(Object *ob)
Definition: draw_cache.c:799
static const uint bone_octahedral_wire_lines_adjacency[12][4]
Definition: draw_cache.c:1989
static float y_axis_name[6][2]
Definition: draw_cache.c:2461
GPUBatch * DRW_cache_lattice_verts_get(Object *ob)
Definition: draw_cache.c:3262
GPUBatch * DRW_cache_cursor_get(bool crosshair_lines)
Definition: draw_cache.c:3438
GPUBatch * DRW_cache_mball_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:3047
GPUBatch * DRW_cache_lightprobe_grid_get(void)
Definition: draw_cache.c:1828
GPUBatch * DRW_cache_light_area_disk_lines_get(void)
Definition: draw_cache.c:1628
static float x_axis_name[4][2]
Definition: draw_cache.c:2449
GPUBatch * DRW_cache_curve_edge_wire_get(Object *ob)
Definition: draw_cache.c:2929
GPUBatch * DRW_cache_bone_dof_lines_get(void)
Definition: draw_cache.c:2638
#define VCLASS_CAMERA_DIST
Definition: draw_cache.c:57
GPUBatch * DRW_cache_empty_cylinder_get(void)
Definition: draw_cache.c:1129
#define OUTER_NSEGMENTS
Definition: draw_cache.c:1454
static const float bone_octahedral_smooth_normals[6][3]
Definition: draw_cache.c:1937
static const float staticSine[16]
Definition: draw_cache.c:2559
GPUBatch * DRW_cache_text_edge_wire_get(Object *ob)
Definition: draw_cache.c:3074
#define VCLASS_EMPTY_AXES_NAME
Definition: draw_cache.c:65
#define Z_LEN
Definition: draw_cache.c:2487
#define VCLASS_LIGHT_SPOT_BLEND
Definition: draw_cache.c:52
GPUBatch * DRW_cache_pointcloud_surface_get(Object *object)
Definition: draw_cache.c:3304
GPUBatch * DRW_cache_mesh_all_verts_get(Object *ob)
Definition: draw_cache.c:2835
GPUBatch * DRW_cache_field_force_get(void)
Definition: draw_cache.c:1283
GPUBatch * DRW_cache_grid_get(void)
Definition: draw_cache.c:434
#define Y_LEN
Definition: draw_cache.c:2469
GPUBatch ** DRW_cache_text_surface_shaded_get(Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:3151
GPUBatch * DRW_cache_field_tube_limit_get(void)
Definition: draw_cache.c:1356
GPUBatch * DRW_cache_field_cone_limit_get(void)
Definition: draw_cache.c:1390
#define DRW_SPHERE_SHAPE_LONGITUDE_MEDIUM
Definition: draw_cache.c:75
GPUBatch * DRW_cache_lattice_vert_overlay_get(Object *ob)
Definition: draw_cache.c:3284
static const uint bone_box_wire_lines_adjacency[12][4]
Definition: draw_cache.c:642
static const uint bone_box_wire[24]
Definition: draw_cache.c:606
GPUBatch * DRW_cache_surf_face_wireframe_get(Object *ob)
Definition: draw_cache.c:3200
#define S_X
Definition: draw_cache.c:2491
GPUBatch * DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:811
GPUBatch * DRW_cache_field_sphere_limit_get(void)
Definition: draw_cache.c:1425
GPUBatch * DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
Definition: draw_cache.c:2887
#define DRW_SPHERE_SHAPE_LATITUDE_LOW
Definition: draw_cache.c:71
GPUBatch * DRW_cache_field_vortex_get(void)
Definition: draw_cache.c:1306
GPUBatch ** DRW_cache_object_surface_material_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:969
GPUBatch * DRW_cache_surf_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:3213
#define VCLASS_EMPTY_AXES
Definition: draw_cache.c:64
GPUBatch * DRW_cache_light_area_square_lines_get(void)
Definition: draw_cache.c:1660
GPUBatch * DRW_cache_bone_box_get(void)
Definition: draw_cache.c:2091
GPUBatch * DRW_cache_light_spot_lines_get(void)
Definition: draw_cache.c:1555
GPUBatch ** DRW_cache_surf_surface_shaded_get(Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:3241
GPUBatch * DRW_cache_speaker_get(void)
Definition: draw_cache.c:1709
GPUBatch * DRW_cache_bone_octahedral_get(void)
Definition: draw_cache.c:2030
GPUBatch * drw_cache_procedural_points_get(void)
Definition: draw_cache.c:170
#define VCLASS_EMPTY_SCALED
Definition: draw_cache.c:63
GPUBatch * DRW_cache_mesh_surface_weights_get(Object *ob)
Definition: draw_cache.c:2905
GPUBatch * DRW_cache_curve_surface_get(Object *ob)
Definition: draw_cache.c:2966
GPUBatch * DRW_cache_surf_surface_get(Object *ob)
Definition: draw_cache.c:3174
#define COL_HEAD
Definition: draw_cache.c:2368
GPUBatch * DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
Definition: draw_cache.c:3270
GPUBatch * DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys)
Definition: draw_cache.c:3337
GPUBatch * DRW_cache_camera_volume_wire_get(void)
Definition: draw_cache.c:2735
static const float bone_box_verts[8][3]
Definition: draw_cache.c:584
#define SPIRAL_RESOL
void drw_batch_cache_generate_requested(Object *ob)
Definition: draw_cache.c:3573
GPUBatch * DRW_cache_text_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:3106
static void circle_dashed_verts(GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
Definition: draw_cache.c:568
GPUBatch * DRW_cache_text_surface_get(Object *ob)
Definition: draw_cache.c:3091
GPUBatch * DRW_cache_volume_selection_surface_get(Object *ob)
Definition: draw_cache.c:3320
GPUBatch * DRW_cache_light_spot_volume_get(void)
Definition: draw_cache.c:1601
GPUBatch * DRW_cache_bone_point_wire_outline_get(void)
Definition: draw_cache.c:2328
GPUBatch * DRW_cache_object_face_wireframe_get(Object *ob)
Definition: draw_cache.c:835
#define INNER_NSEGMENTS
Definition: draw_cache.c:1453
GPUBatch * DRW_cache_field_wind_get(void)
Definition: draw_cache.c:1260
GPUBatch * DRW_cache_bone_stick_get(void)
Definition: draw_cache.c:2376
#define POS_TAIL
Definition: draw_cache.c:2373
static const float bone_octahedral_verts[6][3]
Definition: draw_cache.c:1928
#define MARKER_LEN
Definition: draw_cache.c:2514
GPUBatch * DRW_cache_lightprobe_planar_get(void)
Definition: draw_cache.c:1890
GPUBatch * DRW_cache_bone_envelope_outline_get(void)
Definition: draw_cache.c:2208
GPUBatch * DRW_cache_surf_edge_wire_get(Object *ob)
Definition: draw_cache.c:3187
GPUBatch * drw_cache_procedural_triangles_get(void)
Definition: draw_cache.c:198
#define COL_WIRE
Definition: draw_cache.c:2367
#define NSEGMENTS
static const float bone_octahedral_solid_normals[8][3]
Definition: draw_cache.c:2019
#define CIRCLE_RESOL
GPUBatch * DRW_cache_fullscreen_quad_get(void)
Definition: draw_cache.c:358
#define VCLASS_LIGHT_DIST
Definition: draw_cache.c:54
GPUBatch * DRW_cache_field_curve_get(void)
Definition: draw_cache.c:1336
GPUBatch * DRW_cache_mball_face_wireframe_get(Object *ob)
Definition: draw_cache.c:3053
GPUBatch * DRW_cache_surf_loose_edges_get(Object *ob)
Definition: draw_cache.c:3225
#define DRW_SPHERE_SHAPE_LATITUDE_HIGH
Definition: draw_cache.c:77
void drw_batch_cache_validate(Object *ob)
Definition: draw_cache.c:3538
#define DRW_SPHERE_SHAPE_LONGITUDE_LOW
Definition: draw_cache.c:72
GPUBatch * DRW_cache_curve_face_wireframe_get(Object *ob)
Definition: draw_cache.c:2994
#define VCLASS_LIGHT_SPOT_SHAPE
Definition: draw_cache.c:51
void DRW_shape_cache_free(void)
Definition: draw_cache.c:156
GPUBatch * DRW_cache_cube_get(void)
Definition: draw_cache.c:700
GPUBatch ** DRW_cache_mesh_surface_shaded_get(Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:2872
GPUBatch * DRW_cache_normal_arrow_get(void)
Definition: draw_cache.c:756
void drw_batch_cache_generate_requested_delayed(Object *ob)
Definition: draw_cache.c:3608
GPUBatch * DRW_cache_camera_tria_get(void)
Definition: draw_cache.c:2783
struct Vert Vert
#define X_LEN
Definition: draw_cache.c:2455
#define VCLASS_CAMERA_FRAME
Definition: draw_cache.c:56
#define CIRCLE_NSEGMENTS
Definition: draw_cache.c:1455
GPUBatch * DRW_cache_camera_volume_get(void)
Definition: draw_cache.c:2710
#define VCLASS_CAMERA_VOLUME
Definition: draw_cache.c:58
GPUBatch * DRW_cache_mesh_surface_vertpaint_get(Object *ob)
Definition: draw_cache.c:2893
GPUBatch * DRW_cache_sphere_get(const eDRWLevelOfDetail level_of_detail)
Definition: draw_cache.c:487
#define VCLASS_LIGHT_SPOT_CONE
Definition: draw_cache.c:53
GPUBatch * DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:2853
#define S_Y
Definition: draw_cache.c:2492
static float z_axis_name[10][2]
Definition: draw_cache.c:2475
GPUBatch * DRW_cache_particles_get_prim(int type)
Definition: draw_cache.c:3364
GPUBatch * DRW_cache_light_sun_lines_get(void)
Definition: draw_cache.c:1521
GPUBatch * DRW_cache_bone_envelope_solid_get(void)
Definition: draw_cache.c:2158
GPUBatch * DRW_cache_lightprobe_cube_get(void)
Definition: draw_cache.c:1774
static void UNUSED_FUNCTION() add_fancy_edge(GPUVertBuf *vbo, uint pos_id, uint n1_id, uint n2_id, uint *v_idx, const float co1[3], const float co2[3], const float n1[3], const float n2[3])
Definition: draw_cache.c:226
static const uint bone_octahedral_solid_tris[8][3]
Definition: draw_cache.c:1966
GPUBatch * DRW_cache_bone_point_get(void)
Definition: draw_cache.c:2253
GPUBatch * DRW_cache_mesh_all_edges_get(Object *ob)
Definition: draw_cache.c:2841
GPUBatch * DRW_cache_camera_tria_wire_get(void)
Definition: draw_cache.c:2759
GPUBatch * DRW_cache_curve_vert_overlay_get(Object *ob)
Definition: draw_cache.c:2958
static void circle_verts(GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
Definition: draw_cache.c:553
#define POS_HEAD
Definition: draw_cache.c:2372
#define VCLASS_SCREENALIGNED
Definition: draw_cache.c:61
#define DIAMOND_NSEGMENTS
Definition: draw_cache.c:1452
GPUBatch * DRW_cache_mesh_surface_get(Object *ob)
Definition: draw_cache.c:2859
#define VCLASS_SCREENSPACE
Definition: draw_cache.c:60
GPUBatch * DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
Definition: draw_cache.c:2917
GPUBatch * DRW_cache_curve_edge_overlay_get(Object *ob)
Definition: draw_cache.c:2950
static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lon)
Definition: draw_cache.c:478
static const uint bone_box_solid_tris[12][3]
Definition: draw_cache.c:618
GPUBatch * DRW_cache_particles_get_edit_tip_points(Object *object, ParticleSystem *psys, struct PTCacheEdit *edit)
Definition: draw_cache.c:3357
#define COL_BONE
Definition: draw_cache.c:2370
GPUBatch ** DRW_cache_mesh_surface_texpaint_get(Object *ob)
Definition: draw_cache.c:2881
#define COL_TAIL
Definition: draw_cache.c:2369
#define MARKER_FILL_LAYER
Definition: draw_cache.c:2515
static const float bone_box_smooth_normals[8][3]
Definition: draw_cache.c:595
GPUBatch * DRW_cache_bone_box_wire_get(void)
Definition: draw_cache.c:2124
GPUBatch * DRW_cache_mball_surface_get(Object *ob)
Definition: draw_cache.c:3041
#define POS_BONE
Definition: draw_cache.c:2374
GPUBatch * DRW_cache_curve_loose_edges_get(Object *ob)
Definition: draw_cache.c:2979
int DRW_cache_object_material_count_get(struct Object *ob)
Definition: draw_cache.c:936
static GPUVertFormat extra_vert_format(void)
Definition: draw_cache.c:218
static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3])
Definition: draw_cache.c:2151
GPUBatch * DRW_cache_quad_wires_get(void)
Definition: draw_cache.c:413
#define DRW_SPHERE_SHAPE_LATITUDE_MEDIUM
Definition: draw_cache.c:74
GPUBatch * drw_cache_procedural_lines_get(void)
Definition: draw_cache.c:184
GPUBatch * DRW_cache_mesh_loose_edges_get(Object *ob)
Definition: draw_cache.c:2847
static float axis_marker[8][2]
Definition: draw_cache.c:2493
GPUBatch * DRW_cache_empty_capsule_cap_get(void)
Definition: draw_cache.c:1203
GPUBatch * DRW_cache_volume_face_wireframe_get(Object *ob)
Definition: draw_cache.c:3314
GPUBatch * DRW_cache_particles_get_edit_strands(Object *object, ParticleSystem *psys, struct PTCacheEdit *edit, bool use_weight)
Definition: draw_cache.c:3342
GPUBatch * DRW_cache_single_arrow_get(void)
Definition: draw_cache.c:1043
void DRW_batch_cache_free_old(Object *ob, int ctime)
Definition: draw_cache.c:3613
GPUBatch * DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md)
Definition: draw_cache.c:3332
GPUBatch * DRW_cache_camera_distances_get(void)
Definition: draw_cache.c:2803
GPUBatch * DRW_cache_object_surface_get(Object *ob)
Definition: draw_cache.c:886
GPUBatch * DRW_cache_pointcloud_get_dots(Object *object)
Definition: draw_cache.c:3298
static float light_distance_z_get(char axis, const bool start)
Definition: draw_cache.c:1457
GPUBatch * DRW_cache_empty_cone_get(void)
Definition: draw_cache.c:1090
#define VCLASS_EMPTY_SIZE
Definition: draw_cache.c:67
GPUBatch * DRW_gpencil_dummy_buffer_get(void)
Definition: draw_cache.c:779
GPUBatch * DRW_cache_object_loose_edges_get(struct Object *ob)
Definition: draw_cache.c:862
#define SIDE_STIPPLE
GPUBatch * DRW_cache_light_point_lines_get(void)
Definition: draw_cache.c:1497
GPUBatch * DRW_cache_bone_dof_sphere_get(void)
Definition: draw_cache.c:2585
GPUBatch ** DRW_cache_curve_surface_shaded_get(Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:3020
GPUBatch * DRW_cache_bone_arrows_get(void)
Definition: draw_cache.c:2519
GPUBatch * DRW_cache_empty_cube_get(void)
Definition: draw_cache.c:1023
GPUBatch * DRW_cache_mesh_surface_edges_get(Object *ob)
Definition: draw_cache.c:2865
GPUBatch * DRW_cache_text_loose_edges_get(Object *ob)
Definition: draw_cache.c:3121
struct GPUBatch * DRW_cache_gpencil_face_wireframe_get(struct Object *ob)
eDRWLevelOfDetail
Definition: draw_cache.h:36
@ DRW_LOD_MEDIUM
Definition: draw_cache.h:38
@ DRW_LOD_LOW
Definition: draw_cache.h:37
@ DRW_LOD_HIGH
Definition: draw_cache.h:39
@ DRW_LOD_MAX
Definition: draw_cache.h:41
struct GPUBatch ** DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
struct GPUBatch * DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold)
struct GPUBatch * DRW_curve_batch_cache_get_wire_edge(struct Curve *cu)
struct GPUBatch * DRW_particles_batch_cache_get_edit_tip_points(struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit)
struct GPUBatch ** DRW_mesh_batch_cache_get_surface_shaded(struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
struct GPUBatch * DRW_pointcloud_batch_cache_get_surface(struct Object *ob)
struct GPUBatch * DRW_curve_batch_cache_get_edit_edges(struct Curve *cu)
int DRW_metaball_material_count_get(struct MetaBall *mb)
struct GPUVertBuf * DRW_mesh_batch_cache_pos_vertbuf_get(struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_loose_edges(struct Mesh *me)
void DRW_pointcloud_batch_cache_validate(struct PointCloud *pointcloud)
struct GPUBatch * DRW_volume_batch_cache_get_wireframes_face(struct Volume *volume)
struct GPUBatch * DRW_particles_batch_cache_get_edit_strands(struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit, bool use_weight)
struct GPUBatch * DRW_mesh_batch_cache_get_wireframes_face(struct Mesh *me)
void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, struct Object *ob, struct Mesh *me, const struct Scene *scene, const bool is_paint_mode, const bool use_hide)
struct GPUBatch * DRW_lattice_batch_cache_get_edit_verts(struct Lattice *lt)
struct GPUBatch ** DRW_cache_pointcloud_surface_shaded_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
void DRW_curve_batch_cache_create_requested(struct Object *ob, const struct Scene *scene)
struct GPUBatch * DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, const int actdef)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_sculpt(struct Mesh *me)
struct GPUBatch * DRW_pointcloud_batch_cache_get_dots(struct Object *ob)
struct GPUBatch * DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu)
struct GPUBatch * DRW_volume_batch_cache_get_selection_surface(struct Volume *volume)
struct GPUBatch * DRW_mesh_batch_cache_get_all_edges(struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_weights(struct Mesh *me)
void DRW_lattice_batch_cache_validate(struct Lattice *lt)
struct GPUBatch * DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt)
struct GPUBatch * DRW_mesh_batch_cache_get_all_verts(struct Mesh *me)
struct GPUVertBuf * DRW_mball_batch_cache_pos_vertbuf_get(struct Object *ob)
struct GPUBatch * DRW_particles_batch_cache_get_edit_inner_points(struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit)
void DRW_curve_batch_cache_validate(struct Curve *cu)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_edges(struct Mesh *me)
void DRW_hair_batch_cache_validate(struct Hair *hair)
void DRW_mball_batch_cache_validate(struct MetaBall *mb)
struct GPUBatch * DRW_curve_batch_cache_get_normal_edge(struct Curve *cu)
struct GPUBatch ** DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me)
void DRW_mesh_batch_cache_validate(struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_vertpaint(struct Mesh *me)
int DRW_hair_material_count_get(struct Hair *hair)
struct GPUVertBuf * DRW_curve_batch_cache_pos_vertbuf_get(struct Curve *cu)
int DRW_curve_material_count_get(struct Curve *cu)
struct GPUBatch * DRW_metaball_batch_cache_get_wireframes_face(struct Object *ob)
void DRW_volume_batch_cache_validate(struct Volume *volume)
int DRW_volume_material_count_get(struct Volume *volume)
int DRW_pointcloud_material_count_get(struct PointCloud *pointcloud)
struct GPUBatch * DRW_curve_batch_cache_get_edit_verts(struct Curve *cu)
void DRW_mesh_batch_cache_free_old(struct Mesh *me, int ctime)
struct GPUBatch * DRW_particles_batch_cache_get_dots(struct Object *object, struct ParticleSystem *psys)
struct GPUBatch * DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob)
struct GPUBatch * DRW_particles_batch_cache_get_hair(struct Object *object, struct ParticleSystem *psys, struct ModifierData *md)
int DRW_mesh_material_count_get(struct Mesh *me)
struct GPUBatch * DRW_metaball_batch_cache_get_edge_detection(struct Object *ob, bool *r_is_manifold)
struct GPUBatch ** DRW_curve_batch_cache_get_surface_shaded(struct Curve *cu, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
struct GPUBatch * DRW_curve_batch_cache_get_edge_detection(struct Curve *cu, bool *r_is_manifold)
struct GPUBatch * DRW_mesh_batch_cache_get_edit_mesh_analysis(struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_surface(struct Mesh *me)
struct GPUBatch * DRW_curve_batch_cache_get_wireframes_face(struct Curve *cu)
bool DRW_object_is_in_edit_mode(const Object *ob)
Definition: draw_manager.c:204
DRWManager DST
Definition: draw_manager.c:111
const DRWContextState * DRW_context_state_get(void)
bool DRW_object_use_hide_faces(const struct Object *ob)
Definition: draw_manager.c:252
GPUBatch * batch
Definition: drawnode.c:3779
uint pos
struct @612::@615 attr_id
uint nor
#define sinf(x)
#define cosf(x)
format
Definition: logImageCore.h:47
static unsigned c
Definition: RandGen.cpp:97
static unsigned a[3]
Definition: RandGen.cpp:92
float ext1
struct EditFont * editfont
float ext2
struct Object * obact
Definition: DRW_render.h:749
struct Scene * scene
Definition: DRW_render.h:745
eObjectMode object_mode
Definition: DRW_render.h:757
struct Object * object_edit
Definition: DRW_render.h:769
struct TaskGraph * task_graph
Definition: draw_manager.h:562
struct GSet * delayed_extraction
Definition: draw_manager.h:564
GPUBatch * drw_camera_volume_wire
Definition: draw_cache.c:148
GPUBatch * drw_grid
Definition: draw_cache.c:101
GPUBatch * drw_bone_dof_sphere
Definition: draw_cache.c:141
GPUBatch * drw_lightprobe_grid
Definition: draw_cache.c:130
GPUBatch * drw_single_arrow
Definition: draw_cache.c:103
GPUBatch * drw_empty_cube
Definition: draw_cache.c:107
GPUBatch * drw_bone_envelope_outline
Definition: draw_cache.c:136
GPUBatch * drw_light_point_lines
Definition: draw_cache.c:121
GPUBatch * drw_particle_cross
Definition: draw_cache.c:149
GPUBatch * drw_procedural_verts
Definition: draw_cache.c:93
GPUBatch * drw_gpencil_dummy_quad
Definition: draw_cache.c:152
GPUBatch * drw_lightprobe_cube
Definition: draw_cache.c:128
GPUBatch * drw_plain_axes
Definition: draw_cache.c:102
GPUBatch * drw_empty_cone
Definition: draw_cache.c:112
GPUBatch * drw_speaker
Definition: draw_cache.c:127
GPUBatch * drw_bone_box_wire
Definition: draw_cache.c:134
GPUBatch * drw_quad_wires
Definition: draw_cache.c:100
GPUBatch * drw_circle
Definition: draw_cache.c:105
GPUBatch * drw_light_spot_lines
Definition: draw_cache.c:123
GPUBatch * drw_procedural_tris
Definition: draw_cache.c:95
GPUBatch * drw_bone_envelope
Definition: draw_cache.c:135
GPUBatch * drw_bone_box
Definition: draw_cache.c:133
GPUBatch * drw_cursor_only_circle
Definition: draw_cache.c:97
GPUBatch * drw_camera_frame
Definition: draw_cache.c:143
GPUBatch * drw_empty_sphere
Definition: draw_cache.c:108
GPUBatch * drw_field_sphere_limit
Definition: draw_cache.c:119
GPUBatch * drw_camera_tria_wire
Definition: draw_cache.c:145
GPUBatch * drw_camera_tria
Definition: draw_cache.c:144
GPUBatch * drw_cursor
Definition: draw_cache.c:96
GPUBatch * drw_fullscreen_quad
Definition: draw_cache.c:98
GPUBatch * drw_empty_capsule_cap
Definition: draw_cache.c:111
GPUBatch * drw_field_curve
Definition: draw_cache.c:116
GPUBatch * drw_empty_cylinder
Definition: draw_cache.c:109
GPUBatch * drw_particle_circle
Definition: draw_cache.c:150
GPUBatch * drw_bone_arrows
Definition: draw_cache.c:140
GPUBatch * drw_field_force
Definition: draw_cache.c:114
GPUBatch * drw_sphere_lod[DRW_LOD_MAX]
Definition: draw_cache.c:153
GPUBatch * drw_light_area_disk_lines
Definition: draw_cache.c:125
GPUBatch * drw_procedural_lines
Definition: draw_cache.c:94
GPUBatch * drw_normal_arrow
Definition: draw_cache.c:106
GPUBatch * drw_bone_stick
Definition: draw_cache.c:139
GPUBatch * drw_bone_dof_lines
Definition: draw_cache.c:142
GPUBatch * drw_lightprobe_planar
Definition: draw_cache.c:129
GPUBatch * drw_empty_capsule_body
Definition: draw_cache.c:110
GPUBatch * drw_light_spot_volume
Definition: draw_cache.c:124
GPUBatch * drw_bone_point
Definition: draw_cache.c:137
GPUBatch * drw_bone_octahedral_wire
Definition: draw_cache.c:132
GPUBatch * drw_light_area_square_lines
Definition: draw_cache.c:126
GPUBatch * drw_particle_axis
Definition: draw_cache.c:151
GPUBatch * drw_cube
Definition: draw_cache.c:104
GPUBatch * drw_field_cone_limit
Definition: draw_cache.c:118
GPUBatch * drw_field_vortex
Definition: draw_cache.c:115
GPUBatch * drw_camera_distances
Definition: draw_cache.c:146
GPUBatch * drw_camera_volume
Definition: draw_cache.c:147
GPUBatch * drw_quad
Definition: draw_cache.c:99
GPUBatch * drw_bone_point_wire
Definition: draw_cache.c:138
GPUBatch * drw_field_wind
Definition: draw_cache.c:113
GPUBatch * drw_light_sun_lines
Definition: draw_cache.c:122
GPUBatch * drw_field_tube_limit
Definition: draw_cache.c:117
GPUBatch * drw_bone_octahedral
Definition: draw_cache.c:131
GPUBatch * drw_ground_line
Definition: draw_cache.c:120
struct Lattice * latt
struct MDeformVert * dvert
struct EditLatt * editlatt
void * first
Definition: DNA_listBase.h:47
ListBase defbase
unsigned short actdef
void * data
float nor[3]
Definition: draw_cache.c:88
float pos[3]
Definition: draw_cache.c:86
float pos[3]
Definition: draw_cache.c:81