Blender V4.3
overlay_extra.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "DRW_render.hh"
10
11#include "UI_resources.hh"
12
13#include "BLI_math_color.h"
14#include "BLI_math_matrix.hh"
15#include "BLI_math_rotation.h"
16#include "BLI_math_rotation.hh"
17#include "BLI_math_vector.hh"
18
19#include "BKE_anim_path.h"
20#include "BKE_camera.h"
21#include "BKE_constraint.h"
22#include "BKE_curve.hh"
23#include "BKE_global.hh"
24#include "BKE_mball.hh"
25#include "BKE_mesh.hh"
26#include "BKE_modifier.hh"
27#include "BKE_movieclip.h"
28#include "BKE_object.hh"
29#include "BKE_object_types.hh"
30#include "BKE_tracking.h"
31
32#include "BLI_listbase.h"
33
34#include "DNA_camera_types.h"
36#include "DNA_curve_types.h"
37#include "DNA_fluid_types.h"
40#include "DNA_mesh_types.h"
41#include "DNA_meta_types.h"
42#include "DNA_modifier_types.h"
44#include "DNA_rigidbody_types.h"
45
47
48#include "ED_view3d.hh"
49
50#include "overlay_private.hh"
51
52#include "draw_common_c.hh"
53#include "draw_manager_text.hh"
54
56{
57 OVERLAY_PassList *psl = vedata->psl;
58 OVERLAY_TextureList *txl = vedata->txl;
59 OVERLAY_PrivateData *pd = vedata->stl->pd;
60 const bool is_select = DRW_state_is_select();
61
63 DRW_PASS_CREATE(psl->extra_blend_ps, state_blend | pd->clipping_state);
64 DRW_PASS_CREATE(psl->extra_centers_ps, state_blend | pd->clipping_state);
65
66 {
68
71 DRWShadingGroup *grp;
73 GPUTexture *tex = DRW_state_is_fbo() ? dtxl->depth : txl->dummy_depth_tx;
74
76 DRW_shgroup_uniform_texture(grp, "depthBuffer", tex);
77 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
78 DRW_shgroup_uniform_bool_copy(grp, "isTransform", (G.moving & G_TRANSFORM_OBJ) != 0);
79 }
80
81 for (int i = 0; i < 2; i++) {
82 /* Non Meshes Pass (Camera, empties, lights ...) */
83 GPUShader *sh;
85 DRWShadingGroup *grp, *grp_sub;
86
89 DRWPass **p_extra_ps = &psl->extra_ps[i];
90
91 DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT :
92 DRWState(0);
94 DRW_PASS_CREATE(*p_extra_ps, state | pd->clipping_state | infront_state);
95
96 DRWPass *extra_ps = *p_extra_ps;
97
98#define BUF_INSTANCE DRW_shgroup_call_buffer_instance
99#define BUF_POINT(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_POINTS)
100#define BUF_LINE(grp, format) DRW_shgroup_call_buffer(grp, format, GPU_PRIM_LINES)
101
102 /* Sorted by shader to avoid state changes during render. */
103 {
104 format = formats->instance_extra;
105 sh = OVERLAY_shader_extra(is_select);
106
107 grp = DRW_shgroup_create(sh, extra_ps);
108 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
109
110 grp_sub = DRW_shgroup_create_sub(grp);
147
148 grp_sub = DRW_shgroup_create_sub(grp);
152 }
153 {
154 format = formats->instance_extra;
155 grp = DRW_shgroup_create(sh, psl->extra_blend_ps); /* NOTE: not the same pass! */
156 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
157
158 grp_sub = DRW_shgroup_create_sub(grp);
163
164 grp_sub = DRW_shgroup_create_sub(grp);
167 }
168 {
169 format = formats->instance_pos;
171
172 grp = DRW_shgroup_create(sh, extra_ps);
173 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
175
177 }
178 {
179 sh = OVERLAY_shader_extra_wire(false, is_select);
180
181 grp = DRW_shgroup_create(sh, extra_ps);
182 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
183
184 cb->extra_dashed_lines = BUF_LINE(grp, formats->pos_color);
185 cb->extra_lines = BUF_LINE(grp, formats->wire_extra);
186 }
187 {
188 sh = OVERLAY_shader_extra_wire(true, is_select);
189
190 cb->extra_wire = grp = DRW_shgroup_create(sh, extra_ps);
191 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
192 }
193 {
195
196 cb->extra_loose_points = grp = DRW_shgroup_create(sh, extra_ps);
197 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
198
199 /* Buffer access for drawing isolated points, matching `extra_lines`. */
200 cb->extra_points = BUF_POINT(grp, formats->point_extra);
201 }
202 {
203 format = formats->pos;
205
206 grp = DRW_shgroup_create(sh, psl->extra_centers_ps); /* NOTE: not the same pass! */
207 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
208
209 grp_sub = DRW_shgroup_create_sub(grp);
211 cb->center_active = BUF_POINT(grp_sub, format);
212
213 grp_sub = DRW_shgroup_create_sub(grp);
215 cb->center_selected = BUF_POINT(grp_sub, format);
216
217 grp_sub = DRW_shgroup_create_sub(grp);
219 cb->center_deselected = BUF_POINT(grp_sub, format);
220
221 grp_sub = DRW_shgroup_create_sub(grp);
223 cb->center_selected_lib = BUF_POINT(grp_sub, format);
224
225 grp_sub = DRW_shgroup_create_sub(grp);
227 cb->center_deselected_lib = BUF_POINT(grp_sub, format);
228 }
229 }
230}
231
232void OVERLAY_extra_point(OVERLAY_ExtraCallBuffers *cb, const float point[3], const float color[4])
233{
234 DRW_buffer_add_entry(cb->extra_points, point, color);
235}
236
238 const float start[3],
239 const float end[3],
240 const float color[4])
241{
243 DRW_buffer_add_entry(cb->extra_dashed_lines, start, color);
244}
245
247 const float start[3],
248 const float end[3],
249 const int color_id)
250{
251 DRW_buffer_add_entry(cb->extra_lines, start, &color_id);
252 DRW_buffer_add_entry(cb->extra_lines, end, &color_id);
253}
254
256{
257 bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
258 OVERLAY_PrivateData *pd = vedata->stl->pd;
259 return &pd->extra_call_buffers[do_in_front];
260}
261
263 blender::gpu::Batch *geom,
264 const float mat[4][4],
265 const float color[4])
266{
267 float draw_mat[4][4];
268 pack_v4_in_mat4(draw_mat, mat, color);
269 DRW_shgroup_call_obmat(cb->extra_loose_points, geom, draw_mat);
270}
271
273 blender::gpu::Batch *geom,
274 const float mat[4][4],
275 const float color[4])
276{
277 float draw_mat[4][4];
278 const float col[4] = {UNPACK3(color), 0.0f /* No stipples. */};
279 pack_v4_in_mat4(draw_mat, mat, col);
280 DRW_shgroup_call_obmat(cb->extra_wire, geom, draw_mat);
281}
282
283/* -------------------------------------------------------------------- */
288 const float mat[4][4],
289 const float draw_size,
290 const char draw_type,
291 const float color[4])
292{
293 float instdata[4][4];
294 pack_fl_in_mat4(instdata, mat, draw_size);
295
296 switch (draw_type) {
297 case OB_PLAINAXES:
298 DRW_buffer_add_entry(cb->empty_plain_axes, color, instdata);
299 break;
300 case OB_SINGLE_ARROW:
301 DRW_buffer_add_entry(cb->empty_single_arrow, color, instdata);
302 break;
303 case OB_CUBE:
304 DRW_buffer_add_entry(cb->empty_cube, color, instdata);
305 break;
306 case OB_CIRCLE:
307 DRW_buffer_add_entry(cb->empty_circle, color, instdata);
308 break;
309 case OB_EMPTY_SPHERE:
310 DRW_buffer_add_entry(cb->empty_sphere, color, instdata);
311 break;
312 case OB_EMPTY_CONE:
313 DRW_buffer_add_entry(cb->empty_cone, color, instdata);
314 break;
315 case OB_ARROWS:
316 DRW_buffer_add_entry(cb->empty_axes, color, instdata);
317 break;
318 case OB_EMPTY_IMAGE:
319 /* This only show the frame. See OVERLAY_image_empty_cache_populate() for the image. */
320 DRW_buffer_add_entry(cb->empty_image_frame, color, instdata);
321 break;
322 }
323}
324
326{
327 if (((ob->base_flag & BASE_FROM_DUPLI) != 0) && ((ob->transflag & OB_DUPLICOLLECTION) != 0) &&
329 {
330 return;
331 }
332
334 const DRWContextState *draw_ctx = DRW_context_state_get();
335 ViewLayer *view_layer = draw_ctx->view_layer;
336 float *color;
337
338 switch (ob->empty_drawtype) {
339 case OB_PLAINAXES:
340 case OB_SINGLE_ARROW:
341 case OB_CUBE:
342 case OB_CIRCLE:
343 case OB_EMPTY_SPHERE:
344 case OB_EMPTY_CONE:
345 case OB_ARROWS:
346 DRW_object_wire_theme_get(ob, view_layer, &color);
348 cb, ob->object_to_world().ptr(), ob->empty_drawsize, ob->empty_drawtype, color);
349 break;
350 case OB_EMPTY_IMAGE:
352 break;
353 }
354}
355
357 Object *ob,
358 const float *color,
359 char boundtype,
360 bool around_origin)
361{
362 using namespace blender;
363 float tmp[4][4], final_mat[4][4];
364
365 if (ob->type == OB_MBALL && !BKE_mball_is_basis(ob)) {
366 return;
367 }
368
369 const Bounds<float3> bounds = BKE_object_boundbox_get(ob).value_or(
370 Bounds(float3(-1.0f), float3(1.0f)));
371
372 float3 size = (bounds.max - bounds.min) * 0.5f;
373 const float3 center = around_origin ? float3(0) : math::midpoint(bounds.min, bounds.max);
374
375 switch (boundtype) {
376 case OB_BOUND_BOX:
377 size_to_mat4(tmp, size);
378 copy_v3_v3(tmp[3], center);
379 mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp);
380 DRW_buffer_add_entry(cb->empty_cube, color, tmp);
381 break;
382 case OB_BOUND_SPHERE:
383 size[0] = max_fff(size[0], size[1], size[2]);
384 size[1] = size[2] = size[0];
385 size_to_mat4(tmp, size);
386 copy_v3_v3(tmp[3], center);
387 mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp);
388 DRW_buffer_add_entry(cb->empty_sphere, color, tmp);
389 break;
391 size[0] = max_ff(size[0], size[1]);
392 size[1] = size[0];
393 size_to_mat4(tmp, size);
394 copy_v3_v3(tmp[3], center);
395 mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp);
396 DRW_buffer_add_entry(cb->empty_cylinder, color, tmp);
397 break;
398 case OB_BOUND_CONE:
399 size[0] = max_ff(size[0], size[1]);
400 size[1] = size[0];
401 size_to_mat4(tmp, size);
402 copy_v3_v3(tmp[3], center);
403 /* Cone batch has base at 0 and is pointing towards +Y. */
404 swap_v3_v3(tmp[1], tmp[2]);
405 tmp[3][2] -= size[2];
406 mul_m4_m4m4(tmp, ob->object_to_world().ptr(), tmp);
407 DRW_buffer_add_entry(cb->empty_cone, color, tmp);
408 break;
409 case OB_BOUND_CAPSULE:
410 size[0] = max_ff(size[0], size[1]);
411 size[1] = size[0];
412 scale_m4_fl(tmp, size[0]);
413 copy_v2_v2(tmp[3], center);
414 tmp[3][2] = center[2] + max_ff(0.0f, size[2] - size[0]);
415 mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp);
416 DRW_buffer_add_entry(cb->empty_capsule_cap, color, final_mat);
417 negate_v3(tmp[2]);
418 tmp[3][2] = center[2] - max_ff(0.0f, size[2] - size[0]);
419 mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp);
420 DRW_buffer_add_entry(cb->empty_capsule_cap, color, final_mat);
421 tmp[2][2] = max_ff(0.0f, size[2] * 2.0f - size[0] * 2.0f);
422 mul_m4_m4m4(final_mat, ob->object_to_world().ptr(), tmp);
423 DRW_buffer_add_entry(cb->empty_capsule_body, color, final_mat);
424 break;
425 }
426}
427
428static void OVERLAY_collision(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color)
429{
430 switch (ob->rigidbody_object->shape) {
431 case RB_SHAPE_BOX:
432 OVERLAY_bounds(cb, ob, color, OB_BOUND_BOX, true);
433 break;
434 case RB_SHAPE_SPHERE:
435 OVERLAY_bounds(cb, ob, color, OB_BOUND_SPHERE, true);
436 break;
437 case RB_SHAPE_CONE:
438 OVERLAY_bounds(cb, ob, color, OB_BOUND_CONE, true);
439 break;
441 OVERLAY_bounds(cb, ob, color, OB_BOUND_CYLINDER, true);
442 break;
443 case RB_SHAPE_CAPSULE:
444 OVERLAY_bounds(cb, ob, color, OB_BOUND_CAPSULE, true);
445 break;
446 }
447}
448
449static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color)
450{
451 if (ob->data == nullptr) {
452 return;
453 }
454
455 ID *ob_data = static_cast<ID *>(ob->data);
456 float *texcoloc = nullptr;
457 float *texcosize = nullptr;
458
459 switch (GS(ob_data->name)) {
460 case ID_ME:
461 BKE_mesh_texspace_get_reference((Mesh *)ob_data, nullptr, &texcoloc, &texcosize);
462 break;
463 case ID_CU_LEGACY: {
464 Curve *cu = (Curve *)ob_data;
466 texcoloc = cu->texspace_location;
467 texcosize = cu->texspace_size;
468 break;
469 }
470 case ID_MB: {
471 MetaBall *mb = (MetaBall *)ob_data;
472 texcoloc = mb->texspace_location;
473 texcosize = mb->texspace_size;
474 break;
475 }
476 case ID_CV:
477 case ID_PT:
478 case ID_VO: {
479 /* No user defined texture space support. */
480 break;
481 }
482 default:
483 BLI_assert(0);
484 }
485
486 float mat[4][4];
487
488 if (texcoloc != nullptr && texcosize != nullptr) {
489 size_to_mat4(mat, texcosize);
490 copy_v3_v3(mat[3], texcoloc);
491 }
492 else {
493 unit_m4(mat);
494 }
495
496 mul_m4_m4m4(mat, ob->object_to_world().ptr(), mat);
497
498 DRW_buffer_add_entry(cb->empty_cube, color, mat);
499}
500
502{
503 int theme_id = DRW_object_wire_theme_get(ob, view_layer, nullptr);
504 float *color = DRW_color_background_blend_get(theme_id);
505 PartDeflect *pd = ob->pd;
506 Curve *cu = (ob->type == OB_CURVES_LEGACY) ? static_cast<Curve *>(ob->data) : nullptr;
507
508 union {
509 float mat[4][4];
510 struct {
511 float _pad00[3], size_x;
512 float _pad01[3], size_y;
513 float _pad02[3], size_z;
514 float pos[3], _pad03[1];
515 };
516 } instdata;
517
518 copy_m4_m4(instdata.mat, ob->object_to_world().ptr());
519 instdata.size_x = instdata.size_y = instdata.size_z = ob->empty_drawsize;
520
521 switch (pd->forcefield) {
522 case PFIELD_FORCE:
523 DRW_buffer_add_entry(cb->field_force, color, &instdata);
524 break;
525 case PFIELD_WIND:
526 instdata.size_z = pd->f_strength;
527 DRW_buffer_add_entry(cb->field_wind, color, &instdata);
528 break;
529 case PFIELD_VORTEX:
530 instdata.size_y = (pd->f_strength < 0.0f) ? -instdata.size_y : instdata.size_y;
531 DRW_buffer_add_entry(cb->field_vortex, color, &instdata);
532 break;
533 case PFIELD_GUIDE:
534 if (cu && (cu->flag & CU_PATH) && ob->runtime->curve_cache->anim_path_accum_length) {
535 instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength;
536 float pos[4];
537 BKE_where_on_path(ob, 0.0f, pos, nullptr, nullptr, nullptr, nullptr);
538 copy_v3_v3(instdata.pos, ob->object_to_world().location());
539 translate_m4(instdata.mat, pos[0], pos[1], pos[2]);
540 DRW_buffer_add_entry(cb->field_curve, color, &instdata);
541
542 BKE_where_on_path(ob, 1.0f, pos, nullptr, nullptr, nullptr, nullptr);
543 copy_v3_v3(instdata.pos, ob->object_to_world().location());
544 translate_m4(instdata.mat, pos[0], pos[1], pos[2]);
545 DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata);
546 /* Restore */
547 copy_v3_v3(instdata.pos, ob->object_to_world().location());
548 }
549 break;
550 }
551
552 if (pd->falloff == PFIELD_FALL_TUBE) {
553 if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR)) {
554 instdata.size_z = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f;
555 instdata.size_x = (pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f;
556 instdata.size_y = instdata.size_x;
557 DRW_buffer_add_entry(cb->field_tube_limit, color, &instdata);
558 }
559 if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR)) {
560 instdata.size_z = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f;
561 instdata.size_x = (pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f;
562 instdata.size_y = instdata.size_x;
563 DRW_buffer_add_entry(cb->field_tube_limit, color, &instdata);
564 }
565 }
566 else if (pd->falloff == PFIELD_FALL_CONE) {
567 if (pd->flag & (PFIELD_USEMAX | PFIELD_USEMAXR)) {
568 float radius = DEG2RADF((pd->flag & PFIELD_USEMAXR) ? pd->maxrad : 1.0f);
569 float distance = (pd->flag & PFIELD_USEMAX) ? pd->maxdist : 0.0f;
570 instdata.size_x = distance * sinf(radius);
571 instdata.size_z = distance * cosf(radius);
572 instdata.size_y = instdata.size_x;
573 DRW_buffer_add_entry(cb->field_cone_limit, color, &instdata);
574 }
575 if (pd->flag & (PFIELD_USEMIN | PFIELD_USEMINR)) {
576 float radius = DEG2RADF((pd->flag & PFIELD_USEMINR) ? pd->minrad : 1.0f);
577 float distance = (pd->flag & PFIELD_USEMIN) ? pd->mindist : 0.0f;
578 instdata.size_x = distance * sinf(radius);
579 instdata.size_z = distance * cosf(radius);
580 instdata.size_y = instdata.size_x;
581 DRW_buffer_add_entry(cb->field_cone_limit, color, &instdata);
582 }
583 }
584 else if (pd->falloff == PFIELD_FALL_SPHERE) {
585 if (pd->flag & PFIELD_USEMAX) {
586 instdata.size_x = instdata.size_y = instdata.size_z = pd->maxdist;
587 DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata);
588 }
589 if (pd->flag & PFIELD_USEMIN) {
590 instdata.size_x = instdata.size_y = instdata.size_z = pd->mindist;
591 DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata);
592 }
593 }
594}
595
598/* -------------------------------------------------------------------- */
603{
605 const DRWContextState *draw_ctx = DRW_context_state_get();
606 ViewLayer *view_layer = draw_ctx->view_layer;
607
608 Light *la = static_cast<Light *>(ob->data);
609 float *color_p;
610 DRW_object_wire_theme_get(ob, view_layer, &color_p);
611
612 /* Remove the alpha. */
613 float theme_color[4] = {UNPACK3(color_p), 1.0f};
614 /* Pack render data into object matrix. */
615 union {
616 float mat[4][4];
617 struct {
618 float _pad00[3];
619 union {
620 float area_size_x;
621 float spot_cosine;
622 };
623 float _pad01[3];
624 union {
625 float area_size_y;
626 float spot_blend;
627 };
628 float _pad02[3], clip_sta;
629 float pos[3], clip_end;
630 };
631 } instdata;
632
633 copy_m4_m4(instdata.mat, ob->object_to_world().ptr());
634 /* FIXME / TODO: clip_end has no meaning nowadays.
635 * In EEVEE, Only clip_sta is used shadow-mapping.
636 * Clip end is computed automatically based on light power.
637 * For now, always use the custom distance as clip_end. */
638 instdata.clip_end = la->att_dist;
639 instdata.clip_sta = la->clipsta;
640
641 DRW_buffer_add_entry(cb->groundline, instdata.pos);
642
643 float light_color[4] = {1.0f};
644 const bool show_light_colors = vedata->stl->pd->overlay.flag & V3D_OVERLAY_SHOW_LIGHT_COLORS;
645 if (show_light_colors) {
646 copy_v3_v3(light_color, &la->r);
647 }
648
649 /* Draw the outer ring of the light icon and the sun rays in `light_color`, if required. */
651 cb->light_icon_outer, show_light_colors ? light_color : theme_color, &instdata);
652 DRW_buffer_add_entry(cb->light_icon_inner, theme_color, &instdata);
653
654 if (la->type == LA_LOCAL) {
655 instdata.area_size_x = instdata.area_size_y = la->radius;
656 DRW_buffer_add_entry(cb->light_point, theme_color, &instdata);
657 }
658 else if (la->type == LA_SUN) {
659 DRW_buffer_add_entry(cb->light_sun, theme_color, &instdata);
661 cb->light_icon_sun_rays, show_light_colors ? light_color : theme_color, &instdata);
662 }
663 else if (la->type == LA_SPOT) {
664 /* Previous implementation was using the clip-end distance as cone size.
665 * We cannot do this anymore so we use a fixed size of 10. (see #72871) */
666 const float3 scale_vec = {10.0f, 10.0f, 10.0f};
667 rescale_m4(instdata.mat, scale_vec);
668 /* For cycles and EEVEE the spot attenuation is:
669 * `y = (1/sqrt(1 + x^2) - a)/((1 - a) b)`
670 * x being the tangent of the angle between the light direction and the generatrix of the cone.
671 * We solve the case where spot attenuation y = 1 and y = 0
672 * root for y = 1 is `sqrt(1/c^2 - 1)`.
673 * root for y = 0 is `sqrt(1/a^2 - 1)`
674 * and use that to position the blend circle. */
675 float a = cosf(la->spotsize * 0.5f);
676 float b = la->spotblend;
677 float c = a * b - a - b;
678 float a2 = a * a;
679 float c2 = c * c;
680 /* Optimized version or root1 / root0 */
681 instdata.spot_blend = sqrtf((a2 - a2 * c2) / (c2 - a2 * c2));
682 instdata.spot_cosine = a;
683 /* HACK: We pack the area size in alpha color. This is decoded by the shader. */
684 theme_color[3] = -max_ff(la->radius, FLT_MIN);
685 DRW_buffer_add_entry(cb->light_spot, theme_color, &instdata);
686
687 if ((la->mode & LA_SHOW_CONE) && !DRW_state_is_select()) {
688 const float color_inside[4] = {0.0f, 0.0f, 0.0f, 0.5f};
689 const float color_outside[4] = {1.0f, 1.0f, 1.0f, 0.3f};
690 DRW_buffer_add_entry(cb->light_spot_cone_front, color_inside, &instdata);
691 DRW_buffer_add_entry(cb->light_spot_cone_back, color_outside, &instdata);
692 }
693 }
694 else if (la->type == LA_AREA) {
695 bool uniform_scale = !ELEM(la->area_shape, LA_AREA_RECT, LA_AREA_ELLIPSE);
697 instdata.area_size_x = la->area_size;
698 instdata.area_size_y = uniform_scale ? la->area_size : la->area_sizey;
699 DRW_buffer_add_entry(cb->light_area[sqr], theme_color, &instdata);
700 }
701}
702
705/* -------------------------------------------------------------------- */
710{
711 using namespace blender::math;
712
714 const DRWContextState *draw_ctx = DRW_context_state_get();
715 ViewLayer *view_layer = draw_ctx->view_layer;
716 float *color_p;
717 int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color_p);
718 const LightProbe *prb = (LightProbe *)ob->data;
719 const bool show_clipping = (prb->flag & LIGHTPROBE_FLAG_SHOW_CLIP_DIST) != 0;
720 const bool show_parallax = (prb->flag & LIGHTPROBE_FLAG_SHOW_PARALLAX) != 0;
721 const bool show_influence = (prb->flag & LIGHTPROBE_FLAG_SHOW_INFLUENCE) != 0;
722 const bool show_data = (ob->base_flag & BASE_SELECTED) || DRW_state_is_select();
723
724 union {
725 float mat[4][4];
726 struct {
727 float _pad00[4];
728 float _pad01[4];
729 float _pad02[3], clip_sta;
730 float pos[3], clip_end;
731 };
732 } instdata;
733
734 copy_m4_m4(instdata.mat, ob->object_to_world().ptr());
735
736 switch (prb->type) {
738 instdata.clip_sta = show_clipping ? prb->clipsta : -1.0;
739 instdata.clip_end = show_clipping ? prb->clipend : -1.0;
740 DRW_buffer_add_entry(cb->probe_cube, color_p, &instdata);
741 DRW_buffer_add_entry(cb->groundline, instdata.pos);
742
743 if (show_influence) {
745 float f = 1.0f - prb->falloff;
746 OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), prb->distinf, shape, color_p);
747 OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), prb->distinf * f, shape, color_p);
748 }
749
750 if (show_parallax) {
752 float dist = ((prb->flag & LIGHTPROBE_FLAG_CUSTOM_PARALLAX) != 0) ? prb->distpar :
753 prb->distinf;
754 OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), dist, shape, color_p);
755 }
756 break;
758 instdata.clip_sta = show_clipping ? 0.0f : -1.0f;
759 instdata.clip_end = show_clipping ? prb->clipend : -1.0f;
760 DRW_buffer_add_entry(cb->probe_grid, color_p, &instdata);
761
762 {
763 /* Display surfel density as a cube. */
764 float3 axes_len = to_scale(ob->object_to_world());
765 float max_axis_len = reduce_max(axes_len);
766 float3 local_surfel_size = (0.5f / prb->grid_surfel_density) * (max_axis_len / axes_len);
767
768 float4x4 surfel_density_mat = from_loc_rot_scale<float4x4>(
769 float3(-1.0f + local_surfel_size), Quaternion::identity(), float3(local_surfel_size));
770 surfel_density_mat = ob->object_to_world() * surfel_density_mat;
771
772 OVERLAY_empty_shape(cb, surfel_density_mat.ptr(), 1.0, OB_CUBE, color_p);
773 }
774
775 if (show_influence) {
776 OVERLAY_empty_shape(cb, ob->object_to_world().ptr(), 1.0, OB_CUBE, color_p);
777 }
778
779 /* Data dots */
780 if (show_data) {
781 instdata.mat[0][3] = prb->grid_resolution_x;
782 instdata.mat[1][3] = prb->grid_resolution_y;
783 instdata.mat[2][3] = prb->grid_resolution_z;
784 /* Put theme id in matrix. */
785 if (theme_id == TH_ACTIVE) {
786 instdata.mat[3][3] = 1.0;
787 }
788 else /* TH_SELECT */ {
789 instdata.mat[3][3] = 2.0;
790 }
791
792 uint cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z;
794 DRW_shgroup_uniform_mat4_copy(grp, "gridModelMatrix", instdata.mat);
795 DRW_shgroup_call_procedural_points(grp, nullptr, cell_count);
796 }
797 break;
798 }
800 DRW_buffer_add_entry(cb->probe_planar, color_p, &instdata);
801
803 DRW_buffer_add_entry(cb->solid_quad, color_p, &instdata);
804 }
805
806 if (show_influence) {
807 normalize_v3_length(instdata.mat[2], prb->distinf);
808 DRW_buffer_add_entry(cb->empty_cube, color_p, &instdata);
809 mul_v3_fl(instdata.mat[2], 1.0f - prb->falloff);
810 DRW_buffer_add_entry(cb->empty_cube, color_p, &instdata);
811 }
812 zero_v3(instdata.mat[2]);
813 DRW_buffer_add_entry(cb->empty_cube, color_p, &instdata);
814
815 normalize_m4_m4(instdata.mat, ob->object_to_world().ptr());
816 OVERLAY_empty_shape(cb, instdata.mat, ob->empty_drawsize, OB_SINGLE_ARROW, color_p);
817 break;
818 }
819}
820
823/* -------------------------------------------------------------------- */
828{
830 const DRWContextState *draw_ctx = DRW_context_state_get();
831 ViewLayer *view_layer = draw_ctx->view_layer;
832 float *color_p;
833 DRW_object_wire_theme_get(ob, view_layer, &color_p);
834
835 DRW_buffer_add_entry(cb->speaker, color_p, ob->object_to_world().ptr());
836}
837
840/* -------------------------------------------------------------------- */
845 /* Pack render data into object matrix and object color. */
846 struct {
847 float color[4];
848 float mat[4][4];
849 };
850 struct {
851 float _pad0[2];
853 union {
854 float depth;
855 float focus;
857 };
858 float _pad00[3];
859 union {
860 float corner_x;
862 };
863 float _pad01[3];
864 union {
865 float corner_y;
866 };
867 float _pad02[3];
868 union {
869 float center_x;
870 float clip_sta;
871 float mist_sta;
872 };
873 float pos[3];
874 union {
875 float center_y;
876 float clip_end;
877 float mist_end;
878 };
879 };
880};
881
883 OVERLAY_ExtraCallBuffers *cb, Scene *scene, View3D *v3d, Object *ob, const float color[4])
884{
885 const DRWContextState *draw_ctx = DRW_context_state_get();
886 const bool is_select = DRW_state_is_select();
887
888 MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
889 if (clip == nullptr) {
890 return;
891 }
892
893 const bool is_solid_bundle = (v3d->bundle_drawtype == OB_EMPTY_SPHERE) &&
894 ((v3d->shading.type != OB_SOLID) || !XRAY_FLAG_ENABLED(v3d));
895
896 MovieTracking *tracking = &clip->tracking;
897 /* Index must start in 1, to mimic BKE_tracking_track_get_for_selection_index. */
898 int track_index = 1;
899
900 float bundle_color_custom[4];
901 float *bundle_color_solid = G_draw.block.color_bundle_solid;
902 float *bundle_color_unselected = G_draw.block.color_wire;
903 uchar text_color_selected[4], text_color_unselected[4];
904 /* Color Management: Exception here as texts are drawn in sRGB space directly. */
905 UI_GetThemeColor4ubv(TH_SELECT, text_color_selected);
906 UI_GetThemeColor4ubv(TH_TEXT, text_color_unselected);
907
908 float camera_mat[4][4];
910
911 LISTBASE_FOREACH (MovieTrackingObject *, tracking_object, &tracking->objects) {
912 float tracking_object_mat[4][4];
913
914 if (tracking_object->flag & TRACKING_OBJECT_CAMERA) {
915 copy_m4_m4(tracking_object_mat, camera_mat);
916 }
917 else {
918 const int framenr = BKE_movieclip_remap_scene_to_clip_frame(
919 clip, DEG_get_ctime(draw_ctx->depsgraph));
920
921 float object_mat[4][4];
923 tracking, tracking_object, framenr, object_mat);
924
925 float object_imat[4][4];
926 invert_m4_m4(object_imat, object_mat);
927
928 mul_m4_m4m4(tracking_object_mat, ob->object_to_world().ptr(), object_imat);
929 }
930
931 LISTBASE_FOREACH (MovieTrackingTrack *, track, &tracking_object->tracks) {
932 if ((track->flag & TRACK_HAS_BUNDLE) == 0) {
933 continue;
934 }
935 bool is_selected = TRACK_SELECTED(track);
936
937 float bundle_mat[4][4];
938 copy_m4_m4(bundle_mat, tracking_object_mat);
939 translate_m4(bundle_mat, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
940
941 const float *bundle_color;
942 if (track->flag & TRACK_CUSTOMCOLOR) {
943 /* Meh, hardcoded srgb transform here. */
944 /* TODO: change the actual DNA color to be linear. */
945 srgb_to_linearrgb_v3_v3(bundle_color_custom, track->color);
946 bundle_color_custom[3] = 1.0;
947
948 bundle_color = bundle_color_custom;
949 }
950 else if (is_solid_bundle) {
951 bundle_color = bundle_color_solid;
952 }
953 else if (is_selected) {
954 bundle_color = color;
955 }
956 else {
957 bundle_color = bundle_color_unselected;
958 }
959
960 if (is_select) {
961 DRW_select_load_id(ob->runtime->select_id | (track_index << 16));
962 track_index++;
963 }
964
965 if (is_solid_bundle) {
966 if (is_selected) {
967 OVERLAY_empty_shape(cb, bundle_mat, v3d->bundle_size, v3d->bundle_drawtype, color);
968 }
969
970 const float bundle_color_v4[4] = {
971 bundle_color[0],
972 bundle_color[1],
973 bundle_color[2],
974 1.0f,
975 };
976
977 bundle_mat[3][3] = v3d->bundle_size; /* See shader. */
978 DRW_buffer_add_entry(cb->empty_sphere_solid, bundle_color_v4, bundle_mat);
979 }
980 else {
981 OVERLAY_empty_shape(cb, bundle_mat, v3d->bundle_size, v3d->bundle_drawtype, bundle_color);
982 }
983
984 if ((v3d->flag2 & V3D_SHOW_BUNDLENAME) && !is_select) {
986
988 bundle_mat[3],
989 track->name,
990 strlen(track->name),
991 10,
992 0,
994 is_selected ? text_color_selected : text_color_unselected);
995 }
996 }
997
998 if ((v3d->flag2 & V3D_SHOW_CAMERAPATH) && (tracking_object->flag & TRACKING_OBJECT_CAMERA) &&
999 !is_select)
1000 {
1001 const MovieTrackingReconstruction *reconstruction = &tracking_object->reconstruction;
1002
1003 if (reconstruction->camnr) {
1004 const MovieReconstructedCamera *camera = reconstruction->cameras;
1005 float v0[3], v1[3];
1006 for (int a = 0; a < reconstruction->camnr; a++, camera++) {
1007 copy_v3_v3(v0, v1);
1008 copy_v3_v3(v1, camera->mat[3]);
1009 mul_m4_v3(camera_mat, v1);
1010 if (a > 0) {
1011 /* This one is suboptimal (gl_lines instead of gl_line_strip)
1012 * but we keep this for simplicity */
1014 }
1015 }
1016 }
1017 }
1018 }
1019}
1020
1022 Object *ob,
1023 const OVERLAY_CameraInstanceData *instdata,
1024 bool right_eye)
1025{
1026 const Camera *cam = static_cast<const Camera *>(ob->data);
1028 const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
1029 const float shiftx = BKE_camera_multiview_shift_x(&scene->r, ob, viewnames[right_eye]);
1030 const float delta_shiftx = shiftx - cam->shiftx;
1031 const float width = instdata->corner_x * 2.0f;
1032 return delta_shiftx * width;
1033 }
1034
1035 return 0.0;
1036}
1042 Scene *scene,
1043 View3D *v3d,
1044 Object *ob,
1045 const OVERLAY_CameraInstanceData *instdata)
1046{
1047 OVERLAY_CameraInstanceData stereodata = *instdata;
1048 const Camera *cam = static_cast<const Camera *>(ob->data);
1049 const bool is_select = DRW_state_is_select();
1050 const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
1051
1052 const bool is_stereo3d_cameras = (v3d->stereo3d_flag & V3D_S3D_DISPCAMERAS) != 0;
1053 const bool is_stereo3d_plane = (v3d->stereo3d_flag & V3D_S3D_DISPPLANE) != 0;
1054 const bool is_stereo3d_volume = (v3d->stereo3d_flag & V3D_S3D_DISPVOLUME) != 0;
1055
1056 if (!is_stereo3d_cameras) {
1057 /* Draw single camera. */
1059 }
1060
1061 for (int eye = 0; eye < 2; eye++) {
1062 ob = BKE_camera_multiview_render(scene, ob, viewnames[eye]);
1063 BKE_camera_multiview_model_matrix(&scene->r, ob, viewnames[eye], stereodata.mat);
1064
1065 stereodata.corner_x = instdata->corner_x;
1066 stereodata.corner_y = instdata->corner_y;
1067 stereodata.center_x = instdata->center_x + camera_offaxis_shiftx_get(scene, ob, instdata, eye);
1068 stereodata.center_y = instdata->center_y;
1069 stereodata.depth = instdata->depth;
1070
1071 if (is_stereo3d_cameras) {
1072 DRW_buffer_add_entry_struct(cb->camera_frame, &stereodata);
1073
1074 /* Connecting line between cameras. */
1075 OVERLAY_extra_line_dashed(cb, stereodata.pos, instdata->pos, G_draw.block.color_wire);
1076 }
1077
1078 if (is_stereo3d_volume && !is_select) {
1079 float r = (eye == 1) ? 2.0f : 1.0f;
1080
1081 stereodata.volume_sta = -cam->clip_start;
1082 stereodata.volume_end = -cam->clip_end;
1083 /* Encode eye + intensity and alpha (see shader) */
1084 copy_v2_fl2(stereodata.color, r + 0.15f, 1.0f);
1086
1087 if (v3d->stereo3d_volume_alpha > 0.0f) {
1088 /* Encode eye + intensity and alpha (see shader) */
1089 copy_v2_fl2(stereodata.color, r + 0.999f, v3d->stereo3d_volume_alpha);
1091 }
1092 /* restore */
1093 copy_v3_v3(stereodata.color, instdata->color);
1094 }
1095 }
1096
1097 if (is_stereo3d_plane && !is_select) {
1098 if (cam->stereo.convergence_mode == CAM_S3D_TOE) {
1099 /* There is no real convergence plane but we highlight the center
1100 * point where the views are pointing at. */
1101 // zero_v3(stereodata.mat[0]); /* We reconstruct from Z and Y */
1102 // zero_v3(stereodata.mat[1]); /* Y doesn't change */
1103 zero_v3(stereodata.mat[2]);
1104 zero_v3(stereodata.mat[3]);
1105 for (int i = 0; i < 2; i++) {
1106 float mat[4][4];
1107 /* Need normalized version here. */
1108 BKE_camera_multiview_model_matrix(&scene->r, ob, viewnames[i], mat);
1109 add_v3_v3(stereodata.mat[2], mat[2]);
1110 madd_v3_v3fl(stereodata.mat[3], mat[3], 0.5f);
1111 }
1112 normalize_v3(stereodata.mat[2]);
1113 cross_v3_v3v3(stereodata.mat[0], stereodata.mat[1], stereodata.mat[2]);
1114 }
1115 else if (cam->stereo.convergence_mode == CAM_S3D_PARALLEL) {
1116 /* Show plane at the given distance between the views even if it makes no sense. */
1117 zero_v3(stereodata.pos);
1118 for (int i = 0; i < 2; i++) {
1119 float mat[4][4];
1120 BKE_camera_multiview_model_matrix_scaled(&scene->r, ob, viewnames[i], mat);
1121 madd_v3_v3fl(stereodata.pos, mat[3], 0.5f);
1122 }
1123 }
1124 else if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) {
1125 /* Nothing to do. Everything is already setup. */
1126 }
1127 stereodata.volume_sta = -cam->stereo.convergence_distance;
1128 stereodata.volume_end = -cam->stereo.convergence_distance;
1129 /* Encode eye + intensity and alpha (see shader) */
1130 copy_v2_fl2(stereodata.color, 0.1f, 1.0f);
1132
1133 if (v3d->stereo3d_convergence_alpha > 0.0f) {
1134 /* Encode eye + intensity and alpha (see shader) */
1135 copy_v2_fl2(stereodata.color, 0.0f, v3d->stereo3d_convergence_alpha);
1137 }
1138 }
1139}
1140
1142{
1145
1146 const DRWContextState *draw_ctx = DRW_context_state_get();
1147 ViewLayer *view_layer = draw_ctx->view_layer;
1148 View3D *v3d = draw_ctx->v3d;
1149 Scene *scene = draw_ctx->scene;
1150 RegionView3D *rv3d = draw_ctx->rv3d;
1151
1152 const Camera *cam = static_cast<Camera *>(ob->data);
1153 const Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera);
1154 const bool is_select = DRW_state_is_select();
1155 const bool is_active = (ob == camera_object);
1156 const bool look_through = (is_active && (rv3d->persp == RV3D_CAMOB));
1157
1158 const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
1159 const bool is_stereo3d_view = (scene->r.views_format == SCE_VIEWS_FORMAT_STEREO_3D);
1160 const bool is_stereo3d_display_extra = is_active && is_multiview && (!look_through) &&
1161 ((v3d->stereo3d_flag) != 0);
1162 const bool is_selection_camera_stereo = is_select && look_through && is_multiview &&
1163 is_stereo3d_view;
1164
1165 float vec[4][3], asp[2], shift[2], scale[3], drawsize, center[2], corner[2];
1166
1167 float *color_p;
1168 DRW_object_wire_theme_get(ob, view_layer, &color_p);
1169 copy_v4_v4(instdata.color, color_p);
1170
1171 normalize_m4_m4(instdata.mat, ob->object_to_world().ptr());
1172
1173 /* BKE_camera_multiview_model_matrix already accounts for scale, don't do it here. */
1174 if (is_selection_camera_stereo) {
1175 copy_v3_fl(scale, 1.0f);
1176 }
1177 else {
1178 copy_v3_fl3(scale,
1179 len_v3(ob->object_to_world().ptr()[0]),
1180 len_v3(ob->object_to_world().ptr()[1]),
1181 len_v3(ob->object_to_world().ptr()[2]));
1182 /* Avoid division by 0. */
1183 if (ELEM(0.0f, scale[0], scale[1], scale[2])) {
1184 return;
1185 }
1186 invert_v3(scale);
1187 }
1188
1190 scene, cam, cam->drawsize, look_through, scale, asp, shift, &drawsize, vec);
1191
1192 /* Apply scale to simplify the rest of the drawing. */
1193 invert_v3(scale);
1194 for (int i = 0; i < 4; i++) {
1195 mul_v3_v3(vec[i], scale);
1196 /* Project to z=-1 plane. Makes positioning / scaling easier. (see shader) */
1197 mul_v2_fl(vec[i], 1.0f / fabsf(vec[i][2]));
1198 }
1199
1200 /* Frame coords */
1201 mid_v2_v2v2(center, vec[0], vec[2]);
1202 sub_v2_v2v2(corner, vec[0], center);
1203 instdata.corner_x = corner[0];
1204 instdata.corner_y = corner[1];
1205 instdata.center_x = center[0];
1206 instdata.center_y = center[1];
1207 instdata.depth = vec[0][2];
1208
1209 if (look_through) {
1211 /* Only draw the frame. */
1212 if (is_multiview) {
1213 float mat[4][4];
1214 const bool is_right = v3d->multiview_eye == STEREO_RIGHT_ID;
1215 const char *view_name = is_right ? STEREO_RIGHT_NAME : STEREO_LEFT_NAME;
1216 BKE_camera_multiview_model_matrix(&scene->r, ob, view_name, mat);
1217 instdata.center_x += camera_offaxis_shiftx_get(scene, ob, &instdata, is_right);
1218 for (int i = 0; i < 4; i++) {
1219 /* Partial copy to avoid overriding packed data. */
1220 copy_v3_v3(instdata.mat[i], mat[i]);
1221 }
1222 }
1223 instdata.depth = -instdata.depth; /* Hides the back of the camera wires (see shader). */
1225 }
1226 }
1227 else {
1228 /* Stereo cameras, volumes, plane drawing. */
1229 if (is_stereo3d_display_extra) {
1230 camera_stereoscopy_extra(cb, scene, v3d, ob, &instdata);
1231 }
1232 else {
1234 }
1235 }
1236
1237 if (!look_through) {
1238 /* Triangle. */
1239 float tria_size = 0.7f * drawsize / fabsf(instdata.depth);
1240 float tria_margin = 0.1f * drawsize / fabsf(instdata.depth);
1241 instdata.center_x = center[0];
1242 instdata.center_y = center[1] + instdata.corner_y + tria_margin + tria_size;
1243 instdata.corner_x = instdata.corner_y = -tria_size;
1244 DRW_buffer_add_entry_struct(cb->camera_tria[is_active], &instdata);
1245 }
1246
1247 if (cam->flag & CAM_SHOWLIMITS) {
1248 /* Scale focus point. */
1249 mul_v3_fl(instdata.mat[0], cam->drawsize);
1250 mul_v3_fl(instdata.mat[1], cam->drawsize);
1251
1252 instdata.dist_color_id = (is_active) ? 3 : 2;
1253 instdata.focus = -BKE_camera_object_dof_distance(ob);
1254 instdata.clip_sta = cam->clip_start;
1255 instdata.clip_end = cam->clip_end;
1257 }
1258
1259 if (cam->flag & CAM_SHOWMIST) {
1260 World *world = scene->world;
1261 if (world) {
1262 instdata.dist_color_id = (is_active) ? 1 : 0;
1263 instdata.focus = 1.0f; /* Disable */
1264 instdata.mist_sta = world->miststa;
1265 instdata.mist_end = world->miststa + world->mistdist;
1267 }
1268 }
1269
1270 /* Motion Tracking. */
1271 if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) != 0) {
1272 camera_view3d_reconstruction(cb, scene, v3d, ob, color_p);
1273 }
1274
1275 /* Background images. */
1276 if (look_through && (cam->flag & CAM_SHOW_BG_IMAGE) && !BLI_listbase_is_empty(&cam->bg_images)) {
1278 }
1279}
1280
1283/* -------------------------------------------------------------------- */
1288 Depsgraph *depsgraph,
1289 Scene *scene,
1290 Object *ob)
1291{
1292 float *relation_color = G_draw.block.color_wire;
1293 float *constraint_color = G_draw.block.color_grid_axis_z; /* ? */
1294
1296 float *parent_pos = ob->runtime->parent_display_origin;
1297 OVERLAY_extra_line_dashed(cb, parent_pos, ob->object_to_world().location(), relation_color);
1298 }
1299
1300 /* Drawing the hook lines. */
1302 if (md->type == eModifierType_Hook) {
1304 float center[3];
1305 mul_v3_m4v3(center, ob->object_to_world().ptr(), hmd->cent);
1306 if (hmd->object) {
1308 cb, hmd->object->object_to_world().location(), center, relation_color);
1309 }
1310 OVERLAY_extra_point(cb, center, relation_color);
1311 }
1312 }
1314 if (md->type == eGpencilModifierType_Hook) {
1316 float center[3];
1317 mul_v3_m4v3(center, ob->object_to_world().ptr(), hmd->cent);
1318 if (hmd->object) {
1320 cb, hmd->object->object_to_world().location(), center, relation_color);
1321 }
1322 OVERLAY_extra_point(cb, center, relation_color);
1323 }
1324 }
1325
1326 if (ob->rigidbody_constraint) {
1327 Object *rbc_ob1 = ob->rigidbody_constraint->ob1;
1328 Object *rbc_ob2 = ob->rigidbody_constraint->ob2;
1329 if (rbc_ob1 && (DRW_object_visibility_in_active_context(rbc_ob1) & OB_VISIBLE_SELF)) {
1331 rbc_ob1->object_to_world().location(),
1332 ob->object_to_world().location(),
1333 relation_color);
1334 }
1335 if (rbc_ob2 && (DRW_object_visibility_in_active_context(rbc_ob2) & OB_VISIBLE_SELF)) {
1337 rbc_ob2->object_to_world().location(),
1338 ob->object_to_world().location(),
1339 relation_color);
1340 }
1341 }
1342
1343 /* Drawing the constraint lines */
1345 ListBase *list = &ob->constraints;
1347 depsgraph, scene, ob, nullptr, CONSTRAINT_OBTYPE_OBJECT);
1348
1349 LISTBASE_FOREACH (bConstraint *, curcon, list) {
1351 /* special case for object solver and follow track constraints because they don't fill
1352 * constraint targets properly (design limitation -- scene is needed for their target
1353 * but it can't be accessed from get_targets callback) */
1354 Object *camob = nullptr;
1355
1356 if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
1357 bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data;
1358 camob = data->camera ? data->camera : scene->camera;
1359 }
1360 else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
1361 bObjectSolverConstraint *data = (bObjectSolverConstraint *)curcon->data;
1362 camob = data->camera ? data->camera : scene->camera;
1363 }
1364
1365 if (camob) {
1367 camob->object_to_world().location(),
1368 ob->object_to_world().location(),
1369 constraint_color);
1370 }
1371 }
1372 else {
1374 ListBase targets = {nullptr, nullptr};
1375
1376 if ((curcon->ui_expand_flag & (1 << 0)) && BKE_constraint_targets_get(curcon, &targets)) {
1378
1379 LISTBASE_FOREACH (bConstraintTarget *, ct, &targets) {
1380 /* calculate target's matrix */
1381 if (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE) {
1382 copy_m4_m4(ct->matrix, cob->space_obj_world_matrix);
1383 }
1384 else if (cti->get_target_matrix) {
1385 cti->get_target_matrix(depsgraph, curcon, cob, ct, DEG_get_ctime(depsgraph));
1386 }
1387 else {
1388 unit_m4(ct->matrix);
1389 }
1391 cb, ct->matrix[3], ob->object_to_world().location(), constraint_color);
1392 }
1393
1394 BKE_constraint_targets_flush(curcon, &targets, true);
1395 }
1396 }
1397 }
1398 /* NOTE: Don't use #BKE_constraints_clear_evalob here as that will reset `ob->constinv`. */
1399 MEM_freeN(cob);
1400 }
1401}
1402
1405/* -------------------------------------------------------------------- */
1410 OVERLAY_Data *data,
1411 Object *ob,
1412 ModifierData *md,
1413 Scene *scene,
1414 const float *color)
1415{
1417 FluidDomainSettings *fds = fmd->domain;
1418
1419 /* Don't show smoke before simulation starts, this could be made an option in the future. */
1420 const bool draw_velocity = (fds->draw_velocity && fds->fluid &&
1421 scene->r.cfra >= fds->point_cache[0]->startframe);
1422
1423 /* Show gridlines only for slices with no interpolation. */
1424 const bool show_gridlines = (fds->show_gridlines && fds->fluid &&
1428
1429 const bool color_with_flags = (fds->gridlines_color_field == FLUID_GRIDLINE_COLOR_TYPE_FLAGS);
1430
1431 const bool color_range = (fds->gridlines_color_field == FLUID_GRIDLINE_COLOR_TYPE_RANGE &&
1433
1434 /* Small cube showing voxel size. */
1435 {
1436 float min[3];
1437 madd_v3fl_v3fl_v3fl_v3i(min, fds->p0, fds->cell_size, fds->res_min);
1438 float voxel_cubemat[4][4] = {{0.0f}};
1439 /* scale small cube to voxel size */
1440 voxel_cubemat[0][0] = fds->cell_size[0] / 2.0f;
1441 voxel_cubemat[1][1] = fds->cell_size[1] / 2.0f;
1442 voxel_cubemat[2][2] = fds->cell_size[2] / 2.0f;
1443 voxel_cubemat[3][3] = 1.0f;
1444 /* translate small cube to corner */
1445 copy_v3_v3(voxel_cubemat[3], min);
1446 /* move small cube into the domain (otherwise its centered on vertex of domain object) */
1447 translate_m4(voxel_cubemat, 1.0f, 1.0f, 1.0f);
1448 mul_m4_m4m4(voxel_cubemat, ob->object_to_world().ptr(), voxel_cubemat);
1449
1450 DRW_buffer_add_entry(cb->empty_cube, color, voxel_cubemat);
1451 }
1452
1453 int slice_axis = -1;
1454
1456 float viewinv[4][4];
1457 DRW_view_viewmat_get(nullptr, viewinv, true);
1458
1459 const int axis = (fds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) :
1460 fds->slice_axis - 1;
1461 slice_axis = axis;
1462 }
1463
1464 if (draw_velocity) {
1465 const bool use_needle = (fds->vector_draw_type == VECTOR_DRAW_NEEDLE);
1466 const bool use_mac = (fds->vector_draw_type == VECTOR_DRAW_MAC);
1467 const bool draw_mac_x = (fds->vector_draw_mac_components & VECTOR_DRAW_MAC_X);
1468 const bool draw_mac_y = (fds->vector_draw_mac_components & VECTOR_DRAW_MAC_Y);
1469 const bool draw_mac_z = (fds->vector_draw_mac_components & VECTOR_DRAW_MAC_Z);
1470 const bool cell_centered = (fds->vector_field == FLUID_DOMAIN_VECTOR_FIELD_FORCE);
1471 int line_count = 1;
1472 if (use_needle) {
1473 line_count = 6;
1474 }
1475 else if (use_mac) {
1476 line_count = 3;
1477 }
1478 line_count *= fds->res[0] * fds->res[1] * fds->res[2];
1479
1481 line_count /= fds->res[slice_axis];
1482 }
1483
1485
1486 GPUShader *sh = OVERLAY_shader_volume_velocity(use_needle, use_mac);
1487 DRWShadingGroup *grp = DRW_shgroup_create(sh, data->psl->extra_ps[0]);
1488 DRW_shgroup_uniform_texture(grp, "velocityX", fds->tex_velocity_x);
1489 DRW_shgroup_uniform_texture(grp, "velocityY", fds->tex_velocity_y);
1490 DRW_shgroup_uniform_texture(grp, "velocityZ", fds->tex_velocity_z);
1491 DRW_shgroup_uniform_float_copy(grp, "displaySize", fds->vector_scale);
1492 DRW_shgroup_uniform_float_copy(grp, "slicePosition", fds->slice_depth);
1493 DRW_shgroup_uniform_vec3_copy(grp, "cellSize", fds->cell_size);
1494 DRW_shgroup_uniform_vec3_copy(grp, "domainOriginOffset", fds->p0);
1495 DRW_shgroup_uniform_ivec3_copy(grp, "adaptiveCellOffset", fds->res_min);
1496 DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis);
1497 DRW_shgroup_uniform_bool_copy(grp, "scaleWithMagnitude", fds->vector_scale_with_magnitude);
1498 DRW_shgroup_uniform_bool_copy(grp, "isCellCentered", cell_centered);
1499
1500 if (use_mac) {
1501 DRW_shgroup_uniform_bool_copy(grp, "drawMACX", draw_mac_x);
1502 DRW_shgroup_uniform_bool_copy(grp, "drawMACY", draw_mac_y);
1503 DRW_shgroup_uniform_bool_copy(grp, "drawMACZ", draw_mac_z);
1504 }
1505
1506 DRW_shgroup_call_procedural_lines(grp, ob, line_count);
1507 }
1508
1509 if (show_gridlines) {
1510 GPUShader *sh = OVERLAY_shader_volume_gridlines(color_with_flags, color_range);
1511 DRWShadingGroup *grp = DRW_shgroup_create(sh, data->psl->extra_ps[0]);
1512 DRW_shgroup_uniform_ivec3_copy(grp, "volumeSize", fds->res);
1513 DRW_shgroup_uniform_float_copy(grp, "slicePosition", fds->slice_depth);
1514 DRW_shgroup_uniform_vec3_copy(grp, "cellSize", fds->cell_size);
1515 DRW_shgroup_uniform_vec3_copy(grp, "domainOriginOffset", fds->p0);
1516 DRW_shgroup_uniform_ivec3_copy(grp, "adaptiveCellOffset", fds->res_min);
1517 DRW_shgroup_uniform_int_copy(grp, "sliceAxis", slice_axis);
1518
1519 if (color_with_flags || color_range) {
1521 DRW_shgroup_uniform_texture(grp, "flagTexture", fds->tex_flags);
1522 }
1523
1524 if (color_range) {
1526 DRW_shgroup_uniform_texture(grp, "fieldTexture", fds->tex_range_field);
1530 DRW_shgroup_uniform_int_copy(grp, "cellFilter", fds->gridlines_cell_filter);
1531 }
1532
1533 const int line_count = 4 * fds->res[0] * fds->res[1] * fds->res[2] / fds->res[slice_axis];
1534 DRW_shgroup_call_procedural_lines(grp, ob, line_count);
1535 }
1536
1537 if (draw_velocity || show_gridlines) {
1538 }
1539}
1540
1543/* -------------------------------------------------------------------- */
1544
1546 Object *ob,
1548 const Scene *scene,
1549 ViewLayer *view_layer)
1550{
1551 const bool is_library = ID_REAL_USERS(&ob->id) > 1 || ID_IS_LINKED(ob);
1552 BKE_view_layer_synced_ensure(scene, view_layer);
1553 if (ob == BKE_view_layer_active_object_get(view_layer)) {
1554 DRW_buffer_add_entry(cb->center_active, ob->object_to_world().location());
1555 }
1556 else if (ob->base_flag & BASE_SELECTED) {
1557 DRWCallBuffer *cbuf = (is_library) ? cb->center_selected_lib : cb->center_selected;
1558 DRW_buffer_add_entry(cbuf, ob->object_to_world().location());
1559 }
1560 else if (pd->v3d_flag & V3D_DRAW_CENTERS) {
1561 DRWCallBuffer *cbuf = (is_library) ? cb->center_deselected_lib : cb->center_deselected;
1562 DRW_buffer_add_entry(cbuf, ob->object_to_world().location());
1563 }
1564}
1565
1566static void OVERLAY_object_name(Object *ob, int theme_id)
1567{
1569 uchar color[4];
1570 /* Color Management: Exception here as texts are drawn in sRGB space directly. */
1571 UI_GetThemeColor4ubv(theme_id, color);
1572
1574 ob->object_to_world().location(),
1575 ob->id.name + 2,
1576 strlen(ob->id.name + 2),
1577 10,
1578 0,
1580 color);
1581}
1582
1584{
1586 OVERLAY_PrivateData *pd = vedata->stl->pd;
1587 const DRWContextState *draw_ctx = DRW_context_state_get();
1588 ViewLayer *view_layer = draw_ctx->view_layer;
1589 Scene *scene = draw_ctx->scene;
1590 ModifierData *md = nullptr;
1591
1592 const bool is_select_mode = DRW_state_is_select();
1593 const bool is_paint_mode = (draw_ctx->object_mode &
1595 OB_MODE_SCULPT_CURVES)) != 0;
1596 const bool from_dupli = (ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI)) != 0;
1597 const bool has_bounds = !ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_EMPTY, OB_SPEAKER, OB_LIGHTPROBE);
1598 const bool has_texspace = has_bounds &&
1600
1601 const bool draw_relations = ((pd->v3d_flag & V3D_HIDE_HELPLINES) == 0) && !is_select_mode;
1602 const bool draw_obcenters = !is_paint_mode &&
1604 const bool draw_texspace = (ob->dtx & OB_TEXSPACE) && has_texspace;
1605 const bool draw_obname = (ob->dtx & OB_DRAWNAME) && DRW_state_show_text();
1606 const bool draw_bounds = has_bounds && ((ob->dt == OB_BOUNDBOX) ||
1607 ((ob->dtx & OB_DRAWBOUNDOX) && !from_dupli));
1608 const bool draw_xform = draw_ctx->object_mode == OB_MODE_OBJECT &&
1609 (scene->toolsettings->transform_flag & SCE_XFORM_DATA_ORIGIN) &&
1610 (ob->base_flag & BASE_SELECTED) && !is_select_mode;
1611 /* Don't show fluid domain overlay extras outside of cache range. */
1612 const bool draw_volume = !from_dupli &&
1615 (((FluidModifierData *)md)->domain != nullptr) &&
1616 (scene->r.cfra >=
1617 (((FluidModifierData *)md)->domain->cache_frame_start)) &&
1618 (scene->r.cfra <= (((FluidModifierData *)md)->domain->cache_frame_end));
1619
1620 float *color;
1621 int theme_id = DRW_object_wire_theme_get(ob, view_layer, &color);
1622
1623 if (ob->pd && ob->pd->forcefield) {
1624 OVERLAY_forcefield(cb, ob, view_layer);
1625 }
1626
1627 if (draw_bounds) {
1628 OVERLAY_bounds(cb, ob, color, ob->boundtype, false);
1629 }
1630 /* Helpers for when we're transforming origins. */
1631 if (draw_xform) {
1632 const float color_xform[4] = {0.15f, 0.15f, 0.15f, 0.7f};
1633 DRW_buffer_add_entry(cb->origin_xform, color_xform, ob->object_to_world().ptr());
1634 }
1635 /* don't show object extras in set's */
1636 if (!from_dupli) {
1637 if (draw_obcenters) {
1638 OVERLAY_object_center(cb, ob, pd, scene, view_layer);
1639 }
1640 if (draw_relations) {
1641 OVERLAY_relationship_lines(cb, draw_ctx->depsgraph, draw_ctx->scene, ob);
1642 }
1643 if (draw_obname) {
1644 OVERLAY_object_name(ob, theme_id);
1645 }
1646 if (draw_texspace) {
1647 OVERLAY_texture_space(cb, ob, color);
1648 }
1649 if (ob->rigidbody_object != nullptr) {
1650 OVERLAY_collision(cb, ob, color);
1651 }
1652 if (ob->dtx & OB_AXIS) {
1653 DRW_buffer_add_entry(cb->empty_axes, color, ob->object_to_world().ptr());
1654 }
1655 if (draw_volume) {
1656 OVERLAY_volume_extra(cb, vedata, ob, md, scene, color);
1657 }
1658 }
1659}
1660
1665
1667{
1668 DRW_draw_pass(vedata->psl->extra_ps[0]);
1669}
1670
1672{
1673 DRW_draw_pass(vedata->psl->extra_ps[1]);
1674}
1675
1677{
1678 OVERLAY_PassList *psl = vedata->psl;
1679
1682}
bool BKE_where_on_path(const struct Object *ob, float ctime, float r_vec[4], float r_dir[3], float r_quat[4], float *r_radius, float *r_weight)
Camera data-block and utility functions.
float BKE_camera_multiview_shift_x(const struct RenderData *rd, const struct Object *camera, const char *viewname)
float BKE_camera_object_dof_distance(const struct Object *ob)
struct Object * BKE_camera_multiview_render(const struct Scene *scene, struct Object *camera, const char *viewname)
void BKE_camera_multiview_model_matrix(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4])
void BKE_camera_multiview_model_matrix_scaled(const struct RenderData *rd, const struct Object *camera, const char *viewname, float r_modelmat[4][4])
void BKE_camera_view_frame_ex(const struct Scene *scene, const struct Camera *camera, float drawsize, bool do_clip, const float scale[3], float r_asp[2], float r_shift[2], float *r_drawsize, float r_vec[4][3])
void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targets, bool no_copy)
int BKE_constraint_targets_get(struct bConstraint *con, struct ListBase *r_targets)
void BKE_constraint_custom_object_space_init(struct bConstraintOb *cob, struct bConstraint *con)
const bConstraintTypeInfo * BKE_constraint_typeinfo_get(struct bConstraint *con)
struct bConstraintOb * BKE_constraints_make_evalob(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, void *subdata, short datatype)
void BKE_curve_texspace_ensure(Curve *cu)
Definition curve.cc:500
@ G_TRANSFORM_OBJ
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
bool BKE_mball_is_basis(const Object *ob)
Definition mball.cc:230
void BKE_mesh_texspace_get_reference(Mesh *mesh, char **r_texspace_flag, float **r_texspace_location, float **r_texspace_size)
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
float BKE_movieclip_remap_scene_to_clip_frame(const struct MovieClip *clip, float framenr)
General operations, lookup, etc. for blender objects.
MovieClip * BKE_object_movieclip_get(Scene *scene, const Object *ob, bool use_default)
@ OB_VISIBLE_SELF
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
void BKE_tracking_get_camera_object_matrix(const struct Object *camera_object, float mat[4][4])
#define TRACK_SELECTED(track)
void BKE_tracking_camera_get_reconstructed_interpolate(struct MovieTracking *tracking, struct MovieTrackingObject *tracking_object, float framenr, float mat[4][4])
Definition tracking.cc:2146
#define BLI_assert(a)
Definition BLI_assert.h:50
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_fff(float a, float b, float c)
MINLINE float max_ff(float a, float b)
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
MINLINE int axis_dominant_v3_single(const float vec[3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void normalize_m4_m4(float rmat[4][4], const float mat[4][4]) ATTR_NONNULL()
void unit_m4(float m[4][4])
Definition rct.c:1127
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void rescale_m4(float mat[4][4], const float scale[3])
void size_to_mat4(float R[4][4], const float size[3])
void mul_m4_v3(const float M[4][4], float r[3])
void scale_m4_fl(float R[4][4], float scale)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
#define DEG2RADF(_deg)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE void madd_v3fl_v3fl_v3fl_v3i(float r[3], const float a[3], const float b[3], const int c[3])
MINLINE void mul_v3_v3(float r[3], const float a[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void negate_v3(float r[3])
MINLINE void invert_v3(float r[3])
void mid_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void swap_v3_v3(float a[3], float b[3])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3_length(float n[3], float unit_length)
MINLINE float normalize_v3(float n[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
unsigned char uchar
unsigned int uint
#define UNPACK3(a)
#define ELEM(...)
float DEG_get_ctime(const Depsgraph *graph)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:654
#define ID_REAL_USERS(id)
Definition DNA_ID.h:637
@ ID_VO
@ ID_CV
@ ID_CU_LEGACY
@ ID_ME
@ ID_MB
@ ID_PT
@ CAM_S3D_PARALLEL
@ CAM_S3D_OFFAXIS
@ CAM_S3D_TOE
@ CAM_SHOWLIMITS
@ CAM_SHOW_BG_IMAGE
@ CAM_SHOWMIST
@ CONSTRAINT_TAR_CUSTOM_SPACE
@ CONSTRAINT_TYPE_FOLLOWTRACK
@ CONSTRAINT_TYPE_OBJECTSOLVER
@ CONSTRAINT_OBTYPE_OBJECT
@ CU_PATH
@ AXIS_SLICE_SINGLE
@ FLUID_DOMAIN_FIELD_FLAGS
@ VECTOR_DRAW_MAC_X
@ VECTOR_DRAW_MAC_Y
@ VECTOR_DRAW_MAC_Z
@ FLUID_DISPLAY_INTERP_CLOSEST
@ SLICE_AXIS_AUTO
@ VECTOR_DRAW_NEEDLE
@ VECTOR_DRAW_MAC
@ FLUID_GRIDLINE_COLOR_TYPE_FLAGS
@ FLUID_GRIDLINE_COLOR_TYPE_RANGE
@ FLUID_DOMAIN_VECTOR_FIELD_FORCE
@ eGpencilModifierType_Hook
@ BASE_FROM_DUPLI
@ BASE_FROM_SET
@ LA_SHOW_CONE
@ LA_AREA
@ LA_LOCAL
@ LA_SPOT
@ LA_SUN
@ LA_AREA_ELLIPSE
@ LA_AREA_SQUARE
@ LA_AREA_RECT
@ LIGHTPROBE_SHAPE_BOX
@ LIGHTPROBE_FLAG_SHOW_PARALLAX
@ LIGHTPROBE_FLAG_SHOW_CLIP_DIST
@ LIGHTPROBE_FLAG_SHOW_INFLUENCE
@ LIGHTPROBE_FLAG_SHOW_DATA
@ LIGHTPROBE_FLAG_CUSTOM_PARALLAX
@ LIGHTPROBE_TYPE_PLANE
@ LIGHTPROBE_TYPE_VOLUME
@ LIGHTPROBE_TYPE_SPHERE
@ eModifierMode_Realtime
@ eModifierType_Fluid
@ eModifierType_Hook
#define OB_MODE_ALL_PAINT
@ OB_BOUNDBOX
@ OB_SOLID
#define OB_MODE_ALL_PAINT_GPENCIL
@ OB_MODE_SCULPT_CURVES
@ OB_MODE_OBJECT
@ PFIELD_FALL_SPHERE
@ OB_SPEAKER
@ OB_LATTICE
@ OB_MBALL
@ OB_EMPTY
@ OB_CAMERA
@ OB_ARMATURE
@ OB_LAMP
@ OB_CURVES_LEGACY
@ OB_GPENCIL_LEGACY
@ OB_LIGHTPROBE
@ OB_DRAWNAME
@ OB_DRAWBOUNDOX
@ OB_AXIS
@ OB_DRAW_IN_FRONT
@ OB_TEXSPACE
@ OB_DUPLICOLLECTION
@ OB_EMPTY_CONE
@ OB_SINGLE_ARROW
@ OB_PLAINAXES
@ OB_ARROWS
@ OB_CIRCLE
@ OB_CUBE
@ OB_EMPTY_IMAGE
@ OB_EMPTY_SPHERE
@ OB_BOUND_CAPSULE
@ OB_BOUND_SPHERE
@ OB_BOUND_CONE
@ OB_BOUND_BOX
@ OB_BOUND_CYLINDER
Types and defines for representing Rigid Body entities.
@ RB_SHAPE_CAPSULE
@ RB_SHAPE_BOX
@ RB_SHAPE_SPHERE
@ RB_SHAPE_CYLINDER
@ RB_SHAPE_CONE
#define STEREO_LEFT_NAME
#define BASE_SELECTED(v3d, base)
@ SCE_XFORM_DATA_ORIGIN
@ R_MULTIVIEW
@ SCE_VIEWS_FORMAT_STEREO_3D
#define STEREO_RIGHT_NAME
@ STEREO_RIGHT_ID
@ TRACK_CUSTOMCOLOR
@ TRACK_HAS_BUNDLE
@ TRACKING_OBJECT_CAMERA
@ V3D_OVERLAY_HIDE_OBJECT_ORIGINS
@ V3D_OVERLAY_SHOW_LIGHT_COLORS
@ RV3D_CAMOB
@ V3D_SHOW_BUNDLENAME
@ V3D_SHOW_CAMERAPATH
@ V3D_SHOW_RECONSTRUCTION
@ V3D_DRAW_CENTERS
@ V3D_HIDE_HELPLINES
@ V3D_S3D_DISPCAMERAS
@ V3D_S3D_DISPPLANE
@ V3D_S3D_DISPVOLUME
#define DRW_buffer_add_entry(buffer,...)
#define DRW_PASS_CREATE(pass, state)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
#define DRW_shgroup_call_obmat(shgroup, geom, obmat)
#define XRAY_FLAG_ENABLED(v3d)
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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves 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 Invert a color
@ TH_CAMERA_PATH
@ TH_SELECT
@ TH_TEXT
@ TH_ACTIVE
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
struct GPUShader GPUShader
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
Definition btDbvt.cpp:299
local_group_size(16, 16) .push_constant(Type b
const Depsgraph * depsgraph
#define sinf(x)
#define cosf(x)
#define fabsf(x)
#define sqrtf(x)
blender::gpu::Batch * DRW_cache_groundline_get()
blender::gpu::Batch * DRW_cache_field_sphere_limit_get()
blender::gpu::Batch * DRW_cache_lightprobe_cube_get()
blender::gpu::Batch * DRW_cache_light_icon_outer_lines_get()
blender::gpu::Batch * DRW_cache_field_vortex_get()
blender::gpu::Batch * DRW_cache_camera_volume_get()
blender::gpu::Batch * DRW_cache_empty_cube_get()
blender::gpu::Batch * DRW_cache_lightprobe_grid_get()
blender::gpu::Batch * DRW_cache_light_point_lines_get()
blender::gpu::Batch * DRW_cache_light_spot_lines_get()
blender::gpu::Batch * DRW_cache_field_force_get()
blender::gpu::Batch * DRW_cache_circle_get()
blender::gpu::Batch * DRW_cache_sphere_get(const eDRWLevelOfDetail level_of_detail)
blender::gpu::Batch * DRW_cache_camera_volume_wire_get()
blender::gpu::Batch * DRW_cache_light_area_square_lines_get()
blender::gpu::Batch * DRW_cache_field_cone_limit_get()
blender::gpu::Batch * DRW_cache_light_sun_lines_get()
blender::gpu::Batch * DRW_cache_empty_sphere_get()
blender::gpu::Batch * DRW_cache_light_icon_sun_rays_get()
blender::gpu::Batch * DRW_cache_field_curve_get()
blender::gpu::Batch * DRW_cache_field_wind_get()
blender::gpu::Batch * DRW_cache_bone_arrows_get()
blender::gpu::Batch * DRW_cache_single_arrow_get()
blender::gpu::Batch * DRW_cache_light_icon_inner_lines_get()
blender::gpu::Batch * DRW_cache_lightprobe_planar_get()
blender::gpu::Batch * DRW_cache_quad_get()
blender::gpu::Batch * DRW_cache_speaker_get()
blender::gpu::Batch * DRW_cache_camera_distances_get()
blender::gpu::Batch * DRW_cache_light_area_disk_lines_get()
blender::gpu::Batch * DRW_cache_camera_tria_wire_get()
blender::gpu::Batch * DRW_cache_quad_wires_get()
blender::gpu::Batch * DRW_cache_camera_frame_get()
blender::gpu::Batch * DRW_cache_light_spot_volume_get()
blender::gpu::Batch * DRW_cache_empty_cylinder_get()
blender::gpu::Batch * DRW_cache_empty_capsule_body_get()
blender::gpu::Batch * DRW_cache_camera_tria_get()
blender::gpu::Batch * DRW_cache_plain_axes_get()
blender::gpu::Batch * DRW_cache_field_tube_limit_get()
blender::gpu::Batch * DRW_cache_empty_cone_get()
blender::gpu::Batch * DRW_cache_empty_capsule_cap_get()
@ DRW_LOD_LOW
Definition draw_cache.hh:33
int DRW_object_wire_theme_get(Object *ob, ViewLayer *view_layer, float **r_color)
DRW_Global G_draw
float * DRW_color_background_blend_get(int theme_id)
void DRW_fluid_ensure_flags(FluidModifierData *fmd)
void DRW_fluid_ensure_range_field(FluidModifierData *fmd)
void DRW_smoke_ensure_velocity(FluidModifierData *fmd)
bool DRW_state_show_text()
DRWTextStore * DRW_text_cache_ensure()
int DRW_object_visibility_in_active_context(const Object *ob)
bool DRW_state_is_image_render()
DefaultTextureList * DRW_viewport_texture_list_get()
const DRWContextState * DRW_context_state_get()
bool DRW_state_is_fbo()
bool DRW_state_is_select()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_uniform_ivec3_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
void DRW_buffer_add_entry_struct(DRWCallBuffer *callbuf, const void *data)
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state)
void DRW_shgroup_uniform_vec3_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup, const Object *ob, uint point_count)
void DRW_shgroup_call_procedural_lines(DRWShadingGroup *shgroup, const Object *ob, uint line_count)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_shgroup_uniform_mat4_copy(DRWShadingGroup *shgroup, const char *name, const float(*value)[4])
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_draw_pass(DRWPass *pass)
void DRW_select_load_id(uint id)
void DRW_text_cache_add(DRWTextStore *dt, const float co[3], const char *str, const int str_len, short xoffs, short yoffs, short flag, const uchar col[4], const bool shadow, const bool align_center)
@ DRW_TEXT_CACHE_GLOBALSPACE
@ DRW_TEXT_CACHE_STRING_PTR
DRWState
Definition draw_state.hh:25
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:55
@ DRW_STATE_CULL_FRONT
Definition draw_state.hh:44
@ DRW_STATE_IN_FRONT_SELECT
Definition draw_state.hh:67
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:29
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:38
@ DRW_STATE_CULL_BACK
Definition draw_state.hh:43
@ DRW_STATE_DEPTH_ALWAYS
Definition draw_state.hh:36
uint col
const ProjectiveReconstruction & reconstruction
Definition intersect.cc:198
#define GS(x)
Definition iris.cc:202
format
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
ccl_device_inline float reduce_max(const float2 a)
static ulong state[N]
#define G(x, y, z)
T midpoint(const T &a, const T &b)
void OVERLAY_extra_wire(OVERLAY_ExtraCallBuffers *cb, blender::gpu::Batch *geom, const float mat[4][4], const float color[4])
OVERLAY_ExtraCallBuffers * OVERLAY_extra_call_buffer_get(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_empty_shape(OVERLAY_ExtraCallBuffers *cb, const float mat[4][4], const float draw_size, const char draw_type, const float color[4])
static void camera_view3d_reconstruction(OVERLAY_ExtraCallBuffers *cb, Scene *scene, View3D *v3d, Object *ob, const float color[4])
static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLayer *view_layer)
void OVERLAY_extra_centers_draw(OVERLAY_Data *vedata)
void OVERLAY_extra_in_front_draw(OVERLAY_Data *vedata)
static void OVERLAY_collision(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color)
#define BUF_INSTANCE
void OVERLAY_extra_cache_init(OVERLAY_Data *vedata)
void OVERLAY_extra_line(OVERLAY_ExtraCallBuffers *cb, const float start[3], const float end[3], const int color_id)
void OVERLAY_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
static void OVERLAY_object_name(Object *ob, int theme_id)
void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_extra_line_dashed(OVERLAY_ExtraCallBuffers *cb, const float start[3], const float end[3], const float color[4])
static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, Depsgraph *depsgraph, Scene *scene, Object *ob)
static void camera_stereoscopy_extra(OVERLAY_ExtraCallBuffers *cb, Scene *scene, View3D *v3d, Object *ob, const OVERLAY_CameraInstanceData *instdata)
#define BUF_POINT(grp, format)
#define BUF_LINE(grp, format)
void OVERLAY_extra_point(OVERLAY_ExtraCallBuffers *cb, const float point[3], const float color[4])
static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color, char boundtype, bool around_origin)
static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, OVERLAY_Data *data, Object *ob, ModifierData *md, Scene *scene, const float *color)
static void OVERLAY_object_center(OVERLAY_ExtraCallBuffers *cb, Object *ob, OVERLAY_PrivateData *pd, const Scene *scene, ViewLayer *view_layer)
void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob)
static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color)
void OVERLAY_extra_loose_points(OVERLAY_ExtraCallBuffers *cb, blender::gpu::Batch *geom, const float mat[4][4], const float color[4])
static float camera_offaxis_shiftx_get(Scene *scene, Object *ob, const OVERLAY_CameraInstanceData *instdata, bool right_eye)
void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_extra_blend_draw(OVERLAY_Data *vedata)
void OVERLAY_extra_draw(OVERLAY_Data *vedata)
void OVERLAY_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_speaker_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob)
GPUShader * OVERLAY_shader_extra_wire(bool use_object, bool is_select)
GPUShader * OVERLAY_shader_volume_gridlines(bool color_with_flags, bool color_range)
GPUShader * OVERLAY_shader_extra_grid()
GPUShader * OVERLAY_shader_volume_velocity(bool use_needle, bool use_mac)
GPUShader * OVERLAY_shader_extra_point()
GPUShader * OVERLAY_shader_extra_loose_point()
GPUShader * OVERLAY_shader_extra(bool is_select)
BLI_INLINE void pack_v4_in_mat4(float rmat[4][4], const float mat[4][4], const float v[4])
OVERLAY_InstanceFormats * OVERLAY_shader_instance_formats_get()
GPUShader * OVERLAY_shader_extra_groundline()
BLI_INLINE void pack_fl_in_mat4(float rmat[4][4], const float mat[4][4], float a)
#define min(a, b)
Definition sort.c:32
float clip_end
struct ListBase bg_images
struct CameraStereoSettings stereo
float clip_start
float drawsize
float texspace_size[3]
float texspace_location[3]
ViewLayer * view_layer
Depsgraph * depsgraph
eObjectMode object_mode
RegionView3D * rv3d
GlobalsUboStorage block
GPUUniformBuf * block_ubo
struct GPUTexture * tex_range_field
struct GPUTexture * tex_velocity_x
struct GPUTexture * tex_velocity_y
struct GPUTexture * tex_velocity_z
struct PointCache * point_cache[2]
struct GPUTexture * tex_flags
struct FluidDomainSettings * domain
struct Object * object
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
float att_dist
float area_sizey
short area_shape
float clipsta
float spotblend
float spotsize
float radius
float area_size
short type
float texspace_size[3]
float texspace_location[3]
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
OVERLAY_TextureList * txl
DRWCallBuffer * empty_image_frame
DRWCallBuffer * extra_dashed_lines
DRWCallBuffer * center_selected
DRWCallBuffer * light_area[2]
DRWCallBuffer * empty_single_arrow
DRWCallBuffer * light_icon_inner
DRWCallBuffer * camera_distances
DRWCallBuffer * center_deselected
DRWCallBuffer * light_spot_cone_front
DRWCallBuffer * camera_volume_frame
DRWShadingGroup * extra_wire
DRWCallBuffer * light_spot_cone_back
DRWCallBuffer * light_icon_outer
DRWCallBuffer * field_sphere_limit
DRWCallBuffer * empty_sphere_solid
DRWCallBuffer * empty_capsule_body
DRWCallBuffer * center_deselected_lib
DRWCallBuffer * light_icon_sun_rays
DRWCallBuffer * empty_capsule_cap
DRWCallBuffer * field_tube_limit
DRWShadingGroup * extra_loose_points
DRWCallBuffer * camera_tria[2]
DRWCallBuffer * field_cone_limit
DRWCallBuffer * center_selected_lib
DRWCallBuffer * empty_plain_axes
GPUVertFormat * instance_extra
DRWPass * extra_ps[2]
OVERLAY_ExtraCallBuffers extra_call_buffers[2]
DRWShadingGroup * extra_grid_grp
OVERLAY_PrivateData * pd
GPUTexture * dummy_depth_tx
short transflag
ListBase constraints
struct Collection * instance_collection
short base_flag
ObjectRuntimeHandle * runtime
ListBase modifiers
struct RigidBodyOb * rigidbody_object
ListBase greasepencil_modifiers
struct PartDeflect * pd
char empty_drawtype
float empty_drawsize
struct Object * parent
struct RigidBodyCon * rigidbody_constraint
struct Object * ob1
struct Object * ob2
char multiview_eye
float bundle_size
struct Object * camera
float stereo3d_volume_alpha
View3DShading shading
char bundle_drawtype
short stereo3d_flag
float stereo3d_convergence_alpha
float space_obj_world_matrix[4][4]
void(* get_target_matrix)(struct Depsgraph *depsgraph, struct bConstraint *con, struct bConstraintOb *cob, struct bConstraintTarget *ct, float ctime)
const c_style_mat & ptr() const
ccl_device_inline float sqr(float a)
Definition util/math.h:782