Blender  V3.3
draw_cache.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "DNA_curve_types.h"
8 #include "DNA_curves_types.h"
9 #include "DNA_lattice_types.h"
10 #include "DNA_mesh_types.h"
11 #include "DNA_meta_types.h"
12 #include "DNA_modifier_types.h"
13 #include "DNA_object_types.h"
14 #include "DNA_particle_types.h"
15 #include "DNA_pointcloud_types.h"
16 #include "DNA_scene_types.h"
17 #include "DNA_volume_types.h"
18 
19 #include "UI_resources.h"
20 
21 #include "BLI_math.h"
22 #include "BLI_utildefines.h"
23 
24 #include "BKE_object.h"
25 #include "BKE_paint.h"
26 
27 #include "GPU_batch.h"
28 #include "GPU_batch_utils.h"
29 #include "GPU_capabilities.h"
30 
31 #include "MEM_guardedalloc.h"
32 
33 #include "draw_cache.h"
34 #include "draw_cache_impl.h"
35 #include "draw_manager.h"
36 
37 /* -------------------------------------------------------------------- */
41 #define VCLASS_LIGHT_AREA_SHAPE (1 << 0)
42 #define VCLASS_LIGHT_SPOT_SHAPE (1 << 1)
43 #define VCLASS_LIGHT_SPOT_BLEND (1 << 2)
44 #define VCLASS_LIGHT_SPOT_CONE (1 << 3)
45 #define VCLASS_LIGHT_DIST (1 << 4)
46 
47 #define VCLASS_CAMERA_FRAME (1 << 5)
48 #define VCLASS_CAMERA_DIST (1 << 6)
49 #define VCLASS_CAMERA_VOLUME (1 << 7)
50 
51 #define VCLASS_SCREENSPACE (1 << 8)
52 #define VCLASS_SCREENALIGNED (1 << 9)
53 
54 #define VCLASS_EMPTY_SCALED (1 << 10)
55 #define VCLASS_EMPTY_AXES (1 << 11)
56 #define VCLASS_EMPTY_AXES_NAME (1 << 12)
57 #define VCLASS_EMPTY_AXES_SHADOW (1 << 13)
58 #define VCLASS_EMPTY_SIZE (1 << 14)
59 
60 /* Sphere shape resolution */
61 /* Low */
62 #define DRW_SPHERE_SHAPE_LATITUDE_LOW 32
63 #define DRW_SPHERE_SHAPE_LONGITUDE_LOW 24
64 /* Medium */
65 #define DRW_SPHERE_SHAPE_LATITUDE_MEDIUM 64
66 #define DRW_SPHERE_SHAPE_LONGITUDE_MEDIUM 48
67 /* High */
68 #define DRW_SPHERE_SHAPE_LATITUDE_HIGH 80
69 #define DRW_SPHERE_SHAPE_LONGITUDE_HIGH 60
70 
73 /* -------------------------------------------------------------------- */
77 typedef struct Vert {
78  float pos[3];
79  int class;
80 } Vert;
81 
82 typedef struct VertShaded {
83  float pos[3];
84  int class;
85  float nor[3];
87 
88 /* Batch's only (free'd as an array) */
89 static struct DRWShapeCache {
151 } SHC = {NULL};
152 
154 {
155  uint i = sizeof(SHC) / sizeof(GPUBatch *);
156  GPUBatch **batch = (GPUBatch **)&SHC;
157  while (i--) {
159  batch++;
160  }
161 }
162 
165 /* -------------------------------------------------------------------- */
170 {
171  if (!SHC.drw_procedural_verts) {
172  /* TODO(fclem): get rid of this dummy VBO. */
173  GPUVertFormat format = {0};
176  GPU_vertbuf_data_alloc(vbo, 1);
177 
179  }
180  return SHC.drw_procedural_verts;
181 }
182 
184 {
185  if (!SHC.drw_procedural_lines) {
186  /* TODO(fclem): get rid of this dummy VBO. */
187  GPUVertFormat format = {0};
190  GPU_vertbuf_data_alloc(vbo, 1);
191 
193  }
194  return SHC.drw_procedural_lines;
195 }
196 
198 {
199  if (!SHC.drw_procedural_tris) {
200  /* TODO(fclem): get rid of this dummy VBO. */
201  GPUVertFormat format = {0};
204  GPU_vertbuf_data_alloc(vbo, 1);
205 
207  }
208  return SHC.drw_procedural_tris;
209 }
210 
213 /* -------------------------------------------------------------------- */
218 {
219  GPUVertFormat format = {0};
222  return format;
223 }
224 
226  uint pos_id,
227  uint n1_id,
228  uint n2_id,
229  uint *v_idx,
230  const float co1[3],
231  const float co2[3],
232  const float n1[3],
233  const float n2[3])
234 {
235  GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
236  GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
237  GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co1);
238 
239  GPU_vertbuf_attr_set(vbo, n1_id, *v_idx, n1);
240  GPU_vertbuf_attr_set(vbo, n2_id, *v_idx, n2);
241  GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, co2);
242 }
243 
244 #if 0 /* UNUSED */
245 static void add_lat_lon_vert(GPUVertBuf *vbo,
246  uint pos_id,
247  uint nor_id,
248  uint *v_idx,
249  const float rad,
250  const float lat,
251  const float lon)
252 {
253  float pos[3], nor[3];
254  nor[0] = sinf(lat) * cosf(lon);
255  nor[1] = cosf(lat);
256  nor[2] = sinf(lat) * sinf(lon);
257  mul_v3_v3fl(pos, nor, rad);
258 
259  GPU_vertbuf_attr_set(vbo, nor_id, *v_idx, nor);
260  GPU_vertbuf_attr_set(vbo, pos_id, (*v_idx)++, pos);
261 }
262 
263 static GPUVertBuf *fill_arrows_vbo(const float scale)
264 {
265  /* Position Only 3D format */
266  static GPUVertFormat format = {0};
267  static struct {
268  uint pos;
269  } attr_id;
270  if (format.attr_len == 0) {
272  }
273 
274  /* Line */
276  GPU_vertbuf_data_alloc(vbo, 6 * 3);
277 
278  float v1[3] = {0.0, 0.0, 0.0};
279  float v2[3] = {0.0, 0.0, 0.0};
280  float vtmp1[3], vtmp2[3];
281 
282  for (int axis = 0; axis < 3; axis++) {
283  const int arrow_axis = (axis == 0) ? 1 : 0;
284 
285  v2[axis] = 1.0f;
286  mul_v3_v3fl(vtmp1, v1, scale);
287  mul_v3_v3fl(vtmp2, v2, scale);
288  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 0, vtmp1);
289  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 1, vtmp2);
290 
291  v1[axis] = 0.85f;
292  v1[arrow_axis] = -0.08f;
293  mul_v3_v3fl(vtmp1, v1, scale);
294  mul_v3_v3fl(vtmp2, v2, scale);
295  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 2, vtmp1);
296  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 3, vtmp2);
297 
298  v1[arrow_axis] = 0.08f;
299  mul_v3_v3fl(vtmp1, v1, scale);
300  mul_v3_v3fl(vtmp2, v2, scale);
301  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 4, vtmp1);
302  GPU_vertbuf_attr_set(vbo, attr_id.pos, axis * 6 + 5, vtmp2);
303 
304  /* reset v1 & v2 to zero */
305  v1[arrow_axis] = v1[axis] = v2[axis] = 0.0f;
306  }
307 
308  return vbo;
309 }
310 #endif /* UNUSED */
311 
312 static GPUVertBuf *sphere_wire_vbo(const float rad, int flag)
313 {
314 #define NSEGMENTS 32
315  /* Position Only 3D format */
317 
319  GPU_vertbuf_data_alloc(vbo, NSEGMENTS * 2 * 3);
320 
321  int v = 0;
322  /* a single ring of vertices */
323  float p[NSEGMENTS][2];
324  for (int i = 0; i < NSEGMENTS; i++) {
325  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
326  p[i][0] = rad * cosf(angle);
327  p[i][1] = rad * sinf(angle);
328  }
329 
330  for (int axis = 0; axis < 3; axis++) {
331  for (int i = 0; i < NSEGMENTS; i++) {
332  for (int j = 0; j < 2; j++) {
333  float cv[2];
334 
335  cv[0] = p[(i + j) % NSEGMENTS][0];
336  cv[1] = p[(i + j) % NSEGMENTS][1];
337 
338  if (axis == 0) {
339  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], 0.0f}, flag});
340  }
341  else if (axis == 1) {
342  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
343  }
344  else {
345  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, cv[0], cv[1]}, flag});
346  }
347  }
348  }
349  }
350 
351  return vbo;
352 #undef NSEGMENTS
353 }
354 
355 /* Quads */
357 {
358  if (!SHC.drw_fullscreen_quad) {
359  /* Use a triangle instead of a real quad */
360  /* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */
361  const float pos[3][2] = {{-1.0f, -1.0f}, {3.0f, -1.0f}, {-1.0f, 3.0f}};
362  const float uvs[3][2] = {{0.0f, 0.0f}, {2.0f, 0.0f}, {0.0f, 2.0f}};
363 
364  /* Position Only 2D format */
365  static GPUVertFormat format = {0};
366  static struct {
367  uint pos, uvs;
368  } attr_id;
369  if (format.attr_len == 0) {
372  GPU_vertformat_alias_add(&format, "texCoord");
373  GPU_vertformat_alias_add(&format, "orco"); /* Fix driver bug (see T70004) */
374  }
375 
377  GPU_vertbuf_data_alloc(vbo, 3);
378 
379  for (int i = 0; i < 3; i++) {
380  GPU_vertbuf_attr_set(vbo, attr_id.pos, i, pos[i]);
381  GPU_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]);
382  }
383 
385  }
386  return SHC.drw_fullscreen_quad;
387 }
388 
390 {
391  if (!SHC.drw_quad) {
393 
395  GPU_vertbuf_data_alloc(vbo, 4);
396 
397  int v = 0;
398  int flag = VCLASS_EMPTY_SCALED;
399  const float p[4][2] = {{-1.0f, 1.0f}, {1.0f, 1.0f}, {-1.0f, -1.0f}, {1.0f, -1.0f}};
400  for (int a = 0; a < 4; a++) {
401  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a][0], p[a][1], 0.0f}, flag});
402  }
403 
405  }
406  return SHC.drw_quad;
407 }
408 
410 {
411  if (!SHC.drw_quad_wires) {
413 
415  GPU_vertbuf_data_alloc(vbo, 5);
416 
417  int v = 0;
418  int flag = VCLASS_EMPTY_SCALED;
419  const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
420  for (int a = 0; a < 5; a++) {
421  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a % 4][0], p[a % 4][1], 0.0f}, flag});
422  }
423 
425  }
426  return SHC.drw_quad_wires;
427 }
428 
430 {
431  if (!SHC.drw_grid) {
432  /* Position Only 2D format */
433  static GPUVertFormat format = {0};
434  static struct {
435  uint pos;
436  } attr_id;
437  if (format.attr_len == 0) {
439  }
440 
442  GPU_vertbuf_data_alloc(vbo, 8 * 8 * 2 * 3);
443 
444  uint v_idx = 0;
445  for (int i = 0; i < 8; i++) {
446  for (int j = 0; j < 8; j++) {
447  float pos0[2] = {(float)i / 8.0f, (float)j / 8.0f};
448  float pos1[2] = {(float)(i + 1) / 8.0f, (float)j / 8.0f};
449  float pos2[2] = {(float)i / 8.0f, (float)(j + 1) / 8.0f};
450  float pos3[2] = {(float)(i + 1) / 8.0f, (float)(j + 1) / 8.0f};
451 
452  madd_v2_v2v2fl(pos0, (float[2]){-1.0f, -1.0f}, pos0, 2.0f);
453  madd_v2_v2v2fl(pos1, (float[2]){-1.0f, -1.0f}, pos1, 2.0f);
454  madd_v2_v2v2fl(pos2, (float[2]){-1.0f, -1.0f}, pos2, 2.0f);
455  madd_v2_v2v2fl(pos3, (float[2]){-1.0f, -1.0f}, pos3, 2.0f);
456 
457  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos0);
458  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos1);
459  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos2);
460 
461  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos2);
462  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos1);
463  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, pos3);
464  }
465  }
466 
468  }
469  return SHC.drw_grid;
470 }
471 
472 /* Sphere */
473 static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lon)
474 {
475  float x = sinf(lat) * cosf(lon);
476  float y = cosf(lat);
477  float z = sinf(lat) * sinf(lon);
478  GPU_vertbuf_vert_set(vbo, *v_ofs, &(VertShaded){{x, y, z}, VCLASS_EMPTY_SCALED, {x, y, z}});
479  (*v_ofs)++;
480 }
481 
483 {
484  BLI_assert(level_of_detail >= DRW_LOD_LOW && level_of_detail < DRW_LOD_MAX);
485 
486  if (!SHC.drw_sphere_lod[level_of_detail]) {
487  int lat_res;
488  int lon_res;
489 
490  switch (level_of_detail) {
491  case DRW_LOD_LOW:
494  break;
495  case DRW_LOD_MEDIUM:
498  break;
499  case DRW_LOD_HIGH:
502  break;
503  default:
504  return NULL;
505  }
506 
509 
511  int v_len = (lat_res - 1) * lon_res * 6;
512  GPU_vertbuf_data_alloc(vbo, v_len);
513 
514  const float lon_inc = 2 * M_PI / lon_res;
515  const float lat_inc = M_PI / lat_res;
516  float lon, lat;
517 
518  int v = 0;
519  lon = 0.0f;
520  for (int i = 0; i < lon_res; i++, lon += lon_inc) {
521  lat = 0.0f;
522  for (int j = 0; j < lat_res; j++, lat += lat_inc) {
523  if (j != lat_res - 1) { /* Pole */
524  sphere_lat_lon_vert(vbo, &v, lat + lat_inc, lon + lon_inc);
525  sphere_lat_lon_vert(vbo, &v, lat + lat_inc, lon);
526  sphere_lat_lon_vert(vbo, &v, lat, lon);
527  }
528  if (j != 0) { /* Pole */
529  sphere_lat_lon_vert(vbo, &v, lat, lon + lon_inc);
530  sphere_lat_lon_vert(vbo, &v, lat + lat_inc, lon + lon_inc);
531  sphere_lat_lon_vert(vbo, &v, lat, lon);
532  }
533  }
534  }
535 
536  SHC.drw_sphere_lod[level_of_detail] = GPU_batch_create_ex(
538  }
539  return SHC.drw_sphere_lod[level_of_detail];
540 }
541 
544 /* -------------------------------------------------------------------- */
548 static void circle_verts(
549  GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
550 {
551  for (int a = 0; a < segments; a++) {
552  for (int b = 0; b < 2; b++) {
553  float angle = (2.0f * M_PI * (a + b)) / segments;
554  float s = sinf(angle) * radius;
555  float c = cosf(angle) * radius;
556  int v = *vert_idx;
557  *vert_idx = v + 1;
558  GPU_vertbuf_vert_set(vbo, v, &(Vert){{s, c, z}, flag});
559  }
560  }
561 }
562 
564  GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
565 {
566  for (int a = 0; a < segments * 2; a += 2) {
567  for (int b = 0; b < 2; b++) {
568  float angle = (2.0f * M_PI * (a + b)) / (segments * 2);
569  float s = sinf(angle) * radius;
570  float c = cosf(angle) * radius;
571  int v = *vert_idx;
572  *vert_idx = v + 1;
573  GPU_vertbuf_vert_set(vbo, v, &(Vert){{s, c, z}, flag});
574  }
575  }
576 }
577 
578 /* XXX TODO: move that 1 unit cube to more common/generic place? */
579 static const float bone_box_verts[8][3] = {
580  {1.0f, 0.0f, 1.0f},
581  {1.0f, 0.0f, -1.0f},
582  {-1.0f, 0.0f, -1.0f},
583  {-1.0f, 0.0f, 1.0f},
584  {1.0f, 1.0f, 1.0f},
585  {1.0f, 1.0f, -1.0f},
586  {-1.0f, 1.0f, -1.0f},
587  {-1.0f, 1.0f, 1.0f},
588 };
589 
590 static const float bone_box_smooth_normals[8][3] = {
591  {M_SQRT3, -M_SQRT3, M_SQRT3},
592  {M_SQRT3, -M_SQRT3, -M_SQRT3},
593  {-M_SQRT3, -M_SQRT3, -M_SQRT3},
594  {-M_SQRT3, -M_SQRT3, M_SQRT3},
595  {M_SQRT3, M_SQRT3, M_SQRT3},
596  {M_SQRT3, M_SQRT3, -M_SQRT3},
597  {-M_SQRT3, M_SQRT3, -M_SQRT3},
598  {-M_SQRT3, M_SQRT3, M_SQRT3},
599 };
600 
601 static const uint bone_box_wire[24] = {
602  0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7,
603 };
604 
605 #if 0 /* UNUSED */
606 /* aligned with bone_octahedral_wire
607  * Contains adjacent normal index */
608 static const uint bone_box_wire_adjacent_face[24] = {
609  0, 2, 0, 4, 1, 6, 1, 8, 3, 10, 5, 10, 7, 11, 9, 11, 3, 8, 2, 5, 4, 7, 6, 9,
610 };
611 #endif
612 
613 static const uint bone_box_solid_tris[12][3] = {
614  {0, 2, 1}, /* bottom */
615  {0, 3, 2},
616 
617  {0, 1, 5}, /* sides */
618  {0, 5, 4},
619 
620  {1, 2, 6},
621  {1, 6, 5},
622 
623  {2, 3, 7},
624  {2, 7, 6},
625 
626  {3, 0, 4},
627  {3, 4, 7},
628 
629  {4, 5, 6}, /* top */
630  {4, 6, 7},
631 };
632 
637 static const uint bone_box_wire_lines_adjacency[12][4] = {
638  {4, 2, 0, 11},
639  {0, 1, 2, 8},
640  {2, 4, 1, 14},
641  {1, 0, 4, 20}, /* bottom */
642  {0, 8, 11, 14},
643  {2, 14, 8, 20},
644  {1, 20, 14, 11},
645  {4, 11, 20, 8}, /* top */
646  {20, 0, 11, 2},
647  {11, 2, 8, 1},
648  {8, 1, 14, 4},
649  {14, 4, 20, 0}, /* sides */
650 };
651 
652 #if 0 /* UNUSED */
653 static const uint bone_box_solid_tris_adjacency[12][6] = {
654  {0, 5, 1, 14, 2, 8},
655  {3, 26, 4, 20, 5, 1},
656 
657  {6, 2, 7, 16, 8, 11},
658  {9, 7, 10, 32, 11, 24},
659 
660  {12, 0, 13, 22, 14, 17},
661  {15, 13, 16, 30, 17, 6},
662 
663  {18, 3, 19, 28, 20, 23},
664  {21, 19, 22, 33, 23, 12},
665 
666  {24, 4, 25, 10, 26, 29},
667  {27, 25, 28, 34, 29, 18},
668 
669  {30, 9, 31, 15, 32, 35},
670  {33, 31, 34, 21, 35, 27},
671 };
672 #endif
673 
674 /* aligned with bone_box_solid_tris */
675 static const float bone_box_solid_normals[12][3] = {
676  {0.0f, -1.0f, 0.0f},
677  {0.0f, -1.0f, 0.0f},
678 
679  {1.0f, 0.0f, 0.0f},
680  {1.0f, 0.0f, 0.0f},
681 
682  {0.0f, 0.0f, -1.0f},
683  {0.0f, 0.0f, -1.0f},
684 
685  {-1.0f, 0.0f, 0.0f},
686  {-1.0f, 0.0f, 0.0f},
687 
688  {0.0f, 0.0f, 1.0f},
689  {0.0f, 0.0f, 1.0f},
690 
691  {0.0f, 1.0f, 0.0f},
692  {0.0f, 1.0f, 0.0f},
693 };
694 
696 {
697  if (!SHC.drw_cube) {
699 
700  const int tri_len = ARRAY_SIZE(bone_box_solid_tris);
701  const int vert_len = ARRAY_SIZE(bone_box_verts);
702 
704  GPU_vertbuf_data_alloc(vbo, vert_len);
705 
706  GPUIndexBufBuilder elb;
707  GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, tri_len, vert_len);
708 
709  int v = 0;
710  for (int i = 0; i < vert_len; i++) {
711  float x = bone_box_verts[i][0];
712  float y = bone_box_verts[i][1] * 2.0f - 1.0f;
713  float z = bone_box_verts[i][2];
714  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED});
715  }
716 
717  for (int i = 0; i < tri_len; i++) {
718  const uint *tri_indices = bone_box_solid_tris[i];
719  GPU_indexbuf_add_tri_verts(&elb, tri_indices[0], tri_indices[1], tri_indices[2]);
720  }
721 
724  }
725  return SHC.drw_cube;
726 }
727 
729 {
730 #define CIRCLE_RESOL 64
731  if (!SHC.drw_circle) {
733 
736 
737  int v = 0;
738  for (int a = 0; a < CIRCLE_RESOL + 1; a++) {
739  float x = sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
740  float z = cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
741  float y = 0.0f;
742  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED});
743  }
744 
746  }
747  return SHC.drw_circle;
748 #undef CIRCLE_RESOL
749 }
750 
752 {
753  if (!SHC.drw_normal_arrow) {
754  GPUVertFormat format = {0};
756 
758  GPU_vertbuf_data_alloc(vbo, 2);
759 
760  /* TODO: real arrow. For now, it's a line positioned in the vertex shader. */
761 
763  }
764  return SHC.drw_normal_arrow;
765 }
766 
769 /* -------------------------------------------------------------------- */
777 {
779  GPUVertFormat format = {0};
782  GPU_vertbuf_data_alloc(vbo, 4);
783 
786  }
788 }
789 
792 /* -------------------------------------------------------------------- */
801 {
802  switch (ob->type) {
803  case OB_MESH:
804  return DRW_cache_mesh_all_edges_get(ob);
805 
806  /* TODO: should match #DRW_cache_object_surface_get. */
807  default:
808  return NULL;
809  }
810 }
811 
813 {
814  switch (ob->type) {
815  case OB_MESH:
816  return DRW_cache_mesh_edge_detection_get(ob, r_is_manifold);
817  case OB_CURVES_LEGACY:
818  return NULL;
819  case OB_SURF:
820  return NULL;
821  case OB_FONT:
822  return NULL;
823  case OB_MBALL:
824  return DRW_cache_mball_edge_detection_get(ob, r_is_manifold);
825  case OB_CURVES:
826  return NULL;
827  case OB_POINTCLOUD:
828  return NULL;
829  case OB_VOLUME:
830  return NULL;
831  default:
832  return NULL;
833  }
834 }
835 
837 {
838  switch (ob->type) {
839  case OB_MESH:
841  case OB_CURVES_LEGACY:
842  return NULL;
843  case OB_SURF:
844  return NULL;
845  case OB_FONT:
846  return NULL;
847  case OB_MBALL:
849  case OB_CURVES:
850  return NULL;
851  case OB_POINTCLOUD:
853  case OB_VOLUME:
855  case OB_GPENCIL: {
857  }
858  default:
859  return NULL;
860  }
861 }
862 
864 {
865  switch (ob->type) {
866  case OB_MESH:
868  case OB_CURVES_LEGACY:
869  return NULL;
870  case OB_SURF:
871  return NULL;
872  case OB_FONT:
873  return NULL;
874  case OB_MBALL:
875  return NULL;
876  case OB_CURVES:
877  return NULL;
878  case OB_POINTCLOUD:
879  return NULL;
880  case OB_VOLUME:
881  return NULL;
882  default:
883  return NULL;
884  }
885 }
886 
888 {
889  switch (ob->type) {
890  case OB_MESH:
891  return DRW_cache_mesh_surface_get(ob);
892  case OB_CURVES_LEGACY:
893  return NULL;
894  case OB_SURF:
895  return NULL;
896  case OB_FONT:
897  return NULL;
898  case OB_MBALL:
899  return DRW_cache_mball_surface_get(ob);
900  case OB_CURVES:
901  return NULL;
902  case OB_POINTCLOUD:
904  case OB_VOLUME:
905  return NULL;
906  default:
907  return NULL;
908  }
909 }
910 
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_CURVES_LEGACY:
920  case OB_SURF:
921  case OB_FONT:
922  return NULL;
923  case OB_MBALL:
925  case OB_CURVES:
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 can have one data type in ob->data, but will be rendered as mesh.
943  * For point clouds this never happens. Ideally this check would happen at another level
944  * and we 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(ob, (me != NULL) ? me : ob->data);
951  case OB_CURVES_LEGACY:
952  case OB_SURF:
953  case OB_FONT:
955  case OB_MBALL:
957  case OB_CURVES:
959  case OB_POINTCLOUD:
961  case OB_VOLUME:
963  case OB_GPENCIL:
965  default:
966  BLI_assert(0);
967  return 0;
968  }
969 }
970 
972  struct GPUMaterial **gpumat_array,
973  uint gpumat_array_len)
974 {
975  switch (ob->type) {
976  case OB_MESH:
977  return DRW_cache_mesh_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
978  case OB_CURVES_LEGACY:
979  return NULL;
980  case OB_SURF:
981  return NULL;
982  case OB_FONT:
983  return NULL;
984  case OB_MBALL:
985  return DRW_cache_mball_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
986  case OB_CURVES:
987  return NULL;
988  case OB_POINTCLOUD:
989  return DRW_cache_pointcloud_surface_shaded_get(ob, gpumat_array, gpumat_array_len);
990  case OB_VOLUME:
991  return NULL;
992  default:
993  return NULL;
994  }
995 }
996 
999 /* -------------------------------------------------------------------- */
1004 {
1005  if (!SHC.drw_plain_axes) {
1007 
1009  GPU_vertbuf_data_alloc(vbo, 6);
1010 
1011  int v = 0;
1012  int flag = VCLASS_EMPTY_SCALED;
1013  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, -1.0f, 0.0f}, flag});
1014  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 1.0f, 0.0f}, flag});
1015  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{-1.0f, 0.0f, 0.0f}, flag});
1016  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{1.0f, 0.0f, 0.0f}, flag});
1017  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, -1.0f}, flag});
1018  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 1.0f}, flag});
1019 
1021  }
1022  return SHC.drw_plain_axes;
1023 }
1024 
1026 {
1027  if (!SHC.drw_empty_cube) {
1031 
1032  int v = 0;
1033  for (int i = 0; i < ARRAY_SIZE(bone_box_wire); i++) {
1034  float x = bone_box_verts[bone_box_wire[i]][0];
1035  float y = bone_box_verts[bone_box_wire[i]][1] * 2.0 - 1.0f;
1036  float z = bone_box_verts[bone_box_wire[i]][2];
1037  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, VCLASS_EMPTY_SCALED});
1038  }
1039 
1041  }
1042  return SHC.drw_empty_cube;
1043 }
1044 
1046 {
1047  if (!SHC.drw_single_arrow) {
1050  GPU_vertbuf_data_alloc(vbo, 4 * 2 * 2 + 2);
1051 
1052  int v = 0;
1053  int flag = VCLASS_EMPTY_SCALED;
1054  float p[3][3] = {{0}};
1055  p[0][2] = 1.0f;
1056  p[1][0] = 0.035f;
1057  p[1][1] = 0.035f;
1058  p[2][0] = -0.035f;
1059  p[2][1] = 0.035f;
1060  p[1][2] = p[2][2] = 0.75f;
1061  for (int sides = 0; sides < 4; sides++) {
1062  if (sides % 2 == 1) {
1063  p[1][0] = -p[1][0];
1064  p[2][1] = -p[2][1];
1065  }
1066  else {
1067  p[1][1] = -p[1][1];
1068  p[2][0] = -p[2][0];
1069  }
1070  for (int i = 0, a = 1; i < 2; i++, a++) {
1071  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[i][0], p[i][1], p[i][2]}, flag});
1072  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a][0], p[a][1], p[a][2]}, flag});
1073  }
1074  }
1075  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0}, flag});
1076  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.75f}, flag});
1077 
1079  }
1080  return SHC.drw_single_arrow;
1081 }
1082 
1084 {
1085  if (!SHC.drw_empty_sphere) {
1088  }
1089  return SHC.drw_empty_sphere;
1090 }
1091 
1093 {
1094 #define NSEGMENTS 8
1095  if (!SHC.drw_empty_cone) {
1099 
1100  int v = 0;
1101  int flag = VCLASS_EMPTY_SCALED;
1102  /* a single ring of vertices */
1103  float p[NSEGMENTS][2];
1104  for (int i = 0; i < NSEGMENTS; i++) {
1105  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
1106  p[i][0] = cosf(angle);
1107  p[i][1] = sinf(angle);
1108  }
1109  for (int i = 0; i < NSEGMENTS; i++) {
1110  float cv[2];
1111  cv[0] = p[(i) % NSEGMENTS][0];
1112  cv[1] = p[(i) % NSEGMENTS][1];
1113 
1114  /* cone sides */
1115  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
1116  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 2.0f, 0.0f}, flag});
1117 
1118  /* end ring */
1119  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
1120  cv[0] = p[(i + 1) % NSEGMENTS][0];
1121  cv[1] = p[(i + 1) % NSEGMENTS][1];
1122  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], 0.0f, cv[1]}, flag});
1123  }
1124 
1126  }
1127  return SHC.drw_empty_cone;
1128 #undef NSEGMENTS
1129 }
1130 
1132 {
1133 #define NSEGMENTS 12
1134  if (!SHC.drw_empty_cylinder) {
1138 
1139  /* a single ring of vertices */
1140  int v = 0;
1141  int flag = VCLASS_EMPTY_SCALED;
1142  float p[NSEGMENTS][2];
1143  for (int i = 0; i < NSEGMENTS; i++) {
1144  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
1145  p[i][0] = cosf(angle);
1146  p[i][1] = sinf(angle);
1147  }
1148  for (int i = 0; i < NSEGMENTS; i++) {
1149  float cv[2], pv[2];
1150  cv[0] = p[(i) % NSEGMENTS][0];
1151  cv[1] = p[(i) % NSEGMENTS][1];
1152  pv[0] = p[(i + 1) % NSEGMENTS][0];
1153  pv[1] = p[(i + 1) % NSEGMENTS][1];
1154 
1155  /* cylinder sides */
1156  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], -1.0f}, flag});
1157  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], 1.0f}, flag});
1158  /* top ring */
1159  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], 1.0f}, flag});
1160  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{pv[0], pv[1], 1.0f}, flag});
1161  /* bottom ring */
1162  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{cv[0], cv[1], -1.0f}, flag});
1163  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{pv[0], pv[1], -1.0f}, flag});
1164  }
1165 
1167  }
1168  return SHC.drw_empty_cylinder;
1169 #undef NSEGMENTS
1170 }
1171 
1173 {
1174  if (!SHC.drw_empty_capsule_body) {
1175  const float pos[8][3] = {
1176  {1.0f, 0.0f, 1.0f},
1177  {1.0f, 0.0f, 0.0f},
1178  {0.0f, 1.0f, 1.0f},
1179  {0.0f, 1.0f, 0.0f},
1180  {-1.0f, 0.0f, 1.0f},
1181  {-1.0f, 0.0f, 0.0f},
1182  {0.0f, -1.0f, 1.0f},
1183  {0.0f, -1.0f, 0.0f},
1184  };
1185 
1186  /* Position Only 3D format */
1187  static GPUVertFormat format = {0};
1188  static struct {
1189  uint pos;
1190  } attr_id;
1191  if (format.attr_len == 0) {
1193  }
1194 
1196  GPU_vertbuf_data_alloc(vbo, 8);
1197  GPU_vertbuf_attr_fill(vbo, attr_id.pos, pos);
1198 
1201  }
1202  return SHC.drw_empty_capsule_body;
1203 }
1204 
1206 {
1207 #define NSEGMENTS 24 /* Must be multiple of 2. */
1208  if (!SHC.drw_empty_capsule_cap) {
1209  /* a single ring of vertices */
1210  float p[NSEGMENTS][2];
1211  for (int i = 0; i < NSEGMENTS; i++) {
1212  float angle = 2 * M_PI * ((float)i / (float)NSEGMENTS);
1213  p[i][0] = cosf(angle);
1214  p[i][1] = sinf(angle);
1215  }
1216 
1217  /* Position Only 3D format */
1218  static GPUVertFormat format = {0};
1219  static struct {
1220  uint pos;
1221  } attr_id;
1222  if (format.attr_len == 0) {
1224  }
1225 
1227  GPU_vertbuf_data_alloc(vbo, (NSEGMENTS * 2) * 2);
1228 
1229  /* Base circle */
1230  int vidx = 0;
1231  for (int i = 0; i < NSEGMENTS; i++) {
1232  float v[3] = {0.0f, 0.0f, 0.0f};
1233  copy_v2_v2(v, p[(i) % NSEGMENTS]);
1234  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1235  copy_v2_v2(v, p[(i + 1) % NSEGMENTS]);
1236  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1237  }
1238 
1239  for (int i = 0; i < NSEGMENTS / 2; i++) {
1240  float v[3] = {0.0f, 0.0f, 0.0f};
1241  int ci = i % NSEGMENTS;
1242  int pi = (i + 1) % NSEGMENTS;
1243  /* Y half circle */
1244  copy_v3_fl3(v, p[ci][0], 0.0f, p[ci][1]);
1245  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1246  copy_v3_fl3(v, p[pi][0], 0.0f, p[pi][1]);
1247  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1248  /* X half circle */
1249  copy_v3_fl3(v, 0.0f, p[ci][0], p[ci][1]);
1250  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1251  copy_v3_fl3(v, 0.0f, p[pi][0], p[pi][1]);
1252  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1253  }
1254 
1256  }
1257  return SHC.drw_empty_capsule_cap;
1258 #undef NSEGMENTS
1259 }
1260 
1262 {
1263 #define CIRCLE_RESOL 32
1264  if (!SHC.drw_field_wind) {
1266 
1267  int v_len = 2 * (CIRCLE_RESOL * 4);
1269  GPU_vertbuf_data_alloc(vbo, v_len);
1270 
1271  int v = 0;
1272  int flag = VCLASS_EMPTY_SIZE;
1273  for (int i = 0; i < 4; i++) {
1274  float z = 0.05f * (float)i;
1275  circle_verts(vbo, &v, CIRCLE_RESOL, 1.0f, z, flag);
1276  }
1277 
1279  }
1280  return SHC.drw_field_wind;
1281 #undef CIRCLE_RESOL
1282 }
1283 
1285 {
1286 #define CIRCLE_RESOL 32
1287  if (!SHC.drw_field_force) {
1289 
1290  int v_len = 2 * (CIRCLE_RESOL * 3);
1292  GPU_vertbuf_data_alloc(vbo, v_len);
1293 
1294  int v = 0;
1296  for (int i = 0; i < 3; i++) {
1297  float radius = 1.0f + 0.5f * i;
1298  circle_verts(vbo, &v, CIRCLE_RESOL, radius, 0.0f, flag);
1299  }
1300 
1302  }
1303  return SHC.drw_field_force;
1304 #undef CIRCLE_RESOL
1305 }
1306 
1308 {
1309 #define SPIRAL_RESOL 32
1310  if (!SHC.drw_field_vortex) {
1312 
1313  int v_len = SPIRAL_RESOL * 2 + 1;
1315  GPU_vertbuf_data_alloc(vbo, v_len);
1316 
1317  int v = 0;
1318  int flag = VCLASS_EMPTY_SIZE;
1319  for (int a = SPIRAL_RESOL; a > -1; a--) {
1320  float r = a / (float)SPIRAL_RESOL;
1321  float angle = (2.0f * M_PI * a) / SPIRAL_RESOL;
1322  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle) * r, cosf(angle) * r, 0.0f}, flag});
1323  }
1324  for (int a = 1; a <= SPIRAL_RESOL; a++) {
1325  float r = a / (float)SPIRAL_RESOL;
1326  float angle = (2.0f * M_PI * a) / SPIRAL_RESOL;
1327  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{sinf(angle) * -r, cosf(angle) * -r, 0.0f}, flag});
1328  }
1329 
1331  }
1332  return SHC.drw_field_vortex;
1333 #undef SPIRAL_RESOL
1334 }
1335 
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 
1425 {
1426 #define CIRCLE_RESOL 32
1427  if (!SHC.drw_field_sphere_limit) {
1429 
1430  int v_len = 2 * CIRCLE_RESOL;
1432  GPU_vertbuf_data_alloc(vbo, v_len);
1433 
1434  int v = 0;
1436  circle_dashed_verts(vbo, &v, CIRCLE_RESOL, 1.0f, 0.0f, flag);
1437 
1440  }
1441  return SHC.drw_field_sphere_limit;
1442 #undef CIRCLE_RESOL
1443 }
1444 
1447 /* -------------------------------------------------------------------- */
1451 #define DIAMOND_NSEGMENTS 4
1452 #define INNER_NSEGMENTS 8
1453 #define OUTER_NSEGMENTS 10
1454 #define CIRCLE_NSEGMENTS 32
1455 
1456 static float light_distance_z_get(char axis, const bool start)
1457 {
1458  switch (axis) {
1459  case 'x': /* - X */
1460  return start ? 0.4f : 0.3f;
1461  case 'X': /* + X */
1462  return start ? 0.6f : 0.7f;
1463  case 'y': /* - Y */
1464  return start ? 1.4f : 1.3f;
1465  case 'Y': /* + Y */
1466  return start ? 1.6f : 1.7f;
1467  case 'z': /* - Z */
1468  return start ? 2.4f : 2.3f;
1469  case 'Z': /* + Z */
1470  return start ? 2.6f : 2.7f;
1471  }
1472  return 0.0;
1473 }
1474 
1476 {
1477  if (!SHC.drw_ground_line) {
1479 
1480  int v_len = 2 * (1 + DIAMOND_NSEGMENTS);
1482  GPU_vertbuf_data_alloc(vbo, v_len);
1483 
1484  int v = 0;
1485  /* Ground Point */
1486  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.35f, 0.0f, 0);
1487  /* Ground Line */
1488  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 1.0}, 0});
1489  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 0.0}, 0});
1490 
1492  }
1493  return SHC.drw_ground_line;
1494 }
1495 
1497 {
1498  if (!SHC.drw_light_point_lines) {
1500 
1503  GPU_vertbuf_data_alloc(vbo, v_len);
1504 
1505  const float r = 9.0f;
1506  int v = 0;
1507  /* Light Icon */
1508  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1509  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1510  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1511  /* Light area */
1513  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1514 
1516  }
1517  return SHC.drw_light_point_lines;
1518 }
1519 
1521 {
1522  if (!SHC.drw_light_sun_lines) {
1524 
1525  int v_len = 2 * (DIAMOND_NSEGMENTS + INNER_NSEGMENTS + OUTER_NSEGMENTS + 8 * 2 + 1);
1527  GPU_vertbuf_data_alloc(vbo, v_len);
1528 
1529  const float r = 9.0f;
1530  int v = 0;
1531  /* Light Icon */
1532  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1533  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1534  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1535  /* Sun Rays */
1536  for (int a = 0; a < 8; a++) {
1537  float angle = (2.0f * M_PI * a) / 8.0f;
1538  float s = sinf(angle) * r;
1539  float c = cosf(angle) * r;
1540  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 1.6f, c * 1.6f, 0.0f}, VCLASS_SCREENSPACE});
1541  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 1.9f, c * 1.9f, 0.0f}, VCLASS_SCREENSPACE});
1542  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 2.2f, c * 2.2f, 0.0f}, VCLASS_SCREENSPACE});
1543  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s * 2.5f, c * 2.5f, 0.0f}, VCLASS_SCREENSPACE});
1544  }
1545  /* Direction Line */
1546  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 0.0}, 0});
1547  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, -20.0}, 0}); /* Good default. */
1548 
1550  }
1551  return SHC.drw_light_sun_lines;
1552 }
1553 
1555 {
1556  if (!SHC.drw_light_spot_lines) {
1558 
1559  int v_len = 2 * (DIAMOND_NSEGMENTS * 3 + INNER_NSEGMENTS + OUTER_NSEGMENTS +
1560  CIRCLE_NSEGMENTS * 4 + 1);
1562  GPU_vertbuf_data_alloc(vbo, v_len);
1563 
1564  const float r = 9.0f;
1565  int v = 0;
1566  /* Light Icon */
1567  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1568  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1569  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1570  /* Light area */
1572  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1573  /* Cone cap */
1574  flag = VCLASS_LIGHT_SPOT_SHAPE;
1575  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1577  circle_verts(vbo, &v, CIRCLE_NSEGMENTS, 1.0f, 0.0f, flag);
1578  /* Cone silhouette */
1580  for (int a = 0; a < CIRCLE_NSEGMENTS; a++) {
1581  float angle = (2.0f * M_PI * a) / CIRCLE_NSEGMENTS;
1582  float s = sinf(angle);
1583  float c = cosf(angle);
1584  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0f}, 0});
1585  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s, c, -1.0f}, flag});
1586  }
1587  /* Direction Line */
1588  float zsta = light_distance_z_get('z', true);
1589  float zend = light_distance_z_get('z', false);
1590  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zsta}, VCLASS_LIGHT_DIST});
1591  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zend}, VCLASS_LIGHT_DIST});
1594 
1596  }
1597  return SHC.drw_light_spot_lines;
1598 }
1599 
1601 {
1602  if (!SHC.drw_light_spot_volume) {
1604 
1605  int v_len = CIRCLE_NSEGMENTS + 1 + 1;
1607  GPU_vertbuf_data_alloc(vbo, v_len);
1608 
1609  int v = 0;
1610  /* Cone apex */
1611  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0f}, 0});
1612  /* Cone silhouette */
1613  int flag = VCLASS_LIGHT_SPOT_SHAPE;
1614  for (int a = 0; a < CIRCLE_NSEGMENTS + 1; a++) {
1615  float angle = (2.0f * M_PI * a) / CIRCLE_NSEGMENTS;
1616  float s = sinf(-angle);
1617  float c = cosf(-angle);
1618  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{s, c, -1.0f}, flag});
1619  }
1620 
1623  }
1624  return SHC.drw_light_spot_volume;
1625 }
1626 
1628 {
1631 
1632  int v_len = 2 *
1635  GPU_vertbuf_data_alloc(vbo, v_len);
1636 
1637  const float r = 9.0f;
1638  int v = 0;
1639  /* Light Icon */
1640  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1641  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1642  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1643  /* Light area */
1645  /* Direction Line */
1646  float zsta = light_distance_z_get('z', true);
1647  float zend = light_distance_z_get('z', false);
1648  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zsta}, VCLASS_LIGHT_DIST});
1649  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zend}, VCLASS_LIGHT_DIST});
1652 
1655  }
1657 }
1658 
1660 {
1663 
1665  int v_len = 2 * (DIAMOND_NSEGMENTS * 3 + INNER_NSEGMENTS + OUTER_NSEGMENTS + 4 + 1);
1666  GPU_vertbuf_data_alloc(vbo, v_len);
1667 
1668  const float r = 9.0f;
1669  int v = 0;
1670  /* Light Icon */
1671  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, r * 0.3f, 0.0f, VCLASS_SCREENSPACE);
1672  circle_dashed_verts(vbo, &v, INNER_NSEGMENTS, r * 1.0f, 0.0f, VCLASS_SCREENSPACE);
1673  circle_dashed_verts(vbo, &v, OUTER_NSEGMENTS, r * 1.33f, 0.0f, VCLASS_SCREENSPACE);
1674  /* Light area */
1675  int flag = VCLASS_LIGHT_AREA_SHAPE;
1676  for (int a = 0; a < 4; a++) {
1677  for (int b = 0; b < 2; b++) {
1678  const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
1679  float x = p[(a + b) % 4][0];
1680  float y = p[(a + b) % 4][1];
1681  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x * 0.5f, y * 0.5f, 0.0f}, flag});
1682  }
1683  }
1684  /* Direction Line */
1685  float zsta = light_distance_z_get('z', true);
1686  float zend = light_distance_z_get('z', false);
1687  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zsta}, VCLASS_LIGHT_DIST});
1688  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, zend}, VCLASS_LIGHT_DIST});
1691 
1694  }
1696 }
1697 
1698 #undef CIRCLE_NSEGMENTS
1699 #undef OUTER_NSEGMENTS
1700 #undef INNER_NSEGMENTS
1701 
1704 /* -------------------------------------------------------------------- */
1709 {
1710  if (!SHC.drw_speaker) {
1711  float v[3];
1712  const int segments = 16;
1713  int vidx = 0;
1714 
1715  /* Position Only 3D format */
1716  static GPUVertFormat format = {0};
1717  static struct {
1718  uint pos;
1719  } attr_id;
1720  if (format.attr_len == 0) {
1722  }
1723 
1725  GPU_vertbuf_data_alloc(vbo, 3 * segments * 2 + 4 * 4);
1726 
1727  for (int j = 0; j < 3; j++) {
1728  float z = 0.25f * j - 0.125f;
1729  float r = (j == 0 ? 0.5f : 0.25f);
1730 
1731  copy_v3_fl3(v, r, 0.0f, z);
1732  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1733  for (int i = 1; i < segments; i++) {
1734  float x = cosf(2.0f * (float)M_PI * i / segments) * r;
1735  float y = sinf(2.0f * (float)M_PI * i / segments) * r;
1736  copy_v3_fl3(v, x, y, z);
1737  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1738  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1739  }
1740  copy_v3_fl3(v, r, 0.0f, z);
1741  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1742  }
1743 
1744  for (int j = 0; j < 4; j++) {
1745  float x = (((j + 1) % 2) * (j - 1)) * 0.5f;
1746  float y = ((j % 2) * (j - 2)) * 0.5f;
1747  for (int i = 0; i < 3; i++) {
1748  if (i == 1) {
1749  x *= 0.5f;
1750  y *= 0.5f;
1751  }
1752 
1753  float z = 0.25f * i - 0.125f;
1754  copy_v3_fl3(v, x, y, z);
1755  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1756  if (i == 1) {
1757  GPU_vertbuf_attr_set(vbo, attr_id.pos, vidx++, v);
1758  }
1759  }
1760  }
1761 
1763  }
1764  return SHC.drw_speaker;
1765 }
1766 
1769 /* -------------------------------------------------------------------- */
1774 {
1775  if (!SHC.drw_lightprobe_cube) {
1777 
1778  int v_len = (6 + 3 + (1 + 2 * DIAMOND_NSEGMENTS) * 6) * 2;
1780  GPU_vertbuf_data_alloc(vbo, v_len);
1781 
1782  const float r = 14.0f;
1783  int v = 0;
1784  int flag = VCLASS_SCREENSPACE;
1785  /* Icon */
1786  const float sin_pi_3 = 0.86602540378f;
1787  const float cos_pi_3 = 0.5f;
1788  const float p[7][2] = {
1789  {0.0f, 1.0f},
1790  {sin_pi_3, cos_pi_3},
1791  {sin_pi_3, -cos_pi_3},
1792  {0.0f, -1.0f},
1793  {-sin_pi_3, -cos_pi_3},
1794  {-sin_pi_3, cos_pi_3},
1795  {0.0f, 0.0f},
1796  };
1797  for (int i = 0; i < 6; i++) {
1798  float t1[2], t2[2];
1799  copy_v2_v2(t1, p[i]);
1800  copy_v2_v2(t2, p[(i + 1) % 6]);
1801  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag});
1802  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag});
1803  }
1804  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[1][0] * r, p[1][1] * r, 0.0f}, flag});
1805  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1806  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[5][0] * r, p[5][1] * r, 0.0f}, flag});
1807  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1808  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[3][0] * r, p[3][1] * r, 0.0f}, flag});
1809  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1810  /* Direction Lines */
1812  for (int i = 0; i < 6; i++) {
1813  char axes[] = "zZyYxX";
1814  float zsta = light_distance_z_get(axes[i], true);
1815  float zend = light_distance_z_get(axes[i], false);
1816  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zsta}, flag});
1817  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zend}, flag});
1818  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zsta, flag);
1819  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zend, flag);
1820  }
1821 
1823  }
1824  return SHC.drw_lightprobe_cube;
1825 }
1826 
1828 {
1829  if (!SHC.drw_lightprobe_grid) {
1831 
1832  int v_len = (6 * 2 + 3 + (1 + 2 * DIAMOND_NSEGMENTS) * 6) * 2;
1834  GPU_vertbuf_data_alloc(vbo, v_len);
1835 
1836  const float r = 14.0f;
1837  int v = 0;
1838  int flag = VCLASS_SCREENSPACE;
1839  /* Icon */
1840  const float sin_pi_3 = 0.86602540378f;
1841  const float cos_pi_3 = 0.5f;
1842  const float p[7][2] = {
1843  {0.0f, 1.0f},
1844  {sin_pi_3, cos_pi_3},
1845  {sin_pi_3, -cos_pi_3},
1846  {0.0f, -1.0f},
1847  {-sin_pi_3, -cos_pi_3},
1848  {-sin_pi_3, cos_pi_3},
1849  {0.0f, 0.0f},
1850  };
1851  for (int i = 0; i < 6; i++) {
1852  float t1[2], t2[2], tr[2];
1853  copy_v2_v2(t1, p[i]);
1854  copy_v2_v2(t2, p[(i + 1) % 6]);
1855  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag});
1856  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag});
1857  /* Internal wires. */
1858  for (int j = 1; j < 2; j++) {
1859  mul_v2_v2fl(tr, p[(i / 2) * 2 + 1], -0.5f * j);
1860  add_v2_v2v2(t1, p[i], tr);
1861  add_v2_v2v2(t2, p[(i + 1) % 6], tr);
1862  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t1[0] * r, t1[1] * r, 0.0f}, flag});
1863  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{t2[0] * r, t2[1] * r, 0.0f}, flag});
1864  }
1865  }
1866  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[1][0] * r, p[1][1] * r, 0.0f}, flag});
1867  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1868  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[5][0] * r, p[5][1] * r, 0.0f}, flag});
1869  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1870  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[3][0] * r, p[3][1] * r, 0.0f}, flag});
1871  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[6][0] * r, p[6][1] * r, 0.0f}, flag});
1872  /* Direction Lines */
1874  for (int i = 0; i < 6; i++) {
1875  char axes[] = "zZyYxX";
1876  float zsta = light_distance_z_get(axes[i], true);
1877  float zend = light_distance_z_get(axes[i], false);
1878  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zsta}, flag});
1879  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, zend}, flag});
1880  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zsta, flag);
1881  circle_verts(vbo, &v, DIAMOND_NSEGMENTS, 1.2f, zend, flag);
1882  }
1883 
1885  }
1886  return SHC.drw_lightprobe_grid;
1887 }
1888 
1890 {
1891  if (!SHC.drw_lightprobe_planar) {
1893 
1894  int v_len = 2 * 4;
1896  GPU_vertbuf_data_alloc(vbo, v_len);
1897 
1898  const float r = 20.0f;
1899  int v = 0;
1900  /* Icon */
1901  const float sin_pi_3 = 0.86602540378f;
1902  const float p[4][2] = {
1903  {0.0f, 0.5f},
1904  {sin_pi_3, 0.0f},
1905  {0.0f, -0.5f},
1906  {-sin_pi_3, 0.0f},
1907  };
1908  for (int i = 0; i < 4; i++) {
1909  for (int a = 0; a < 2; a++) {
1910  float x = p[(i + a) % 4][0] * r;
1911  float y = p[(i + a) % 4][1] * r;
1912  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 0.0}, VCLASS_SCREENSPACE});
1913  }
1914  }
1915 
1917  }
1918  return SHC.drw_lightprobe_planar;
1919 }
1920 
1923 /* -------------------------------------------------------------------- */
1927 static const float bone_octahedral_verts[6][3] = {
1928  {0.0f, 0.0f, 0.0f},
1929  {0.1f, 0.1f, 0.1f},
1930  {0.1f, 0.1f, -0.1f},
1931  {-0.1f, 0.1f, -0.1f},
1932  {-0.1f, 0.1f, 0.1f},
1933  {0.0f, 1.0f, 0.0f},
1934 };
1935 
1936 static const float bone_octahedral_smooth_normals[6][3] = {
1937  {0.0f, -1.0f, 0.0f},
1938 #if 0 /* creates problems for outlines when scaled */
1939  {0.943608f * M_SQRT1_2, -0.331048f, 0.943608f * M_SQRT1_2},
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 #else
1944  {M_SQRT1_2, 0.0f, M_SQRT1_2},
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 #endif
1949  {0.0f, 1.0f, 0.0f},
1950 };
1951 
1952 #if 0 /* UNUSED */
1953 
1954 static const uint bone_octahedral_wire[24] = {
1955  0, 1, 1, 5, 5, 3, 3, 0, 0, 4, 4, 5, 5, 2, 2, 0, 1, 2, 2, 3, 3, 4, 4, 1,
1956 };
1957 
1958 /* aligned with bone_octahedral_wire
1959  * Contains adjacent normal index */
1960 static const uint bone_octahedral_wire_adjacent_face[24] = {
1961  0, 3, 4, 7, 5, 6, 1, 2, 2, 3, 6, 7, 4, 5, 0, 1, 0, 4, 1, 5, 2, 6, 3, 7,
1962 };
1963 #endif
1964 
1965 static const uint bone_octahedral_solid_tris[8][3] = {
1966  {2, 1, 0}, /* bottom */
1967  {3, 2, 0},
1968  {4, 3, 0},
1969  {1, 4, 0},
1970 
1971  {5, 1, 2}, /* top */
1972  {5, 2, 3},
1973  {5, 3, 4},
1974  {5, 4, 1},
1975 };
1976 
1989  {0, 1, 2, 6},
1990  {0, 12, 1, 6},
1991  {0, 3, 12, 6},
1992  {0, 2, 3, 6},
1993  {1, 6, 2, 3},
1994  {1, 12, 6, 3},
1995  {1, 0, 12, 3},
1996  {1, 2, 0, 3},
1997  {2, 0, 1, 12},
1998  {2, 3, 0, 12},
1999  {2, 6, 3, 12},
2000  {2, 1, 6, 12},
2001 };
2002 
2003 #if 0 /* UNUSED */
2004 static const uint bone_octahedral_solid_tris_adjacency[8][6] = {
2005  {0, 12, 1, 10, 2, 3},
2006  {3, 15, 4, 1, 5, 6},
2007  {6, 18, 7, 4, 8, 9},
2008  {9, 21, 10, 7, 11, 0},
2009 
2010  {12, 22, 13, 2, 14, 17},
2011  {15, 13, 16, 5, 17, 20},
2012  {18, 16, 19, 8, 20, 23},
2013  {21, 19, 22, 11, 23, 14},
2014 };
2015 #endif
2016 
2017 /* aligned with bone_octahedral_solid_tris */
2018 static const float bone_octahedral_solid_normals[8][3] = {
2019  {M_SQRT1_2, -M_SQRT1_2, 0.00000000f},
2020  {-0.00000000f, -M_SQRT1_2, -M_SQRT1_2},
2021  {-M_SQRT1_2, -M_SQRT1_2, 0.00000000f},
2022  {0.00000000f, -M_SQRT1_2, M_SQRT1_2},
2023  {0.99388373f, 0.11043154f, -0.00000000f},
2024  {0.00000000f, 0.11043154f, -0.99388373f},
2025  {-0.99388373f, 0.11043154f, 0.00000000f},
2026  {0.00000000f, 0.11043154f, 0.99388373f},
2027 };
2028 
2030 {
2031  if (!SHC.drw_bone_octahedral) {
2032  uint v_idx = 0;
2033 
2034  static GPUVertFormat format = {0};
2035  static struct {
2036  uint pos, nor, snor;
2037  } attr_id;
2038  if (format.attr_len == 0) {
2042  }
2043 
2044  /* Vertices */
2046  GPU_vertbuf_data_alloc(vbo, 24);
2047 
2048  for (int i = 0; i < 8; i++) {
2049  for (int j = 0; j < 3; j++) {
2052  attr_id.snor,
2053  v_idx,
2056  vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][j]]);
2057  }
2058  }
2059 
2061  }
2062  return SHC.drw_bone_octahedral;
2063 }
2064 
2066 {
2068  GPUIndexBufBuilder elb;
2069  GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 24);
2070 
2071  for (int i = 0; i < 12; i++) {
2077  }
2078 
2079  /* HACK Reuse vertex buffer. */
2080  GPUBatch *pos_nor_batch = DRW_cache_bone_octahedral_get();
2081 
2083  pos_nor_batch->verts[0],
2084  GPU_indexbuf_build(&elb),
2086  }
2088 }
2089 
2091 {
2092  if (!SHC.drw_bone_box) {
2093  uint v_idx = 0;
2094 
2095  static GPUVertFormat format = {0};
2096  static struct {
2097  uint pos, nor, snor;
2098  } attr_id;
2099  if (format.attr_len == 0) {
2103  }
2104 
2105  /* Vertices */
2107  GPU_vertbuf_data_alloc(vbo, 36);
2108 
2109  for (int i = 0; i < 12; i++) {
2110  for (int j = 0; j < 3; j++) {
2113  vbo, attr_id.snor, v_idx, bone_box_smooth_normals[bone_box_solid_tris[i][j]]);
2115  }
2116  }
2117 
2119  }
2120  return SHC.drw_bone_box;
2121 }
2122 
2124 {
2125  if (!SHC.drw_bone_box_wire) {
2126  GPUIndexBufBuilder elb;
2127  GPU_indexbuf_init(&elb, GPU_PRIM_LINES_ADJ, 12, 36);
2128 
2129  for (int i = 0; i < 12; i++) {
2135  }
2136 
2137  /* HACK Reuse vertex buffer. */
2138  GPUBatch *pos_nor_batch = DRW_cache_bone_box_get();
2139 
2141  pos_nor_batch->verts[0],
2142  GPU_indexbuf_build(&elb),
2144  }
2145  return SHC.drw_bone_box_wire;
2146 }
2147 
2148 /* Helpers for envelope bone's solid sphere-with-hidden-equatorial-cylinder.
2149  * Note that here we only encode head/tail in forth component of the vector. */
2150 static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3])
2151 {
2152  r_nor[0] = sinf(lat) * cosf(lon);
2153  r_nor[1] = sinf(lat) * sinf(lon);
2154  r_nor[2] = cosf(lat);
2155 }
2156 
2158 {
2159  if (!SHC.drw_bone_envelope) {
2160  const int lon_res = 24;
2161  const int lat_res = 24;
2162  const float lon_inc = 2.0f * M_PI / lon_res;
2163  const float lat_inc = M_PI / lat_res;
2164  uint v_idx = 0;
2165 
2166  static GPUVertFormat format = {0};
2167  static struct {
2168  uint pos;
2169  } attr_id;
2170  if (format.attr_len == 0) {
2172  }
2173 
2174  /* Vertices */
2176  GPU_vertbuf_data_alloc(vbo, ((lat_res + 1) * 2) * lon_res * 1);
2177 
2178  float lon = 0.0f;
2179  for (int i = 0; i < lon_res; i++, lon += lon_inc) {
2180  float lat = 0.0f;
2181  float co1[3], co2[3];
2182 
2183  /* NOTE: the poles are duplicated on purpose, to restart the strip. */
2184 
2185  /* 1st sphere */
2186  for (int j = 0; j < lat_res; j++, lat += lat_inc) {
2187  benv_lat_lon_to_co(lat, lon, co1);
2188  benv_lat_lon_to_co(lat, lon + lon_inc, co2);
2189 
2190  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
2191  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
2192  }
2193 
2194  /* Closing the loop */
2195  benv_lat_lon_to_co(M_PI, lon, co1);
2196  benv_lat_lon_to_co(M_PI, lon + lon_inc, co2);
2197 
2198  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co1);
2199  GPU_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, co2);
2200  }
2201 
2203  }
2204  return SHC.drw_bone_envelope;
2205 }
2206 
2208 {
2210 #define CIRCLE_RESOL 64
2211  float v0[2], v1[2], v2[2];
2212  const float radius = 1.0f;
2213 
2214  /* Position Only 2D format */
2215  static GPUVertFormat format = {0};
2216  static struct {
2217  uint pos0, pos1, pos2;
2218  } attr_id;
2219  if (format.attr_len == 0) {
2223  }
2224 
2227 
2228  v0[0] = radius * sinf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL));
2229  v0[1] = radius * cosf((2.0f * M_PI * -2) / ((float)CIRCLE_RESOL));
2230  v1[0] = radius * sinf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL));
2231  v1[1] = radius * cosf((2.0f * M_PI * -1) / ((float)CIRCLE_RESOL));
2232 
2233  /* Output 4 verts for each position. See shader for explanation. */
2234  uint v = 0;
2235  for (int a = 0; a <= CIRCLE_RESOL; a++) {
2236  v2[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2237  v2[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2238  GPU_vertbuf_attr_set(vbo, attr_id.pos0, v, v0);
2239  GPU_vertbuf_attr_set(vbo, attr_id.pos1, v, v1);
2240  GPU_vertbuf_attr_set(vbo, attr_id.pos2, v++, v2);
2241  copy_v2_v2(v0, v1);
2242  copy_v2_v2(v1, v2);
2243  }
2244 
2247 #undef CIRCLE_RESOL
2248  }
2250 }
2251 
2253 {
2254  if (!SHC.drw_bone_point) {
2255 #if 0 /* old style geometry sphere */
2256  const int lon_res = 16;
2257  const int lat_res = 8;
2258  const float rad = 0.05f;
2259  const float lon_inc = 2 * M_PI / lon_res;
2260  const float lat_inc = M_PI / lat_res;
2261  uint v_idx = 0;
2262 
2263  static GPUVertFormat format = {0};
2264  static struct {
2265  uint pos, nor;
2266  } attr_id;
2267  if (format.attr_len == 0) {
2270  }
2271 
2272  /* Vertices */
2274  GPU_vertbuf_data_alloc(vbo, (lat_res - 1) * lon_res * 6);
2275 
2276  float lon = 0.0f;
2277  for (int i = 0; i < lon_res; i++, lon += lon_inc) {
2278  float lat = 0.0f;
2279  for (int j = 0; j < lat_res; j++, lat += lat_inc) {
2280  if (j != lat_res - 1) { /* Pole */
2281  add_lat_lon_vert(
2282  vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
2283  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon);
2284  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
2285  }
2286 
2287  if (j != 0) { /* Pole */
2288  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon + lon_inc);
2289  add_lat_lon_vert(
2290  vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat + lat_inc, lon + lon_inc);
2291  add_lat_lon_vert(vbo, attr_id.pos, attr_id.nor, &v_idx, rad, lat, lon);
2292  }
2293  }
2294  }
2295 
2297 #else
2298 # define CIRCLE_RESOL 64
2299  float v[2];
2300  const float radius = 0.05f;
2301 
2302  /* Position Only 2D format */
2303  static GPUVertFormat format = {0};
2304  static struct {
2305  uint pos;
2306  } attr_id;
2307  if (format.attr_len == 0) {
2309  }
2310 
2313 
2314  for (int a = 0; a < CIRCLE_RESOL; a++) {
2315  v[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2316  v[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2317  GPU_vertbuf_attr_set(vbo, attr_id.pos, a, v);
2318  }
2319 
2321 # undef CIRCLE_RESOL
2322 #endif
2323  }
2324  return SHC.drw_bone_point;
2325 }
2326 
2328 {
2329  if (!SHC.drw_bone_point_wire) {
2330 #if 0 /* old style geometry sphere */
2331  GPUVertBuf *vbo = sphere_wire_vbo(0.05f);
2333 #else
2334 # define CIRCLE_RESOL 64
2335  const float radius = 0.05f;
2336 
2337  /* Position Only 2D format */
2338  static GPUVertFormat format = {0};
2339  static struct {
2340  uint pos;
2341  } attr_id;
2342  if (format.attr_len == 0) {
2344  }
2345 
2348 
2349  uint v = 0;
2350  for (int a = 0; a <= CIRCLE_RESOL; a++) {
2351  float pos[2];
2352  pos[0] = radius * sinf((2.0f * M_PI * a) / CIRCLE_RESOL);
2353  pos[1] = radius * cosf((2.0f * M_PI * a) / CIRCLE_RESOL);
2354  GPU_vertbuf_attr_set(vbo, attr_id.pos, v++, pos);
2355  }
2356 
2359 # undef CIRCLE_RESOL
2360 #endif
2361  }
2362  return SHC.drw_bone_point_wire;
2363 }
2364 
2365 /* keep in sync with armature_stick_vert.glsl */
2366 #define COL_WIRE (1 << 0)
2367 #define COL_HEAD (1 << 1)
2368 #define COL_TAIL (1 << 2)
2369 #define COL_BONE (1 << 3)
2370 
2371 #define POS_HEAD (1 << 4)
2372 #define POS_TAIL (1 << 5)
2373 #define POS_BONE (1 << 6)
2374 
2376 {
2377  if (!SHC.drw_bone_stick) {
2378 #define CIRCLE_RESOL 12
2379  uint v = 0;
2380  uint flag;
2381  const float radius = 2.0f; /* head/tail radius */
2382  float pos[2];
2383 
2384  /* Position Only 2D format */
2385  static GPUVertFormat format = {0};
2386  static struct {
2387  uint pos, flag;
2388  } attr_id;
2389  if (format.attr_len == 0) {
2392  }
2393 
2394  const uint vcount = (CIRCLE_RESOL + 1) * 2 + 6;
2395 
2397  GPU_vertbuf_data_alloc(vbo, vcount);
2398 
2399  GPUIndexBufBuilder elb;
2400  GPU_indexbuf_init_ex(&elb, GPU_PRIM_TRI_FAN, (CIRCLE_RESOL + 2) * 2 + 6 + 2, vcount);
2401 
2402  /* head/tail points */
2403  for (int i = 0; i < 2; i++) {
2404  /* center vertex */
2405  copy_v2_fl(pos, 0.0f);
2406  flag = (i == 0) ? POS_HEAD : POS_TAIL;
2407  flag |= (i == 0) ? COL_HEAD : COL_TAIL;
2408  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
2409  GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
2411  /* circle vertices */
2412  flag |= COL_WIRE;
2413  for (int a = 0; a < CIRCLE_RESOL; a++) {
2414  pos[0] = radius * sinf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2415  pos[1] = radius * cosf((2.0f * M_PI * a) / ((float)CIRCLE_RESOL));
2416  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
2417  GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
2419  }
2420  /* Close the circle */
2422 
2424  }
2425 
2426  /* Bone rectangle */
2427  pos[0] = 0.0f;
2428  for (int i = 0; i < 6; i++) {
2429  pos[1] = ELEM(i, 0, 3) ? 0.0f : ((i < 3) ? 1.0f : -1.0f);
2430  flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) | (ELEM(i, 0, 3) ? 0 : COL_WIRE) | COL_BONE |
2431  POS_BONE;
2432  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos);
2433  GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag);
2435  }
2436 
2438  vbo,
2439  GPU_indexbuf_build(&elb),
2441 #undef CIRCLE_RESOL
2442  }
2443  return SHC.drw_bone_stick;
2444 }
2445 
2446 #define S_X 0.0215f
2447 #define S_Y 0.025f
2448 static float x_axis_name[4][2] = {
2449  {0.9f * S_X, 1.0f * S_Y},
2450  {-1.0f * S_X, -1.0f * S_Y},
2451  {-0.9f * S_X, 1.0f * S_Y},
2452  {1.0f * S_X, -1.0f * S_Y},
2453 };
2454 #define X_LEN (sizeof(x_axis_name) / (sizeof(float[2])))
2455 #undef S_X
2456 #undef S_Y
2457 
2458 #define S_X 0.0175f
2459 #define S_Y 0.025f
2460 static float y_axis_name[6][2] = {
2461  {-1.0f * S_X, 1.0f * S_Y},
2462  {0.0f * S_X, -0.1f * S_Y},
2463  {1.0f * S_X, 1.0f * S_Y},
2464  {0.0f * S_X, -0.1f * S_Y},
2465  {0.0f * S_X, -0.1f * S_Y},
2466  {0.0f * S_X, -1.0f * S_Y},
2467 };
2468 #define Y_LEN (sizeof(y_axis_name) / (sizeof(float[2])))
2469 #undef S_X
2470 #undef S_Y
2471 
2472 #define S_X 0.02f
2473 #define S_Y 0.025f
2474 static float z_axis_name[10][2] = {
2475  {-0.95f * S_X, 1.00f * S_Y},
2476  {0.95f * S_X, 1.00f * S_Y},
2477  {0.95f * S_X, 1.00f * S_Y},
2478  {0.95f * S_X, 0.90f * S_Y},
2479  {0.95f * S_X, 0.90f * S_Y},
2480  {-1.00f * S_X, -0.90f * S_Y},
2481  {-1.00f * S_X, -0.90f * S_Y},
2482  {-1.00f * S_X, -1.00f * S_Y},
2483  {-1.00f * S_X, -1.00f * S_Y},
2484  {1.00f * S_X, -1.00f * S_Y},
2485 };
2486 #define Z_LEN (sizeof(z_axis_name) / (sizeof(float[2])))
2487 #undef S_X
2488 #undef S_Y
2489 
2490 #define S_X 0.007f
2491 #define S_Y 0.007f
2492 static float axis_marker[8][2] = {
2493 #if 0 /* square */
2494  {-1.0f * S_X, 1.0f * S_Y},
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 #else /* diamond */
2503  {-S_X, 0.0f},
2504  {0.0f, S_Y},
2505  {0.0f, S_Y},
2506  {S_X, 0.0f},
2507  {S_X, 0.0f},
2508  {0.0f, -S_Y},
2509  {0.0f, -S_Y},
2510  {-S_X, 0.0f}
2511 #endif
2512 };
2513 #define MARKER_LEN (sizeof(axis_marker) / (sizeof(float[2])))
2514 #define MARKER_FILL_LAYER 6
2515 #undef S_X
2516 #undef S_Y
2517 
2519 {
2520  if (!SHC.drw_bone_arrows) {
2523  int v_len = (2 + MARKER_LEN * MARKER_FILL_LAYER) * 3 + (X_LEN + Y_LEN + Z_LEN);
2524  GPU_vertbuf_data_alloc(vbo, v_len);
2525 
2526  int v = 0;
2527  for (int axis = 0; axis < 3; axis++) {
2529  /* Vertex layout is XY screen position and axis in Z.
2530  * Fractional part of Z is a positive offset at axis unit position. */
2531  float p[3] = {0.0f, 0.0f, axis};
2532  /* center to axis line */
2533  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0f}, 0});
2534  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[0], p[1], p[2]}, flag});
2535  /* Axis end marker */
2536  for (int j = 1; j < MARKER_FILL_LAYER + 1; j++) {
2537  for (int i = 0; i < MARKER_LEN; i++) {
2538  mul_v2_v2fl(p, axis_marker[i], 4.0f * j / (float)MARKER_FILL_LAYER);
2539  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[0], p[1], p[2]}, flag});
2540  }
2541  }
2542  /* Axis name */
2544  int axis_v_len[] = {X_LEN, Y_LEN, Z_LEN};
2545  float(*axis_v)[2] = (axis == 0) ? x_axis_name : ((axis == 1) ? y_axis_name : z_axis_name);
2546  p[2] = axis + 0.25f;
2547  for (int i = 0; i < axis_v_len[axis]; i++) {
2548  mul_v2_v2fl(p, axis_v[i], 4.0f);
2549  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[0], p[1], p[2]}, flag});
2550  }
2551  }
2552 
2554  }
2555  return SHC.drw_bone_arrows;
2556 }
2557 
2558 static const float staticSine[16] = {
2559  0.0f,
2560  0.104528463268f,
2561  0.207911690818f,
2562  0.309016994375f,
2563  0.406736643076f,
2564  0.5f,
2565  0.587785252292f,
2566  0.669130606359f,
2567  0.743144825477f,
2568  0.809016994375f,
2569  0.866025403784f,
2570  0.913545457643f,
2571  0.951056516295f,
2572  0.978147600734f,
2573  0.994521895368f,
2574  1.0f,
2575 };
2576 
2577 #define set_vert(a, b, quarter) \
2578  { \
2579  copy_v2_fl2(pos, (quarter % 2 == 0) ? -(a) : (a), (quarter < 2) ? -(b) : (b)); \
2580  GPU_vertbuf_attr_set(vbo, attr_id.pos, v++, pos); \
2581  } \
2582  ((void)0)
2583 
2585 {
2586  if (!SHC.drw_bone_dof_sphere) {
2587  int i, j, q, n = ARRAY_SIZE(staticSine);
2588  float x, z, px, pz, pos[2];
2589 
2590  /* Position Only 3D format */
2591  static GPUVertFormat format = {0};
2592  static struct {
2593  uint pos;
2594  } attr_id;
2595  if (format.attr_len == 0) {
2597  }
2598 
2600  GPU_vertbuf_data_alloc(vbo, n * n * 6 * 4);
2601 
2602  uint v = 0;
2603  for (q = 0; q < 4; q++) {
2604  pz = 0.0f;
2605  for (i = 1; i < n; i++) {
2606  z = staticSine[i];
2607  px = 0.0f;
2608  for (j = 1; j <= (n - i); j++) {
2609  x = staticSine[j];
2610  if (j == n - i) {
2611  set_vert(px, z, q);
2612  set_vert(px, pz, q);
2613  set_vert(x, pz, q);
2614  }
2615  else {
2616  set_vert(x, z, q);
2617  set_vert(x, pz, q);
2618  set_vert(px, z, q);
2619 
2620  set_vert(x, pz, q);
2621  set_vert(px, pz, q);
2622  set_vert(px, z, q);
2623  }
2624  px = x;
2625  }
2626  pz = z;
2627  }
2628  }
2629  /* TODO: allocate right count from the beginning. */
2630  GPU_vertbuf_data_resize(vbo, v);
2631 
2633  }
2634  return SHC.drw_bone_dof_sphere;
2635 }
2636 
2638 {
2639  if (!SHC.drw_bone_dof_lines) {
2640  int i, n = ARRAY_SIZE(staticSine);
2641  float pos[2];
2642 
2643  /* Position Only 3D format */
2644  static GPUVertFormat format = {0};
2645  static struct {
2646  uint pos;
2647  } attr_id;
2648  if (format.attr_len == 0) {
2650  }
2651 
2653  GPU_vertbuf_data_alloc(vbo, n * 4);
2654 
2655  uint v = 0;
2656  for (i = 0; i < n * 4; i++) {
2657  float a = (1.0f - (i / (float)(n * 4))) * 2.0f * M_PI;
2658  float x = cosf(a);
2659  float y = sinf(a);
2660  set_vert(x, y, 0);
2661  }
2662 
2665  }
2666  return SHC.drw_bone_dof_lines;
2667 }
2668 
2669 #undef set_vert
2670 
2673 /* -------------------------------------------------------------------- */
2678 {
2679  if (!SHC.drw_camera_frame) {
2681 
2682  const int v_len = 2 * (4 + 4);
2684  GPU_vertbuf_data_alloc(vbo, v_len);
2685 
2686  int v = 0;
2687  const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}};
2688  /* Frame */
2689  for (int a = 0; a < 4; a++) {
2690  for (int b = 0; b < 2; b++) {
2691  float x = p[(a + b) % 4][0];
2692  float y = p[(a + b) % 4][1];
2693  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 1.0f}, VCLASS_CAMERA_FRAME});
2694  }
2695  }
2696  /* Wires to origin. */
2697  for (int a = 0; a < 4; a++) {
2698  float x = p[a][0];
2699  float y = p[a][1];
2700  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 1.0f}, VCLASS_CAMERA_FRAME});
2701  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 0.0f}, VCLASS_CAMERA_FRAME});
2702  }
2703 
2705  }
2706  return SHC.drw_camera_frame;
2707 }
2708 
2710 {
2711  if (!SHC.drw_camera_volume) {
2713 
2714  const int v_len = ARRAY_SIZE(bone_box_solid_tris) * 3;
2716  GPU_vertbuf_data_alloc(vbo, v_len);
2717 
2718  int v = 0;
2720  for (int i = 0; i < ARRAY_SIZE(bone_box_solid_tris); i++) {
2721  for (int a = 0; a < 3; a++) {
2722  float x = bone_box_verts[bone_box_solid_tris[i][a]][2];
2723  float y = bone_box_verts[bone_box_solid_tris[i][a]][0];
2724  float z = bone_box_verts[bone_box_solid_tris[i][a]][1];
2725  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, flag});
2726  }
2727  }
2728 
2730  }
2731  return SHC.drw_camera_volume;
2732 }
2733 
2735 {
2736  if (!SHC.drw_camera_volume_wire) {
2738 
2739  const int v_len = ARRAY_SIZE(bone_box_wire);
2741  GPU_vertbuf_data_alloc(vbo, v_len);
2742 
2743  int v = 0;
2745  for (int i = 0; i < ARRAY_SIZE(bone_box_wire); i++) {
2746  float x = bone_box_verts[bone_box_wire[i]][2];
2747  float y = bone_box_verts[bone_box_wire[i]][0];
2748  float z = bone_box_verts[bone_box_wire[i]][1];
2749  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, z}, flag});
2750  }
2751 
2754  }
2755  return SHC.drw_camera_volume_wire;
2756 }
2757 
2759 {
2760  if (!SHC.drw_camera_tria_wire) {
2762 
2763  const int v_len = 2 * 3;
2765  GPU_vertbuf_data_alloc(vbo, v_len);
2766 
2767  int v = 0;
2768  const float p[3][2] = {{-1.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}};
2769  for (int a = 0; a < 3; a++) {
2770  for (int b = 0; b < 2; b++) {
2771  float x = p[(a + b) % 3][0];
2772  float y = p[(a + b) % 3][1];
2773  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 1.0f}, VCLASS_CAMERA_FRAME});
2774  }
2775  }
2776 
2778  }
2779  return SHC.drw_camera_tria_wire;
2780 }
2781 
2783 {
2784  if (!SHC.drw_camera_tria) {
2786 
2787  const int v_len = 3;
2789  GPU_vertbuf_data_alloc(vbo, v_len);
2790 
2791  int v = 0;
2792  /* Use camera frame position */
2793  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{-1.0f, 1.0f, 1.0f}, VCLASS_CAMERA_FRAME});
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){{0.0f, 0.0f, 1.0f}, VCLASS_CAMERA_FRAME});
2796 
2798  }
2799  return SHC.drw_camera_tria;
2800 }
2801 
2803 {
2804  if (!SHC.drw_camera_distances) {
2806 
2807  const int v_len = 2 * (1 + DIAMOND_NSEGMENTS * 2 + 2);
2809  GPU_vertbuf_data_alloc(vbo, v_len);
2810 
2811  int v = 0;
2812  /* Direction Line */
2813  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 0.0}, VCLASS_CAMERA_DIST});
2814  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, 0.0, 1.0}, VCLASS_CAMERA_DIST});
2817  /* Focus cross */
2818  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{1.0, 0.0, 2.0}, VCLASS_CAMERA_DIST});
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){{0.0, 1.0, 2.0}, VCLASS_CAMERA_DIST});
2821  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0, -1.0, 2.0}, VCLASS_CAMERA_DIST});
2822 
2824  }
2825  return SHC.drw_camera_distances;
2826 }
2827 
2830 /* -------------------------------------------------------------------- */
2835 {
2836  BLI_assert(ob->type == OB_MESH);
2838 }
2839 
2841 {
2842  BLI_assert(ob->type == OB_MESH);
2844 }
2845 
2847 {
2848  BLI_assert(ob->type == OB_MESH);
2850 }
2851 
2853 {
2854  BLI_assert(ob->type == OB_MESH);
2855  return DRW_mesh_batch_cache_get_edge_detection(ob->data, r_is_manifold);
2856 }
2857 
2859 {
2860  BLI_assert(ob->type == OB_MESH);
2862 }
2863 
2865 {
2866  BLI_assert(ob->type == OB_MESH);
2868 }
2869 
2871  struct GPUMaterial **gpumat_array,
2872  uint gpumat_array_len)
2873 {
2874  BLI_assert(ob->type == OB_MESH);
2875  return DRW_mesh_batch_cache_get_surface_shaded(ob, ob->data, gpumat_array, gpumat_array_len);
2876 }
2877 
2879 {
2880  BLI_assert(ob->type == OB_MESH);
2882 }
2883 
2885 {
2886  BLI_assert(ob->type == OB_MESH);
2888 }
2889 
2891 {
2892  BLI_assert(ob->type == OB_MESH);
2894 }
2895 
2897 {
2898  BLI_assert(ob->type == OB_MESH);
2900 }
2901 
2903 {
2904  BLI_assert(ob->type == OB_MESH);
2906 }
2907 
2909 {
2910  BLI_assert(ob->type == OB_MESH);
2912 }
2913 
2915 {
2916  BLI_assert(ob->type == OB_MESH);
2918 }
2919 
2922 /* -------------------------------------------------------------------- */
2927 {
2929  struct Curve *cu = ob->data;
2931 }
2932 
2934 {
2936  struct Curve *cu = ob->data;
2938 }
2939 
2941 {
2943 
2944  struct Curve *cu = ob->data;
2946 }
2947 
2949 {
2951 
2952  struct Curve *cu = ob->data;
2954 }
2955 
2958 /* -------------------------------------------------------------------- */
2963 {
2964  BLI_assert(ob->type == OB_MBALL);
2966 }
2967 
2969 {
2970  BLI_assert(ob->type == OB_MBALL);
2971  return DRW_metaball_batch_cache_get_edge_detection(ob, r_is_manifold);
2972 }
2973 
2975 {
2976  BLI_assert(ob->type == OB_MBALL);
2978 }
2979 
2981  struct GPUMaterial **gpumat_array,
2982  uint gpumat_array_len)
2983 {
2984  BLI_assert(ob->type == OB_MBALL);
2985  MetaBall *mb = ob->data;
2986  return DRW_metaball_batch_cache_get_surface_shaded(ob, mb, gpumat_array, gpumat_array_len);
2987 }
2988 
2991 /* -------------------------------------------------------------------- */
2996 {
2997  BLI_assert(ob->type == OB_FONT);
2998  struct Curve *cu = ob->data;
3000 }
3001 
3004 /* -------------------------------------------------------------------- */
3009 {
3010  BLI_assert(ob->type == OB_SURF);
3011  struct Curve *cu = ob->data;
3013 }
3014 
3017 /* -------------------------------------------------------------------- */
3022 {
3023  BLI_assert(ob->type == OB_LATTICE);
3024 
3025  struct Lattice *lt = ob->data;
3027 }
3028 
3030 {
3031  BLI_assert(ob->type == OB_LATTICE);
3032 
3033  Lattice *lt = ob->data;
3034  int actdef = -1;
3035 
3036  if (use_weight && !BLI_listbase_is_empty(&lt->vertex_group_names) && lt->editlatt->latt->dvert) {
3037  actdef = lt->vertex_group_active_index - 1;
3038  }
3039 
3040  return DRW_lattice_batch_cache_get_all_edges(lt, use_weight, actdef);
3041 }
3042 
3044 {
3045  BLI_assert(ob->type == OB_LATTICE);
3046 
3047  struct Lattice *lt = ob->data;
3049 }
3050 
3053 /* -------------------------------------------------------------------- */
3058 {
3059  BLI_assert(object->type == OB_POINTCLOUD);
3060  return DRW_pointcloud_batch_cache_get_dots(object);
3061 }
3062 
3064 {
3065  BLI_assert(object->type == OB_POINTCLOUD);
3067 }
3068 
3071 /* -------------------------------------------------------------------- */
3076 {
3077  BLI_assert(ob->type == OB_VOLUME);
3079 }
3080 
3082 {
3083  BLI_assert(ob->type == OB_VOLUME);
3085 }
3086 
3089 /* -------------------------------------------------------------------- */
3094 {
3095  return DRW_particles_batch_cache_get_hair(object, psys, md);
3096 }
3097 
3099 {
3100  return DRW_particles_batch_cache_get_dots(object, psys);
3101 }
3102 
3104  ParticleSystem *psys,
3105  struct PTCacheEdit *edit,
3106  bool use_weight)
3107 {
3108  return DRW_particles_batch_cache_get_edit_strands(object, psys, edit, use_weight);
3109 }
3110 
3112  ParticleSystem *psys,
3113  struct PTCacheEdit *edit)
3114 {
3115  return DRW_particles_batch_cache_get_edit_inner_points(object, psys, edit);
3116 }
3117 
3119  ParticleSystem *psys,
3120  struct PTCacheEdit *edit)
3121 {
3122  return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit);
3123 }
3124 
3126 {
3127  switch (type) {
3128  case PART_DRAW_CROSS:
3129  if (!SHC.drw_particle_cross) {
3132  GPU_vertbuf_data_alloc(vbo, 6);
3133 
3134  int v = 0;
3135  int flag = 0;
3136  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, -1.0f, 0.0f}, flag});
3137  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 1.0f, 0.0f}, flag});
3138  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{-1.0f, 0.0f, 0.0f}, flag});
3139  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{1.0f, 0.0f, 0.0f}, flag});
3140  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, -1.0f}, flag});
3141  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 1.0f}, flag});
3142 
3145  }
3146 
3147  return SHC.drw_particle_cross;
3148  case PART_DRAW_AXIS:
3149  if (!SHC.drw_particle_axis) {
3152  GPU_vertbuf_data_alloc(vbo, 6);
3153 
3154  int v = 0;
3155  int flag = VCLASS_EMPTY_AXES;
3156  /* Set minimum to 0.001f so we can easily normalize to get the color. */
3157  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0001f, 0.0f}, flag});
3158  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 2.0f, 0.0f}, flag});
3159  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0001f, 0.0f, 0.0f}, flag});
3160  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{2.0f, 0.0f, 0.0f}, flag});
3161  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 0.0001f}, flag});
3162  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{0.0f, 0.0f, 2.0f}, flag});
3163 
3165  }
3166 
3167  return SHC.drw_particle_axis;
3168  case PART_DRAW_CIRC:
3169 #define CIRCLE_RESOL 32
3170  if (!SHC.drw_particle_circle) {
3174 
3175  int v = 0;
3176  int flag = VCLASS_SCREENALIGNED;
3177  for (int a = 0; a <= CIRCLE_RESOL; a++) {
3178  float angle = (2.0f * M_PI * a) / CIRCLE_RESOL;
3179  float x = sinf(angle);
3180  float y = cosf(angle);
3181  GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x, y, 0.0f}, flag});
3182  }
3183 
3186  }
3187 
3188  return SHC.drw_particle_circle;
3189 #undef CIRCLE_RESOL
3190  default:
3191  BLI_assert(false);
3192  break;
3193  }
3194 
3195  return NULL;
3196 }
3197 
3198 GPUBatch *DRW_cache_cursor_get(bool crosshair_lines)
3199 {
3200  GPUBatch **drw_cursor = crosshair_lines ? &SHC.drw_cursor : &SHC.drw_cursor_only_circle;
3201 
3202  if (*drw_cursor == NULL) {
3203  const float f5 = 0.25f;
3204  const float f10 = 0.5f;
3205  const float f20 = 1.0f;
3206 
3207  const int segments = 16;
3208  const int vert_len = segments + 8;
3209  const int index_len = vert_len + 5;
3210 
3211  const uchar red[3] = {255, 0, 0};
3212  const uchar white[3] = {255, 255, 255};
3213 
3214  static GPUVertFormat format = {0};
3215  static struct {
3216  uint pos, color;
3217  } attr_id;
3218  if (format.attr_len == 0) {
3222  }
3223 
3224  GPUIndexBufBuilder elb;
3225  GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len);
3226 
3228  GPU_vertbuf_data_alloc(vbo, vert_len);
3229 
3230  int v = 0;
3231  for (int i = 0; i < segments; i++) {
3232  float angle = (float)(2 * M_PI) * ((float)i / (float)segments);
3233  float x = f10 * cosf(angle);
3234  float y = f10 * sinf(angle);
3235 
3236  GPU_vertbuf_attr_set(vbo, attr_id.color, v, (i % 2 == 0) ? red : white);
3237 
3238  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){x, y});
3240  }
3242 
3243  if (crosshair_lines) {
3244  uchar crosshair_color[3];
3245  UI_GetThemeColor3ubv(TH_VIEW_OVERLAY, crosshair_color);
3246 
3248 
3249  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f20, 0});
3250  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3252  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){-f5, 0});
3253  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3255 
3257 
3258  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f5, 0});
3259  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3261  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){+f20, 0});
3262  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3264 
3266 
3267  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f20});
3268  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3270  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, -f5});
3271  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3273 
3275 
3276  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f5});
3277  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3279  GPU_vertbuf_attr_set(vbo, attr_id.pos, v, (const float[2]){0, +f20});
3280  GPU_vertbuf_attr_set(vbo, attr_id.color, v, crosshair_color);
3282  }
3283 
3284  GPUIndexBuf *ibo = GPU_indexbuf_build(&elb);
3285 
3286  *drw_cursor = GPU_batch_create_ex(
3288  }
3289  return *drw_cursor;
3290 }
3291 
3294 /* -------------------------------------------------------------------- */
3299 {
3300  switch (ob->type) {
3301  case OB_MESH:
3303  break;
3304  case OB_CURVES_LEGACY:
3305  case OB_FONT:
3306  case OB_SURF:
3308  break;
3309  case OB_MBALL:
3311  break;
3312  case OB_LATTICE:
3314  break;
3315  case OB_CURVES:
3317  break;
3318  case OB_POINTCLOUD:
3320  break;
3321  case OB_VOLUME:
3323  break;
3324  default:
3325  break;
3326  }
3327 }
3328 
3330 {
3331  const DRWContextState *draw_ctx = DRW_context_state_get();
3332  const Scene *scene = draw_ctx->scene;
3333  const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
3334  draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
3335  const bool is_paint_mode = ELEM(
3337 
3338  const bool use_hide = ((ob->type == OB_MESH) &&
3339  ((is_paint_mode && (ob == draw_ctx->obact) &&
3341  ((mode == CTX_MODE_EDIT_MESH) && DRW_object_is_in_edit_mode(ob))));
3342 
3343  switch (ob->type) {
3344  case OB_MESH:
3346  DST.task_graph, ob, (Mesh *)ob->data, scene, is_paint_mode, use_hide);
3347  break;
3348  case OB_CURVES_LEGACY:
3349  case OB_FONT:
3350  case OB_SURF:
3352  break;
3353  case OB_CURVES:
3355  break;
3356  /* TODO: all cases. */
3357  default:
3358  break;
3359  }
3360 }
3361 
3363 {
3364  /* NOTE: Logic here is duplicated from #drw_batch_cache_generate_requested. */
3365 
3366  const DRWContextState *draw_ctx = DRW_context_state_get();
3367  const Scene *scene = draw_ctx->scene;
3368  const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
3369  draw_ctx->object_edit, draw_ctx->obact, draw_ctx->object_mode);
3370  const bool is_paint_mode = ELEM(
3372 
3373  const bool use_hide = ((ob->type == OB_MESH) &&
3374  ((is_paint_mode && (ob == draw_ctx->obact) &&
3376  ((mode == CTX_MODE_EDIT_MESH) && DRW_object_is_in_edit_mode(ob))));
3377 
3379  /* Try getting the mesh first and if that fails, try getting the curve data.
3380  * If the curves are surfaces or have certain modifiers applied to them, the will have mesh data
3381  * of the final result.
3382  */
3383  if (mesh != NULL) {
3385  DST.task_graph, ob, mesh, scene, is_paint_mode, use_hide);
3386  }
3387  else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) {
3389  }
3390 }
3391 
3393 {
3395 }
3396 
3397 void DRW_batch_cache_free_old(Object *ob, int ctime)
3398 {
3399  switch (ob->type) {
3400  case OB_MESH:
3401  DRW_mesh_batch_cache_free_old((Mesh *)ob->data, ctime);
3402  break;
3403  case OB_CURVES:
3405  break;
3406  /* TODO: all cases. */
3407  default:
3408  break;
3409  }
3410 }
3411 
3415  const char *base_name,
3416  const CustomData *UNUSED(data),
3417  const CustomDataLayer *cl,
3418  bool is_active_render,
3419  bool is_active_layer)
3420 {
3421  char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
3422  const char *layer_name = cl->name;
3423 
3424  GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
3425 
3426  /* Attribute layer name. */
3427  BLI_snprintf(attr_name, sizeof(attr_name), "%s%s", base_name, attr_safe_name);
3428  GPU_vertformat_alias_add(format, attr_name);
3429 
3430  /* Auto layer name. */
3431  BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name);
3432  GPU_vertformat_alias_add(format, attr_name);
3433 
3434  /* Active render layer name. */
3435  if (is_active_render) {
3436  GPU_vertformat_alias_add(format, base_name);
3437  }
3438 
3439  /* Active display layer name. */
3440  if (is_active_layer) {
3441  BLI_snprintf(attr_name, sizeof(attr_name), "a%s", base_name);
3442  GPU_vertformat_alias_add(format, attr_name);
3443  }
3444 }
typedef float(TangentPoint)[2]
enum eContextObjectMode CTX_data_mode_enum_ex(const struct Object *obedit, const struct Object *ob, eObjectMode object_mode)
eContextObjectMode
Definition: BKE_context.h:103
@ CTX_MODE_PAINT_TEXTURE
Definition: BKE_context.h:116
@ CTX_MODE_SCULPT
Definition: BKE_context.h:113
@ CTX_MODE_EDIT_MESH
Definition: BKE_context.h:104
@ CTX_MODE_PAINT_VERTEX
Definition: BKE_context.h:115
@ CTX_MODE_PAINT_WEIGHT
Definition: BKE_context.h:114
General operations, lookup, etc. for blender objects.
struct Mesh * BKE_object_get_evaluated_mesh_no_subsurf(const struct Object *object)
#define BLI_assert(a)
Definition: BLI_assert.h:46
bool BLI_gset_add(GSet *gs, void *key)
Definition: BLI_ghash.c:969
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define M_SQRT3
Definition: BLI_math_base.h:35
#define M_SQRT1_2
Definition: BLI_math_base.h:32
#define M_PI
Definition: BLI_math_base.h:20
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)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED_FUNCTION(x)
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define ELEM(...)
Object is a sort of wrapper for general info.
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_MESH
@ OB_POINTCLOUD
@ OB_VOLUME
@ OB_CURVES_LEGACY
@ OB_CURVES
@ OB_GPENCIL
#define PART_DRAW_AXIS
#define PART_DRAW_CROSS
#define PART_DRAW_CIRC
GPUBatch
Definition: GPU_batch.h:78
#define GPU_BATCH_DISCARD_SAFE(batch)
Definition: GPU_batch.h:216
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
Definition: gpu_batch.cc:43
@ GPU_BATCH_OWNS_INDEX
Definition: GPU_batch.h:39
@ GPU_BATCH_OWNS_VBO
Definition: GPU_batch.h:30
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 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 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 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:25
@ GPU_PRIM_LINE_LOOP
Definition: GPU_primitive.h:23
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_PRIM_POINTS
Definition: GPU_primitive.h:19
@ GPU_PRIM_LINES_ADJ
Definition: GPU_primitive.h:29
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:22
@ GPU_PRIM_TRI_STRIP
Definition: GPU_primitive.h:24
@ GPU_PRIM_TRIS
Definition: GPU_primitive.h:21
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)
void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uint max_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)
#define GPU_MAX_SAFE_ATTR_NAME
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.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a producing a negative Combine Generate a color from its red
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
@ TH_VIEW_OVERLAY
Definition: UI_resources.h:327
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
Definition: resources.c:1323
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
#define sinf(x)
Definition: cuda/compat.h:102
#define cosf(x)
Definition: cuda/compat.h:101
Scene scene
struct VertShaded VertShaded
#define DRW_SPHERE_SHAPE_LONGITUDE_HIGH
Definition: draw_cache.c:69
GPUBatch * DRW_cache_mesh_face_wireframe_get(Object *ob)
Definition: draw_cache.c:2908
GPUBatch * DRW_cache_camera_frame_get(void)
Definition: draw_cache.c:2677
GPUBatch * DRW_cache_empty_capsule_body_get(void)
Definition: draw_cache.c:1172
GPUBatch * DRW_cache_curve_edge_normal_get(Object *ob)
Definition: draw_cache.c:2933
#define VCLASS_LIGHT_AREA_SHAPE
Definition: draw_cache.c:41
GPUBatch * DRW_cache_groundline_get(void)
Definition: draw_cache.c:1475
GPUBatch * DRW_cache_circle_get(void)
Definition: draw_cache.c:728
#define set_vert(a, b, quarter)
Definition: draw_cache.c:2577
static struct DRWShapeCache SHC
GPUBatch * DRW_cache_plain_axes_get(void)
Definition: draw_cache.c:1003
GPUBatch * DRW_cache_empty_sphere_get(void)
Definition: draw_cache.c:1083
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:2896
static const float bone_box_solid_normals[12][3]
Definition: draw_cache.c:675
static GPUVertBuf * sphere_wire_vbo(const float rad, int flag)
Definition: draw_cache.c:312
GPUBatch ** DRW_cache_mball_surface_shaded_get(Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:2980
GPUBatch * DRW_cache_bone_octahedral_wire_get(void)
Definition: draw_cache.c:2065
GPUBatch * DRW_cache_quad_get(void)
Definition: draw_cache.c:389
GPUBatch * DRW_cache_particles_get_edit_inner_points(Object *object, ParticleSystem *psys, struct PTCacheEdit *edit)
Definition: draw_cache.c:3111
GPUBatch * DRW_cache_object_all_edges_get(Object *ob)
Definition: draw_cache.c:800
static const uint bone_octahedral_wire_lines_adjacency[12][4]
Definition: draw_cache.c:1988
void drw_batch_cache_generate_requested_evaluated_mesh_or_curve(Object *ob)
Definition: draw_cache.c:3362
static float y_axis_name[6][2]
Definition: draw_cache.c:2460
GPUBatch * DRW_cache_lattice_verts_get(Object *ob)
Definition: draw_cache.c:3021
GPUBatch * DRW_cache_cursor_get(bool crosshair_lines)
Definition: draw_cache.c:3198
GPUBatch * DRW_cache_mball_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:2968
GPUBatch * DRW_cache_lightprobe_grid_get(void)
Definition: draw_cache.c:1827
GPUBatch * DRW_cache_light_area_disk_lines_get(void)
Definition: draw_cache.c:1627
static float x_axis_name[4][2]
Definition: draw_cache.c:2448
GPUBatch * DRW_cache_curve_edge_wire_get(Object *ob)
Definition: draw_cache.c:2926
GPUBatch * DRW_cache_bone_dof_lines_get(void)
Definition: draw_cache.c:2637
#define VCLASS_CAMERA_DIST
Definition: draw_cache.c:48
GPUBatch * DRW_cache_empty_cylinder_get(void)
Definition: draw_cache.c:1131
#define OUTER_NSEGMENTS
Definition: draw_cache.c:1453
static const float bone_octahedral_smooth_normals[6][3]
Definition: draw_cache.c:1936
static const float staticSine[16]
Definition: draw_cache.c:2558
GPUBatch * DRW_cache_text_edge_wire_get(Object *ob)
Definition: draw_cache.c:2995
#define VCLASS_EMPTY_AXES_NAME
Definition: draw_cache.c:56
#define Z_LEN
Definition: draw_cache.c:2486
#define VCLASS_LIGHT_SPOT_BLEND
Definition: draw_cache.c:43
GPUBatch * DRW_cache_pointcloud_surface_get(Object *object)
Definition: draw_cache.c:3063
GPUBatch * DRW_cache_mesh_all_verts_get(Object *ob)
Definition: draw_cache.c:2834
GPUBatch * DRW_cache_field_force_get(void)
Definition: draw_cache.c:1284
GPUBatch * DRW_cache_grid_get(void)
Definition: draw_cache.c:429
#define Y_LEN
Definition: draw_cache.c:2468
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:66
GPUBatch * DRW_cache_lattice_vert_overlay_get(Object *ob)
Definition: draw_cache.c:3043
static const uint bone_box_wire_lines_adjacency[12][4]
Definition: draw_cache.c:637
static const uint bone_box_wire[24]
Definition: draw_cache.c:601
#define S_X
Definition: draw_cache.c:2490
GPUBatch * DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:812
GPUBatch * DRW_cache_field_sphere_limit_get(void)
Definition: draw_cache.c:1424
GPUBatch * DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
Definition: draw_cache.c:2884
#define DRW_SPHERE_SHAPE_LATITUDE_LOW
Definition: draw_cache.c:62
GPUBatch * DRW_cache_field_vortex_get(void)
Definition: draw_cache.c:1307
GPUBatch ** DRW_cache_object_surface_material_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:971
void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format, const char *base_name, const CustomData *UNUSED(data), const CustomDataLayer *cl, bool is_active_render, bool is_active_layer)
Definition: draw_cache.c:3414
#define VCLASS_EMPTY_AXES
Definition: draw_cache.c:55
GPUBatch * DRW_cache_light_area_square_lines_get(void)
Definition: draw_cache.c:1659
GPUBatch * DRW_cache_bone_box_get(void)
Definition: draw_cache.c:2090
GPUBatch * DRW_cache_light_spot_lines_get(void)
Definition: draw_cache.c:1554
GPUBatch * DRW_cache_speaker_get(void)
Definition: draw_cache.c:1708
GPUBatch * DRW_cache_bone_octahedral_get(void)
Definition: draw_cache.c:2029
GPUBatch * drw_cache_procedural_points_get(void)
Definition: draw_cache.c:169
#define VCLASS_EMPTY_SCALED
Definition: draw_cache.c:54
GPUBatch * DRW_cache_mesh_surface_weights_get(Object *ob)
Definition: draw_cache.c:2902
#define COL_HEAD
Definition: draw_cache.c:2367
GPUBatch * DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
Definition: draw_cache.c:3029
GPUBatch * DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys)
Definition: draw_cache.c:3098
GPUBatch * DRW_cache_camera_volume_wire_get(void)
Definition: draw_cache.c:2734
static const float bone_box_verts[8][3]
Definition: draw_cache.c:579
#define SPIRAL_RESOL
void drw_batch_cache_generate_requested(Object *ob)
Definition: draw_cache.c:3329
static void circle_dashed_verts(GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
Definition: draw_cache.c:563
GPUBatch * DRW_cache_volume_selection_surface_get(Object *ob)
Definition: draw_cache.c:3081
GPUBatch * DRW_cache_light_spot_volume_get(void)
Definition: draw_cache.c:1600
GPUBatch * DRW_cache_bone_point_wire_outline_get(void)
Definition: draw_cache.c:2327
GPUBatch * DRW_cache_object_face_wireframe_get(Object *ob)
Definition: draw_cache.c:836
#define INNER_NSEGMENTS
Definition: draw_cache.c:1452
GPUBatch * DRW_cache_field_wind_get(void)
Definition: draw_cache.c:1261
GPUBatch * DRW_cache_bone_stick_get(void)
Definition: draw_cache.c:2375
#define POS_TAIL
Definition: draw_cache.c:2372
static const float bone_octahedral_verts[6][3]
Definition: draw_cache.c:1927
#define MARKER_LEN
Definition: draw_cache.c:2513
GPUBatch * DRW_cache_lightprobe_planar_get(void)
Definition: draw_cache.c:1889
GPUBatch * DRW_cache_bone_envelope_outline_get(void)
Definition: draw_cache.c:2207
GPUBatch * DRW_cache_surf_edge_wire_get(Object *ob)
Definition: draw_cache.c:3008
GPUBatch * drw_cache_procedural_triangles_get(void)
Definition: draw_cache.c:197
#define COL_WIRE
Definition: draw_cache.c:2366
#define NSEGMENTS
static const float bone_octahedral_solid_normals[8][3]
Definition: draw_cache.c:2018
#define CIRCLE_RESOL
GPUBatch * DRW_cache_fullscreen_quad_get(void)
Definition: draw_cache.c:356
#define VCLASS_LIGHT_DIST
Definition: draw_cache.c:45
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:2974
#define DRW_SPHERE_SHAPE_LATITUDE_HIGH
Definition: draw_cache.c:68
void drw_batch_cache_validate(Object *ob)
Definition: draw_cache.c:3298
#define DRW_SPHERE_SHAPE_LONGITUDE_LOW
Definition: draw_cache.c:63
#define VCLASS_LIGHT_SPOT_SHAPE
Definition: draw_cache.c:42
void DRW_shape_cache_free(void)
Definition: draw_cache.c:153
GPUBatch * DRW_cache_cube_get(void)
Definition: draw_cache.c:695
GPUBatch ** DRW_cache_mesh_surface_shaded_get(Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
Definition: draw_cache.c:2870
GPUBatch * DRW_cache_normal_arrow_get(void)
Definition: draw_cache.c:751
void drw_batch_cache_generate_requested_delayed(Object *ob)
Definition: draw_cache.c:3392
GPUBatch * DRW_cache_camera_tria_get(void)
Definition: draw_cache.c:2782
struct Vert Vert
#define X_LEN
Definition: draw_cache.c:2454
#define VCLASS_CAMERA_FRAME
Definition: draw_cache.c:47
#define CIRCLE_NSEGMENTS
Definition: draw_cache.c:1454
GPUBatch * DRW_cache_camera_volume_get(void)
Definition: draw_cache.c:2709
#define VCLASS_CAMERA_VOLUME
Definition: draw_cache.c:49
GPUBatch * DRW_cache_mesh_surface_vertpaint_get(Object *ob)
Definition: draw_cache.c:2890
GPUBatch * DRW_cache_sphere_get(const eDRWLevelOfDetail level_of_detail)
Definition: draw_cache.c:482
#define VCLASS_LIGHT_SPOT_CONE
Definition: draw_cache.c:44
GPUBatch * DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
Definition: draw_cache.c:2852
#define S_Y
Definition: draw_cache.c:2491
static float z_axis_name[10][2]
Definition: draw_cache.c:2474
GPUBatch * DRW_cache_particles_get_prim(int type)
Definition: draw_cache.c:3125
GPUBatch * DRW_cache_light_sun_lines_get(void)
Definition: draw_cache.c:1520
GPUBatch * DRW_cache_bone_envelope_solid_get(void)
Definition: draw_cache.c:2157
GPUBatch * DRW_cache_lightprobe_cube_get(void)
Definition: draw_cache.c:1773
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:225
static const uint bone_octahedral_solid_tris[8][3]
Definition: draw_cache.c:1965
GPUBatch * DRW_cache_bone_point_get(void)
Definition: draw_cache.c:2252
GPUBatch * DRW_cache_mesh_all_edges_get(Object *ob)
Definition: draw_cache.c:2840
GPUBatch * DRW_cache_camera_tria_wire_get(void)
Definition: draw_cache.c:2758
GPUBatch * DRW_cache_curve_vert_overlay_get(Object *ob)
Definition: draw_cache.c:2948
static void circle_verts(GPUVertBuf *vbo, int *vert_idx, int segments, float radius, float z, int flag)
Definition: draw_cache.c:548
#define POS_HEAD
Definition: draw_cache.c:2371
#define VCLASS_SCREENALIGNED
Definition: draw_cache.c:52
#define DIAMOND_NSEGMENTS
Definition: draw_cache.c:1451
GPUBatch * DRW_cache_mesh_surface_get(Object *ob)
Definition: draw_cache.c:2858
#define VCLASS_SCREENSPACE
Definition: draw_cache.c:51
GPUBatch * DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
Definition: draw_cache.c:2914
GPUBatch * DRW_cache_curve_edge_overlay_get(Object *ob)
Definition: draw_cache.c:2940
static void sphere_lat_lon_vert(GPUVertBuf *vbo, int *v_ofs, float lat, float lon)
Definition: draw_cache.c:473
static const uint bone_box_solid_tris[12][3]
Definition: draw_cache.c:613
GPUBatch * DRW_cache_particles_get_edit_tip_points(Object *object, ParticleSystem *psys, struct PTCacheEdit *edit)
Definition: draw_cache.c:3118
#define COL_BONE
Definition: draw_cache.c:2369
GPUBatch ** DRW_cache_mesh_surface_texpaint_get(Object *ob)
Definition: draw_cache.c:2878
#define COL_TAIL
Definition: draw_cache.c:2368
#define MARKER_FILL_LAYER
Definition: draw_cache.c:2514
static const float bone_box_smooth_normals[8][3]
Definition: draw_cache.c:590
GPUBatch * DRW_cache_bone_box_wire_get(void)
Definition: draw_cache.c:2123
GPUBatch * DRW_cache_mball_surface_get(Object *ob)
Definition: draw_cache.c:2962
#define POS_BONE
Definition: draw_cache.c:2373
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:217
static void benv_lat_lon_to_co(const float lat, const float lon, float r_nor[3])
Definition: draw_cache.c:2150
GPUBatch * DRW_cache_quad_wires_get(void)
Definition: draw_cache.c:409
#define DRW_SPHERE_SHAPE_LATITUDE_MEDIUM
Definition: draw_cache.c:65
GPUBatch * drw_cache_procedural_lines_get(void)
Definition: draw_cache.c:183
GPUBatch * DRW_cache_mesh_loose_edges_get(Object *ob)
Definition: draw_cache.c:2846
static float axis_marker[8][2]
Definition: draw_cache.c:2492
GPUBatch * DRW_cache_empty_capsule_cap_get(void)
Definition: draw_cache.c:1205
GPUBatch * DRW_cache_volume_face_wireframe_get(Object *ob)
Definition: draw_cache.c:3075
GPUBatch * DRW_cache_particles_get_edit_strands(Object *object, ParticleSystem *psys, struct PTCacheEdit *edit, bool use_weight)
Definition: draw_cache.c:3103
GPUBatch * DRW_cache_single_arrow_get(void)
Definition: draw_cache.c:1045
void DRW_batch_cache_free_old(Object *ob, int ctime)
Definition: draw_cache.c:3397
GPUBatch * DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md)
Definition: draw_cache.c:3093
GPUBatch * DRW_cache_camera_distances_get(void)
Definition: draw_cache.c:2802
GPUBatch * DRW_cache_object_surface_get(Object *ob)
Definition: draw_cache.c:887
GPUBatch * DRW_cache_pointcloud_get_dots(Object *object)
Definition: draw_cache.c:3057
static float light_distance_z_get(char axis, const bool start)
Definition: draw_cache.c:1456
GPUBatch * DRW_cache_empty_cone_get(void)
Definition: draw_cache.c:1092
#define VCLASS_EMPTY_SIZE
Definition: draw_cache.c:58
GPUBatch * DRW_gpencil_dummy_buffer_get(void)
Definition: draw_cache.c:776
GPUBatch * DRW_cache_object_loose_edges_get(struct Object *ob)
Definition: draw_cache.c:863
#define SIDE_STIPPLE
GPUBatch * DRW_cache_light_point_lines_get(void)
Definition: draw_cache.c:1496
GPUBatch * DRW_cache_bone_dof_sphere_get(void)
Definition: draw_cache.c:2584
GPUBatch * DRW_cache_bone_arrows_get(void)
Definition: draw_cache.c:2518
GPUBatch * DRW_cache_empty_cube_get(void)
Definition: draw_cache.c:1025
GPUBatch * DRW_cache_mesh_surface_edges_get(Object *ob)
Definition: draw_cache.c:2864
struct GPUBatch * DRW_cache_gpencil_face_wireframe_get(struct Object *ob)
eDRWLevelOfDetail
Definition: draw_cache.h:28
@ DRW_LOD_MEDIUM
Definition: draw_cache.h:30
@ DRW_LOD_LOW
Definition: draw_cache.h:29
@ DRW_LOD_HIGH
Definition: draw_cache.h:31
@ DRW_LOD_MAX
Definition: draw_cache.h:33
int DRW_gpencil_material_count_get(struct bGPdata *gpd)
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_mesh_batch_cache_get_surface_texpaint(struct Object *object, struct Mesh *me)
struct GPUBatch * DRW_curve_batch_cache_get_wire_edge(struct Curve *cu)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_sculpt(struct Object *object, struct Mesh *me)
void DRW_mesh_batch_cache_validate(struct Object *object, struct Mesh *me)
struct GPUBatch * DRW_particles_batch_cache_get_edit_tip_points(struct Object *object, struct ParticleSystem *psys, struct PTCacheEdit *edit)
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)
void DRW_mesh_batch_cache_create_requested(struct TaskGraph *task_graph, struct Object *ob, struct Mesh *me, const struct Scene *scene, bool is_paint_mode, bool use_hide)
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)
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_pointcloud_batch_cache_get_dots(struct Object *ob)
struct GPUBatch * DRW_volume_batch_cache_get_selection_surface(struct Volume *volume)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_vertpaint(struct Object *object, struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_all_edges(struct Mesh *me)
int DRW_mesh_material_count_get(const struct Object *object, const 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)
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_single(struct Object *object, struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_surface_edges(struct Object *object, struct Mesh *me)
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)
void DRW_curves_batch_cache_free_old(struct Curves *curves, int ctime)
int DRW_pointcloud_material_count_get(struct PointCloud *pointcloud)
struct GPUBatch * DRW_curve_batch_cache_get_edit_verts(struct Curve *cu)
void DRW_curves_batch_cache_create_requested(struct Object *ob)
struct GPUBatch ** DRW_mesh_batch_cache_get_surface_shaded(struct Object *object, struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len)
void DRW_mesh_batch_cache_free_old(struct Mesh *me, int ctime)
struct GPUBatch * DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool use_weight, int actdef)
void DRW_curves_batch_cache_validate(struct Curves *curves)
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)
struct GPUBatch * DRW_metaball_batch_cache_get_edge_detection(struct Object *ob, bool *r_is_manifold)
int DRW_curves_material_count_get(struct Curves *curves)
struct GPUBatch * DRW_mesh_batch_cache_get_edit_mesh_analysis(struct Mesh *me)
struct GPUBatch * DRW_mesh_batch_cache_get_surface(struct Mesh *me)
bool DRW_object_is_in_edit_mode(const Object *ob)
Definition: draw_manager.c:196
DRWManager DST
Definition: draw_manager.c:104
const DRWContextState * DRW_context_state_get(void)
bool DRW_object_use_hide_faces(const struct Object *ob)
Definition: draw_manager.c:215
uint pos
uint nor
struct @653::@656 attr_id
struct @653::@655 batch
format
Definition: logImageCore.h:38
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
struct Object * obact
Definition: DRW_render.h:983
struct Scene * scene
Definition: DRW_render.h:979
eObjectMode object_mode
Definition: DRW_render.h:991
struct Object * object_edit
Definition: DRW_render.h:1003
struct TaskGraph * task_graph
Definition: draw_manager.h:635
struct GSet * delayed_extraction
Definition: draw_manager.h:637
GPUBatch * drw_camera_volume_wire
Definition: draw_cache.c:145
GPUBatch * drw_grid
Definition: draw_cache.c:98
GPUBatch * drw_bone_dof_sphere
Definition: draw_cache.c:138
GPUBatch * drw_lightprobe_grid
Definition: draw_cache.c:127
GPUBatch * drw_single_arrow
Definition: draw_cache.c:100
GPUBatch * drw_empty_cube
Definition: draw_cache.c:104
GPUBatch * drw_bone_envelope_outline
Definition: draw_cache.c:133
GPUBatch * drw_light_point_lines
Definition: draw_cache.c:118
GPUBatch * drw_particle_cross
Definition: draw_cache.c:146
GPUBatch * drw_procedural_verts
Definition: draw_cache.c:90
GPUBatch * drw_gpencil_dummy_quad
Definition: draw_cache.c:149
GPUBatch * drw_lightprobe_cube
Definition: draw_cache.c:125
GPUBatch * drw_plain_axes
Definition: draw_cache.c:99
GPUBatch * drw_empty_cone
Definition: draw_cache.c:109
GPUBatch * drw_speaker
Definition: draw_cache.c:124
GPUBatch * drw_bone_box_wire
Definition: draw_cache.c:131
GPUBatch * drw_quad_wires
Definition: draw_cache.c:97
GPUBatch * drw_circle
Definition: draw_cache.c:102
GPUBatch * drw_light_spot_lines
Definition: draw_cache.c:120
GPUBatch * drw_procedural_tris
Definition: draw_cache.c:92
GPUBatch * drw_bone_envelope
Definition: draw_cache.c:132
GPUBatch * drw_bone_box
Definition: draw_cache.c:130
GPUBatch * drw_cursor_only_circle
Definition: draw_cache.c:94
GPUBatch * drw_camera_frame
Definition: draw_cache.c:140
GPUBatch * drw_empty_sphere
Definition: draw_cache.c:105
GPUBatch * drw_field_sphere_limit
Definition: draw_cache.c:116
GPUBatch * drw_camera_tria_wire
Definition: draw_cache.c:142
GPUBatch * drw_camera_tria
Definition: draw_cache.c:141
GPUBatch * drw_cursor
Definition: draw_cache.c:93
GPUBatch * drw_fullscreen_quad
Definition: draw_cache.c:95
GPUBatch * drw_empty_capsule_cap
Definition: draw_cache.c:108
GPUBatch * drw_field_curve
Definition: draw_cache.c:113
GPUBatch * drw_empty_cylinder
Definition: draw_cache.c:106
GPUBatch * drw_particle_circle
Definition: draw_cache.c:147
GPUBatch * drw_bone_arrows
Definition: draw_cache.c:137
GPUBatch * drw_field_force
Definition: draw_cache.c:111
GPUBatch * drw_sphere_lod[DRW_LOD_MAX]
Definition: draw_cache.c:150
GPUBatch * drw_light_area_disk_lines
Definition: draw_cache.c:122
GPUBatch * drw_procedural_lines
Definition: draw_cache.c:91
GPUBatch * drw_normal_arrow
Definition: draw_cache.c:103
GPUBatch * drw_bone_stick
Definition: draw_cache.c:136
GPUBatch * drw_bone_dof_lines
Definition: draw_cache.c:139
GPUBatch * drw_lightprobe_planar
Definition: draw_cache.c:126
GPUBatch * drw_empty_capsule_body
Definition: draw_cache.c:107
GPUBatch * drw_light_spot_volume
Definition: draw_cache.c:121
GPUBatch * drw_bone_point
Definition: draw_cache.c:134
GPUBatch * drw_bone_octahedral_wire
Definition: draw_cache.c:129
GPUBatch * drw_light_area_square_lines
Definition: draw_cache.c:123
GPUBatch * drw_particle_axis
Definition: draw_cache.c:148
GPUBatch * drw_cube
Definition: draw_cache.c:101
GPUBatch * drw_field_cone_limit
Definition: draw_cache.c:115
GPUBatch * drw_field_vortex
Definition: draw_cache.c:112
GPUBatch * drw_camera_distances
Definition: draw_cache.c:143
GPUBatch * drw_camera_volume
Definition: draw_cache.c:144
GPUBatch * drw_quad
Definition: draw_cache.c:96
GPUBatch * drw_bone_point_wire
Definition: draw_cache.c:135
GPUBatch * drw_field_wind
Definition: draw_cache.c:110
GPUBatch * drw_light_sun_lines
Definition: draw_cache.c:119
GPUBatch * drw_field_tube_limit
Definition: draw_cache.c:114
GPUBatch * drw_bone_octahedral
Definition: draw_cache.c:128
GPUBatch * drw_ground_line
Definition: draw_cache.c:117
struct Lattice * latt
ListBase vertex_group_names
struct MDeformVert * dvert
int vertex_group_active_index
struct EditLatt * editlatt
void * data
float nor[3]
Definition: draw_cache.c:85
float pos[3]
Definition: draw_cache.c:83
float pos[3]
Definition: draw_cache.c:78