Blender V5.3
overlay_mesh.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <string>
12
13#include "BKE_customdata.hh"
14#include "BKE_editmesh.hh"
15#include "BKE_image_gpu.hh"
16#include "BKE_mask.hh"
17#include "BKE_mesh.hh"
18#include "BKE_mesh_types.hh"
19#include "BKE_paint.hh"
21
23
24#include "DNA_brush_types.h"
25#include "DNA_mask_types.h"
26#include "DNA_mesh_types.h"
27#include "DNA_userdef_types.h"
28
29#include "ED_view3d.hh"
30
31#include "GPU_capabilities.hh"
32
33#include "draw_cache.hh"
34#include "draw_cache_impl.hh"
35#include "draw_manager_text.hh"
36#include "overlay_base.hh"
37
38namespace blender::draw::overlay {
39
43
47class Meshes : Overlay {
48 private:
49 PassSimple edit_mesh_normals_ps_ = {"Normals"};
50 PassSimple::Sub *face_normals_ = nullptr;
51 PassSimple::Sub *face_normals_subdiv_ = nullptr;
52 PassSimple::Sub *loop_normals_ = nullptr;
53 PassSimple::Sub *loop_normals_subdiv_ = nullptr;
54 PassSimple::Sub *vert_normals_ = nullptr;
55 PassSimple::Sub *vert_normals_subdiv_ = nullptr;
56
57 PassSimple edit_mesh_analysis_ps_ = {"Mesh Analysis"};
58 PassSimple edit_mesh_weight_ps_ = {"Edit Weight"};
59
60 PassSimple edit_mesh_edges_ps_ = {"Edges"};
61 PassSimple edit_mesh_faces_ps_ = {"Faces"};
62 PassSimple edit_mesh_cages_ps_ = {"Cages"}; /* Same as faces but with a different offset. */
63 PassSimple edit_mesh_verts_ps_ = {"Verts"};
64 PassSimple edit_mesh_facedots_ps_ = {"FaceDots"};
65 PassSimple edit_mesh_skin_roots_ps_ = {"SkinRoots"};
66
67 /* Depth pre-pass to cull edit cage in case the object is not opaque. */
68 PassSimple edit_mesh_prepass_ps_ = {"Prepass"};
69
70 bool xray_enabled_ = false;
71 bool xray_flag_enabled_ = false;
72
73 bool show_retopology_ = false;
74 bool show_mesh_analysis_ = false;
75 bool show_face_overlay_ = false;
76 bool show_weight_ = false;
77
78 bool select_vert_ = false;
79 bool select_edge_ = false;
80 bool select_face_ = false;
81 bool select_face_dots_ = false;
82
87 static constexpr float cage_ndc_offset_ = 0.5f;
88 static constexpr float edge_ndc_offset_ = 1.0f;
89 static constexpr float vert_ndc_offset_ = 1.5f;
90
91 /* TODO(fclem): This is quite wasteful and expensive, prefer in shader Z modification like the
92 * retopology offset. */
93 View view_edit_cage_ = {"view_edit_cage"};
94 View::OffsetData offset_data_;
95
96 public:
97 void begin_sync(Resources &res, const State &state) final
98 {
99 enabled_ = state.is_space_v3d();
100
101 if (!enabled_) {
102 return;
103 }
104
105 offset_data_ = state.offset_data_get();
106 xray_enabled_ = state.xray_enabled;
107 xray_flag_enabled_ = state.xray_flag_enabled;
108
109 const int edit_flag = state.v3d->overlay.edit_flag;
110
111 const ToolSettings *tsettings = state.scene->toolsettings;
112 select_vert_ = (tsettings->selectmode & SCE_SELECT_VERTEX);
113 select_edge_ = (tsettings->selectmode & SCE_SELECT_EDGE);
114 select_face_ = (tsettings->selectmode & SCE_SELECT_FACE);
115 select_face_dots_ = ((edit_flag & V3D_OVERLAY_EDIT_FACE_DOT) || state.xray_flag_enabled) &
116 select_face_;
117
118 show_retopology_ = (edit_flag & V3D_OVERLAY_EDIT_RETOPOLOGY) && !state.xray_enabled;
119 show_mesh_analysis_ = (edit_flag & V3D_OVERLAY_EDIT_STATVIS);
120 show_face_overlay_ = (edit_flag & V3D_OVERLAY_EDIT_FACES);
121 show_weight_ = (edit_flag & V3D_OVERLAY_EDIT_WEIGHT);
122
123 const bool show_face_nor = (edit_flag & V3D_OVERLAY_EDIT_FACE_NORMALS);
124 const bool show_loop_nor = (edit_flag & V3D_OVERLAY_EDIT_LOOP_NORMALS);
125 const bool show_vert_nor = (edit_flag & V3D_OVERLAY_EDIT_VERT_NORMALS);
126
127 const bool do_smooth_wire = (U.gpu_flag & USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE) == 0;
128 const bool is_wire_shading_mode = (state.v3d->shading.type == OB_WIRE);
129
130 uint4 data_mask = data_mask_get(edit_flag);
131
132 float backwire_opacity = (state.xray_flag_enabled) ? 0.5f : 1.0f;
133 float face_alpha = (show_face_overlay_) ? 1.0f : 0.0f;
134 float retopology_offset = state.is_depth_only_drawing ? 0.0f : RETOPOLOGY_OFFSET(state.v3d);
135 /* Cull back-faces for retopology face pass. This makes it so back-faces are not drawn.
136 * Doing so lets us distinguish back-faces from front-faces. */
137 DRWState face_culling = (show_retopology_) ? DRW_STATE_CULL_BACK : DRWState(0);
138
139 gpu::Texture **depth_tex = (state.xray_flag_enabled) ? &res.depth_tx : &res.dummy_depth_tx;
140
141 {
142 auto &pass = edit_mesh_prepass_ps_;
143 pass.init();
144 pass.state_set(DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | face_culling,
145 state.clipping_plane_count);
146 pass.shader_set(res.shaders->mesh_edit_depth.get());
147 pass.push_constant("retopology_offset", retopology_offset);
148 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
149 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
150 }
151 {
152 /* Normals */
153 const bool use_screen_size = (edit_flag & V3D_OVERLAY_EDIT_CONSTANT_SCREEN_SIZE_NORMALS);
154 const bool use_hq_normals = (state.scene->r.perf_flag & SCE_PERF_HQ_NORMALS) ||
156
159 if (state.xray_flag_enabled) {
160 pass_state |= DRW_STATE_BLEND_ALPHA;
161 }
162
163 auto &pass = edit_mesh_normals_ps_;
164 pass.init();
165 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
166 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
167 pass.state_set(pass_state, state.clipping_plane_count);
168
169 auto shader_pass = [&](gpu::Shader *shader, const char *name) {
170 auto &sub = pass.sub(name);
171 sub.shader_set(shader);
172 sub.bind_texture("depth_tx", depth_tex);
173 sub.push_constant("alpha", backwire_opacity);
174 sub.push_constant("is_constant_screen_size_normals", use_screen_size);
175 sub.push_constant("normal_size", state.overlay.normals_length);
176 sub.push_constant("normal_screen_size", state.overlay.normals_constant_screen_size);
177 sub.push_constant("retopology_offset", retopology_offset);
178 sub.push_constant("hq_normals", use_hq_normals);
179 return &sub;
180 };
181
182 face_normals_ = loop_normals_ = vert_normals_ = nullptr;
183
184 if (show_face_nor) {
185 face_normals_subdiv_ = shader_pass(res.shaders->mesh_face_normal_subdiv.get(), "SubdFNor");
186 face_normals_ = shader_pass(res.shaders->mesh_face_normal.get(), "FaceNor");
187 }
188 if (show_loop_nor) {
189 loop_normals_subdiv_ = shader_pass(res.shaders->mesh_loop_normal_subdiv.get(), "SubdLNor");
190 loop_normals_ = shader_pass(res.shaders->mesh_loop_normal.get(), "LoopNor");
191 }
192 if (show_vert_nor) {
193 vert_normals_subdiv_ = shader_pass(res.shaders->mesh_vert_normal_subdiv.get(), "SubdVNor");
194 vert_normals_ = shader_pass(res.shaders->mesh_vert_normal.get(), "VertexNor");
195 }
196 }
197 {
198 /* Support masked transparency in Workbench.
199 * EEVEE can't be supported since depth won't match. */
200 const bool shadeless = eDrawType(state.v3d->shading.type) == OB_WIRE;
201
202 auto &pass = edit_mesh_weight_ps_;
203 pass.init();
205 state.clipping_plane_count);
206 pass.shader_set(shadeless ? res.shaders->paint_weight.get() :
207 res.shaders->paint_weight_fake_shading.get());
208 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
209 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
210 pass.bind_texture("colorramp", &res.weight_ramp_tx);
211 pass.push_constant("draw_contours", false);
212 pass.push_constant("opacity", state.overlay.weight_paint_mode_opacity);
213 if (!shadeless) {
214 /* Arbitrary light to give a hint of the geometry behind the weights. */
215 pass.push_constant("light_dir", math::normalize(float3(0.0f, 0.5f, 0.86602f)));
216 }
217 }
218 {
219 auto &pass = edit_mesh_analysis_ps_;
220 pass.init();
222 state.clipping_plane_count);
223 pass.shader_set(res.shaders->mesh_analysis.get());
224 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
225 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
226 pass.bind_texture("weight_tx", res.weight_ramp_tx);
227 }
228
229 auto mesh_edit_common_resource_bind = [&](PassSimple &pass, float alpha, float ndc_offset) {
230 pass.bind_texture("depth_tx", depth_tex);
231 /* TODO(fclem): UBO. */
232 pass.push_constant("wire_shading", is_wire_shading_mode);
233 pass.push_constant("select_face", select_face_);
234 pass.push_constant("select_edge", select_edge_);
235 pass.push_constant("alpha", alpha);
236 pass.push_constant("retopology_offset", retopology_offset);
237 pass.push_constant("ndc_offset_factor", &state.ndc_offset_factor);
238 pass.push_constant("ndc_offset", ndc_offset);
239 pass.push_constant("data_mask", int4(data_mask));
240 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
241 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
242 };
243
244 {
245 auto &pass = edit_mesh_edges_ps_;
246 pass.init();
247 /* Change first vertex convention to match blender loop structure. */
250 state.clipping_plane_count);
251 pass.shader_set(res.shaders->mesh_edit_edge.get());
252 pass.push_constant("do_smooth_wire", do_smooth_wire);
253 pass.push_constant("use_vertex_selection", select_vert_);
254 mesh_edit_common_resource_bind(pass, backwire_opacity, edge_ndc_offset_);
255 }
256 {
257 auto &pass = edit_mesh_faces_ps_;
258 pass.init();
260 face_culling,
261 state.clipping_plane_count);
262 pass.shader_set(res.shaders->mesh_edit_face.get());
263 mesh_edit_common_resource_bind(pass, face_alpha, 0.0f);
264 }
265 {
266 auto &pass = edit_mesh_cages_ps_;
267 pass.init();
269 state.clipping_plane_count);
270 pass.shader_set(res.shaders->mesh_edit_face.get());
271 mesh_edit_common_resource_bind(pass, face_alpha, cage_ndc_offset_);
272 }
273 {
274 auto &pass = edit_mesh_verts_ps_;
275 pass.init();
278 state.clipping_plane_count);
279 pass.shader_set(res.shaders->mesh_edit_vert.get());
280 mesh_edit_common_resource_bind(pass, backwire_opacity, vert_ndc_offset_);
281 }
282 {
283 auto &pass = edit_mesh_facedots_ps_;
284 pass.init();
287 state.clipping_plane_count);
288 pass.shader_set(res.shaders->mesh_edit_facedot.get());
289 mesh_edit_common_resource_bind(pass, backwire_opacity, vert_ndc_offset_);
290 }
291 {
292 auto &pass = edit_mesh_skin_roots_ps_;
293 pass.init();
296 state.clipping_plane_count);
297 pass.shader_set(res.shaders->mesh_edit_skin_root.get());
298 pass.push_constant("retopology_offset", retopology_offset);
299 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
300 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
301 }
302 }
303
305 const ObjectRef &ob_ref,
306 Resources & /*res*/,
307 const State &state) final
308 {
309 if (!enabled_) {
310 return;
311 }
312
313 ResourceHandleRange res_handle = manager.unique_handle(ob_ref);
314
315 Object *ob = ob_ref.object;
317 /* WORKAROUND: GPU subdiv uses a different normal format. Remove this once GPU subdiv is
318 * refactored. */
319 const bool use_gpu_subdiv = BKE_subsurf_modifier_has_gpu_subdiv(&mesh);
320 const bool draw_as_solid = (ob->dt > OB_WIRE) && !state.xray_enabled;
321 const bool has_edit_cage = mesh_has_edit_cage(ob);
322
323 if (show_retopology_) {
325 edit_mesh_prepass_ps_.draw(geom, res_handle);
326 }
327 if (draw_as_solid && !state.is_render_depth_available) {
328 gpu::Batch *geom = DRW_cache_mesh_surface_get(ob);
329 edit_mesh_prepass_ps_.draw(geom, res_handle);
330 }
331
332 if (show_mesh_analysis_) {
333 gpu::Batch *geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
334 edit_mesh_analysis_ps_.draw(geom, res_handle);
335 }
336
337 if (show_weight_) {
338 gpu::Batch *geom = DRW_cache_mesh_surface_weights_get(ob);
339 edit_mesh_weight_ps_.draw(geom, res_handle);
340 }
341
342 if (face_normals_) {
344 (use_gpu_subdiv && !has_edit_cage ? face_normals_subdiv_ : face_normals_)
345 ->draw_expand(geom, GPU_PRIM_LINES, 1, 1, res_handle);
346 }
347 if (loop_normals_) {
349 (use_gpu_subdiv && !has_edit_cage ? loop_normals_subdiv_ : loop_normals_)
350 ->draw_expand(geom, GPU_PRIM_LINES, 1, 1, res_handle);
351 }
352 if (vert_normals_) {
354 ((use_gpu_subdiv && !has_edit_cage) ? vert_normals_subdiv_ : vert_normals_)
355 ->draw_expand(geom, GPU_PRIM_LINES, 1, 1, res_handle);
356 }
357
358 {
359 gpu::Batch *geom = DRW_mesh_batch_cache_get_edit_edges(mesh);
360 edit_mesh_edges_ps_.draw_expand(geom, GPU_PRIM_TRIS, 2, 1, res_handle);
361 }
362 {
364 (has_edit_cage ? &edit_mesh_cages_ps_ : &edit_mesh_faces_ps_)->draw(geom, res_handle);
365 }
366 if (select_vert_) {
368 edit_mesh_verts_ps_.draw(geom, res_handle);
369 }
370 if (select_face_dots_) {
372 edit_mesh_facedots_ps_.draw(geom, res_handle);
373 }
374
375 if (mesh_has_skin_roots(ob)) {
377 edit_mesh_skin_roots_ps_.draw_expand(geom, GPU_PRIM_LINES, 15, 1, res_handle);
378 }
379 if (state.show_text && (state.overlay.edit_flag & overlay_edit_text)) {
380 DRW_text_edit_mesh_measure_stats(state.region, state.v3d, ob, state.scene->unit, state.dt);
381 }
382 }
383
384 void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
385 {
386 if (!enabled_) {
387 return;
388 }
389
390 GPU_debug_group_begin("Mesh Edit");
391
392 GPU_framebuffer_bind(framebuffer);
393 manager.submit(edit_mesh_prepass_ps_, view);
394 manager.submit(edit_mesh_analysis_ps_, view);
395 manager.submit(edit_mesh_weight_ps_, view);
396
397 if (!xray_enabled_) {
398 /* Still use depth-testing for selected faces when X-Ray flag is enabled but transparency is
399 * off (X-Ray Opacity == 1.0 or in Preview/Render mode) (See #135325). */
400 manager.submit(edit_mesh_faces_ps_, view);
401 manager.submit(edit_mesh_cages_ps_, view);
402 }
403
404 if (xray_flag_enabled_) {
406 return;
407 }
408
409 manager.submit(edit_mesh_normals_ps_, view);
410 manager.submit(edit_mesh_edges_ps_, view);
411 manager.submit(edit_mesh_verts_ps_, view);
412 manager.submit(edit_mesh_skin_roots_ps_, view);
413 manager.submit(edit_mesh_facedots_ps_, view);
414
416 }
417
418 void draw_line_only(Framebuffer &framebuffer, Manager &manager, View &view) final
419 {
420 if (!enabled_) {
421 return;
422 }
423
424 if (xray_enabled_) {
425 /* Still use depth-testing for selected faces when X-Ray flag is enabled but transparency is
426 * off (X-Ray Opacity == 1.0 or in Preview/Render mode) (See #135325). */
427 GPU_framebuffer_bind(framebuffer);
428 manager.submit(edit_mesh_faces_ps_, view);
429 manager.submit(edit_mesh_cages_ps_, view);
430 }
431
432 if (!xray_flag_enabled_) {
433 return;
434 }
435
436 GPU_debug_group_begin("Mesh Edit Line Only");
437
438 GPU_framebuffer_bind(framebuffer);
439 manager.submit(edit_mesh_normals_ps_, view);
440 manager.submit(edit_mesh_edges_ps_, view);
441 manager.submit(edit_mesh_verts_ps_, view);
442 manager.submit(edit_mesh_skin_roots_ps_, view);
443 manager.submit(edit_mesh_facedots_ps_, view);
444
446 }
447
448 static bool mesh_has_edit_cage(const Object *ob)
449 {
450 BLI_assert(ob->type == OB_MESH);
452 if (mesh.runtime->edit_mesh != nullptr) {
453 const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob);
454 const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob);
455
456 return (editmesh_eval_cage != nullptr) && (editmesh_eval_cage != editmesh_eval_final);
457 }
458 return false;
459 }
460
461 private:
462 uint4 data_mask_get(const int flag)
463 {
464 uint4 mask = {0xFF, 0xFF, 0x00, 0x00};
472 return mask;
473 }
474
475 static bool mesh_has_skin_roots(const Object *ob)
476 {
478 if (const BMesh *bm = BKE_editmesh_bmesh_get(&mesh)) {
479 if (CustomData_get_offset_named(&bm->vdata, CD_PROP_FLOAT2, "skin_modifier_radius") == -1) {
480 return false;
481 }
482 if (CustomData_get_offset_named(&bm->vdata, CD_PROP_BOOL, "skin_modifier_root") == -1) {
483 return false;
484 }
485 return true;
486 }
487 return false;
488 }
489};
490
495 private:
496 PassSimple analysis_ps_ = {"Mesh Analysis"};
497
498 /* TODO(fclem): Should be its own Overlay?. */
499 PassSimple wireframe_ps_ = {"Wireframe"};
500
501 PassSimple edges_ps_ = {"Edges"};
502 PassSimple faces_ps_ = {"Faces"};
503 PassSimple verts_ps_ = {"Verts"};
504 PassSimple facedots_ps_ = {"FaceDots"};
505
506 /* TODO(fclem): Should be its own Overlay?. */
507 PassSimple image_border_ps_ = {"ImageBorder"};
508
509 /* TODO(fclem): Should be its own Overlay?. */
510 PassSimple brush_stencil_ps_ = {"BrushStencil"};
511
512 /* TODO(fclem): Should be its own Overlay?. */
513 PassSimple paint_mask_ps_ = {"PaintMask"};
514
515 bool select_vert_ = false;
516 bool select_edge_ = false;
517 bool select_face_ = false;
518 bool select_face_dots_ = false;
519
520 bool show_face_overlay_ = false;
521
522 bool show_uv_edit_ = false;
523
525 /* Draw final evaluated UVs (modifier stack applied) as grayed out wire-frame. */
526 /* TODO(fclem): Maybe should be its own Overlay?. */
527 bool show_wireframe_ = false;
528
530 /* TODO(fclem): Maybe should be its own Overlay?. */
531 bool show_stencil_ = false;
532
534 /* TODO(fclem): Maybe should be its own Overlay?. */
535 bool show_mask_ = false;
537 Mask *mask_id_ = nullptr;
538 Texture mask_texture_ = {"mask_texture_"};
539
541 bool show_mesh_analysis_ = false;
542 eSpaceImage_UVDT_Stretch mesh_analysis_type_;
548 Vector<float *> per_mesh_area_3d_;
549 Vector<float *> per_mesh_area_2d_;
550 float total_area_ratio_;
551
553 bool show_tiled_image_active_ = false;
554 bool show_tiled_image_border_ = false;
555 bool show_tiled_image_label_ = false;
556
557 public:
558 void begin_sync(Resources &res, const State &state) final
559 {
560 enabled_ = state.is_space_image();
561
562 if (!enabled_) {
563 return;
564 }
565
566 const ToolSettings *tool_setting = state.scene->toolsettings;
567 const SpaceImage *space_image = reinterpret_cast<const SpaceImage *>(state.space_data);
568 blender::Image *image = space_image->image;
569 const bool space_mode_is_paint = space_image->mode == SI_MODE_PAINT;
570 const bool space_mode_is_mask = space_image->mode == SI_MODE_MASK;
571 const bool space_mode_is_uv = space_image->mode == SI_MODE_UV;
572
573 const bool object_mode_is_edit = state.object_mode & OB_MODE_EDIT;
574
575 const bool is_viewer = image && ELEM(image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE);
576 const bool is_tiled_image = image && (image->source == IMA_SRC_TILED);
577
578 /* The mask overlay is always drawn when enabled, even on top of viewers. */
579 {
580 /* Mask Overlay. */
581 show_mask_ = space_mode_is_mask && space_image->mask_info.mask &&
583 if (show_mask_) {
584 mask_mode_ = MaskOverlayMode(space_image->mask_info.overlay_mode);
585 mask_id_ = DEG_get_evaluated(state.depsgraph, space_image->mask_info.mask);
586 }
587 else {
588 mask_id_ = nullptr;
589 }
590 }
591
592 /* Only disable UV drawing on top of render results.
593 * Otherwise, show UVs even in the absence of active image. */
594 enabled_ = !is_viewer || show_mask_;
595
596 if (!enabled_) {
597 return;
598 }
599
600 {
601 /* Edit UV Overlay. */
602 show_uv_edit_ = space_mode_is_uv && object_mode_is_edit;
603 show_mesh_analysis_ = show_uv_edit_ && (space_image->flag & SI_DRAW_STRETCH);
604
605 if (!show_uv_edit_) {
606 select_vert_ = false;
607 select_edge_ = false;
608 select_face_ = false;
609 select_face_dots_ = false;
610
611 show_face_overlay_ = false;
612 }
613 else {
614 const bool hide_faces = space_image->flag & SI_NO_DRAWFACES;
615 select_face_ = !show_mesh_analysis_ && !hide_faces;
616
617 /* FIXME: Always showing verts in edge mode when `uv_select_sync_valid`.
618 * needs investigation. */
619 if (tool_setting->uv_flag & UV_FLAG_SELECT_SYNC) {
620 const char sel_mode_3d = tool_setting->selectmode;
621 if (tool_setting->uv_sticky == UV_STICKY_VERT) {
622 /* NOTE: Ignore #SCE_SELECT_VERTEX because a single selected edge
623 * on the mesh may cause single UV vertices to be selected. */
624 select_vert_ = true;
625 }
626 else {
627 select_vert_ = (sel_mode_3d & SCE_SELECT_VERTEX);
628 }
629 /* When */
630 select_edge_ = (sel_mode_3d & SCE_SELECT_VERTEX) == 0;
631 select_face_dots_ = (sel_mode_3d & SCE_SELECT_FACE) && !hide_faces;
632 }
633 else {
634 const char sel_mode_2d = tool_setting->uv_selectmode;
635 select_vert_ = (sel_mode_2d != UV_SELECT_EDGE);
636 select_edge_ = (sel_mode_2d == UV_SELECT_EDGE);
637 select_face_dots_ = (sel_mode_2d & UV_SELECT_FACE) && !hide_faces;
638 }
639 }
640
641 if (show_mesh_analysis_) {
642 mesh_analysis_type_ = eSpaceImage_UVDT_Stretch(space_image->dt_uvstretch);
643 }
644 }
645 {
646 /* Wireframe UV Overlay. */
647 const bool show_wireframe_uv_edit = space_image->flag & SI_DRAWSHADOW;
648 const bool show_wireframe_uv_guide = !(space_image->flag & SI_NO_DRAW_UV_GUIDE) &&
649 (space_mode_is_paint || space_mode_is_uv);
650
651 if (space_mode_is_uv && object_mode_is_edit) {
652 show_wireframe_ = show_wireframe_uv_edit;
653 show_face_overlay_ = !(space_image->flag & SI_NO_DRAWFACES);
654 }
655 else {
656 show_wireframe_ = show_wireframe_uv_guide;
657 /* The face overlay is always enabled when showing wire-frame. */
658 show_face_overlay_ = show_wireframe_;
659 }
660 }
661
662 {
663 /* Brush Stencil Overlay. */
664 const ImagePaintSettings &image_paint_settings = tool_setting->imapaint;
665 const Brush *brush = BKE_paint_brush_for_read(&image_paint_settings.paint);
666 show_stencil_ = space_mode_is_paint && brush &&
667 (brush->image_brush_type == IMAGE_PAINT_BRUSH_TYPE_CLONE) &&
668 image_paint_settings.clone;
669 }
670 {
671 /* UDIM Overlay. */
672 /* TODO: Always enable this overlay even if overlays are disabled. */
673 show_tiled_image_border_ = is_tiled_image;
674 show_tiled_image_active_ = is_tiled_image; /* TODO: Only disable this if overlays are off. */
675 show_tiled_image_label_ = is_tiled_image; /* TODO: Only disable this if overlays are off. */
676 }
677
678 const bool do_smooth_wire = (U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0;
679 const float dash_length = 4.0f * UI_SCALE_FAC;
680
681 if (show_wireframe_) {
682 auto &pass = wireframe_ps_;
683 pass.init();
686 pass.shader_set(res.shaders->uv_wireframe.get());
687 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
688 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
689 pass.push_constant("alpha", space_image->uv_edge_opacity);
690 pass.push_constant("do_smooth_wire", do_smooth_wire);
691 }
692
693 if (show_uv_edit_) {
694 auto &pass = edges_ps_;
695 pass.init();
698
699 gpu::Shader *sh = res.shaders->uv_edit_edge.get();
700 pass.specialize_constant(sh, "use_edge_select", select_edge_);
701 pass.shader_set(sh);
702 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
703 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
704 pass.push_constant("line_style", int(edit_uv_line_style_from_space_image(space_image)));
705
706 /* The `uv_opacity` setting does not apply to vertices & face-dots.
707 * This means it may be useful show vertices/faces while hiding the wire-frame.
708 * An exception to this is when only UV edges are displayed (UV edge mode).
709 * In this case, hiding the wire-frame has the effect of hiding UV's entirely.
710 * Set the alpha to 1.0 in this case.
711 * To hide all UV's, overlays can be disabled entirely. */
712 const float alpha = (select_vert_ || select_face_dots_) ? space_image->uv_opacity : 1.0f;
713 pass.push_constant("alpha", alpha);
714 pass.push_constant("dash_length", dash_length);
715 pass.push_constant("do_smooth_wire", do_smooth_wire);
716 }
717
718 if (select_vert_) {
719 const float dot_size = ui::theme::get_value_f(TH_VERTEX_SIZE) * UI_SCALE_FAC;
720 float4 theme_color;
722 srgb_to_linearrgb_v4(theme_color, theme_color);
723
724 auto &pass = verts_ps_;
725 pass.init();
728 pass.shader_set(res.shaders->uv_edit_vert.get());
729 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
730 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
731 pass.push_constant("dot_size", (dot_size + 1.5f) * float(M_SQRT2));
732 pass.push_constant("outline_width", 0.75f);
733 pass.push_constant("color", theme_color);
734 }
735
736 if (select_face_dots_) {
737 const float dot_size = ui::theme::get_value_f(TH_FACEDOT_SIZE) * UI_SCALE_FAC;
738
739 auto &pass = facedots_ps_;
740 pass.init();
743 pass.shader_set(res.shaders->uv_edit_facedot.get());
744 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
745 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
746 pass.push_constant("dot_size", dot_size);
747 }
748
749 if (show_face_overlay_ || select_face_) {
750 const float opacity = (object_mode_is_edit && space_mode_is_uv) ?
751 space_image->uv_opacity :
752 space_image->uv_face_opacity;
753
754 auto &pass = faces_ps_;
755 pass.init();
757 pass.shader_set(res.shaders->uv_edit_face.get());
758 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
759 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
760 pass.push_constant("uv_opacity", opacity);
761 }
762
763 if (show_mesh_analysis_) {
764 auto &pass = analysis_ps_;
765 pass.init();
767 pass.shader_set(mesh_analysis_type_ == SI_UVDT_STRETCH_ANGLE ?
768 res.shaders->uv_analysis_stretch_angle.get() :
769 res.shaders->uv_analysis_stretch_area.get());
770 pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
771 pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
772 pass.push_constant("aspect", state.image_uv_aspect);
773 pass.push_constant("stretch_opacity", space_image->stretch_opacity);
774 pass.push_constant("total_area_ratio", &total_area_ratio_);
775 }
776
777 per_mesh_area_3d_.clear();
778 per_mesh_area_2d_.clear();
779 }
780
781 void object_sync(Manager &manager,
782 const ObjectRef &ob_ref,
783 Resources & /*res*/,
784 const State &state) final
785 {
786 if (!enabled_ || ob_ref.object->type != OB_MESH ||
787 !((ob_ref.object->base_flag & BASE_SELECTED) || (ob_ref.object == state.object_active)))
788 {
789 return;
790 }
791
792 Object *ob = ob_ref.object;
794
795 const SpaceImage *space_image = reinterpret_cast<const SpaceImage *>(state.space_data);
796 const StringRef active_uv_map = mesh.active_or_default_uv_map_name();
797 const bke::AttributeAccessor attributes = mesh.attributes();
798 const std::optional<bke::AttributeMetaData> meta_data = attributes.lookup_meta_data(
799 active_uv_map);
800 const bool has_active_object_uvmap = bke::mesh::is_uv_map(meta_data);
801
802 ResourceHandleRange res_handle = manager.unique_handle(ob_ref);
803
804 if (show_wireframe_ && has_active_object_uvmap) {
805 gpu::Batch *geom = DRW_mesh_batch_cache_get_all_uv_wireframe(*ob, mesh);
806 wireframe_ps_.draw_expand(geom, GPU_PRIM_TRIS, 2, 1, res_handle);
807 }
808 if (show_face_overlay_ && has_active_object_uvmap && space_image->uv_face_opacity > 0.0f) {
809 gpu::Batch *geom = DRW_mesh_batch_cache_get_uv_faces(*ob, mesh);
810 faces_ps_.draw(geom, res_handle);
811 }
812 }
813
815 const ObjectRef &ob_ref,
816 Resources & /*res*/,
817 const State &state) final
818 {
819 if (!enabled_ || ob_ref.object->type != OB_MESH) {
820 return;
821 }
822
823 Object &ob = *ob_ref.object;
825
826 const Object *ob_orig = DEG_get_original(ob_ref.object);
827 const Mesh &mesh_orig = ob_orig->type == OB_MESH ? *id_cast<Mesh *>(ob_orig->data) : mesh;
828 const BMesh *bm = BKE_editmesh_bmesh_get(&mesh_orig);
829
830 const SpaceImage *space_image = reinterpret_cast<const SpaceImage *>(state.space_data);
831 const bool is_edit_object = DRW_object_is_in_edit_mode(&ob);
832 const bool is_uv_editable = is_edit_object && space_image->mode == SI_MODE_UV;
833 /* Sculpt is left out here because selection does not exist in it. */
834 const bool is_paint_mode = ELEM(
836 const bool use_face_selection = (mesh_orig.editflag & ME_EDIT_PAINT_FACE_SEL);
837 const bool is_face_selectable = (is_edit_object || (is_paint_mode && use_face_selection));
838 const StringRef active_uv_map = mesh.active_or_default_uv_map_name();
839 const bke::AttributeAccessor attributes = mesh.attributes();
840 const std::optional<bke::AttributeMetaData> meta_data = attributes.lookup_meta_data(
841 active_uv_map);
842 const bool has_active_object_uvmap = bke::mesh::is_uv_map(meta_data);
843
844 const bool has_active_edit_uvmap = is_edit_object && CustomData_has_layer_named(&bm->ldata,
846 active_uv_map);
847
848 ResourceHandleRange res_handle = manager.unique_handle(ob_ref);
849
850 /* Fully editable UVs in the UV Editor. */
851 if (has_active_edit_uvmap && is_uv_editable) {
852 if (show_uv_edit_) {
853 gpu::Batch *geom = DRW_mesh_batch_cache_get_edituv_edges(ob, mesh);
854 edges_ps_.draw_expand(geom, GPU_PRIM_TRIS, 2, 1, res_handle);
855 }
856 if (select_vert_) {
857 gpu::Batch *geom = DRW_mesh_batch_cache_get_edituv_verts(ob, mesh);
858 verts_ps_.draw(geom, res_handle);
859 }
860 if (select_face_dots_) {
861 gpu::Batch *geom = DRW_mesh_batch_cache_get_edituv_facedots(ob, mesh);
862 facedots_ps_.draw(geom, res_handle);
863 }
864 if (show_face_overlay_ || select_face_) {
865 gpu::Batch *geom = DRW_mesh_batch_cache_get_edituv_faces(ob, mesh);
866 faces_ps_.draw(geom, res_handle);
867 }
868 if (show_wireframe_) {
869 gpu::Batch *geom = DRW_mesh_batch_cache_get_edituv_wireframe(ob, mesh);
870 wireframe_ps_.draw_expand(geom, GPU_PRIM_TRIS, 2, 1, res_handle);
871 }
872
873 if (show_mesh_analysis_) {
874 int index_3d, index_2d;
875 if (mesh_analysis_type_ == SI_UVDT_STRETCH_AREA) {
876 index_3d = per_mesh_area_3d_.append_and_get_index(nullptr);
877 index_2d = per_mesh_area_2d_.append_and_get_index(nullptr);
878 }
879
880 gpu::Batch *geom =
881 mesh_analysis_type_ == SI_UVDT_STRETCH_ANGLE ?
884 ob, mesh, &per_mesh_area_3d_[index_3d], &per_mesh_area_2d_[index_2d]);
885
886 analysis_ps_.draw(geom, res_handle);
887 }
888 return;
889 }
890
891 /* Selectable faces in 3D viewport that sync with image editor paint mode. */
892 if ((has_active_object_uvmap || has_active_edit_uvmap) && is_face_selectable) {
893 if (show_wireframe_) {
894 gpu::Batch *geom = DRW_mesh_batch_cache_get_uv_wireframe(ob, mesh);
895 wireframe_ps_.draw_expand(geom, GPU_PRIM_TRIS, 2, 1, res_handle);
896 }
897 if ((show_face_overlay_ && space_image->uv_face_opacity > 0.0f) || select_face_) {
898 gpu::Batch *geom = DRW_mesh_batch_cache_get_uv_faces(ob, mesh);
899 faces_ps_.draw(geom, res_handle);
900 }
901 return;
902 }
903
904 /* Non-selectable & non-editable faces in image editor paint mode. */
905 if ((has_active_object_uvmap || has_active_edit_uvmap) && !is_uv_editable &&
906 !is_face_selectable)
907 {
908 if (show_wireframe_) {
909 gpu::Batch *geom = DRW_mesh_batch_cache_get_all_uv_wireframe(ob, mesh);
910 wireframe_ps_.draw_expand(geom, GPU_PRIM_TRIS, 2, 1, res_handle);
911 }
912 if (show_face_overlay_ && space_image->uv_face_opacity > 0.0f) {
913 gpu::Batch *geom = DRW_mesh_batch_cache_get_uv_faces(ob, mesh);
914 faces_ps_.draw(geom, res_handle);
915 }
916 }
917 }
918
919 void end_sync(Resources &res, const State &state) final
920 {
921 if (!enabled_) {
922 return;
923 }
924
925 {
926 float total_3d = 0.0f;
927 float total_2d = 0.0f;
928 for (const float *mesh_area_2d : per_mesh_area_2d_) {
929 total_2d += *mesh_area_2d;
930 }
931 for (const float *mesh_area_3d : per_mesh_area_3d_) {
932 total_3d += *mesh_area_3d;
933 }
934 total_area_ratio_ = total_3d * math::safe_rcp(total_2d);
935 }
936
937 const ToolSettings *tool_setting = state.scene->toolsettings;
938 const SpaceImage *space_image = reinterpret_cast<const SpaceImage *>(state.space_data);
939 blender::Image *image = space_image->image;
940
941 if (show_tiled_image_border_) {
942 float4 theme_color;
943 float4 selected_color;
944 uchar4 text_color;
945 /* Color Management: Exception here as texts are drawn in sRGB space directly. No conversion
946 * required. */
948 ui::theme::get_color_shade_4fv(TH_BACK, 60, theme_color);
950 srgb_to_linearrgb_v4(theme_color, theme_color);
951 srgb_to_linearrgb_v4(selected_color, selected_color);
952
953 auto &pass = image_border_ps_;
954 pass.init();
956 pass.shader_set(res.shaders->uv_image_borders.get());
957
958 auto draw_tile = [&](const ImageTile *tile, const bool is_active) {
959 const int tile_x = ((tile->tile_number - 1001) % 10);
960 const int tile_y = ((tile->tile_number - 1001) / 10);
961 const float3 tile_location(tile_x, tile_y, 0.0f);
962 pass.push_constant("tile_pos", tile_location);
963 pass.push_constant("ucolor", is_active ? selected_color : theme_color);
964 pass.draw(res.shapes.quad_wire.get());
965
966 /* Note: don't draw label twice for active tile. */
967 if (show_tiled_image_label_ && !is_active) {
968 std::string text = std::to_string(tile->tile_number);
970 tile_location,
971 text.c_str(),
972 text.size(),
973 10,
974 10,
976 text_color);
977 }
978 };
979
981 /* image->active_tile_index could point to a non existing ImageTile. To work around this we
982 * get the active tile when looping over all tiles. */
983 const ImageTile *active_tile = nullptr;
984 int tile_index = 0;
985 for (const ImageTile *tile : tiles) {
986 draw_tile(tile, false);
987 if (tile_index == image->active_tile_index) {
988 active_tile = tile;
989 }
990 tile_index++;
991 }
992 /* Draw active tile on top. */
993 if (show_tiled_image_active_ && active_tile != nullptr) {
994 draw_tile(active_tile, true);
995 }
996 }
997
998 if (show_stencil_) {
999 auto &pass = brush_stencil_ps_;
1000 pass.init();
1003
1004 const ImagePaintSettings &image_paint_settings = tool_setting->imapaint;
1005 blender::Image *stencil_image = image_paint_settings.clone;
1006 gpu::Texture *stencil_gpu_texture = BKE_image_acquire_gpu_texture(stencil_image, nullptr);
1007 DRW_manager_get()->hold_texture(stencil_gpu_texture);
1008 TextureRef stencil_texture;
1009 stencil_texture.wrap(stencil_gpu_texture);
1010
1011 if (stencil_texture.is_valid()) {
1012 float2 size_image;
1013 BKE_image_get_size_fl(image, nullptr, &size_image[0]);
1014
1015 pass.shader_set(res.shaders->uv_brush_stencil.get());
1016 pass.bind_texture("img_tx", stencil_texture);
1017 pass.push_constant("img_premultiplied", true);
1018 pass.push_constant("img_alpha_blend", true);
1019 pass.push_constant("ucolor", float4(1.0f, 1.0f, 1.0f, image_paint_settings.clone_alpha));
1020 pass.push_constant("brush_offset", float2(image_paint_settings.clone_offset));
1021 pass.push_constant("brush_scale", float2(stencil_texture.size().xy()) / size_image);
1022 pass.draw(res.shapes.quad_solid.get());
1023 }
1024 }
1025
1026 if (show_mask_) {
1027 paint_mask_texture_ensure(mask_id_, state.image_size, state.image_aspect);
1028
1029 const bool is_combined = mask_mode_ == MASK_OVERLAY_COMBINED;
1030 const float opacity = is_combined ? space_image->mask_info.blend_factor : 1.0f;
1031
1032 auto &pass = paint_mask_ps_;
1033 pass.init();
1035 (is_combined ? DRW_STATE_BLEND_MUL : DRW_STATE_BLEND_ALPHA));
1036 pass.shader_set(res.shaders->uv_paint_mask.get());
1037 pass.bind_texture("img_tx", mask_texture_);
1038 pass.push_constant("color", float4(1.0f, 1.0f, 1.0f, 1.0f));
1039 pass.push_constant("opacity", opacity);
1040 pass.push_constant("brush_offset", float2(0.0f));
1041 pass.push_constant("brush_scale", float2(1.0f));
1042 pass.draw(res.shapes.quad_solid.get());
1043 }
1044 }
1045
1046 void draw(Framebuffer &framebuffer, Manager &manager, View &view) final
1047 {
1048 if (!enabled_) {
1049 return;
1050 }
1051
1052 GPU_debug_group_begin("Mesh Edit UVs");
1053
1054 GPU_framebuffer_bind(framebuffer);
1055 if (show_mask_ && (mask_mode_ != MASK_OVERLAY_COMBINED)) {
1056 manager.submit(paint_mask_ps_, view);
1057 }
1058 if (show_tiled_image_border_) {
1059 manager.submit(image_border_ps_, view);
1060 }
1061 if (show_wireframe_) {
1062 manager.submit(wireframe_ps_, view);
1063 }
1064 if (show_mesh_analysis_) {
1065 manager.submit(analysis_ps_, view);
1066 }
1067 if (show_face_overlay_ || select_face_) {
1068 manager.submit(faces_ps_, view);
1069 }
1070 if (show_uv_edit_) {
1071 manager.submit(edges_ps_, view);
1072 }
1073 if (select_face_dots_) {
1074 manager.submit(facedots_ps_, view);
1075 }
1076 if (select_vert_) {
1077 manager.submit(verts_ps_, view);
1078 }
1079 if (show_stencil_) {
1080 manager.submit(brush_stencil_ps_, view);
1081 }
1082
1084 }
1085
1086 void draw_on_render(gpu::FrameBuffer *framebuffer, Manager &manager, View &view) final
1087 {
1088 if (!enabled_) {
1089 return;
1090 }
1091
1092 GPU_framebuffer_bind(framebuffer);
1093 /* Mask in #MASK_OVERLAY_COMBINED mode renders onto the render framebuffer and modifies the
1094 * image in scene referred color space. The #MASK_OVERLAY_ALPHACHANNEL renders onto the overlay
1095 * framebuffer. */
1096 if (show_mask_ && (mask_mode_ == MASK_OVERLAY_COMBINED)) {
1097 manager.submit(paint_mask_ps_, view);
1098 }
1099 }
1100
1101 private:
1102 static OVERLAY_UVLineStyle edit_uv_line_style_from_space_image(const SpaceImage *sima)
1103 {
1104 const bool is_uv_editor = sima->mode == SI_MODE_UV;
1105 if (is_uv_editor) {
1106 switch (sima->dt_uv) {
1107 case SI_UVDT_OUTLINE:
1109 case SI_UVDT_BLACK:
1111 case SI_UVDT_WHITE:
1113 case SI_UVDT_DASH:
1115 default:
1117 }
1118 }
1119 else {
1121 }
1122 }
1123
1124 /* TODO(jbakker): the GPU texture should be cached with the mask. */
1125 void paint_mask_texture_ensure(Mask *mask, const int2 &resolution, const float2 &aspect)
1126 {
1127 const int width = resolution.x;
1128 const int height = floor(float(resolution.y) * (aspect.y / aspect.x));
1129 float *buffer = MEM_new_array_uninitialized<float>(height * width, __func__);
1130
1131 MaskRasterHandle *handle = BKE_maskrasterize_handle_new();
1132 BKE_maskrasterize_handle_init(handle, mask, width, height, true, true, true);
1133 BKE_maskrasterize_buffer(handle, width, height, buffer);
1135
1136 mask_texture_.free();
1137 mask_texture_.ensure_2d(
1138 gpu::TextureFormat::SFLOAT_16, int2(width, height), GPU_TEXTURE_USAGE_SHADER_READ, buffer);
1139
1140 MEM_delete(buffer);
1141 }
1142};
1143
1144} // namespace blender::draw::overlay
CustomData interface, see also DNA_customdata_types.h.
#define M_SQRT2
#define UI_SCALE_FAC
#define RETOPOLOGY_OFFSET(v3d)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define ELEM(...)
std::optional< AttributeMetaData > lookup_meta_data(StringRef name) const
void hold_texture(gpu::Texture *texture)
void wrap(gpu::Texture *tex)
int3 size(int miplvl=0) const
void shader_set(gpu::Shader *shader)
void bind_texture(const char *name, gpu::Texture *texture, GPUSamplerState state=sampler_auto)
void state_set(DRWState state, int clip_plane_count=0)
void bind_ubo(const char *name, gpu::UniformBuf *buffer)
void push_constant(const char *name, const float &data)
detail::PassBase< command::DrawCommandBuf > Sub
Definition draw_pass.hh:509
void end_sync(Resources &res, const State &state) final
void object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &, const State &state) final
void draw_on_render(gpu::FrameBuffer *framebuffer, Manager &manager, View &view) final
void draw(Framebuffer &framebuffer, Manager &manager, View &view) final
void edit_object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &, const State &state) final
void begin_sync(Resources &res, const State &state) final
void draw_line(Framebuffer &framebuffer, Manager &manager, View &view) final
void draw_line_only(Framebuffer &framebuffer, Manager &manager, View &view) final
void edit_object_sync(Manager &manager, const ObjectRef &ob_ref, Resources &, const State &state) final
static bool mesh_has_edit_cage(const Object *ob)
void begin_sync(Resources &res, const State &state) final
#define DRW_CLIPPING_UBO_SLOT
#define OVERLAY_GLOBALS_SLOT
#define floor
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
const int tile_index
const int state
const ccl_global KernelWorkTile * tile
bool is_uv_map(const AttributeMetaData &meta_data)
constexpr int overlay_edit_text
gpu::Batch * DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edituv_edges(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edit_edges(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edituv_facedots(Object &object, Mesh &mesh)
detail::Pass< command::DrawCommandBuf > PassSimple
gpu::Batch * DRW_mesh_batch_cache_get_edituv_wireframe(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edit_facedots(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edituv_verts(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edituv_faces(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edit_loop_normals(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edit_triangles(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edit_vertices(Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_all_uv_wireframe(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edit_vert_normals(Mesh &mesh)
gpu::Batch * DRW_cache_mesh_surface_weights_get(Object *ob)
gpu::Batch * DRW_mesh_batch_cache_get_uv_faces(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Object &object, Mesh &mesh, float **tot_area, float **tot_uv_area)
gpu::Batch * DRW_cache_mesh_surface_get(Object *ob)
gpu::Batch * DRW_mesh_batch_cache_get_uv_wireframe(Object &object, Mesh &mesh)
gpu::Batch * DRW_mesh_batch_cache_get_edit_skin_roots(Mesh &mesh)
gpu::Batch * DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
T safe_rcp(const T &a)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
void get_color_4fv(int colorid, float col[4])
float get_value_f(int colorid)
void get_color_shade_4fv(int colorid, int offset, float col[4])
void get_color_shade_4ubv(int colorid, int offset, unsigned char col[4])
void GPU_framebuffer_bind(gpu::FrameBuffer *fb)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
VecBase< uint8_t, 4 > uchar4
const Mesh * BKE_object_get_editmesh_eval_cage(const Object *object)
Definition object.cc:4492
@ MASK_OVERLAY_COMBINED
@ MASK_OVERLAY_ALPHACHANNEL
@ SI_UVDT_STRETCH_ANGLE
MaskRasterHandle * BKE_maskrasterize_handle_new()
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
bool BKE_subsurf_modifier_has_gpu_subdiv(const Mesh *mesh)
VecBase< uint32_t, 4 > uint4
const Mesh * BKE_object_get_editmesh_eval_final(const Object *object)
Definition object.cc:4477
@ DRW_TEXT_CACHE_GLOBALSPACE
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
@ CTX_MODE_PAINT_VERTEX
@ CTX_MODE_PAINT_TEXTURE
@ CTX_MODE_PAINT_WEIGHT
bool GPU_use_hq_normals_workaround()
@ ME_EDIT_PAINT_FACE_SEL
@ GPU_TEXTURE_USAGE_SHADER_READ
T & DRW_object_get_data_for_drawing(const Object &object)
ListBaseWrapperTemplate< ListBase, T > ListBaseWrapper
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)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, Mask *mask, int width, int height, bool do_aspect_correct, bool do_mask_aa, bool do_feather)
@ USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE
@ USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE
void BKE_maskrasterize_handle_free(MaskRasterHandle *mr_handle)
@ IMAGE_PAINT_BRUSH_TYPE_CLONE
@ DRW_STATE_CULL_BACK
Definition draw_state.hh:45
@ DRW_STATE_FIRST_VERTEX_CONVENTION
Definition draw_state.hh:73
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:32
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:57
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:31
@ DRW_STATE_BLEND_ALPHA_PREMUL
Definition draw_state.hh:59
@ DRW_STATE_DEPTH_ALWAYS
Definition draw_state.hh:38
@ DRW_STATE_BLEND_MUL
Definition draw_state.hh:62
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:40
@ MASK_DRAWFLAG_OVERLAY
void GPU_debug_group_end()
Definition gpu_debug.cc:34
void DRW_text_edit_mesh_measure_stats(const ARegion *region, const View3D *v3d, const Object *ob, const UnitSettings &unit, DRWTextStore *dt)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
T * DEG_get_original(T *id)
draw::Manager * DRW_manager_get()
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
Definition editmesh.cc:65
@ V3D_OVERLAY_EDIT_LOOP_NORMALS
@ V3D_OVERLAY_EDIT_WEIGHT
@ V3D_OVERLAY_EDIT_CONSTANT_SCREEN_SIZE_NORMALS
@ V3D_OVERLAY_EDIT_BWEIGHTS
@ V3D_OVERLAY_EDIT_FACE_AREA
@ V3D_OVERLAY_EDIT_STATVIS
@ V3D_OVERLAY_EDIT_CREASES
@ V3D_OVERLAY_EDIT_EDGE_ANG
@ V3D_OVERLAY_EDIT_EDGE_LEN
@ V3D_OVERLAY_EDIT_VERT_NORMALS
@ V3D_OVERLAY_EDIT_FACE_NORMALS
@ V3D_OVERLAY_EDIT_FREESTYLE_EDGE
@ V3D_OVERLAY_EDIT_FACE_ANG
@ V3D_OVERLAY_EDIT_RETOPOLOGY
@ V3D_OVERLAY_EDIT_FREESTYLE_FACE
@ V3D_OVERLAY_EDIT_FACE_DOT
@ V3D_OVERLAY_EDIT_INDICES
gpu::Texture * BKE_image_acquire_gpu_texture(Image *image, ImageUser *iuser)
Definition image_gpu.cc:732
void BKE_maskrasterize_buffer(MaskRasterHandle *mr_handle, unsigned int width, unsigned int height, float *buffer)
Rasterize a buffer from a single mask (threaded execution).
void BKE_image_get_size_fl(Image *image, ImageUser *iuser, float r_size[2])
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, StringRef name)
bool DRW_object_is_in_edit_mode(const Object *ob)
void GPU_debug_group_begin(const char *name)
Definition gpu_debug.cc:23
@ OVERLAY_UV_LINE_STYLE_DASH
@ OVERLAY_UV_LINE_STYLE_SHADOW
@ OVERLAY_UV_LINE_STYLE_WHITE
@ OVERLAY_UV_LINE_STYLE_OUTLINE
@ OVERLAY_UV_LINE_STYLE_BLACK
CustomData vdata
CustomData ldata
MaskOverlayMode overlay_mode
eMesh_EditFlag editflag
eSpaceImage_UVDT_Stretch dt_uvstretch
MaskSpaceInfo mask_info
eSpaceImage_UVDT dt_uv
eSpaceImage_Mode mode
eSpaceImage_Flag flag
struct ImagePaintSettings imapaint
eTool_UvSelectMode uv_selectmode
float x
float y