Blender V4.5
overlay_private.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BKE_context.hh"
12#include "BKE_movieclip.h"
13#include "BKE_object.hh"
14
15#include "BLI_function_ref.hh"
16
17#include "DNA_space_types.h"
18#include "DNA_world_types.h"
19
20#include "GPU_matrix.hh"
21
22#include "DRW_gpu_wrapper.hh"
23#include "DRW_render.hh"
24#include "UI_resources.hh"
25#include "draw_manager.hh"
26#include "draw_pass.hh"
27#include "draw_view_data.hh"
29
32
33#include "draw_common.hh"
34
35namespace blender::draw::overlay {
36
38 /* Keep sync with bone instance vertex format (OVERLAY_InstanceFormats) */
39 union {
41 float mat[4][4];
42 struct {
45 float _pad2[3], color_a;
46 float _pad3[3], color_b;
47 };
48 struct {
49 float _pad00[3], amin_a;
50 float _pad01[3], amin_b;
51 float _pad02[3], amax_a;
52 float _pad03[3], amax_b;
53 };
54 };
55
56 BoneInstanceData() = default;
57
63 const float3 &pos,
64 const float radius,
65 const float color[4])
66
67 {
68 mat44[0] = ob_mat[0] * radius;
69 mat44[1] = ob_mat[1] * radius;
70 mat44[2] = ob_mat[2] * radius;
73 }
74
75 BoneInstanceData(const float4x4 &bone_mat, const float4 &bone_color, const float4 &hint_color)
76 : mat44(bone_mat)
77 {
78 set_color(bone_color);
79 set_hint_color(hint_color);
80 };
81
82 BoneInstanceData(const float4x4 &bone_mat, const float4 &bone_color) : mat44(bone_mat)
83 {
84 set_color(bone_color);
85 };
86
87 void set_color(const float4 &bone_color)
88 {
89 /* Encoded color into 2 floats to be able to use the matrix to color the custom bones. */
90 color_a = encode_2f_to_float(bone_color[0], bone_color[1]);
91 color_b = encode_2f_to_float(bone_color[2], bone_color[3]);
92 }
93
94 void set_hint_color(const float4 &hint_color)
95 {
96 /* Encoded color into 2 floats to be able to use the matrix to color the custom bones. */
97 color_hint_a = encode_2f_to_float(hint_color[0], hint_color[1]);
98 color_hint_b = encode_2f_to_float(hint_color[2], hint_color[3]);
99 }
100
101 private:
102 /* Encode 2 units float with byte precision into a float. */
103 float encode_2f_to_float(float a, float b) const
104 {
105 /* NOTE: `b` can go up to 2. Needed to encode wire size. */
106 return float(int(clamp_f(a, 0.0f, 1.0f) * 255) | (int(clamp_f(b, 0.0f, 2.0f) * 255) << 8));
107 }
108};
109
111
117
118struct State {
119 Depsgraph *depsgraph = nullptr;
120 const ViewLayer *view_layer = nullptr;
121 const Scene *scene = nullptr;
122 const View3D *v3d = nullptr;
123 const SpaceLink *space_data = nullptr;
124 const ARegion *region = nullptr;
125 const RegionView3D *rv3d = nullptr;
126 DRWTextStore *dt = nullptr;
131 const Object *object_active = nullptr;
132 bool clear_in_front = false;
133 bool use_in_front = false;
134 bool is_wireframe_mode = false;
138 bool is_image_render = false;
142 bool skip_particles = false;
144 bool is_material_select = false;
146 bool draw_background = false;
150 bool show_text = false;
151 bool hide_overlays = false;
152 bool xray_enabled = false;
155 bool xray_flag_enabled = false;
157 bool do_pose_xray = false;
159 bool do_pose_fade_geom = false;
160 float xray_opacity = 0.0f;
161 short v3d_flag = 0; /* TODO: move to #View3DOverlay. */
162 short v3d_gridflag = 0; /* TODO: move to #View3DOverlay. */
163 int cfra = 0;
167
169 bool is_image_valid = false;
173
175 {
176 if (rv3d == nullptr) {
177 return View::OffsetData();
178 }
179 return View::OffsetData(*rv3d);
180 }
181
182 /* Factor to use for wireframe offset.
183 * Result of GPU_polygon_offset_calc for the current view.
184 * Only valid at draw time, so use push constant reference instead of copy. */
185 float ndc_offset_factor = 0.0f;
186
188
190 bool is_solid() const
191 {
192 return xray_opacity == 1.0f;
193 }
194
195 bool is_xray() const
196 {
197 return (xray_opacity < 1.0f) && (xray_opacity > 0.0f);
198 }
199
200 bool is_wire() const
201 {
202 return xray_opacity == 0.0f;
203 }
204
205 bool is_space_v3d() const
206 {
207 return this->space_type == SPACE_VIEW3D;
208 }
209 bool is_space_image() const
210 {
211 return this->space_type == SPACE_IMAGE;
212 }
213 bool is_space_node() const
214 {
215 return this->space_type == SPACE_NODE;
216 }
217
218 bool show_extras() const
219 {
220 return (this->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) == 0;
221 }
223 {
224 return (this->overlay.flag & V3D_OVERLAY_FACE_ORIENTATION);
225 }
227 {
228 return (this->overlay.flag & V3D_OVERLAY_BONE_SELECT);
229 }
230 bool show_wireframes() const
231 {
232 return (this->overlay.flag & V3D_OVERLAY_WIREFRAMES);
233 }
234 bool show_motion_paths() const
235 {
236 return (this->overlay.flag & V3D_OVERLAY_HIDE_MOTION_PATHS) == 0;
237 }
238 bool show_bones() const
239 {
240 return (this->overlay.flag & V3D_OVERLAY_HIDE_BONES) == 0;
241 }
243 {
244 return (this->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_ORIGINS) == 0;
245 }
247 {
248 return (this->overlay.flag & V3D_OVERLAY_FADE_INACTIVE);
249 }
251 {
252 return (this->overlay.flag & V3D_OVERLAY_VIEWER_ATTRIBUTE);
253 }
255 {
256 return (this->overlay.flag & V3D_OVERLAY_VIEWER_ATTRIBUTE_TEXT);
257 }
258 bool show_sculpt_mask() const
259 {
260 return (this->overlay.flag & V3D_OVERLAY_SCULPT_SHOW_MASK);
261 }
263 {
264 return (this->overlay.flag & V3D_OVERLAY_SCULPT_SHOW_FACE_SETS);
265 }
267 {
268 return (this->overlay.flag & V3D_OVERLAY_SCULPT_CURVES_CAGE);
269 }
270 bool show_light_colors() const
271 {
272 return (this->overlay.flag & V3D_OVERLAY_SHOW_LIGHT_COLORS);
273 }
274};
275
276/* Matches Vertex Format. */
281
286
291
297
298/* TODO(fclem): Might be good to remove for simplicity. */
304
309 private:
310 struct BatchDeleter {
311 void operator()(gpu::Batch *shader)
312 {
314 }
315 };
316 using BatchPtr = std::unique_ptr<gpu::Batch, BatchDeleter>;
317
318 public:
319 BatchPtr bone_box;
325 BatchPtr bone_sphere;
327 BatchPtr bone_stick;
328
331
332 BatchPtr grid;
333 BatchPtr cube_solid;
334
336 BatchPtr cursor_lines;
337
338 BatchPtr quad_wire;
339 BatchPtr quad_solid;
340 BatchPtr plain_axes;
341 BatchPtr single_arrow;
342 BatchPtr cube;
343 BatchPtr circle;
344 BatchPtr empty_sphere;
345 BatchPtr empty_cone;
346 BatchPtr cylinder;
347 BatchPtr capsule_body;
348 BatchPtr capsule_cap;
349 BatchPtr arrows;
351
352 BatchPtr speaker;
353
355 BatchPtr camera_frame;
357 BatchPtr camera_tria;
358
361
363
364 BatchPtr ground_line;
365
366 /* Batch drawing a quad with coordinate [0..1] at 0.75 depth. */
367 BatchPtr image_quad;
368
378
379 BatchPtr field_force;
380 BatchPtr field_wind;
381 BatchPtr field_vortex;
382 BatchPtr field_curve;
386
390
391 ShapeCache();
392
393 private:
394 GPUVertFormat format_vert = {0};
395 GPUVertFormat format_vert_with_color = {0};
396 GPUVertFormat format_vert_shaded = {0};
397 GPUVertFormat format_vert_triple = {0};
398
399 const GPUVertFormat &get_format(Vertex /*unused*/)
400 {
401 GPUVertFormat &format = format_vert;
402 if (format.attr_len != 0) {
403 return format;
404 }
407 return format;
408 }
409
410 const GPUVertFormat &get_format(VertexBone /*unused*/)
411 {
412 GPUVertFormat &format = format_vert;
413 if (format.attr_len != 0) {
414 return format;
415 }
418 return format;
419 }
420
421 const GPUVertFormat &get_format(VertexWithColor /*unused*/)
422 {
423 GPUVertFormat &format = format_vert_with_color;
424 if (format.attr_len != 0) {
425 return format;
426 }
429 return format;
430 }
431
432 const GPUVertFormat &get_format(VertShaded /*unused*/)
433 {
434 GPUVertFormat &format = format_vert_shaded;
435 if (format.attr_len != 0) {
436 return format;
437 }
441 return format;
442 }
443
444 const GPUVertFormat &get_format(VertexTriple /*unused*/)
445 {
446 GPUVertFormat &format = format_vert_triple;
447 if (format.attr_len != 0) {
448 return format;
449 }
453 return format;
454 }
455
456 /* Caller gets ownership of the #gpu::VertBuf. */
457 template<typename T> gpu::VertBuf *vbo_from_vector(const Vector<T> &vector)
458 {
459 gpu::VertBuf *vbo = GPU_vertbuf_create_with_format(get_format(T()));
460 GPU_vertbuf_data_alloc(*vbo, vector.size());
461 vbo->data<T>().copy_from(vector);
462 return vbo;
463 }
464};
465
467
471class ShaderModule {
472 private:
473 /* Allow StaticShaderCache access to the constructor. */
475
476 using StaticCache =
477 gpu::StaticShaderCache<ShaderModule>[2 /* Selection Instance. */][2 /* Clipping Enabled. */];
478
479 static StaticCache &get_static_cache()
480 {
482 static StaticCache static_cache;
483 return static_cache;
484 }
485
486 const SelectionType selection_type_;
489 const bool clipping_enabled_;
490
491 public:
493 StaticShader anti_aliasing = {"overlay_antialiasing"};
494 StaticShader armature_degrees_of_freedom = shader_clippable("overlay_armature_dof");
495 StaticShader attribute_viewer_mesh = shader_clippable("overlay_viewer_attribute_mesh");
497 "overlay_viewer_attribute_pointcloud");
498 StaticShader attribute_viewer_curve = shader_clippable("overlay_viewer_attribute_curve");
499 StaticShader attribute_viewer_curves = shader_clippable("overlay_viewer_attribute_curves");
500 StaticShader background_fill = {"overlay_background"};
501 StaticShader background_clip_bound = {"overlay_clipbound"};
502 StaticShader curve_edit_points = shader_clippable("overlay_edit_curves_point");
503 StaticShader curve_edit_line = shader_clippable("overlay_edit_particle_strand");
504 StaticShader curve_edit_handles = shader_clippable("overlay_edit_curves_handle");
505 StaticShader facing = shader_clippable("overlay_facing");
506 StaticShader grid = {"overlay_grid_next"};
507 StaticShader grid_background = {"overlay_grid_background"};
508 StaticShader grid_grease_pencil = shader_clippable("overlay_gpencil_canvas");
509 StaticShader grid_image = {"overlay_grid_image"};
510 StaticShader lattice_points = shader_clippable("overlay_edit_lattice_point");
511 StaticShader lattice_wire = shader_clippable("overlay_edit_lattice_wire");
512 StaticShader legacy_curve_edit_handles = shader_clippable("overlay_edit_curve_handle");
513 StaticShader legacy_curve_edit_normals = shader_clippable("overlay_edit_curve_normals");
514 StaticShader legacy_curve_edit_points = shader_clippable("overlay_edit_curve_point");
515 StaticShader legacy_curve_edit_wires = shader_clippable("overlay_edit_curve_wire");
516 StaticShader light_spot_cone = shader_clippable("overlay_extra_spot_cone");
517 StaticShader mesh_analysis = shader_clippable("overlay_edit_mesh_analysis");
518 StaticShader mesh_edit_depth = shader_clippable("overlay_edit_mesh_depth");
519 StaticShader mesh_edit_edge = shader_clippable("overlay_edit_mesh_edge");
520 StaticShader mesh_edit_face = shader_clippable("overlay_edit_mesh_face");
521 StaticShader mesh_edit_facedot = shader_clippable("overlay_edit_mesh_facedot");
522 StaticShader mesh_edit_vert = shader_clippable("overlay_edit_mesh_vert");
523 StaticShader mesh_edit_skin_root = shader_clippable("overlay_edit_mesh_skin_root");
524 StaticShader mesh_face_normal = shader_clippable("overlay_mesh_face_normal");
525 StaticShader mesh_face_normal_subdiv = shader_clippable("overlay_mesh_face_normal_subdiv");
526 StaticShader mesh_loop_normal = shader_clippable("overlay_mesh_loop_normal");
527 StaticShader mesh_loop_normal_subdiv = shader_clippable("overlay_mesh_loop_normal_subdiv");
528 StaticShader mesh_vert_normal = shader_clippable("overlay_mesh_vert_normal");
529 StaticShader mesh_vert_normal_subdiv = shader_clippable("overlay_mesh_vert_normal_subdiv");
530 StaticShader motion_path_line = shader_clippable("overlay_motion_path_line");
531 StaticShader motion_path_vert = shader_clippable("overlay_motion_path_point");
532 StaticShader outline_detect = {"overlay_outline_detect"};
533 StaticShader outline_prepass_curves = shader_clippable("overlay_outline_prepass_curves");
534 StaticShader outline_prepass_gpencil = shader_clippable("overlay_outline_prepass_gpencil");
535 StaticShader outline_prepass_mesh = shader_clippable("overlay_outline_prepass_mesh");
536 StaticShader outline_prepass_pointcloud = shader_clippable("overlay_outline_prepass_pointcloud");
537 StaticShader outline_prepass_wire = shader_clippable("overlay_outline_prepass_wire");
538 StaticShader paint_region_edge = shader_clippable("overlay_paint_wire");
539 StaticShader paint_region_face = shader_clippable("overlay_paint_face");
540 StaticShader paint_region_vert = shader_clippable("overlay_paint_point");
541 StaticShader paint_texture = shader_clippable("overlay_paint_texture");
542 StaticShader paint_weight = shader_clippable("overlay_paint_weight");
543 /* TODO(fclem): Specialization constant. */
544 StaticShader paint_weight_fake_shading = shader_clippable("overlay_paint_weight_fake_shading");
545 StaticShader particle_edit_vert = shader_clippable("overlay_edit_particle_point");
546 StaticShader particle_edit_edge = shader_clippable("overlay_edit_particle_strand");
547 StaticShader pointcloud_points = shader_clippable("overlay_edit_pointcloud");
548 StaticShader sculpt_curves = shader_clippable("overlay_sculpt_curves_selection");
549 StaticShader sculpt_curves_cage = shader_clippable("overlay_sculpt_curves_cage");
550 StaticShader sculpt_mesh = shader_clippable("overlay_sculpt_mask");
551 StaticShader uniform_color = shader_clippable("overlay_uniform_color");
552 StaticShader uv_analysis_stretch_angle = {"overlay_edit_uv_stretching_angle"};
553 StaticShader uv_analysis_stretch_area = {"overlay_edit_uv_stretching_area"};
554 StaticShader uv_brush_stencil = {"overlay_edit_uv_stencil_image"};
555 StaticShader uv_edit_edge = {"overlay_edit_uv_edges"};
556 StaticShader uv_edit_face = {"overlay_edit_uv_faces"};
557 StaticShader uv_edit_facedot = {"overlay_edit_uv_face_dots"};
558 StaticShader uv_edit_vert = {"overlay_edit_uv_verts"};
559 StaticShader uv_image_borders = {"overlay_edit_uv_tiled_image_borders"};
560 StaticShader uv_paint_mask = {"overlay_edit_uv_mask_image"};
561 StaticShader uv_wireframe = {"overlay_wireframe_uv"};
562 StaticShader xray_fade = {"overlay_xray_fade"};
563
565 StaticShader armature_envelope_fill = shader_selectable("overlay_armature_envelope_solid");
566 StaticShader armature_envelope_outline = shader_selectable("overlay_armature_envelope_outline");
567 StaticShader armature_shape_outline = shader_selectable("overlay_armature_shape_outline");
568 StaticShader armature_shape_fill = shader_selectable("overlay_armature_shape_solid");
569 StaticShader armature_shape_wire = shader_selectable("overlay_armature_shape_wire");
570 StaticShader armature_shape_wire_strip = shader_selectable("overlay_armature_shape_wire_strip");
571 StaticShader armature_sphere_outline = shader_selectable("overlay_armature_sphere_outline");
572 StaticShader armature_sphere_fill = shader_selectable("overlay_armature_sphere_solid");
573 StaticShader armature_stick = shader_selectable("overlay_armature_stick");
574 StaticShader armature_wire = shader_selectable("overlay_armature_wire");
575 StaticShader depth_curves = shader_selectable("overlay_depth_curves");
576 StaticShader depth_grease_pencil = shader_selectable("overlay_depth_gpencil");
577 StaticShader depth_mesh = shader_selectable("overlay_depth_mesh");
578 StaticShader depth_mesh_conservative = shader_selectable("overlay_depth_mesh_conservative");
579 StaticShader depth_pointcloud = shader_selectable("overlay_depth_pointcloud");
580 StaticShader extra_shape = shader_selectable("overlay_extra");
581 StaticShader extra_point = shader_selectable("overlay_extra_point");
582 StaticShader extra_wire = shader_selectable("overlay_extra_wire");
583 StaticShader extra_wire_object = shader_selectable("overlay_extra_wire_object");
584 StaticShader extra_loose_points = shader_selectable("overlay_extra_loose_point");
585 StaticShader extra_grid = shader_selectable("overlay_extra_grid");
586 StaticShader extra_ground_line = shader_selectable("overlay_extra_groundline");
587 StaticShader image_plane = shader_selectable("overlay_image");
588 StaticShader image_plane_depth_bias = shader_selectable("overlay_image_depth_bias");
589 StaticShader particle_dot = shader_selectable("overlay_particle_dot");
590 StaticShader particle_shape = shader_selectable("overlay_particle_shape");
591 StaticShader particle_hair = shader_selectable("overlay_particle_hair");
592 StaticShader wireframe_mesh = shader_selectable("overlay_wireframe");
593 /* Draw objects without edges for the wireframe overlay. */
594 StaticShader wireframe_points = shader_selectable("overlay_wireframe_points");
595 StaticShader wireframe_curve = shader_selectable("overlay_wireframe_curve");
596
597 StaticShader fluid_grid_lines_flags = shader_selectable_no_clip(
598 "overlay_volume_gridlines_flags");
599 StaticShader fluid_grid_lines_flat = shader_selectable_no_clip("overlay_volume_gridlines_flat");
600 StaticShader fluid_grid_lines_range = shader_selectable_no_clip(
601 "overlay_volume_gridlines_range");
602 StaticShader fluid_velocity_streamline = shader_selectable_no_clip(
603 "overlay_volume_velocity_streamline");
604 StaticShader fluid_velocity_mac = shader_selectable_no_clip("overlay_volume_velocity_mac");
605 StaticShader fluid_velocity_needle = shader_selectable_no_clip("overlay_volume_velocity_needle");
606
609 static ShaderModule &module_get(SelectionType selection_type, bool clipping_enabled);
610 static void module_free();
611
612 private:
613 ShaderModule(const SelectionType selection_type, const bool clipping_enabled)
614 : selection_type_(selection_type), clipping_enabled_(clipping_enabled){};
615
616 StaticShader shader_clippable(const char *create_info_name);
617 StaticShader shader_selectable(const char *create_info_name);
618 StaticShader shader_selectable_no_clip(const char *create_info_name);
619};
620
622 /* Plane data to reference as push constant.
623 * Will be computed just before drawing. */
625 /* Center and size of the bounding box of the Grease Pencil object. */
627 /* Grease-pencil object resource handle. */
629};
630
633
634 /* Overlay Color. */
635 Framebuffer overlay_color_only_fb = {"overlay_color_only_fb"};
636 /* Overlay Color, Line Data. */
637 Framebuffer overlay_line_only_fb = {"overlay_line_only_fb"};
638 /* Depth, Overlay Color. */
639 Framebuffer overlay_fb = {"overlay_fb"};
640 /* Depth, Overlay Color, Line Data. */
641 Framebuffer overlay_line_fb = {"overlay_line_fb"};
642 /* Depth In-Front, Overlay Color. */
643 Framebuffer overlay_in_front_fb = {"overlay_in_front_fb"};
644 /* Depth In-Front, Overlay Color, Line Data. */
645 Framebuffer overlay_line_in_front_fb = {"overlay_line_in_front_fb"};
646
647 /* Output Color. */
648 Framebuffer overlay_output_color_only_fb = {"overlay_output_color_only_fb"};
649 /* Depth, Output Color. */
650 Framebuffer overlay_output_fb = {"overlay_output_fb"};
651
652 /* Render Frame-buffers. Only used for multiplicative blending on top of the render. */
653 /* TODO(fclem): Remove the usage of these somehow. This is against design. */
654 GPUFrameBuffer *render_fb = nullptr;
655 GPUFrameBuffer *render_in_front_fb = nullptr;
656
657 /* Target containing line direction and data for line expansion and anti-aliasing. */
659 /* Target containing overlay color before anti-aliasing. */
660 TextureFromPool overlay_tx = {"overlay_tx"};
661 /* Target containing depth of overlays when xray is enabled. */
662 TextureFromPool xray_depth_tx = {"xray_depth_tx"};
663 TextureFromPool xray_depth_in_front_tx = {"xray_depth_in_front_tx"};
664
665 /* Texture that are usually allocated inside. These are fallback when they aren't.
666 * They are then wrapped inside the #TextureRefs below. */
667 TextureFromPool depth_in_front_alloc_tx = {"overlay_depth_in_front_tx"};
668 TextureFromPool color_overlay_alloc_tx = {"overlay_color_overlay_alloc_tx"};
669 TextureFromPool color_render_alloc_tx = {"overlay_color_render_alloc_tx"};
670
671 /* 1px texture containing only maximum depth. To be used for fulfilling bindings when depth
672 * texture is not available or not needed. */
673 Texture dummy_depth_tx = {"dummy_depth_tx"};
674
675 /* Global vector for all grease pencil depth planes.
676 * Managed by the grease pencil overlay module.
677 * This is to avoid passing the grease pencil overlay class to other overlay and
678 * keep draw_grease_pencil as a static function.
679 * Memory is reference, so we have to use a container with fixed memory. */
682
686 /* Wrappers around #DefaultTextureList members. */
705
707 bool weight_ramp_custom = false;
710 Texture weight_ramp_tx = {"weight_ramp"};
711
713
715
716 Resources(const SelectionType selection_type_, const ShapeCache &shapes_)
717 : select::SelectMap(selection_type_), shapes(shapes_){};
718
723
724 void update_theme_settings(const DRWContext *ctx, const State &state);
725 void update_clip_planes(const State &state);
726
727 void init(bool clipping_enabled)
728 {
730 shaders->anti_aliasing.ensure_compile_async();
731 shaders->armature_degrees_of_freedom.ensure_compile_async();
732 shaders->armature_envelope_fill.ensure_compile_async();
733 shaders->armature_envelope_outline.ensure_compile_async();
734 shaders->armature_shape_fill.ensure_compile_async();
735 shaders->armature_shape_outline.ensure_compile_async();
736 shaders->armature_shape_wire_strip.ensure_compile_async();
737 shaders->armature_shape_wire.ensure_compile_async();
738 shaders->armature_sphere_fill.ensure_compile_async();
739 shaders->armature_sphere_outline.ensure_compile_async();
740 shaders->armature_stick.ensure_compile_async();
741 shaders->armature_wire.ensure_compile_async();
742 shaders->attribute_viewer_curve.ensure_compile_async();
743 shaders->attribute_viewer_curves.ensure_compile_async();
744 shaders->attribute_viewer_mesh.ensure_compile_async();
745 shaders->attribute_viewer_pointcloud.ensure_compile_async();
746 shaders->background_fill.ensure_compile_async();
747 shaders->curve_edit_handles.ensure_compile_async();
748 shaders->curve_edit_line.ensure_compile_async();
749 shaders->curve_edit_points.ensure_compile_async();
750 shaders->depth_curves.ensure_compile_async();
751 shaders->depth_grease_pencil.ensure_compile_async();
752 shaders->depth_mesh.ensure_compile_async();
753 shaders->depth_pointcloud.ensure_compile_async();
754 shaders->extra_grid.ensure_compile_async();
755 shaders->extra_ground_line.ensure_compile_async();
756 shaders->extra_loose_points.ensure_compile_async();
757 shaders->extra_point.ensure_compile_async();
758 shaders->extra_shape.ensure_compile_async();
759 shaders->extra_wire_object.ensure_compile_async();
760 shaders->extra_wire.ensure_compile_async();
761 shaders->fluid_grid_lines_flags.ensure_compile_async();
762 shaders->fluid_grid_lines_flat.ensure_compile_async();
763 shaders->fluid_grid_lines_range.ensure_compile_async();
764 shaders->fluid_velocity_mac.ensure_compile_async();
765 shaders->fluid_velocity_needle.ensure_compile_async();
766 shaders->fluid_velocity_streamline.ensure_compile_async();
767 shaders->grid.ensure_compile_async();
768 shaders->image_plane_depth_bias.ensure_compile_async();
769 shaders->lattice_points.ensure_compile_async();
770 shaders->lattice_wire.ensure_compile_async();
771 shaders->legacy_curve_edit_handles.ensure_compile_async();
772 shaders->legacy_curve_edit_points.ensure_compile_async();
773 shaders->legacy_curve_edit_wires.ensure_compile_async();
774 shaders->light_spot_cone.ensure_compile_async();
775 shaders->mesh_analysis.ensure_compile_async();
776 shaders->mesh_edit_depth.ensure_compile_async();
777 shaders->mesh_edit_edge.ensure_compile_async();
778 shaders->mesh_edit_face.ensure_compile_async();
779 shaders->mesh_edit_facedot.ensure_compile_async();
780 shaders->mesh_edit_skin_root.ensure_compile_async();
781 shaders->mesh_edit_vert.ensure_compile_async();
782 shaders->motion_path_line.ensure_compile_async();
783 shaders->motion_path_vert.ensure_compile_async();
784 shaders->outline_detect.ensure_compile_async();
785 shaders->outline_prepass_curves.ensure_compile_async();
786 shaders->outline_prepass_gpencil.ensure_compile_async();
787 shaders->outline_prepass_mesh.ensure_compile_async();
788 shaders->outline_prepass_pointcloud.ensure_compile_async();
789 shaders->outline_prepass_wire.ensure_compile_async();
790 shaders->paint_weight_fake_shading.ensure_compile_async();
791 shaders->particle_dot.ensure_compile_async();
792 shaders->particle_edit_edge.ensure_compile_async();
793 shaders->particle_edit_vert.ensure_compile_async();
794 shaders->particle_hair.ensure_compile_async();
795 shaders->particle_shape.ensure_compile_async();
796 shaders->pointcloud_points.ensure_compile_async();
797 shaders->uniform_color.ensure_compile_async();
798 shaders->wireframe_curve.ensure_compile_async();
799 shaders->wireframe_mesh.ensure_compile_async();
800 shaders->wireframe_points.ensure_compile_async();
801 }
802
804 {
805 SelectMap::begin_sync(clipping_plane_count);
807 }
808
809 void acquire(const DRWContext *draw_ctx, const State &state)
810 {
811 DefaultTextureList &viewport_textures = *draw_ctx->viewport_texture_list_get();
812 DefaultFramebufferList &viewport_framebuffers = *draw_ctx->viewport_framebuffer_list_get();
813 this->depth_tx.wrap(viewport_textures.depth);
814 this->depth_in_front_tx.wrap(viewport_textures.depth_in_front);
815 this->color_overlay_tx.wrap(viewport_textures.color_overlay);
816 this->color_render_tx.wrap(viewport_textures.color);
817
818 this->render_fb = viewport_framebuffers.default_fb;
819 this->render_in_front_fb = viewport_framebuffers.in_front_fb;
820
821 int2 render_size = int2(this->depth_tx.size());
822
823 if (state.xray_enabled) {
824 /* For X-ray we render the scene to a separate depth buffer. */
825 this->xray_depth_tx.acquire(render_size, GPU_DEPTH24_STENCIL8);
826 this->depth_target_tx.wrap(this->xray_depth_tx);
827 /* TODO(fclem): Remove mandatory allocation. */
828 this->xray_depth_in_front_tx.acquire(render_size, GPU_DEPTH24_STENCIL8);
829 this->depth_target_in_front_tx.wrap(this->xray_depth_in_front_tx);
830 }
831 else {
832 /* TODO(fclem): Remove mandatory allocation. */
833 if (!this->depth_in_front_tx.is_valid()) {
834 this->depth_in_front_alloc_tx.acquire(render_size, GPU_DEPTH24_STENCIL8);
835 this->depth_in_front_tx.wrap(this->depth_in_front_alloc_tx);
836 }
837 this->depth_target_tx.wrap(this->depth_tx);
838 this->depth_target_in_front_tx.wrap(this->depth_in_front_tx);
839 }
840
841 /* TODO: Better semantics using a switch? */
842 if (!this->color_overlay_tx.is_valid()) {
843 /* Likely to be the selection case. Allocate dummy texture and bind only depth buffer. */
844 this->color_overlay_alloc_tx.acquire(int2(1, 1), GPU_SRGB8_A8);
845 this->color_render_alloc_tx.acquire(int2(1, 1), GPU_SRGB8_A8);
846
847 this->color_overlay_tx.wrap(this->color_overlay_alloc_tx);
848 this->color_render_tx.wrap(this->color_render_alloc_tx);
849
850 this->line_tx.acquire(int2(1, 1), GPU_RGBA8);
851 this->overlay_tx.acquire(int2(1, 1), GPU_SRGB8_A8);
852
853 this->overlay_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_tx));
854 this->overlay_line_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_tx));
855 this->overlay_in_front_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_tx));
856 this->overlay_line_in_front_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_tx));
857 }
858 else {
861 this->line_tx.acquire(render_size, GPU_RGBA8, usage);
862 this->overlay_tx.acquire(render_size, GPU_SRGB8_A8, usage);
863
864 this->overlay_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_tx),
865 GPU_ATTACHMENT_TEXTURE(this->overlay_tx));
866 this->overlay_line_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_tx),
867 GPU_ATTACHMENT_TEXTURE(this->overlay_tx),
868 GPU_ATTACHMENT_TEXTURE(this->line_tx));
869 this->overlay_in_front_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_in_front_tx),
870 GPU_ATTACHMENT_TEXTURE(this->overlay_tx));
871 this->overlay_line_in_front_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_target_in_front_tx),
872 GPU_ATTACHMENT_TEXTURE(this->overlay_tx),
873 GPU_ATTACHMENT_TEXTURE(this->line_tx));
874 }
875
876 this->overlay_line_only_fb.ensure(GPU_ATTACHMENT_NONE,
877 GPU_ATTACHMENT_TEXTURE(this->overlay_tx),
878 GPU_ATTACHMENT_TEXTURE(this->line_tx));
879 this->overlay_color_only_fb.ensure(GPU_ATTACHMENT_NONE,
880 GPU_ATTACHMENT_TEXTURE(this->overlay_tx));
881
882 this->overlay_output_color_only_fb.ensure(GPU_ATTACHMENT_NONE,
883 GPU_ATTACHMENT_TEXTURE(this->color_overlay_tx));
884 this->overlay_output_fb.ensure(GPU_ATTACHMENT_TEXTURE(this->depth_tx),
885 GPU_ATTACHMENT_TEXTURE(this->color_overlay_tx));
886 }
887
888 void release()
889 {
890 this->line_tx.release();
891 this->overlay_tx.release();
892 this->xray_depth_tx.release();
893 this->xray_depth_in_front_tx.release();
894 this->depth_in_front_alloc_tx.release();
895 this->color_overlay_alloc_tx.release();
896 this->color_render_alloc_tx.release();
898 }
899
901 {
902 const bool is_edit = (state.object_mode & OB_MODE_EDIT) &&
903 (ob_ref.object->mode & OB_MODE_EDIT);
904 const bool active = ((ob_ref.dupli_parent != nullptr) ?
905 (state.object_active == ob_ref.dupli_parent) :
906 (state.object_active == ob_ref.object));
907 const bool is_selected = ((ob_ref.object->base_flag & BASE_SELECTED) != 0);
908
909 /* Object in edit mode. */
910 if (is_edit) {
911 return TH_WIRE_EDIT;
912 }
913 /* Transformed object during operators. */
914 if (((G.moving & G_TRANSFORM_OBJ) != 0) && is_selected) {
915 return TH_TRANSFORM;
916 }
917 /* Sets the 'theme_id' or fall back to wire */
918 if ((ob_ref.object->base_flag & BASE_SELECTED) != 0) {
919 return (active) ? TH_ACTIVE : TH_SELECT;
920 }
921
922 switch (ob_ref.object->type) {
923 case OB_LAMP:
924 return TH_LIGHT;
925 case OB_SPEAKER:
926 return TH_SPEAKER;
927 case OB_CAMERA:
928 return TH_CAMERA;
929 case OB_LIGHTPROBE:
930 /* TODO: add light-probe color. Use empty color for now. */
931 case OB_EMPTY:
932 return TH_EMPTY;
933 default:
934 return (is_edit) ? TH_WIRE_EDIT : TH_WIRE;
935 }
936 }
937
938 const float4 &object_wire_color(const ObjectRef &ob_ref, ThemeColorID theme_id) const
939 {
940 if (UNLIKELY(ob_ref.object->base_flag & BASE_FROM_SET)) {
941 return theme.colors.wire;
942 }
943 switch (theme_id) {
944 case TH_WIRE_EDIT:
945 return theme.colors.wire_edit;
946 case TH_ACTIVE:
947 return theme.colors.active_object;
948 case TH_SELECT:
949 return theme.colors.object_select;
950 case TH_TRANSFORM:
951 return theme.colors.transform;
952 case TH_SPEAKER:
953 return theme.colors.speaker;
954 case TH_CAMERA:
955 return theme.colors.camera;
956 case TH_EMPTY:
957 return theme.colors.empty;
958 case TH_LIGHT:
959 return theme.colors.light;
960 default:
961 return theme.colors.wire;
962 }
963 }
964
965 const float4 &object_wire_color(const ObjectRef &ob_ref, const State &state) const
966 {
967 ThemeColorID theme_id = object_wire_theme_id(ob_ref, state);
968 return object_wire_color(ob_ref, theme_id);
969 }
970
972 {
974 UI_GetThemeColorBlendShade4fv(theme_id, TH_BACK, 0.5, 0, color);
975 return color;
976 }
977
979 {
980 ThemeColorID theme_id = object_wire_theme_id(ob_ref, state);
981 return background_blend_color(theme_id);
982 }
983
985 {
986 if (state.v3d->shading.background_type == V3D_SHADING_BACKGROUND_WORLD) {
987 if (state.scene->world) {
988 return float4(float3(&state.scene->world->horr), 0.0f);
989 }
990 }
991 else if (state.v3d->shading.background_type == V3D_SHADING_BACKGROUND_VIEWPORT) {
992 return state.v3d->shading.background_color;
993 }
996 return color;
997 }
998
1000 {
1001 /* Free Movie clip textures after rendering */
1002 for (MovieClip *clip : bg_movie_clips) {
1004 }
1005 bg_movie_clips.clear();
1006 }
1007
1008 static float vertex_size_get()
1009 {
1010 /* M_SQRT2 to be at least the same size of the old square */
1011 return max_ff(1.0f, UI_GetThemeValuef(TH_VERTEX_SIZE) * float(M_SQRT2) / 2.0f);
1012 }
1013
1015
1016 /* Returns true if drawing for any selection mode. */
1017 bool is_selection() const
1018 {
1019 return this->selection_type != SelectionType::DISABLED;
1020 }
1021};
1022
1023/* List of flat objects draw-calls.
1024 * In order to not loose selection display of flat objects view from the side,
1025 * we store them in a list and add them to the pass just in time if their flat side is
1026 * perpendicular to the view. */
1027/* Reference to a flat object.
1028 * Allow deferred rendering condition of flat object for special purpose. */
1030 gpu::Batch *geom;
1033
1034 /* Returns flat axis index if only one axis is flat. Returns -1 otherwise. */
1035 static int flat_axis_index_get(const Object *ob)
1036 {
1037 BLI_assert(ELEM(ob->type,
1038 OB_MESH,
1040 OB_SURF,
1041 OB_FONT,
1042 OB_CURVES,
1044 OB_VOLUME));
1045
1046 float dim[3];
1048
1049 /* Small epsilon relative to object size to handle float errors in flat axis detection after
1050 * rotation. See #139555. */
1051 const float max_dim = math::reduce_max(float3(dim));
1052 const float epsilon = max_dim * 1e-6f;
1053
1054 if (dim[0] <= epsilon) {
1055 return 0;
1056 }
1057 if (dim[1] <= epsilon) {
1058 return 1;
1059 }
1060 if (dim[2] <= epsilon) {
1061 return 2;
1062 }
1063 return -1;
1064 }
1065
1066 using Callback = FunctionRef<void(gpu::Batch *geom, ResourceHandle handle)>;
1067
1068 /* Execute callback for every handles that is orthogonal to the view.
1069 * Note: Only works in orthogonal view. */
1070 void if_flat_axis_orthogonal_to_view(Manager &manager, const View &view, Callback callback) const
1071 {
1072 const float4x4 &object_to_world =
1073 manager.matrix_buf.current().get_or_resize(handle.resource_index()).model;
1074
1075 float3 view_forward = view.forward();
1076 float3 axis_not_flat_a = (flattened_axis_id == 0) ? object_to_world.y_axis() :
1077 object_to_world.x_axis();
1078 float3 axis_not_flat_b = (flattened_axis_id == 1) ? object_to_world.z_axis() :
1079 object_to_world.y_axis();
1080 float3 axis_flat = math::cross(axis_not_flat_a, axis_not_flat_b);
1081
1082 if (math::abs(math::dot(view_forward, axis_flat)) < 1e-3f) {
1083 callback(geom, handle);
1084 }
1085 }
1086};
1087
1091template<typename InstanceDataT> struct ShapeInstanceBuf : private select::SelectBuf {
1092
1094
1095 ShapeInstanceBuf(const SelectionType selection_type, const char *name = nullptr)
1097
1098 void clear()
1099 {
1100 this->select_clear();
1101 data_buf.clear();
1102 }
1103
1104 void append(const InstanceDataT &data, select::ID select_id)
1105 {
1106 this->select_append(select_id);
1107 data_buf.append(data);
1108 }
1109
1110 void end_sync(PassSimple::Sub &pass, gpu::Batch *shape)
1111 {
1112 if (data_buf.is_empty()) {
1113 return;
1114 }
1115 this->select_bind(pass);
1116 data_buf.push_update();
1117 pass.bind_ssbo("data_buf", &data_buf);
1118 pass.draw(shape, data_buf.size());
1119 }
1120
1122 gpu::Batch *shape,
1123 GPUPrimType primitive_type,
1124 uint primitive_len)
1125 {
1126 if (data_buf.is_empty()) {
1127 return;
1128 }
1129 this->select_bind(pass);
1130 data_buf.push_update();
1131 pass.bind_ssbo("data_buf", &data_buf);
1132 pass.draw_expand(
1133 shape, primitive_type, primitive_len, data_buf.size(), ResourceHandle(0), uint(0));
1134 }
1135};
1136
1138 protected:
1141 int color_id = 0;
1142
1143 VertexPrimitiveBuf(const SelectionType selection_type, const char *name = nullptr)
1144 : select_buf(selection_type), data_buf(name){};
1145
1146 void append(const float3 &position, const float4 &color)
1147 {
1148 data_buf.append({float4(position, 0.0f), color});
1149 }
1150
1151 void end_sync(PassSimple::Sub &pass, GPUPrimType primitive)
1152 {
1153 if (data_buf.is_empty()) {
1154 return;
1155 }
1156 select_buf.select_bind(pass);
1157 data_buf.push_update();
1158 pass.bind_ssbo("data_buf", &data_buf);
1159 pass.push_constant("colorid", color_id);
1160 pass.draw_procedural(primitive, 1, data_buf.size());
1161 }
1162
1163 public:
1164 void clear()
1165 {
1166 select_buf.select_clear();
1167 data_buf.clear();
1168 color_id = 0;
1169 }
1170};
1171
1173
1174 public:
1175 PointPrimitiveBuf(const SelectionType selection_type, const char *name = nullptr)
1176 : VertexPrimitiveBuf(selection_type, name)
1177 {
1178 }
1179
1180 void append(const float3 &position,
1181 const float4 &color,
1183 {
1184 select_buf.select_append(select_id);
1186 }
1187
1188 void append(const float3 &position, const int color_id, select::ID select_id)
1189 {
1190 this->color_id = color_id;
1191 append(position, float4(), select_id);
1192 }
1193
1198};
1199
1201
1202 public:
1203 LinePrimitiveBuf(const SelectionType selection_type, const char *name = nullptr)
1204 : VertexPrimitiveBuf(selection_type, name)
1205 {
1206 }
1207
1208 void append(const float3 &start,
1209 const float3 &end,
1210 const float4 &color,
1212 {
1213 select_buf.select_append(select_id);
1216 }
1217
1218 void append(const float3 &start,
1219 const float3 &end,
1220 const int color_id,
1222 {
1223 this->color_id = color_id;
1224 append(start, end, float4(), select_id);
1225 }
1226
1231};
1232
1233/* Consider instance any object form a set or a dupli system.
1234 * This hides some overlay to avoid making the viewport unreadable. */
1235static inline bool is_from_dupli_or_set(const Object *ob)
1236{
1237 return ob->base_flag & (BASE_FROM_SET | BASE_FROM_DUPLI);
1238}
1239
1240/* Consider instance any object form a set or a dupli system.
1241 * This hides some overlay to avoid making the viewport unreadable. */
1242static inline bool is_from_dupli_or_set(const ObjectRef &ob_ref)
1243{
1244 return is_from_dupli_or_set(ob_ref.object);
1245}
1246
1247} // namespace blender::draw::overlay
eContextObjectMode
@ CTX_MODE_EDIT_MESH
@ G_TRANSFORM_OBJ
void BKE_movieclip_free_gputexture(struct MovieClip *clip)
General operations, lookup, etc. for blender objects.
void BKE_object_dimensions_get(const Object *ob, float r_vec[3])
#define BLI_assert(a)
Definition BLI_assert.h:46
MINLINE float max_ff(float a, float b)
MINLINE float clamp_f(float value, float min, float max)
#define M_SQRT2
unsigned int uint
#define UNLIKELY(x)
#define ELEM(...)
float[3] Vector
@ BASE_FROM_DUPLI
@ BASE_FROM_SET
eObjectMode
@ OB_MODE_EDIT
@ OB_MODE_OBJECT
@ OB_SPEAKER
@ OB_EMPTY
@ OB_SURF
@ OB_CAMERA
@ OB_FONT
@ OB_LAMP
@ OB_MESH
@ OB_POINTCLOUD
@ OB_VOLUME
@ OB_CURVES_LEGACY
@ OB_CURVES
@ OB_LIGHTPROBE
#define BASE_SELECTED(v3d, base)
eSpace_Type
@ SPACE_NODE
@ SPACE_EMPTY
@ SPACE_IMAGE
@ SPACE_VIEW3D
@ V3D_SHADING_BACKGROUND_VIEWPORT
@ V3D_SHADING_BACKGROUND_WORLD
@ V3D_OVERLAY_SCULPT_SHOW_FACE_SETS
@ V3D_OVERLAY_FACE_ORIENTATION
@ V3D_OVERLAY_VIEWER_ATTRIBUTE
@ V3D_OVERLAY_HIDE_OBJECT_ORIGINS
@ V3D_OVERLAY_HIDE_BONES
@ V3D_OVERLAY_HIDE_MOTION_PATHS
@ V3D_OVERLAY_WIREFRAMES
@ V3D_OVERLAY_SHOW_LIGHT_COLORS
@ V3D_OVERLAY_SCULPT_SHOW_MASK
@ V3D_OVERLAY_HIDE_OBJECT_XTRAS
@ V3D_OVERLAY_FADE_INACTIVE
@ V3D_OVERLAY_SCULPT_CURVES_CAGE
@ V3D_OVERLAY_VIEWER_ATTRIBUTE_TEXT
@ V3D_OVERLAY_BONE_SELECT
static AppView * view
#define GPU_BATCH_DISCARD_SAFE(batch)
Definition GPU_batch.hh:204
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define GPU_ATTACHMENT_NONE
GPUPrimType
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
eGPUTextureUsage
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_SRGB8_A8
@ GPU_DEPTH24_STENCIL8
@ GPU_RGBA8
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT
uint GPU_vertformat_attr_add(GPUVertFormat *, blender::StringRef name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_I32
void UI_GetThemeColor3fv(int colorid, float col[3])
ThemeColorID
@ TH_LIGHT
@ TH_BACK
@ TH_WIRE
@ TH_CAMERA
@ TH_TRANSFORM
@ TH_SPEAKER
@ TH_VERTEX_SIZE
@ TH_EMPTY
@ TH_SELECT
@ TH_WIRE_EDIT
@ TH_ACTIVE
void UI_GetThemeColorBlendShade4fv(int colorid1, int colorid2, float fac, int offset, float col[4])
float UI_GetThemeValuef(int colorid)
BMesh const char void * data
long long int int64_t
SIMD_FORCE_INLINE btVector3 operator()(const btVector3 &x) const
Return the transform of the vector.
Definition btTransform.h:90
void ensure(GPUAttachment depth=GPU_ATTACHMENT_NONE, GPUAttachment color1=GPU_ATTACHMENT_NONE, GPUAttachment color2=GPU_ATTACHMENT_NONE, GPUAttachment color3=GPU_ATTACHMENT_NONE, GPUAttachment color4=GPU_ATTACHMENT_NONE, GPUAttachment color5=GPU_ATTACHMENT_NONE, GPUAttachment color6=GPU_ATTACHMENT_NONE, GPUAttachment color7=GPU_ATTACHMENT_NONE, GPUAttachment color8=GPU_ATTACHMENT_NONE)
SwapChain< ObjectMatricesBuf, 2 > matrix_buf
void acquire(int2 extent, eGPUTextureFormat format, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL)
void wrap(GPUTexture *tex)
int3 size(int miplvl=0) const
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceHandleRange handle={0}, uint custom_id=0)
Definition draw_pass.hh:884
void draw_expand(gpu::Batch *batch, GPUPrimType primitive_type, uint primitive_len, uint instance_len, uint vertex_len=-1, uint vertex_first=-1, ResourceHandleRange handle={0}, uint custom_id=0)
Definition draw_pass.hh:915
void push_constant(const char *name, const float &data)
void draw_procedural(GPUPrimType primitive, uint instance_len, uint vertex_len, uint vertex_first=-1, ResourceHandleRange handle={0}, uint custom_id=0)
Definition draw_pass.hh:953
void bind_ssbo(const char *name, GPUStorageBuf *buffer)
detail::PassBase< command::DrawCommandBuf > Sub
Definition draw_pass.hh:490
static ShaderModule & module_get(SelectionType selection_type, bool clipping_enabled)
uint pos
#define active
format
static ulong state[N]
#define T
#define G(x, y, z)
gpu::StaticShader StaticShader
select::SelectionType SelectionType
static bool is_from_dupli_or_set(const Object *ob)
T reduce_max(const VecBase< T, Size > &a)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
T abs(const T &a)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
DefaultFramebufferList * viewport_framebuffer_list_get() const
DefaultTextureList * viewport_texture_list_get() const
GPUFrameBuffer * in_front_fb
GPUFrameBuffer * default_fb
GPUTexture * depth_in_front
GPUTexture * color_overlay
short base_flag
void set_color(const float4 &bone_color)
BoneInstanceData(const float4x4 &ob_mat, const float3 &pos, const float radius, const float color[4])
void set_hint_color(const float4 &hint_color)
BoneInstanceData(const float4x4 &bone_mat, const float4 &bone_color, const float4 &hint_color)
BoneInstanceData(const float4x4 &bone_mat, const float4 &bone_color)
void if_flat_axis_orthogonal_to_view(Manager &manager, const View &view, Callback callback) const
FunctionRef< void(gpu::Batch *geom, ResourceHandle handle)> Callback
static int flat_axis_index_get(const Object *ob)
void append(const float3 &start, const float3 &end, const float4 &color, select::ID select_id=select::SelectMap::select_invalid_id())
void append(const float3 &start, const float3 &end, const int color_id, select::ID select_id=select::SelectMap::select_invalid_id())
LinePrimitiveBuf(const SelectionType selection_type, const char *name=nullptr)
PointPrimitiveBuf(const SelectionType selection_type, const char *name=nullptr)
void append(const float3 &position, const int color_id, select::ID select_id)
void append(const float3 &position, const float4 &color, select::ID select_id=select::SelectMap::select_invalid_id())
float4 background_color_get(const State &state)
const float4 & object_wire_color(const ObjectRef &ob_ref, ThemeColorID theme_id) const
const float4 & object_wire_color(const ObjectRef &ob_ref, const State &state) const
void begin_sync(int clipping_plane_count)
void acquire(const DRWContext *draw_ctx, const State &state)
void update_theme_settings(const DRWContext *ctx, const State &state)
detail::SubPassVector< GreasePencilDepthPlane, 16 > depth_planes
float4 object_background_blend_color(const ObjectRef &ob_ref, const State &state) const
draw::UniformArrayBuffer< float4, 6 > clip_planes_buf
void init(bool clipping_enabled)
float4 background_blend_color(ThemeColorID theme_id) const
ThemeColorID object_wire_theme_id(const ObjectRef &ob_ref, const State &state) const
draw::UniformBuffer< UniformData > globals_buf
Resources(const SelectionType selection_type_, const ShapeCache &shapes_)
void update_clip_planes(const State &state)
ShapeInstanceBuf(const SelectionType selection_type, const char *name=nullptr)
void end_sync(PassSimple::Sub &pass, gpu::Batch *shape)
void append(const InstanceDataT &data, select::ID select_id)
void end_sync(PassSimple::Sub &pass, gpu::Batch *shape, GPUPrimType primitive_type, uint primitive_len)
View::OffsetData offset_data_get() const
void end_sync(PassSimple::Sub &pass, GPUPrimType primitive)
void append(const float3 &position, const float4 &color)
VertexPrimitiveBuf(const SelectionType selection_type, const char *name=nullptr)
StorageVectorBuffer< VertexData > data_buf
void select_bind(PassSimple::Sub &pass)
SelectBuf(const SelectionType selection_type)
SelectMap(const SelectionType selection_type)