Blender V5.3
object_remesh.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
8
9#include <cctype>
10#include <cfloat>
11#include <cmath>
12#include <cstdlib>
13#include <cstring>
14
15#include "MEM_guardedalloc.h"
16
17#include "BLI_bounds.hh"
18#include "BLI_math_geom_c.hh"
19#include "BLI_math_matrix_c.hh"
20#include "BLI_string_utf8.hh"
21#include "BLI_utildefines.hh"
22
23#include "DNA_object_types.h"
24#include "DNA_userdef_types.h"
25
26#include "BLT_translation.hh"
27
28#include "BKE_attribute.hh"
29#include "BKE_context.hh"
30#include "BKE_global.hh"
31#include "BKE_lib_id.hh"
32#include "BKE_library.hh"
33#include "BKE_main.hh"
34#include "BKE_mesh.hh"
35#include "BKE_mesh_mirror.hh"
37#include "BKE_modifier.hh"
38#include "BKE_object.hh"
39#include "BKE_object_types.hh"
40#include "BKE_paint.hh"
41#include "BKE_report.hh"
42#include "BKE_screen.hh"
43#include "BKE_shrinkwrap.hh"
44#include "BKE_unit.hh"
45
46#include "DEG_depsgraph.hh"
47
48#include "ED_screen.hh"
49#include "ED_sculpt.hh"
50#include "ED_space_api.hh"
51#include "ED_view3d.hh"
52
53#include "RNA_access.hh"
54#include "RNA_define.hh"
55
56#include "GPU_immediate.hh"
57#include "GPU_matrix.hh"
58#include "GPU_state.hh"
59
60#include "WM_api.hh"
61#include "WM_types.hh"
62
63#include "UI_interface.hh"
64
65#include "BLF_api.hh"
66
67#include "object_intern.hh" /* own include */
68
69namespace blender::ed::object {
70
71/* TODO(sebpa): unstable, can lead to unrecoverable errors. */
72// #define USE_MESH_CURVATURE
73
74/* -------------------------------------------------------------------- */
77
79{
81
82 if (ob == nullptr || ob->data == nullptr) {
83 return false;
84 }
85
87 CTX_wm_operator_poll_msg_set(C, "The remesher cannot work on linked or override data");
88 return false;
89 }
90
92 CTX_wm_operator_poll_msg_set(C, "The remesher cannot run from edit mode");
93 return false;
94 }
95
96 if (ob->mode == OB_MODE_SCULPT && ob->runtime->sculpt_session->bm) {
97 CTX_wm_operator_poll_msg_set(C, "The remesher cannot run with dyntopo activated");
98 return false;
99 }
100
103 C, "The remesher cannot run with a Multires modifier in the modifier stack");
104 return false;
105 }
106
108}
109
111{
112 const Scene &scene = *CTX_data_scene(C);
114
115 Mesh *mesh = id_cast<Mesh *>(ob->data);
116
117 if (mesh->remesh_voxel_size <= 0.0f) {
118 BKE_report(op->reports, RPT_ERROR, "Voxel remesher cannot run with a voxel size of 0.0");
119 return OPERATOR_CANCELLED;
120 }
121
122 if (mesh->faces_num == 0) {
123 return OPERATOR_CANCELLED;
124 }
125
126 float isovalue = 0.0f;
127 if (mesh->flag & ME_REMESH_REPROJECT_VOLUME) {
128 isovalue = mesh->remesh_voxel_size * 0.3f;
129 }
130
131 Mesh *new_mesh = BKE_mesh_remesh_voxel(
132 mesh, mesh->remesh_voxel_size, mesh->remesh_voxel_adaptivity, isovalue, op->reports);
133
134 if (!new_mesh) {
135 BKE_report(op->reports, RPT_ERROR, "Voxel remesher failed to create mesh");
136 return OPERATOR_CANCELLED;
137 }
138
139 if (ob->mode == OB_MODE_SCULPT) {
141 }
142
143 if (mesh->flag & ME_REMESH_FIX_POLES && mesh->remesh_voxel_adaptivity <= 0.0f) {
144 Mesh *mesh_fixed_poles = BKE_mesh_remesh_voxel_fix_poles(new_mesh);
145 BKE_id_free(nullptr, new_mesh);
146 new_mesh = mesh_fixed_poles;
147 }
148
149 if (mesh->flag & ME_REMESH_REPROJECT_VOLUME) {
151 }
152
155 }
156 else {
157 const VArray<bool> sharp_face = *mesh->attributes().lookup_or_default<bool>(
158 "sharp_face", bke::AttrDomain::Face, false);
159 bke::mesh_smooth_set(*new_mesh, !sharp_face[0]);
160 }
161
162 BKE_mesh_nomain_to_mesh(new_mesh, mesh, ob);
163 /* Spatially organize the mesh after remesh. */
165
166 if (ob->mode == OB_MODE_SCULPT) {
169 }
173
174 return OPERATOR_FINISHED;
175}
176
178{
179 /* identifiers */
180 ot->name = "Voxel Remesh";
181 ot->description =
182 "Calculates a new manifold mesh based on the volume of the current mesh. All data layers "
183 "will be lost";
184 ot->idname = "OBJECT_OT_voxel_remesh";
185
186 /* API callbacks. */
189
191}
192
194
195/* -------------------------------------------------------------------- */
198
199#define VOXEL_SIZE_EDIT_MAX_GRIDS_LINES 500
200#define VOXEL_SIZE_EDIT_MAX_STR_LEN 20
201
221
223 const float initial_co[3],
224 const float end_co[3],
225 const float length_co[3],
226 const float spacing)
227{
228 const float total_len = len_v3v3(initial_co, end_co);
229 const int tot_lines = int(total_len / spacing);
230 const int tot_lines_half = (tot_lines / 2) + 1;
231 float spacing_dir[3], lines_start[3];
232 float line_dir[3];
233 sub_v3_v3v3(spacing_dir, end_co, initial_co);
234 normalize_v3(spacing_dir);
235
236 sub_v3_v3v3(line_dir, length_co, initial_co);
237
238 if (tot_lines > VOXEL_SIZE_EDIT_MAX_GRIDS_LINES || tot_lines <= 1) {
239 return;
240 }
241
242 mid_v3_v3v3(lines_start, initial_co, end_co);
243
244 immBegin(GPU_PRIM_LINES, uint(tot_lines_half) * 2);
245 for (int i = 0; i < tot_lines_half; i++) {
246 float line_start[3];
247 float line_end[3];
248 madd_v3_v3v3fl(line_start, lines_start, spacing_dir, spacing * i);
249 add_v3_v3v3(line_end, line_start, line_dir);
250 immVertex3fv(pos3d, line_start);
251 immVertex3fv(pos3d, line_end);
252 }
253 immEnd();
254
255 mul_v3_fl(spacing_dir, -1.0f);
256
257 immBegin(GPU_PRIM_LINES, uint(tot_lines_half - 1) * 2);
258 for (int i = 1; i < tot_lines_half; i++) {
259 float line_start[3];
260 float line_end[3];
261 madd_v3_v3v3fl(line_start, lines_start, spacing_dir, spacing * i);
262 add_v3_v3v3(line_end, line_start, line_dir);
263 immVertex3fv(pos3d, line_start);
264 immVertex3fv(pos3d, line_end);
265 }
266 immEnd();
267}
268
269static void voxel_size_edit_draw(const bContext *C, ARegion * /*region*/, void *arg)
270{
271 VoxelSizeEditCustomData *cd = static_cast<VoxelSizeEditCustomData *>(arg);
272
274 GPU_line_smooth(true);
275
277 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
280 GPU_matrix_mul(cd->active_object->object_to_world().ptr());
281
282 /* Draw Rect */
283 immUniformColor4f(0.9f, 0.9f, 0.9f, 0.8f);
284 GPU_line_width(3.0f);
285
287 immVertex3fv(pos3d, cd->preview_plane[0]);
288 immVertex3fv(pos3d, cd->preview_plane[1]);
289
290 immVertex3fv(pos3d, cd->preview_plane[1]);
291 immVertex3fv(pos3d, cd->preview_plane[2]);
292
293 immVertex3fv(pos3d, cd->preview_plane[2]);
294 immVertex3fv(pos3d, cd->preview_plane[3]);
295
296 immVertex3fv(pos3d, cd->preview_plane[3]);
297 immVertex3fv(pos3d, cd->preview_plane[0]);
298 immEnd();
299
300 /* Draw Grid */
301 GPU_line_width(1.0f);
302
303 const float total_len = len_v3v3(cd->preview_plane[0], cd->preview_plane[1]);
304 const int tot_lines = int(total_len / cd->voxel_size);
305
306 /* Smooth-step to reduce the alpha of the grid as the line number increases. */
307 const float a = VOXEL_SIZE_EDIT_MAX_GRIDS_LINES * 0.1f;
309 const float x = clamp_f((tot_lines - a) / (b - a), 0.0f, 1.0);
310 const float alpha_factor = 1.0f - (x * x * (3.0f - 2.0f * x));
311
312 immUniformColor4f(0.9f, 0.9f, 0.9f, 0.75f * alpha_factor);
314 pos3d, cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[3], cd->voxel_size);
316 pos3d, cd->preview_plane[1], cd->preview_plane[2], cd->preview_plane[0], cd->voxel_size);
317
318 /* Draw text */
319 const uiStyle *style = ui::style_get();
320 const uiFontStyle *fstyle = &style->widget;
321 const int fontid = fstyle->uifont_id;
322 float strwidth, strheight;
323 short fstyle_points = fstyle->points;
325 short strdrawlen = 0;
326 Scene *scene = CTX_data_scene(C);
327 const UnitSettings &unit = scene->unit;
328
330 str, sizeof(str), cd->voxel_size, -3, B_UNIT_LENGTH, unit, true, true);
331 strdrawlen = BLI_strlen_utf8(str);
332
334
337 /* (Constant viewport) scale is already accounted for in 'text_mat'. */
338 BLF_size(fontid, 10.0f * fstyle_points);
339 BLF_color3f(fontid, 1.0f, 1.0f, 1.0f);
340 BLF_width_and_height(fontid, str, strdrawlen, &strwidth, &strheight);
341 BLF_position(fontid, -0.5f * strwidth, -0.5f * strheight, 0.0f);
342 BLF_draw(fontid, str, strdrawlen);
344
346
348 GPU_line_smooth(false);
349}
350
352{
353 ARegion *region = CTX_wm_region(C);
355
357
358 MEM_delete(cd);
359
360 ED_workspace_status_text(C, nullptr);
361}
362
364{
366 WorkspaceStatus status(C);
367 status.item(IFACE_("Confirm"), ICON_EVENT_RETURN, ICON_MOUSE_LMB);
368 status.item(IFACE_("Cancel"), ICON_EVENT_ESC, ICON_MOUSE_RMB);
369 status.item(IFACE_("Change Size"), ICON_MOUSE_MOVE);
370 status.item_bool(IFACE_("Precision Mode"), cd->slow_mode, ICON_EVENT_SHIFT);
371}
372
374{
375 ARegion *region = CTX_wm_region(C);
377 Object *active_object = cd->active_object;
378 Mesh *mesh = id_cast<Mesh *>(active_object->data);
379
380 /* Cancel modal operator */
381 if ((event->type == EVT_ESCKEY && event->val == KM_PRESS) ||
382 (event->type == RIGHTMOUSE && event->val == KM_PRESS))
383 {
385 ED_region_tag_redraw(region);
386 return OPERATOR_FINISHED;
387 }
388
389 /* Finish modal operator */
390 if ((event->type == LEFTMOUSE && event->val == KM_RELEASE) ||
391 (event->type == EVT_RETKEY && event->val == KM_PRESS) ||
392 (event->type == EVT_PADENTER && event->val == KM_PRESS))
393 {
395 mesh->remesh_voxel_size = cd->voxel_size;
396 MEM_delete(cd);
397 ED_region_tag_redraw(region);
398 ED_workspace_status_text(C, nullptr);
400 return OPERATOR_FINISHED;
401 }
402
403 const float mval[2] = {float(event->mval[0]), float(event->mval[1])};
404
405 float d = cd->init_mval[0] - mval[0];
406
407 if (cd->slow_mode) {
408 d = cd->slow_mval[0] - mval[0];
409 }
410
411 d *= cd->voxel_size_min * 0.25f;
412
413 if (cd->slow_mode) {
414 cd->voxel_size = cd->slow_voxel_size + d * 0.05f;
415 }
416 else {
417 cd->voxel_size = cd->init_voxel_size + d;
418 }
419
420 if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_PRESS) {
421 cd->slow_mode = true;
422 copy_v2_v2(cd->slow_mval, mval);
423 cd->slow_voxel_size = cd->voxel_size;
424 }
425 if (event->type == EVT_LEFTSHIFTKEY && event->val == KM_RELEASE) {
426 cd->slow_mode = false;
427 cd->slow_voxel_size = 0.0f;
428 }
429
430 cd->voxel_size = clamp_f(
431 cd->voxel_size, max_ff(cd->voxel_size_min, 0.0001f), cd->voxel_size_max);
432
433 ED_region_tag_redraw(region);
434
437}
438
440{
441 ARegion *region = CTX_wm_region(C);
442 Object *active_object = CTX_data_active_object(C);
443 Mesh *mesh = id_cast<Mesh *>(active_object->data);
444
446 "Voxel Size Edit OP Custom Data");
447
448 /* Initial operator Custom Data setup. */
451 cd->active_object = active_object;
452 cd->init_mval[0] = event->mval[0];
453 cd->init_mval[1] = event->mval[1];
454 cd->slow_mode = false;
455 op->customdata = cd;
456
457 /* Select the front facing face of the mesh bounding box. */
458 const Bounds<float3> bounds = *mesh->bounds_min_max();
459 const std::array<float3, 8> bounds_box = bounds::corners(bounds);
460
461 /* Indices of the Bounding Box faces. */
462 const int BB_faces[6][4] = {
463 {3, 0, 4, 7},
464 {1, 2, 6, 5},
465 {3, 2, 1, 0},
466 {4, 5, 6, 7},
467 {0, 1, 5, 4},
468 {2, 3, 7, 6},
469 };
470
471 copy_v3_v3(cd->preview_plane[0], bounds_box[BB_faces[0][0]]);
472 copy_v3_v3(cd->preview_plane[1], bounds_box[BB_faces[0][1]]);
473 copy_v3_v3(cd->preview_plane[2], bounds_box[BB_faces[0][2]]);
474 copy_v3_v3(cd->preview_plane[3], bounds_box[BB_faces[0][3]]);
475
477
478 float mat[3][3];
479 float current_normal[3];
480 float view_normal[3] = {0.0f, 0.0f, 1.0f};
481
482 /* Calculate the view normal. */
483 invert_m4_m4(active_object->runtime->world_to_object.ptr(),
484 active_object->object_to_world().ptr());
485 copy_m3_m4(mat, rv3d->viewinv);
486 mul_m3_v3(mat, view_normal);
487 copy_m3_m4(mat, active_object->world_to_object().ptr());
488 mul_m3_v3(mat, view_normal);
489 normalize_v3(view_normal);
490
491 normal_tri_v3(current_normal, cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[2]);
492
493 float min_dot = dot_v3v3(current_normal, view_normal);
494 float current_dot = 1;
495
496 /* Check if there is a face that is more aligned towards the view. */
497 for (int i = 0; i < 6; i++) {
498 normal_tri_v3(current_normal,
499 bounds_box[BB_faces[i][0]],
500 bounds_box[BB_faces[i][1]],
501 bounds_box[BB_faces[i][2]]);
502 current_dot = dot_v3v3(current_normal, view_normal);
503
504 if (current_dot < min_dot) {
505 min_dot = current_dot;
506 copy_v3_v3(cd->preview_plane[0], bounds_box[BB_faces[i][0]]);
507 copy_v3_v3(cd->preview_plane[1], bounds_box[BB_faces[i][1]]);
508 copy_v3_v3(cd->preview_plane[2], bounds_box[BB_faces[i][2]]);
509 copy_v3_v3(cd->preview_plane[3], bounds_box[BB_faces[i][3]]);
510 }
511 }
512
513 /* Cap the max/min voxel size based on the point where we cant visually display any more info
514 * with grid lines. */
516 len_v3v3(cd->preview_plane[3], cd->preview_plane[0])) *
517 0.5f;
520 mesh->remesh_voxel_size, max_ff(cd->voxel_size_min, 0.0001f), cd->voxel_size_max);
521 cd->voxel_size = cd->init_voxel_size;
522
523 /* Matrix calculation to position the text in 3D space. */
524 float text_pos[3];
525 float scale_mat[4][4];
526
527 float d_a[3], d_b[3];
528 float d_a_proj[2], d_b_proj[2];
529 float preview_plane_proj[4][2];
530 const float y_axis_proj[2] = {0.0f, 1.0f};
531
532 mid_v3_v3v3(text_pos, cd->preview_plane[0], cd->preview_plane[2]);
533
534 /* Project the selected face in the previous step of the Bounding Box. */
535 for (int i = 0; i < 4; i++) {
536 float preview_plane_world_space[3];
538 preview_plane_world_space, active_object->object_to_world().ptr(), cd->preview_plane[i]);
539 ED_view3d_project_v2(region, preview_plane_world_space, preview_plane_proj[i]);
540 }
541
542 /* Get the initial X and Y axis of the basis from the edges of the Bounding Box face. */
543 sub_v3_v3v3(d_a, cd->preview_plane[1], cd->preview_plane[0]);
544 sub_v3_v3v3(d_b, cd->preview_plane[3], cd->preview_plane[0]);
545 normalize_v3(d_a);
546 normalize_v3(d_b);
547
548 /* Project the X and Y axis. */
549 sub_v2_v2v2(d_a_proj, preview_plane_proj[1], preview_plane_proj[0]);
550 sub_v2_v2v2(d_b_proj, preview_plane_proj[3], preview_plane_proj[0]);
551 normalize_v2(d_a_proj);
552 normalize_v2(d_b_proj);
553
554 unit_m4(cd->text_mat);
555
556 /* Select the axis that is aligned with the view Y axis to use it as the basis Y. */
557 if (fabsf(dot_v2v2(d_a_proj, y_axis_proj)) > fabsf(dot_v2v2(d_b_proj, y_axis_proj))) {
558 copy_v3_v3(cd->text_mat[0], d_b);
559 copy_v3_v3(cd->text_mat[1], d_a);
560
561 /* Flip the X and Y basis vectors to make sure they always point upwards and to the right. */
562 if (d_b_proj[0] < 0.0f) {
563 mul_v3_fl(cd->text_mat[0], -1.0f);
564 }
565 if (d_a_proj[1] < 0.0f) {
566 mul_v3_fl(cd->text_mat[1], -1.0f);
567 }
568 }
569 else {
570 copy_v3_v3(cd->text_mat[0], d_a);
571 copy_v3_v3(cd->text_mat[1], d_b);
572 if (d_a_proj[0] < 0.0f) {
573 mul_v3_fl(cd->text_mat[0], -1.0f);
574 }
575 if (d_b_proj[1] < 0.0f) {
576 mul_v3_fl(cd->text_mat[1], -1.0f);
577 }
578 }
579
580 /* Use the Bounding Box face normal as the basis Z. */
581 normal_tri_v3(cd->text_mat[2], cd->preview_plane[0], cd->preview_plane[1], cd->preview_plane[2]);
582
583 /* Invert object scale. */
584 float scale[3];
585 mat4_to_size(scale, active_object->object_to_world().ptr());
587 size_to_mat4(scale_mat, scale);
588
589 mul_m4_m4_pre(cd->text_mat, scale_mat);
590
591 /* Write the text position into the matrix. */
592 copy_v3_v3(cd->text_mat[3], text_pos);
593
594 /* Scale the text to constant viewport size. */
595 float text_pos_word_space[3];
596 mul_v3_m4v3(text_pos_word_space, active_object->object_to_world().ptr(), text_pos);
597 const float pixelsize = ED_view3d_pixel_size_no_ui_scale(rv3d, text_pos_word_space);
598 scale_m4_fl(scale_mat, pixelsize * 0.5f);
599 mul_m4_m4_post(cd->text_mat, scale_mat);
600
602
603 ED_region_tag_redraw(region);
604
606
608}
609
614
616{
617 /* identifiers */
618 ot->name = "Edit Voxel Size";
619 ot->description = "Modify the mesh voxel size interactively used in the voxel remesher";
620 ot->idname = "OBJECT_OT_voxel_size_edit";
621
622 /* API callbacks. */
627
629}
630
632
633/* -------------------------------------------------------------------- */
636
637#define QUADRIFLOW_MIRROR_BISECT_TOLERANCE 0.005f
638
639enum {
643};
644
651
653 SYMMETRY_AXES_X = (1 << 0),
654 SYMMETRY_AXES_Y = (1 << 1),
655 SYMMETRY_AXES_Z = (1 << 2),
656};
657
680
682{
683 /* In this check we count boundary edges as manifold. Additionally, we also
684 * check that the direction of the faces are consistent and doesn't suddenly
685 * flip
686 */
687 const Span<float3> positions = mesh->vert_positions();
688 const Span<int2> edges = mesh->edges();
689 const Span<int> corner_verts = mesh->corner_verts();
690 const Span<int> corner_edges = mesh->corner_edges();
691
692 bool is_manifold_consistent = true;
693 char *edge_faces = MEM_new_array_zeroed<char>(mesh->edges_num, "remesh_manifold_check");
694 int *edge_vert = MEM_new_array_uninitialized<int>(mesh->edges_num, "remesh_consistent_check");
695
696 for (uint i = 0; i < mesh->edges_num; i++) {
697 edge_vert[i] = -1;
698 }
699
700 for (const int corner_i : corner_verts.index_range()) {
701 const int vert = corner_verts[corner_i];
702 const int edge = corner_edges[corner_i];
703 edge_faces[edge] += 1;
704 if (edge_faces[edge] > 2) {
705 is_manifold_consistent = false;
706 break;
707 }
708
709 if (edge_vert[edge] == -1) {
710 edge_vert[edge] = vert;
711 }
712 else if (edge_vert[edge] == vert) {
713 /* Mesh has flips in the surface so it is non consistent */
714 is_manifold_consistent = false;
715 break;
716 }
717 }
718
719 if (is_manifold_consistent) {
720 for (const int i : edges.index_range()) {
721 /* Check for wire edges. */
722 if (edge_faces[i] == 0) {
723 is_manifold_consistent = false;
724 break;
725 }
726 /* Check for zero length edges */
727 if (compare_v3v3(positions[edges[i][0]], positions[edges[i][1]], 1e-4f)) {
728 is_manifold_consistent = false;
729 break;
730 }
731 }
732 }
733
734 MEM_delete(edge_faces);
735 MEM_delete(edge_vert);
736
737 return is_manifold_consistent;
738}
739
740static void quadriflow_free_job(void *customdata)
741{
742 QuadriFlowJob *qj = static_cast<QuadriFlowJob *>(customdata);
743 MEM_delete(qj);
744}
745
746/* called by quadriflowjob, only to check job 'stop' value */
747static int quadriflow_break_job(void *customdata)
748{
749 QuadriFlowJob *qj = static_cast<QuadriFlowJob *>(customdata);
750 // return *(qj->stop);
751
752 /* this is not nice yet, need to make the jobs list template better
753 * for identifying/acting upon various different jobs canceled */
754 /* but for now we'll reuse the render break... */
755 bool should_break = false;
756
757 if (qj->is_nonblocking_job) {
758 bool should_break = (G.is_break);
759 if (should_break) {
761 }
762 }
763
764 return should_break;
765}
766
768static void quadriflow_update_job(void *customdata, float progress, int *cancel)
769{
770 QuadriFlowJob *qj = static_cast<QuadriFlowJob *>(customdata);
771
772 if (quadriflow_break_job(qj)) {
773 *cancel = 1;
774 }
775 else {
776 *cancel = 0;
777 }
778
779 qj->worker_status->do_update = true;
780 qj->worker_status->progress = progress;
781}
782
784{
785 MirrorModifierData mmd = {};
787
788 Mesh *mesh_bisect, *mesh_bisect_temp;
789 mesh_bisect = BKE_mesh_copy_for_eval(*mesh);
790
791 int axis;
792 float plane_co[3], plane_no[3];
793 zero_v3(plane_co);
794
795 for (char i = 0; i < 3; i++) {
796 eSymmetryAxes symm_it = eSymmetryAxes(1 << i);
797 if (symmetry_axes & symm_it) {
798 axis = i;
799 mmd.flag = {};
801 zero_v3(plane_no);
802 plane_no[axis] = -1.0f;
803 mesh_bisect_temp = mesh_bisect;
805 &mmd, mesh_bisect, axis, plane_co, plane_no);
806 if (mesh_bisect_temp != mesh_bisect) {
807 BKE_id_free(nullptr, mesh_bisect_temp);
808 }
809 }
810 }
811
812 BKE_id_free(nullptr, mesh);
813
814 return mesh_bisect;
815}
816
818{
819 MirrorModifierData mmd = {};
821 Mesh *mesh_mirror, *mesh_mirror_temp;
822
823 mesh_mirror = mesh;
824
825 int axis;
826
827 for (char i = 0; i < 3; i++) {
828 eSymmetryAxes symm_it = eSymmetryAxes(1 << i);
829 if (symmetry_axes & symm_it) {
830 axis = i;
831 mmd.flag = {};
832 mmd.flag &= MirrorModifierFlag(int(MOD_MIR_AXIS_X) << i);
833 mesh_mirror_temp = mesh_mirror;
835 &mmd, ob, mesh_mirror, axis, true, nullptr, nullptr);
836 if (mesh_mirror_temp != mesh_mirror) {
837 BKE_id_free(nullptr, mesh_mirror_temp);
838 }
839 }
840 }
841
842 return mesh_mirror;
843}
844
845static void quadriflow_start_job(void *customdata, wmJobWorkerStatus *worker_status)
846{
847 QuadriFlowJob *qj = static_cast<QuadriFlowJob *>(customdata);
848
849 qj->worker_status = worker_status;
851
852 if (qj->is_nonblocking_job) {
853 G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */
854 }
855
856 Object *ob = qj->owner;
857 Mesh *mesh = id_cast<Mesh *>(ob->data);
858 Scene &scene = *qj->scene;
859 Mesh *new_mesh;
860 Mesh *bisect_mesh;
861
862 /* Check if the mesh is manifold. Quadriflow requires manifold meshes */
865 return;
866 }
867
868 /* Run Quadriflow bisect operations on a copy of the mesh to keep the code readable without
869 * freeing the original ID */
870 bisect_mesh = BKE_mesh_copy_for_eval(*mesh);
871
872 /* Bisect the input mesh using the paint symmetry settings */
873 bisect_mesh = remesh_symmetry_bisect(bisect_mesh, qj->symmetry_axes);
874
875 new_mesh = BKE_mesh_remesh_quadriflow(bisect_mesh,
876 qj->target_faces,
877 qj->seed,
880#ifdef USE_MESH_CURVATURE
882#else
883 false,
884#endif
886 static_cast<void *>(qj));
887
888 BKE_id_free(nullptr, bisect_mesh);
889
890 if (new_mesh == nullptr) {
891 worker_status->do_update = true;
892 worker_status->stop = false;
894 /* This is not a user cancellation event. */
896 }
897 return;
898 }
899
900 /* Mirror the Quadriflow result to build the final mesh */
901 new_mesh = remesh_symmetry_mirror(qj->owner, new_mesh, qj->symmetry_axes);
902
903 if (ob->mode == OB_MODE_SCULPT) {
904 sculpt_paint::undo::geometry_begin(scene, *ob, qj->op);
905 }
906
907 if (qj->preserve_attributes) {
909 }
910
911 BKE_mesh_nomain_to_mesh(new_mesh, mesh, ob);
912
913 bke::mesh_smooth_set(*id_cast<Mesh *>(ob->data), qj->smooth_normals);
914
915 if (ob->mode == OB_MODE_SCULPT) {
918 }
920
921 worker_status->do_update = true;
922 worker_status->stop = false;
923}
924
925static void quadriflow_end_job(void *customdata)
926{
927 QuadriFlowJob *qj = static_cast<QuadriFlowJob *>(customdata);
928
929 Object *ob = qj->owner;
930
931 if (qj->is_nonblocking_job) {
932 WM_locked_interface_set(G_MAIN->wm.first(), false);
933 }
934
935 ReportList *reports = qj->worker_status->reports;
936 switch (qj->status) {
938 /* Spatially organize the mesh after remesh. */
939 bke::mesh_apply_spatial_organization(*id_cast<Mesh *>(ob->data));
941 BKE_reportf(reports, RPT_INFO, "QuadriFlow: Remeshing completed");
942 break;
944 BKE_reportf(reports, RPT_ERROR, "QuadriFlow: Remeshing failed");
945 break;
947 BKE_report(reports, RPT_WARNING, "QuadriFlow: Remeshing canceled");
948 break;
950 BKE_report(reports,
952 "QuadriFlow: The mesh needs to be manifold and have face normals that point in a "
953 "consistent direction");
954 break;
955 }
956}
957
959{
961
962 job->op = op;
964 job->scene = CTX_data_scene(C);
965
966 job->target_faces = RNA_int_get(op->ptr, "target_faces");
967 job->seed = RNA_int_get(op->ptr, "seed");
968
969 job->use_mesh_symmetry = RNA_boolean_get(op->ptr, "use_mesh_symmetry");
970
971 job->use_preserve_sharp = RNA_boolean_get(op->ptr, "use_preserve_sharp");
972 job->use_preserve_boundary = RNA_boolean_get(op->ptr, "use_preserve_boundary");
973
974#ifdef USE_MESH_CURVATURE
975 job->use_mesh_curvature = RNA_boolean_get(op->ptr, "use_mesh_curvature");
976#endif
977
978 job->preserve_attributes = RNA_boolean_get(op->ptr, "preserve_attributes");
979 job->smooth_normals = RNA_boolean_get(op->ptr, "smooth_normals");
980
981 /* Update the target face count if symmetry is enabled */
983 if (ob && job->use_mesh_symmetry) {
985 job->symmetry_axes = eSymmetryAxes(mesh->symmetry);
986 for (char i = 0; i < 3; i++) {
987 eSymmetryAxes symm_it = eSymmetryAxes(1 << i);
988 if (job->symmetry_axes & symm_it) {
989 job->target_faces = job->target_faces / 2;
990 }
991 }
992 }
993 else {
994 job->use_mesh_symmetry = false;
996 }
997
999 if ((op->flag & OP_IS_INVOKE) == 0) {
1000 /* This is called directly from the exec operator, this operation is now blocking */
1001 job->is_nonblocking_job = false;
1002 wmJobWorkerStatus worker_status = {};
1003 worker_status.reports = op->reports;
1004 quadriflow_start_job(job, &worker_status);
1005
1006 status = job->status;
1007 quadriflow_end_job(job);
1009 }
1010 else {
1011 /* Non blocking call. For when the operator has been called from the GUI. */
1012 job->is_nonblocking_job = true;
1013
1014 wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
1017 "Remeshing with QuadriFlow...",
1020
1022 WM_jobs_timer(wm_job, 0.1, NC_GEOM | ND_DATA, NC_GEOM | ND_DATA);
1023 WM_jobs_callbacks(wm_job, quadriflow_start_job, nullptr, nullptr, quadriflow_end_job);
1024
1026
1027 WM_jobs_start(CTX_wm_manager(C), wm_job);
1028 }
1029
1030 if (status == QUADRIFLOW_STATUS_SUCCESS) {
1031 return OPERATOR_FINISHED;
1032 }
1033 /* Only ever runs with immediate execution. */
1034 return OPERATOR_CANCELLED;
1035}
1036
1038{
1039 int mode = RNA_enum_get(op->ptr, "mode");
1040
1041 if (mode == QUADRIFLOW_REMESH_EDGE_LENGTH) {
1042 float area = RNA_float_get(op->ptr, "mesh_area");
1043 if (area < 0.0f) {
1045 area = BKE_mesh_calc_area(id_cast<const Mesh *>(ob->data));
1046 RNA_float_set(op->ptr, "mesh_area", area);
1047 }
1048 int faces_num;
1049 float edge_len = RNA_float_get(op->ptr, "target_edge_length");
1050
1051 faces_num = area / (edge_len * edge_len);
1052 RNA_int_set(op->ptr, "target_faces", faces_num);
1053 }
1054 else if (mode == QUADRIFLOW_REMESH_RATIO) {
1056 Mesh *mesh = id_cast<Mesh *>(ob->data);
1057
1058 int faces_num;
1059 float ratio = RNA_float_get(op->ptr, "target_ratio");
1060
1061 faces_num = mesh->faces_num * ratio;
1062
1063 RNA_int_set(op->ptr, "target_faces", faces_num);
1064 }
1065
1066 return true;
1067}
1068
1069/* Hide the target variables if they are not active */
1070static bool quadriflow_poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop)
1071{
1072 const char *prop_id = RNA_property_identifier(prop);
1073
1074 if (STRPREFIX(prop_id, "target")) {
1075 int mode = RNA_enum_get(op->ptr, "mode");
1076
1077 if (STREQ(prop_id, "target_edge_length") && mode != QUADRIFLOW_REMESH_EDGE_LENGTH) {
1078 return false;
1079 }
1080 if (STREQ(prop_id, "target_faces")) {
1081 if (mode != QUADRIFLOW_REMESH_FACES) {
1082 /* Make sure we can edit the target_faces value even if it doesn't start as EDITABLE */
1083 float area = RNA_float_get(op->ptr, "mesh_area");
1084 if (area < -0.8f) {
1085 area += 0.2f;
1086 /* Make sure we have up to date values from the start */
1087 RNA_def_property_flag(const_cast<PropertyRNA *>(prop), PROP_EDITABLE);
1088 quadriflow_check(const_cast<bContext *>(C), op);
1089 }
1090
1091 /* Only disable input */
1093 }
1094 else {
1095 RNA_def_property_flag(const_cast<PropertyRNA *>(prop), PROP_EDITABLE);
1096 }
1097 }
1098 else if (STREQ(prop_id, "target_ratio") && mode != QUADRIFLOW_REMESH_RATIO) {
1099 return false;
1100 }
1101 }
1102
1103 return true;
1104}
1105
1108 "RATIO",
1109 0,
1110 "Ratio",
1111 "Specify target number of faces relative to the current mesh"},
1113 "EDGE",
1114 0,
1115 "Edge Length",
1116 "Input target edge length in the new mesh"},
1117 {QUADRIFLOW_REMESH_FACES, "FACES", 0, "Faces", "Input target number of faces in the new mesh"},
1118 {0, nullptr, 0, nullptr, nullptr},
1119};
1120
1122{
1124 C, op, event, IFACE_("QuadriFlow Remesh the Selected Mesh"), IFACE_("Remesh"));
1125}
1126
1128{
1129 /* identifiers */
1130 ot->name = "QuadriFlow Remesh";
1131 ot->description =
1132 "Create a new quad based mesh using the surface data of the current mesh. All data "
1133 "layers will be lost";
1134 ot->idname = "OBJECT_OT_quadriflow_remesh";
1135
1136 /* API callbacks. */
1139 ot->check = quadriflow_check;
1142
1144
1145 PropertyRNA *prop;
1146
1147 /* properties */
1149 "use_mesh_symmetry",
1150 true,
1151 "Use Mesh Symmetry",
1152 "Generates a symmetrical mesh using the mesh symmetry configuration");
1153
1155 "use_preserve_sharp",
1156 false,
1157 "Preserve Sharp",
1158 "Try to preserve sharp features on the mesh");
1159
1161 "use_preserve_boundary",
1162 false,
1163 "Preserve Mesh Boundary",
1164 "Try to preserve mesh boundary on the mesh");
1165#ifdef USE_MESH_CURVATURE
1167 "use_mesh_curvature",
1168 false,
1169 "Use Mesh Curvature",
1170 "Take the mesh curvature into account when remeshing");
1171#endif
1173 "preserve_attributes",
1174 false,
1175 "Preserve Attributes",
1176 "Reproject attributes onto the new mesh");
1177
1179 "smooth_normals",
1180 false,
1181 "Smooth Normals",
1182 "Set the output mesh normals to smooth");
1183
1184 RNA_def_enum(ot->srna,
1185 "mode",
1188 "Mode",
1189 "How to specify the amount of detail for the new mesh");
1190
1191 prop = RNA_def_float(ot->srna,
1192 "target_ratio",
1193 1,
1194 0,
1195 FLT_MAX,
1196 "Ratio",
1197 "Relative number of faces compared to the current mesh",
1198 0.0f,
1199 1.0f);
1200
1201 prop = RNA_def_float(ot->srna,
1202 "target_edge_length",
1203 0.1f,
1204 0.0000001f,
1205 FLT_MAX,
1206 "Edge Length",
1207 "Target edge length in the new mesh",
1208 0.00001f,
1209 1.0f);
1210
1211 prop = RNA_def_int(ot->srna,
1212 "target_faces",
1213 4000,
1214 1,
1215 INT_MAX,
1216 "Number of Faces",
1217 "Approximate number of faces (quads) in the new mesh",
1218 1,
1219 INT_MAX);
1220
1221 prop = RNA_def_float(
1222 ot->srna,
1223 "mesh_area",
1224 -1.0f,
1225 -FLT_MAX,
1226 FLT_MAX,
1227 "Old Object Face Area",
1228 "This property is only used to cache the object area for later calculations",
1229 0.0f,
1230 FLT_MAX);
1232
1233 RNA_def_int(ot->srna,
1234 "seed",
1235 0,
1236 0,
1237 INT_MAX,
1238 "Seed",
1239 "Random seed to use with the solver. Different seeds will cause the remesher to "
1240 "come up with different quad layouts on the mesh",
1241 0,
1242 255);
1243}
1244
1246
1247} // namespace blender::ed::object
#define G_MAIN
General operations, lookup, etc. for blender objects.
#define IFACE_(msgid)
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object is a sort of wrapper for general info.
#define REGION_DRAW_POST_VIEW
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define STRPREFIX(a, b)
#define STREQ(a, b)
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
void item(std::string text, int icon1, int icon2=0)
Definition area.cc:1076
void item_bool(std::string text, bool inverted, int icon1, int icon2=0)
Definition area.cc:1097
#define str(s)
#define FLT_MAX
#define INT_MAX
float3x3 scale(float3x3 mat, float2 scale)
void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
void mesh_smooth_set(Mesh &mesh, bool use_smooth, bool keep_sharp_edges=false)
void mesh_apply_spatial_organization(Mesh &mesh)
std::array< VecBase< T, 3 >, 8 > corners(const Bounds< VecBase< T, 3 > > &bounds)
static bool object_remesh_poll(bContext *C)
static Mesh * remesh_symmetry_bisect(Mesh *mesh, eSymmetryAxes symmetry_axes)
static void quadriflow_end_job(void *customdata)
static void quadriflow_update_job(void *customdata, float progress, int *cancel)
static wmOperatorStatus voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int quadriflow_break_job(void *customdata)
static void voxel_size_edit_cancel(bContext *C, wmOperator *op)
static bool mesh_is_manifold_consistent(Mesh *mesh)
static bool voxel_size_edit_poll(bContext *C)
static bool quadriflow_check(bContext *C, wmOperator *op)
void OBJECT_OT_voxel_size_edit(wmOperatorType *ot)
static const EnumPropertyItem mode_type_items[]
static void voxel_size_parallel_lines_draw(uint pos3d, const float initial_co[3], const float end_co[3], const float length_co[3], const float spacing)
static void voxel_size_edit_update_header(wmOperator *op, bContext *C)
static void voxel_size_edit_draw(const bContext *C, ARegion *, void *arg)
void OBJECT_OT_voxel_remesh(wmOperatorType *ot)
static wmOperatorStatus voxel_remesh_exec(bContext *C, wmOperator *op)
static wmOperatorStatus quadriflow_remesh_exec(bContext *C, wmOperator *op)
static Mesh * remesh_symmetry_mirror(Object *ob, Mesh *mesh, eSymmetryAxes symmetry_axes)
static void quadriflow_free_job(void *customdata)
void OBJECT_OT_quadriflow_remesh(wmOperatorType *ot)
static void quadriflow_start_job(void *customdata, wmJobWorkerStatus *worker_status)
static wmOperatorStatus voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool quadriflow_poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop)
static wmOperatorStatus quadriflow_remesh_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void geometry_begin(const Scene &scene, Object &ob, const wmOperator *op)
const uiStyle * style_get()
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void mul_m3_v3(const float M[3][3], float r[3])
int RNA_enum_get(PointerRNA *ptr, const char *name)
@ RPT_WARNING
Definition BKE_report.hh:40
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:390
void immEnd()
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition wm_jobs.cc:407
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void mul_m4_m4_pre(float R[4][4], const float A[4][4])
Mesh * BKE_mesh_remesh_quadriflow(const Mesh *mesh, int target_faces, int seed, bool preserve_sharp, bool preserve_boundary, bool adaptive_scale, void(*update_cb)(void *, float progress, int *cancel), void *update_cb_data)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
Mesh * BKE_mesh_copy_for_eval(const Mesh &source)
const char * RNA_property_identifier(const PropertyRNA *prop)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
GPUVertFormat * immVertexFormat()
MINLINE void invert_v3(float r[3])
@ WM_JOB_TYPE_QUADRIFLOW_REMESH
Definition WM_api.hh:2044
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, bool process_shape_keys=true)
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void immBegin(GPUPrimType, uint vertex_len)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void GPU_line_smooth(bool enable)
Definition gpu_state.cc:80
int RNA_int_get(PointerRNA *ptr, const char *name)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
wmWindow * CTX_wm_window(const bContext *C)
MINLINE float normalize_v2(float n[2])
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))
Definition wm_jobs.cc:377
void ED_view3d_project_v2(const ARegion *region, const float world[3], float r_region_co[2])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
Definition math_geom.cc:45
@ WM_JOB_PROGRESS
Definition WM_api.hh:1997
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
void BKE_shrinkwrap_remesh_target_project(Mesh *src_me, Mesh *target_me, Object *ob_target)
void immUnbindProgram()
void BKE_sculptsession_free_pbvh(Object &object)
void GPU_matrix_mul(const float m[4][4])
MINLINE void mul_v3_fl(float r[3], float f)
void GPU_line_width(float width)
Definition gpu_state.cc:151
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition wm_jobs.cc:498
Global G
Definition blender.cc:57
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void WM_locked_interface_set(wmWindowManager *wm, bool lock)
float BKE_mesh_calc_area(const Mesh *mesh)
void BLF_size(int fontid, float size)
Definition blf.cc:445
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
void size_to_mat4(float R[4][4], const float size[3])
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
Mesh * BKE_mesh_mirror_bisect_on_mirror_plane_for_modifier(MirrorModifierData *mmd, const Mesh *mesh, int axis, const float plane_co[3], float plane_no[3])
Mesh * BKE_mesh_from_object(Object *ob)
void BKE_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode)
wmWindowManager * CTX_wm_manager(const bContext *C)
void immUniformColor4f(float r, float g, float b, float a)
Mesh * BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd, Object *ob, const Mesh *mesh, int axis, bool use_correct_order_on_merge, int **r_vert_merge_map, int *r_vert_merge_map_len)
void unit_m4(float m[4][4])
RegionView3D * CTX_wm_region_view3d(const bContext *C)
Mesh * BKE_mesh_remesh_voxel(const Mesh *mesh, float voxel_size, float adaptivity, float isovalue, const Object *object, ModifierData *modifier_data)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
size_t BKE_unit_value_as_string_scaled(char *str, int str_maxncpy, double value, int prec, int type, const UnitSettings &settings, bool pad, bool do_unit_suffix)
Definition unit.cc:1944
MINLINE void zero_v3(float r[3])
@ ME_REMESH_REPROJECT_ATTRIBUTES
@ ME_REMESH_REPROJECT_VOLUME
@ ME_REMESH_FIX_POLES
void BKE_id_free(Main *bmain, void *idv)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:587
MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
bool BKE_modifiers_uses_multires(Object *ob)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Mesh * BKE_mesh_remesh_voxel_fix_poles(const Mesh *mesh)
void mat4_to_size(float size[3], const float M[4][4])
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
bool BKE_object_is_in_editmode(const Object *ob)
Definition object.cc:1898
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)
MINLINE float normalize_v3(float n[3])
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void immVertex3fv(uint attr_id, const float data[3])
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE bool compare_v3v3(const float v1[3], const float v2[3], float limit) ATTR_WARN_UNUSED_RESULT
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void BLF_color3f(int fontid, float r, float g, float b)
Definition blf.cc:530
float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[3])
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, const eWM_JobFlag flag, const eWM_JobType job_type)
Definition wm_jobs.cc:228
MINLINE float max_ff(float a, float b)
void mul_m4_m4_post(float R[4][4], const float B[4][4])
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
@ KM_RELEASE
Definition WM_types.hh:325
Scene * CTX_data_scene(const bContext *C)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
void scale_m4_fl(float R[4][4], float scale)
size_t BLI_strlen_utf8(const char *strc) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
Definition blf.cc:822
bool ED_operator_object_active_editable_mesh(bContext *C)
@ BKE_MESH_BATCH_DIRTY_ALL
Definition BKE_mesh.h:48
@ B_UNIT_LENGTH
Definition BKE_unit.hh:166
void GPU_matrix_pop()
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
Object * CTX_data_active_object(const bContext *C)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
ARegion * CTX_wm_region(const bContext *C)
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote, void(*timer_step)(void *))
Definition wm_jobs.cc:393
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
float RNA_float_get(PointerRNA *ptr, const char *name)
void GPU_matrix_push()
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE float clamp_f(float value, float min, float max)
#define VOXEL_SIZE_EDIT_MAX_GRIDS_LINES
#define VOXEL_SIZE_EDIT_MAX_STR_LEN
#define QUADRIFLOW_MIRROR_BISECT_TOLERANCE
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ARegionRuntime * runtime
const c_style_mat & ptr() const
bke::ObjectRuntime * runtime
struct UnitSettings unit
struct ARegionType * type
wmEventType type
Definition WM_types.hh:817
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
bool(*) poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1171
bool(*) check(bContext *C, wmOperator *op)
Definition WM_types.hh:1133
const char * description
Definition WM_types.hh:1115
void(*) cancel(bContext *C, wmOperator *op)
Definition WM_types.hh:1149
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports
uiFontStyle widget