Blender V5.3
MOD_screw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2005 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9/* Screw modifier: revolves the edges about an axis */
10#include <algorithm>
11#include <climits>
12
13#include "BLI_utildefines.hh"
14
15#include "BLI_array_utils.hh"
16#include "BLI_bitmap.hh"
17#include "BLI_math_geom_c.hh"
18#include "BLI_math_matrix_c.hh"
20#include "BLI_math_vector_c.hh"
21#include "BLI_span.hh"
22
23#include "BLT_translation.hh"
24
25#include "DNA_mesh_types.h"
26#include "DNA_object_types.h"
27#include "DNA_screen_types.h"
28
29#include "BKE_attribute.hh"
31#include "BKE_customdata.hh"
32#include "BKE_lib_id.hh"
33#include "BKE_lib_query.hh"
34#include "BKE_mesh.hh"
35
37#include "UI_resources.hh"
38
39#include "RNA_access.hh"
40#include "RNA_prototypes.hh"
41
43
44#include "MEM_guardedalloc.h"
45
46#include "MOD_modifiertypes.hh"
47#include "MOD_ui_common.hh"
48
50
51#include "BLI_strict_flags.hh" /* IWYU pragma: keep. Keep last. */
52
53namespace blender {
54
55static void init_data(ModifierData *md)
56{
57 ScrewModifierData *ltmd = reinterpret_cast<ScrewModifierData *>(md);
59}
60
64 float dist_sq;
66 float co[3];
68 uint v[2];
70 int2 *e[2];
71 char flag;
72};
73
80
81#define SV_UNUSED (UINT_MAX)
82#define SV_INVALID ((UINT_MAX) - 1)
83#define SV_IS_VALID(v) ((v) < SV_INVALID)
84
87 uint v_init,
88 uint dir)
89{
90 iter->v_array = array;
91 iter->v = v_init;
92
93 if (SV_IS_VALID(v_init)) {
94 iter->v_poin = &array[v_init];
95 iter->v_other = iter->v_poin->v[dir];
96 iter->e = iter->v_poin->e[!dir];
97 }
98 else {
99 iter->v_poin = nullptr;
100 iter->e = nullptr;
101 }
102}
103
105{
106 if (iter->v_poin->v[0] == iter->v_other) {
107 iter->v_other = iter->v;
108 iter->v = iter->v_poin->v[1];
109 }
110 else if (iter->v_poin->v[1] == iter->v_other) {
111 iter->v_other = iter->v;
112 iter->v = iter->v_poin->v[0];
113 }
114 if (SV_IS_VALID(iter->v)) {
115 iter->v_poin = &iter->v_array[iter->v];
116 iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)];
117 }
118 else {
119 iter->e = nullptr;
120 iter->v_poin = nullptr;
121 }
122}
123
125 MutableSpan<float3> vert_positions_new,
126 const uint totvert,
127 const uint step_tot,
128 const float axis_vec[3],
129 const float axis_offset[3],
130 const float merge_threshold)
131{
132 BLI_bitmap *vert_tag = BLI_BITMAP_NEW(totvert, __func__);
133
134 const float merge_threshold_sq = square_f(merge_threshold);
135 const bool use_offset = axis_offset != nullptr;
136 uint tot_doubles = 0;
137 for (uint i = 0; i < totvert; i += 1) {
138 float axis_co[3];
139 if (use_offset) {
140 float offset_co[3];
141 sub_v3_v3v3(offset_co, vert_positions_new[i], axis_offset);
142 project_v3_v3v3_normalized(axis_co, offset_co, axis_vec);
143 add_v3_v3(axis_co, axis_offset);
144 }
145 else {
146 project_v3_v3v3_normalized(axis_co, vert_positions_new[i], axis_vec);
147 }
148 const float dist_sq = len_squared_v3v3(axis_co, vert_positions_new[i]);
149 if (dist_sq <= merge_threshold_sq) {
150 BLI_BITMAP_ENABLE(vert_tag, i);
151 tot_doubles += 1;
152 copy_v3_v3(vert_positions_new[i], axis_co);
153 }
154 }
155
156 if (tot_doubles != 0) {
157 uint tot = totvert * step_tot;
158 int *full_doubles_map = MEM_new_array_uninitialized<int>(tot, __func__);
159 /* Vertices that aren't merged point at themselves, as #geometry::mesh_merge_verts expects. */
161
162 uint tot_doubles_left = tot_doubles;
163 for (uint i = 0; i < totvert; i += 1) {
164 if (BLI_BITMAP_TEST(vert_tag, i)) {
165 int *doubles_map = &full_doubles_map[totvert + i];
166 for (uint step = 1; step < step_tot; step += 1) {
167 *doubles_map = int(i);
168 doubles_map += totvert;
169 }
170 tot_doubles_left -= 1;
171 if (tot_doubles_left == 0) {
172 break;
173 }
174 }
175 }
176
177 Mesh *tmp = result;
178
179 /* TODO(mano-wii): Polygons with all vertices merged are the ones that form duplicates.
180 * Therefore the duplicate face test can be skipped. */
182 Span<int>{full_doubles_map, result->verts_num},
183 int(tot_doubles * (step_tot - 1)),
184 false);
185
186 BKE_id_free(nullptr, tmp);
187 MEM_delete(full_doubles_map);
188 }
189
190 MEM_delete(vert_tag);
191
192 return result;
193}
194
195static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *meshData)
196{
197 const Mesh *mesh = meshData;
198 Mesh *result;
199 ScrewModifierData *ltmd = reinterpret_cast<ScrewModifierData *>(md);
200 const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER) != 0;
201
202 int face_index = 0;
203 uint step;
204 uint j;
205 uint i1, i2;
206 uint step_tot = use_render_params ? ltmd->render_steps : ltmd->steps;
207 const bool do_flip = (ltmd->flag & MOD_SCREW_NORMAL_FLIP) != 0;
208
209 const int quad_ord[4] = {
210 do_flip ? 3 : 0,
211 do_flip ? 2 : 1,
212 do_flip ? 1 : 2,
213 do_flip ? 0 : 3,
214 };
215 const int quad_ord_ofs[4] = {
216 do_flip ? 2 : 0,
217 1,
218 do_flip ? 0 : 2,
219 3,
220 };
221
222 uint maxVerts = 0, maxEdges = 0, maxPolys = 0;
223 const uint totvert = uint(mesh->verts_num);
224 const uint totedge = uint(mesh->edges_num);
225 const uint faces_num = uint(mesh->faces_num);
226
227 uint *edge_face_map = nullptr; /* orig edge to orig face */
228 uint *vert_loop_map = nullptr; /* orig vert to orig loop */
229
230 /* UV Coords */
231 const VectorSet<StringRefNull> uv_map_names = mesh->uv_map_names();
232 Array<bke::SpanAttributeWriter<float2>> uv_map_layers(uv_map_names.size());
233 float uv_u_scale;
234 float uv_v_minmax[2] = {FLT_MAX, -FLT_MAX};
235 float uv_v_range_inv;
236 float uv_axis_plane[4];
237
238 char axis_char = 'X';
239 bool close;
240 float angle = ltmd->angle;
241 float screw_ofs = ltmd->screw_ofs;
242 float axis_vec[3] = {0.0f, 0.0f, 0.0f};
243 float tmp_vec1[3], tmp_vec2[3];
244 float mat3[3][3];
245 /* transform the coords by an object relative to this objects transformation */
246 float mtx_tx[4][4];
247 float mtx_tx_inv[4][4]; /* inverted */
248 float mtx_tmp_a[4][4];
249
250 uint vc_tot_linked = 0;
251 short other_axis_1, other_axis_2;
252 const float *tmpf1, *tmpf2;
253
254 uint edge_offset;
255
256 int2 *edge_new, *med_new_firstloop;
257 Object *ob_axis = ltmd->ob_axis;
258
259 ScrewVertConnect *vc, *vc_tmp, *vert_connect = nullptr;
260
261 const bool use_flat_shading = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) == 0;
262
263 /* don't do anything? */
264 if (!totvert) {
265 return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0);
266 }
267
268 switch (ltmd->axis) {
269 case 0:
270 other_axis_1 = 1;
271 other_axis_2 = 2;
272 break;
273 case 1:
274 other_axis_1 = 0;
275 other_axis_2 = 2;
276 break;
277 default: /* 2, use default to quiet warnings */
278 other_axis_1 = 0;
279 other_axis_2 = 1;
280 break;
281 }
282
283 axis_vec[ltmd->axis] = 1.0f;
284
285 if (ob_axis != nullptr) {
286 /* Calculate the matrix relative to the axis object. */
287 invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world().ptr());
288 copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world().ptr());
289 mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv);
290
291 /* Calculate the axis vector. */
292 mul_mat3_m4_v3(mtx_tx, axis_vec); /* only rotation component */
293 normalize_v3(axis_vec);
294
295 /* screw */
296 if (ltmd->flag & MOD_SCREW_OBJECT_OFFSET) {
297 /* Find the offset along this axis relative to this objects matrix. */
298 float totlen = len_v3(mtx_tx[3]);
299
300 if (totlen != 0.0f) {
301 const float zero[3] = {0.0f, 0.0f, 0.0f};
302 float cp[3];
303 screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec);
304 }
305 else {
306 screw_ofs = 0.0f;
307 }
308 }
309
310 /* angle */
311
312#if 0 /* can't include this, not predictable enough, though quite fun. */
313 if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) {
314 float mtx3_tx[3][3];
315 copy_m3_m4(mtx3_tx, mtx_tx);
316
317 float vec[3] = {0, 1, 0};
318 float cross1[3];
319 float cross2[3];
320 cross_v3_v3v3(cross1, vec, axis_vec);
321
322 mul_v3_m3v3(cross2, mtx3_tx, cross1);
323 {
324 float c1[3];
325 float c2[3];
326 float axis_tmp[3];
327
328 cross_v3_v3v3(c1, cross2, axis_vec);
329 cross_v3_v3v3(c2, axis_vec, c1);
330
331 angle = angle_v3v3(cross1, c2);
332
333 cross_v3_v3v3(axis_tmp, cross1, c2);
334 normalize_v3(axis_tmp);
335
336 if (len_v3v3(axis_tmp, axis_vec) > 1.0f) {
337 angle = -angle;
338 }
339 }
340 }
341#endif
342 }
343 else {
344 axis_char = char(axis_char + ltmd->axis); /* 'X' + axis */
345
346 /* Useful to be able to use the axis vector in some cases still. */
347 zero_v3(axis_vec);
348 axis_vec[ltmd->axis] = 1.0f;
349 }
350
351 /* apply the multiplier */
352 angle *= float(ltmd->iter);
353 screw_ofs *= float(ltmd->iter);
354 uv_u_scale = 1.0f / float(step_tot);
355
356 /* multiplying the steps is a bit tricky, this works best */
357 step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);
358
359 /* Will the screw be closed?
360 * NOTE: smaller than `FLT_EPSILON * 100`
361 * gives problems with float precision so its never closed. */
362 if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) &&
363 fabsf(fabsf(angle) - (float(M_PI) * 2.0f)) <= (FLT_EPSILON * 100.0f) && step_tot > 3)
364 {
365 close = true;
366 step_tot--;
367
368 maxVerts = totvert * step_tot; /* -1 because we're joining back up */
369 maxEdges = (totvert * step_tot) + /* these are the edges between new verts */
370 (totedge * step_tot); /* -1 because vert edges join */
371 maxPolys = totedge * step_tot;
372
373 screw_ofs = 0.0f;
374 }
375 else {
376 close = false;
377 step_tot = std::max<uint>(step_tot, 2);
378
379 maxVerts = totvert * step_tot; /* -1 because we're joining back up */
380 maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */
381 (totedge * step_tot); /* -1 because vert edges join */
382 maxPolys = totedge * (step_tot - 1);
383 }
384
385 if ((ltmd->flag & MOD_SCREW_UV_STRETCH_U) == 0) {
386 uv_u_scale = (uv_u_scale / float(ltmd->iter)) * (angle / (float(M_PI) * 2.0f));
387 }
388
389 /* The `screw_ofs` cannot change from now on. */
390 const bool do_remove_doubles = (ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f);
391
393 mesh, int(maxVerts), int(maxEdges), int(maxPolys), int(maxPolys) * 4);
394 /* The modifier doesn't support original index mapping on the edge or face domains. Remove
395 * original index layers, since otherwise edges aren't displayed at all in wireframe view. */
398
399 const Span<float3> vert_positions_orig = mesh->vert_positions();
400 const Span<int2> edges_orig = mesh->edges();
401 const OffsetIndices faces_orig = mesh->faces();
402 const Span<int> corner_verts_orig = mesh->corner_verts();
403 const Span<int> corner_edges_orig = mesh->corner_edges();
404
405 MutableSpan<float3> vert_positions_new = result->vert_positions_for_write();
406 MutableSpan<int2> edges_new = result->edges_for_write();
407 MutableSpan<int> face_offests_new = result->face_offsets_for_write();
408 MutableSpan<int> corner_verts_new = result->corner_verts_for_write();
409 MutableSpan<int> corner_edges_new = result->corner_edges_for_write();
410 bke::MutableAttributeAccessor attributes = result->attributes_for_write();
412 "sharp_face", bke::AttrDomain::Face);
413
414 if (!CustomData_has_layer(&result->face_data, CD_ORIGINDEX)) {
415 CustomData_add_layer(&result->face_data, CD_ORIGINDEX, CD_SET_DEFAULT, int(maxPolys));
416 }
417
418 int *origindex = static_cast<int *>(
419 CustomData_get_layer_for_write(&result->face_data, CD_ORIGINDEX, result->faces_num));
420
425
426 vert_interp.copy(0, 0, int(totvert));
427
428 if (!uv_map_names.is_empty()) {
429 const float zero_co[3] = {0};
430 plane_from_point_normal_v3(uv_axis_plane, zero_co, axis_vec);
431 }
432
433 if (!uv_map_names.is_empty()) {
434 for (const int64_t uv_lay : uv_map_names.index_range()) {
435 uv_map_layers[uv_lay] = attributes.lookup_for_write_span<float2>(uv_map_names[uv_lay]);
436 }
437
438 if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) {
439 for (uint i = 0; i < totvert; i++) {
440 const float v = dist_signed_squared_to_plane_v3(vert_positions_orig[i], uv_axis_plane);
441 uv_v_minmax[0] = min_ff(v, uv_v_minmax[0]);
442 uv_v_minmax[1] = max_ff(v, uv_v_minmax[1]);
443 }
444 uv_v_minmax[0] = sqrtf_signed(uv_v_minmax[0]);
445 uv_v_minmax[1] = sqrtf_signed(uv_v_minmax[1]);
446 }
447
448 uv_v_range_inv = uv_v_minmax[1] - uv_v_minmax[0];
449 uv_v_range_inv = uv_v_range_inv ? 1.0f / uv_v_range_inv : 0.0f;
450 }
451
452 /* Set the locations of the first set of verts */
453
454 /* Copy the first set of edges */
455 const int2 *edge_orig = edges_orig.data();
456 edge_new = edges_new.data();
457 for (uint i = 0; i < totedge; i++, edge_orig++, edge_new++) {
458 *edge_new = *edge_orig;
459 }
460
461 /* build face -> edge map */
462 if (faces_num) {
463
464 edge_face_map = MEM_new_array_uninitialized<uint>(totedge, __func__);
465 memset(edge_face_map, 0xff, sizeof(*edge_face_map) * totedge);
466
467 vert_loop_map = MEM_new_array_uninitialized<uint>(totvert, __func__);
468 memset(vert_loop_map, 0xff, sizeof(*vert_loop_map) * totvert);
469
470 for (const int64_t i : faces_orig.index_range()) {
471 for (const int64_t corner : faces_orig[i]) {
472 const int vert_i = corner_verts_orig[corner];
473 const int edge_i = corner_edges_orig[corner];
474 edge_face_map[edge_i] = uint(i);
475 vert_loop_map[vert_i] = uint(corner);
476
477 /* also order edges based on faces */
478 if (edges_new[edge_i][0] != vert_i) {
479 std::swap(edges_new[edge_i][0], edges_new[edge_i][1]);
480 }
481 }
482 }
483 }
484
485 if (ltmd->flag & MOD_SCREW_NORMAL_CALC) {
486
487 /* Normal Calculation (for face flipping)
488 * Sort edge verts for correct face flipping
489 * NOT REALLY NEEDED but face flipping is nice. */
490
491 vert_connect = MEM_new_array_uninitialized<ScrewVertConnect>(totvert, __func__);
492 /* skip the first slice of verts. */
493 // vert_connect = (ScrewVertConnect *) &medge_new[totvert];
494 vc = vert_connect;
495
496 /* Copy Vert Locations */
497 if (totedge != 0) {
498 // printf("\n\n\n\n\nStarting Modifier\n");
499 /* set edge users */
500 edge_new = edges_new.data();
501
502 if (ob_axis != nullptr) {
503 /* `mtx_tx` is initialized early on. */
504 for (uint i = 0; i < totvert; i++, vc++) {
505 vc->co[0] = vert_positions_new[i][0] = vert_positions_orig[i][0];
506 vc->co[1] = vert_positions_new[i][1] = vert_positions_orig[i][1];
507 vc->co[2] = vert_positions_new[i][2] = vert_positions_orig[i][2];
508
509 vc->flag = 0;
510 vc->e[0] = vc->e[1] = nullptr;
511 vc->v[0] = vc->v[1] = SV_UNUSED;
512
513 mul_m4_v3(mtx_tx, vc->co);
514 /* Length in 2D, don't `sqrt` because this is only for comparison. */
515 vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] +
516 vc->co[other_axis_2] * vc->co[other_axis_2];
517
518 // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq);
519 }
520 }
521 else {
522 for (uint i = 0; i < totvert; i++, vc++) {
523 vc->co[0] = vert_positions_new[i][0] = vert_positions_orig[i][0];
524 vc->co[1] = vert_positions_new[i][1] = vert_positions_orig[i][1];
525 vc->co[2] = vert_positions_new[i][2] = vert_positions_orig[i][2];
526
527 vc->flag = 0;
528 vc->e[0] = vc->e[1] = nullptr;
529 vc->v[0] = vc->v[1] = SV_UNUSED;
530
531 /* Length in 2D, don't `sqrt` because this is only for comparison. */
532 vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] +
533 vc->co[other_axis_2] * vc->co[other_axis_2];
534
535 // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq);
536 }
537 }
538
539 /* this loop builds connectivity info for verts */
540 for (uint i = 0; i < totedge; i++, edge_new++) {
541 vc = &vert_connect[(*edge_new)[0]];
542
543 if (vc->v[0] == SV_UNUSED) { /* unused */
544 vc->v[0] = uint((*edge_new)[1]);
545 vc->e[0] = edge_new;
546 }
547 else if (vc->v[1] == SV_UNUSED) {
548 vc->v[1] = uint((*edge_new)[1]);
549 vc->e[1] = edge_new;
550 }
551 else {
552 vc->v[0] = vc->v[1] = SV_INVALID; /* error value - don't use, 3 edges on vert */
553 }
554
555 vc = &vert_connect[(*edge_new)[1]];
556
557 /* same as above but swap v1/2 */
558 if (vc->v[0] == SV_UNUSED) { /* unused */
559 vc->v[0] = uint((*edge_new)[0]);
560 vc->e[0] = edge_new;
561 }
562 else if (vc->v[1] == SV_UNUSED) {
563 vc->v[1] = uint((*edge_new)[0]);
564 vc->e[1] = edge_new;
565 }
566 else {
567 vc->v[0] = vc->v[1] = SV_INVALID; /* error value - don't use, 3 edges on vert */
568 }
569 }
570
571 /* find the first vert */
572 vc = vert_connect;
573 for (uint i = 0; i < totvert; i++, vc++) {
574 /* Now do search for connected verts, order all edges and flip them
575 * so resulting faces are flipped the right way */
576 vc_tot_linked = 0; /* count the number of linked verts for this loop */
577 if (vc->flag == 0) {
578 uint v_best = SV_UNUSED, ed_loop_closed = 0; /* vert and vert new */
579 ScrewVertIter lt_iter;
580 float fl = -1.0f;
581
582 /* compiler complains if not initialized, but it should be initialized below */
583 bool ed_loop_flip = false;
584
585 // printf("Loop on connected vert: %i\n", i);
586
587 for (j = 0; j < 2; j++) {
588 // printf("\tSide: %i\n", j);
589 screwvert_iter_init(&lt_iter, vert_connect, i, j);
590 if (j == 1) {
591 screwvert_iter_step(&lt_iter);
592 }
593 while (lt_iter.v_poin) {
594 // printf("\t\tVERT: %i\n", lt_iter.v);
595 if (lt_iter.v_poin->flag) {
596 // printf("\t\t\tBreaking Found end\n");
597 // endpoints[0] = endpoints[1] = SV_UNUSED;
598 ed_loop_closed = 1; /* circle */
599 break;
600 }
601 lt_iter.v_poin->flag = 1;
602 vc_tot_linked++;
603 // printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist_sq);
604 if (fl <= lt_iter.v_poin->dist_sq) {
605 fl = lt_iter.v_poin->dist_sq;
606 v_best = lt_iter.v;
607 // printf("\t\t\tVERT BEST: %i\n", v_best);
608 }
609 screwvert_iter_step(&lt_iter);
610 if (!lt_iter.v_poin) {
611 // printf("\t\t\tFound End Also Num %i\n", j);
612 // endpoints[j] = lt_iter.v_other; /* other is still valid */
613 break;
614 }
615 }
616 }
617
618 /* Now we have a collection of used edges. flip their edges the right way. */
619 /* if (v_best != SV_UNUSED) - */
620
621 // printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);
622
623 if (vc_tot_linked > 1) {
624 float vf_1, vf_2, vf_best;
625
626 vc_tmp = &vert_connect[v_best];
627
628 tmpf1 = vert_connect[vc_tmp->v[0]].co;
629 tmpf2 = vert_connect[vc_tmp->v[1]].co;
630
631 /* edge connects on each side! */
632 if (SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) {
633 // printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);
634 /* Find out which is higher. */
635
636 vf_1 = tmpf1[ltmd->axis];
637 vf_2 = tmpf2[ltmd->axis];
638 vf_best = vc_tmp->co[ltmd->axis];
639
640 if (vf_1 < vf_best && vf_best < vf_2) {
641 ed_loop_flip = false;
642 }
643 else if (vf_1 > vf_best && vf_best > vf_2) {
644 ed_loop_flip = true;
645 }
646 else {
647 /* not so simple to work out which edge is higher */
648 sub_v3_v3v3(tmp_vec1, tmpf1, vc_tmp->co);
649 sub_v3_v3v3(tmp_vec2, tmpf2, vc_tmp->co);
650 normalize_v3(tmp_vec1);
651 normalize_v3(tmp_vec2);
652
653 if (tmp_vec1[ltmd->axis] < tmp_vec2[ltmd->axis]) {
654 ed_loop_flip = true;
655 }
656 else {
657 ed_loop_flip = false;
658 }
659 }
660 }
661 else if (SV_IS_VALID(vc_tmp->v[0])) { /* Vertex only connected on 1 side. */
662 // printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);
663 if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */
664 ed_loop_flip = true;
665 }
666 else { /* best is below or even... in even case we can't know what to do. */
667 ed_loop_flip = false;
668 }
669 }
670#if 0
671 else {
672 printf("No Connected ___\n");
673 }
674#endif
675
676 // printf("flip direction %i\n", ed_loop_flip);
677
678 /* Switch the flip option if set
679 * NOTE: flip is now done at face level so copying group slices is easier. */
680#if 0
681 if (do_flip) {
682 ed_loop_flip = !ed_loop_flip;
683 }
684#endif
685
686 if (angle < 0.0f) {
687 ed_loop_flip = !ed_loop_flip;
688 }
689
690 /* if its closed, we only need 1 loop */
691 for (j = ed_loop_closed; j < 2; j++) {
692 // printf("Ordering Side J %i\n", j);
693
694 screwvert_iter_init(&lt_iter, vert_connect, v_best, j);
695 // printf("\n\nStarting - Loop\n");
696 lt_iter.v_poin->flag = 1; /* so a non loop will traverse the other side */
697
698 /* If this is the vert off the best vert and
699 * the best vert has 2 edges connected too it
700 * then swap the flip direction */
701 if (j == 1 && SV_IS_VALID(vc_tmp->v[0]) && SV_IS_VALID(vc_tmp->v[1])) {
702 ed_loop_flip = !ed_loop_flip;
703 }
704
705 while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) {
706 // printf("\tOrdering Vert V %i\n", lt_iter.v);
707
708 lt_iter.v_poin->flag = 2;
709 if (lt_iter.e) {
710 if (lt_iter.v == uint((*lt_iter.e)[0])) {
711 if (ed_loop_flip == 0) {
712 // printf("\t\t\tFlipping 0\n");
713 std::swap((*lt_iter.e)[0], (*lt_iter.e)[1]);
714 }
715#if 0
716 else {
717 printf("\t\t\tFlipping Not 0\n");
718 }
719#endif
720 }
721 else if (lt_iter.v == uint((*lt_iter.e)[1])) {
722 if (ed_loop_flip == 1) {
723 // printf("\t\t\tFlipping 1\n");
724 std::swap((*lt_iter.e)[0], (*lt_iter.e)[1]);
725 }
726#if 0
727 else {
728 printf("\t\t\tFlipping Not 1\n");
729 }
730#endif
731 }
732#if 0
733 else {
734 printf("\t\tIncorrect edge topology");
735 }
736#endif
737 }
738#if 0
739 else {
740 printf("\t\tNo Edge at this point\n");
741 }
742#endif
743 screwvert_iter_step(&lt_iter);
744 }
745 }
746 }
747 }
748 }
749 }
750 }
751 else {
752 for (uint i = 0; i < totvert; i++) {
753 copy_v3_v3(vert_positions_new[i], vert_positions_orig[i]);
754 }
755 }
756 /* done with edge connectivity based normal flipping */
757
758 /* Add Faces */
759 for (step = 1; step < step_tot; step++) {
760 const uint varray_stride = totvert * step;
761 float step_angle;
762 float mat[4][4];
763 /* Rotation Matrix */
764 step_angle = (angle / float(step_tot - (!close))) * float(step);
765
766 if (ob_axis != nullptr) {
767 axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle);
768 }
769 else {
770 axis_angle_to_mat3_single(mat3, axis_char, step_angle);
771 }
772 copy_m4_m3(mat, mat3);
773
774 if (screw_ofs) {
775 madd_v3_v3fl(mat[3], axis_vec, screw_ofs * (float(step) / float(step_tot - 1)));
776 }
777
778 /* copy a slice */
779 vert_interp.copy(0, int(varray_stride), int(totvert));
780
781 /* set location */
782 for (j = 0; j < totvert; j++) {
783 const int vert_new = int(varray_stride) + int(j);
784
785 copy_v3_v3(vert_positions_new[vert_new], vert_positions_new[j]);
786
787 /* only need to set these if using non cleared memory */
788 // mv_new->mat_nr = mv_new->flag = 0;
789
790 if (ob_axis != nullptr) {
791 sub_v3_v3(vert_positions_new[vert_new], mtx_tx[3]);
792
793 mul_m4_v3(mat, vert_positions_new[vert_new]);
794
795 add_v3_v3(vert_positions_new[vert_new], mtx_tx[3]);
796 }
797 else {
798 mul_m4_v3(mat, vert_positions_new[vert_new]);
799 }
800
801 /* add the new edge */
802 (*edge_new)[0] = int(varray_stride + j);
803 (*edge_new)[1] = (*edge_new)[0] - int(totvert);
804 edge_new++;
805 }
806 }
807
808 /* we can avoid if using vert alloc trick */
809 if (vert_connect) {
810 MEM_delete(vert_connect);
811 vert_connect = nullptr;
812 }
813
814 if (close) {
815 /* last loop of edges, previous loop doesn't account for the last set of edges */
816 const uint varray_stride = (step_tot - 1) * totvert;
817
818 for (uint i = 0; i < totvert; i++) {
819 (*edge_new)[0] = int(i);
820 (*edge_new)[1] = int(varray_stride + i);
821 edge_new++;
822 }
823 }
824
825 int new_loop_index = 0;
826 med_new_firstloop = edges_new.data();
827
828 /* more of an offset in this case */
829 edge_offset = totedge + (totvert * (step_tot - (close ? 0 : 1)));
830
831 const bke::AttributeAccessor src_attributes = mesh->attributes();
832 const VArraySpan src_material_index = *src_attributes.lookup<int>("material_index",
834
835 bke::MutableAttributeAccessor dst_attributes = result->attributes_for_write();
836 bke::SpanAttributeWriter dst_material_index = dst_attributes.lookup_or_add_for_write_span<int>(
837 "material_index", bke::AttrDomain::Face);
838
839 for (uint i = 0; i < totedge; i++, med_new_firstloop++) {
840 const uint step_last = step_tot - (close ? 1 : 2);
841 const uint face_index_orig = faces_num ? edge_face_map[i] : UINT_MAX;
842 const bool has_mpoly_orig = (face_index_orig != UINT_MAX);
843 float uv_v_offset_a, uv_v_offset_b;
844
845 const uint mloop_index_orig[2] = {
846 vert_loop_map ? vert_loop_map[edges_new[i][0]] : UINT_MAX,
847 vert_loop_map ? vert_loop_map[edges_new[i][1]] : UINT_MAX,
848 };
849
850 const bool has_mloop_orig = edge_face_map && (edge_face_map[i] != UINT_MAX) &&
851 (mloop_index_orig[0] != UINT_MAX);
852
853 int mat_nr;
854
855 /* for each edge, make a cylinder of quads */
856 i1 = uint((*med_new_firstloop)[0]);
857 i2 = uint((*med_new_firstloop)[1]);
858
859 if (has_mpoly_orig) {
860 mat_nr = src_material_index.is_empty() ? 0 : src_material_index[face_index_orig];
861 }
862 else {
863 mat_nr = 0;
864 }
865
866 if (has_mloop_orig == false && !uv_map_names.is_empty()) {
867 uv_v_offset_a = dist_signed_to_plane_v3(vert_positions_new[edges_new[i][0]], uv_axis_plane);
868 uv_v_offset_b = dist_signed_to_plane_v3(vert_positions_new[edges_new[i][1]], uv_axis_plane);
869
870 if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) {
871 uv_v_offset_a = (uv_v_offset_a - uv_v_minmax[0]) * uv_v_range_inv;
872 uv_v_offset_b = (uv_v_offset_b - uv_v_minmax[0]) * uv_v_range_inv;
873 }
874 }
875
876 for (step = 0; step <= step_last; step++) {
877
878 /* Polygon */
879 if (has_mpoly_orig) {
880 face_interp.copy(int(face_index_orig), face_index, 1);
881 origindex[face_index] = int(face_index_orig);
882 }
883 else {
884 origindex[face_index] = ORIGINDEX_NONE;
885 dst_material_index.span[face_index] = mat_nr;
886 sharp_faces.span[face_index] = use_flat_shading;
887 }
888 face_offests_new[face_index] = face_index * 4;
889
890 /* Loop-Custom-Data */
891 if (has_mloop_orig) {
892
893 corner_interp.copy(int(mloop_index_orig[0]), new_loop_index + 0, 1);
894 corner_interp.copy(int(mloop_index_orig[1]), new_loop_index + 1, 1);
895 corner_interp.copy(int(mloop_index_orig[1]), new_loop_index + 2, 1);
896 corner_interp.copy(int(mloop_index_orig[0]), new_loop_index + 3, 1);
897
898 if (!uv_map_names.is_empty()) {
899 const float uv_u_offset_a = float(step) * uv_u_scale;
900 const float uv_u_offset_b = float(step + 1) * uv_u_scale;
901 for (const int64_t uv_lay : uv_map_layers.index_range()) {
902 float2 *mluv = &uv_map_layers[uv_lay].span[new_loop_index];
903
904 mluv[quad_ord[0]][0] += uv_u_offset_a;
905 mluv[quad_ord[1]][0] += uv_u_offset_a;
906 mluv[quad_ord[2]][0] += uv_u_offset_b;
907 mluv[quad_ord[3]][0] += uv_u_offset_b;
908 }
909 }
910 }
911 else {
912 if (!uv_map_names.is_empty()) {
913 const float uv_u_offset_a = float(step) * uv_u_scale;
914 const float uv_u_offset_b = float(step + 1) * uv_u_scale;
915 for (const int64_t uv_lay : uv_map_layers.index_range()) {
916 float2 *mluv = &uv_map_layers[uv_lay].span[new_loop_index];
917
918 copy_v2_fl2(mluv[quad_ord[0]], uv_u_offset_a, uv_v_offset_a);
919 copy_v2_fl2(mluv[quad_ord[1]], uv_u_offset_a, uv_v_offset_b);
920 copy_v2_fl2(mluv[quad_ord[2]], uv_u_offset_b, uv_v_offset_b);
921 copy_v2_fl2(mluv[quad_ord[3]], uv_u_offset_b, uv_v_offset_a);
922 }
923 }
924 }
925
926 /* Loop-Data */
927 if (!(close && step == step_last)) {
928 /* regular segments */
929 corner_verts_new[new_loop_index + quad_ord[0]] = int(i1);
930 corner_verts_new[new_loop_index + quad_ord[1]] = int(i2);
931 corner_verts_new[new_loop_index + quad_ord[2]] = int(i2 + totvert);
932 corner_verts_new[new_loop_index + quad_ord[3]] = int(i1 + totvert);
933
934 corner_edges_new[new_loop_index + quad_ord_ofs[0]] = int(
935 step == 0 ? i : (edge_offset + step + (i * (step_tot - 1))) - 1);
936 corner_edges_new[new_loop_index + quad_ord_ofs[1]] = int(totedge + i2);
937 corner_edges_new[new_loop_index + quad_ord_ofs[2]] = int(edge_offset + step +
938 (i * (step_tot - 1)));
939 corner_edges_new[new_loop_index + quad_ord_ofs[3]] = int(totedge + i1);
940
941 /* new vertical edge */
942 if (step) { /* The first set is already done */
943 (*edge_new)[0] = int(i1);
944 (*edge_new)[1] = int(i2);
945 edge_new++;
946 }
947 i1 += totvert;
948 i2 += totvert;
949 }
950 else {
951 /* last segment */
952 corner_verts_new[new_loop_index + quad_ord[0]] = int(i1);
953 corner_verts_new[new_loop_index + quad_ord[1]] = int(i2);
954 corner_verts_new[new_loop_index + quad_ord[2]] = int((*med_new_firstloop)[1]);
955 corner_verts_new[new_loop_index + quad_ord[3]] = int((*med_new_firstloop)[0]);
956
957 corner_edges_new[new_loop_index + quad_ord_ofs[0]] = int(
958 (edge_offset + step + (i * (step_tot - 1))) - 1);
959 corner_edges_new[new_loop_index + quad_ord_ofs[1]] = int(totedge + i2);
960 corner_edges_new[new_loop_index + quad_ord_ofs[2]] = int(i);
961 corner_edges_new[new_loop_index + quad_ord_ofs[3]] = int(totedge + i1);
962 }
963
964 new_loop_index += 4;
965 face_index++;
966 }
967
968 /* new vertical edge */
969 (*edge_new)[0] = int(i1);
970 (*edge_new)[1] = int(i2);
971 edge_new++;
972 }
973
974/* validate loop edges */
975#if 0
976 {
977 uint i = 0;
978 printf("\n");
979 for (; i < maxPolys * 4; i += 4) {
980 uint ii;
981 ml_new = mloop_new + i;
982 ii = findEd(edges_new, maxEdges, ml_new[0].v, ml_new[1].v);
983 printf("%d %d -- ", ii, ml_new[0].e);
984 ml_new[0].e = ii;
985
986 ii = findEd(edges_new, maxEdges, ml_new[1].v, ml_new[2].v);
987 printf("%d %d -- ", ii, ml_new[1].e);
988 ml_new[1].e = ii;
989
990 ii = findEd(edges_new, maxEdges, ml_new[2].v, ml_new[3].v);
991 printf("%d %d -- ", ii, ml_new[2].e);
992 ml_new[2].e = ii;
993
994 ii = findEd(edges_new, maxEdges, ml_new[3].v, ml_new[0].v);
995 printf("%d %d\n", ii, ml_new[3].e);
996 ml_new[3].e = ii;
997 }
998 }
999#endif
1000
1001 sharp_faces.finish();
1002 dst_material_index.finish();
1003 for (bke::SpanAttributeWriter<float2> &uv_map : uv_map_layers) {
1004 uv_map.finish();
1005 }
1006
1007 if (edge_face_map) {
1008 MEM_delete(edge_face_map);
1009 }
1010
1011 if (vert_loop_map) {
1012 MEM_delete(vert_loop_map);
1013 }
1014
1015 if (do_remove_doubles) {
1017 vert_positions_new,
1018 totvert,
1019 step_tot,
1020 axis_vec,
1021 ob_axis != nullptr ? mtx_tx[3] : nullptr,
1022 ltmd->merge_dist);
1023 }
1024
1025 return result;
1026}
1027
1029{
1030 ScrewModifierData *ltmd = reinterpret_cast<ScrewModifierData *>(md);
1031 if (ltmd->ob_axis != nullptr) {
1032 DEG_add_object_relation(ctx->node, ltmd->ob_axis, DEG_OB_COMP_TRANSFORM, "Screw Modifier");
1033 DEG_add_depends_on_transform_relation(ctx->node, "Screw Modifier");
1034 }
1035}
1036
1037static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
1038{
1039 ScrewModifierData *ltmd = reinterpret_cast<ScrewModifierData *>(md);
1040
1041 walk(user_data, ob, reinterpret_cast<ID **>(&ltmd->ob_axis), IDWALK_CB_NOP);
1042}
1043
1044static void panel_draw(const bContext * /*C*/, Panel *panel)
1045{
1046 ui::Layout *sub, *row, *col;
1047 ui::Layout &layout = *panel->layout;
1049
1050 PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
1051
1052 PointerRNA screw_obj_ptr = RNA_pointer_get(ptr, "object");
1053
1054 layout.use_property_split_set(true);
1055
1056 col = &layout.column(false);
1057 col->prop(ptr, "angle", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1058 row = &col->row(false);
1059 row->active_set(!screw_obj_ptr || !RNA_boolean_get(ptr, "use_object_screw_offset"));
1060 row->prop(ptr, "screw_offset", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1061 col->prop(ptr, "iterations", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1062
1063 layout.separator();
1064 col = &layout.column(false);
1065 row = &col->row(false);
1066 row->prop(ptr, "axis", ui::ITEM_R_EXPAND, std::nullopt, ICON_NONE);
1067 col->prop(ptr, "object", UI_ITEM_NONE, IFACE_("Axis Object"), ICON_NONE);
1068 sub = &col->column(false);
1069 sub->active_set(screw_obj_ptr);
1070 sub->prop(ptr, "use_object_screw_offset", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1071
1072 layout.separator();
1073
1074 col = &layout.column(true);
1075 col->prop(ptr, "steps", UI_ITEM_NONE, IFACE_("Steps Viewport"), ICON_NONE);
1076 col->prop(ptr, "render_steps", UI_ITEM_NONE, IFACE_("Render"), ICON_NONE);
1077
1078 layout.separator();
1079
1080 row = &layout.row(true, IFACE_("Merge"));
1081 row->prop(ptr, "use_merge_vertices", UI_ITEM_NONE, "", ICON_NONE);
1082 sub = &row->row(true);
1083 sub->active_set(RNA_boolean_get(ptr, "use_merge_vertices"));
1084 sub->prop(ptr, "merge_threshold", UI_ITEM_NONE, "", ICON_NONE);
1085
1086 layout.separator();
1087
1088 row = &layout.row(true, IFACE_("Stretch UVs"));
1089 row->prop(ptr, "use_stretch_u", toggles_flag, IFACE_("U"), ICON_NONE);
1090 row->prop(ptr, "use_stretch_v", toggles_flag, IFACE_("V"), ICON_NONE);
1091
1092 modifier_error_message_draw(layout, ptr);
1093}
1094
1095static void normals_panel_draw(const bContext * /*C*/, Panel *panel)
1096{
1097 ui::Layout &layout = *panel->layout;
1098
1099 PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
1100
1101 layout.use_property_split_set(true);
1102
1103 ui::Layout &col = layout.column(false);
1104 col.prop(ptr, "use_smooth_shade", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1105 col.prop(ptr, "use_normal_calculate", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1106 col.prop(ptr, "use_normal_flip", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1107}
1108
1109static void panel_register(ARegionType *region_type)
1110{
1113 region_type, "normals", "Normals", nullptr, normals_panel_draw, panel_type);
1114}
1115
1117 /*idname*/ "Screw",
1118 /*name*/ N_("Screw"),
1119 /*struct_name*/ "ScrewModifierData",
1120 /*struct_size*/ sizeof(ScrewModifierData),
1121 /*srna*/ &RNA_ScrewModifier,
1123
1126 /*icon*/ ICON_MOD_SCREW,
1127
1128 /*copy_data*/ BKE_modifier_copydata_generic,
1129
1130 /*deform_verts*/ nullptr,
1131 /*deform_matrices*/ nullptr,
1132 /*deform_verts_EM*/ nullptr,
1133 /*deform_matrices_EM*/ nullptr,
1134 /*modify_mesh*/ modify_mesh,
1135 /*modify_geometry_set*/ nullptr,
1136
1137 /*init_data*/ init_data,
1138 /*required_data_mask*/ nullptr,
1139 /*free_data*/ nullptr,
1140 /*is_disabled*/ nullptr,
1141 /*update_depsgraph*/ update_depsgraph,
1142 /*depends_on_time*/ nullptr,
1143 /*depends_on_normals*/ nullptr,
1144 /*foreach_ID_link*/ foreach_ID_link,
1145 /*foreach_tex_link*/ nullptr,
1146 /*free_runtime_data*/ nullptr,
1147 /*panel_register*/ panel_register,
1148 /*blend_write*/ nullptr,
1149 /*blend_read*/ nullptr,
1150 /*foreach_cache*/ nullptr,
1151 /*foreach_working_space_color*/ nullptr,
1152};
1153
1154} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
#define ORIGINDEX_NONE
#define BLI_BITMAP_NEW(_num, _alloc_string)
Definition BLI_bitmap.hh:39
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition BLI_bitmap.hh:63
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition BLI_bitmap.hh:80
#define M_PI
#define IFACE_(msgid)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define SV_INVALID
Definition MOD_screw.cc:82
#define SV_UNUSED
Definition MOD_screw.cc:81
#define SV_IS_VALID(v)
Definition MOD_screw.cc:83
#define UI_ITEM_NONE
#define INIT_DEFAULT_STRUCT_AFTER(struct_dst, member)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
IndexRange index_range() const
Definition BLI_array.hh:371
constexpr T * data() const
Definition BLI_span.hh:545
constexpr const T * data() const
Definition BLI_span.hh:219
int64_t size() const
IndexRange index_range() const
void copy(int src_index, int dst_index, int count) const
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef name, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
GSpanAttributeWriter lookup_for_write_span(StringRef name)
constexpr bool is_empty() const
#define FLT_MAX
#define FLT_EPSILON
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define UINT_MAX
Definition hash_md5.cc:46
void fill_index_range(MutableSpan< T > span, const T start=0)
Mesh * mesh_merge_verts(const Mesh &mesh, Span< int > vert_src_to_target, int removed_verts_num, bool do_mix_data)
BMesh Iterators.
MINLINE float min_ff(float a, float b)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
__int64 int64_t
Definition BKE_text.h:90
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
ModifierTypeInfo modifierType_Screw
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])
bool CustomData_free_layers(CustomData *data, eCustomDataType type)
float dist_signed_squared_to_plane_v3(const float p[3], const float plane[4])
Definition math_geom.cc:479
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
void copy_m4_m3(float m1[4][4], const float m2[3][3])
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
Definition math_geom.cc:511
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
float angle_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
static void init_data(ModifierData *md)
void(*)(void *user_data, Object *ob, ID **idpoin, LibraryForeachIDCallbackFlag cb_flag) IDWalkFunc
static void update_depsgraph(tGraphSliderOp *gso)
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
ATTR_WARN_UNUSED_RESULT const BMVert * v
void DEG_add_object_relation(DepsNodeHandle *node_handle, Object *object, eDepsObjectComponentType component, const char *description)
void DEG_add_depends_on_transform_relation(DepsNodeHandle *node_handle, const char *description)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
Definition math_geom.cc:225
MINLINE float sqrtf_signed(float f)
MINLINE void sub_v3_v3(float r[3], const float a[3])
void mul_m4_v3(const float M[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void modifier_error_message_draw(ui::Layout &layout, PointerRNA *ptr)
static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, uint v_init, uint dir)
Definition MOD_screw.cc:85
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
static void panel_register(ARegionType *region_type)
static void screwvert_iter_step(ScrewVertIter *iter)
Definition MOD_screw.cc:104
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static Mesh * modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
Definition MOD_array.cc:873
MINLINE void zero_v3(float r[3])
void BKE_id_free(Main *bmain, void *idv)
@ eModifierTypeFlag_AcceptsCVs
@ eModifierTypeFlag_EnableInEditmode
@ eModifierTypeFlag_SupportsEditmode
@ eModifierTypeFlag_AcceptsMesh
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
MINLINE float normalize_v3(float n[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
unsigned int BLI_bitmap
Definition BLI_bitmap.hh:15
static Mesh * mesh_remove_doubles_on_axis(Mesh *result, MutableSpan< float3 > vert_positions_new, const uint totvert, const uint step_tot, const float axis_vec[3], const float axis_offset[3], const float merge_threshold)
Definition MOD_screw.cc:124
MINLINE float max_ff(float a, float b)
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
Mesh * BKE_mesh_new_nomain_from_template(const Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num)
MINLINE float square_f(float a)
static void panel_draw(const bContext *, Panel *panel)
PanelType * modifier_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
static void normals_panel_draw(const bContext *, Panel *panel)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], float angle)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
void axis_angle_to_mat3_single(float R[3][3], char axis, float angle)
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
void BKE_modifier_copydata_generic(const ModifierData *md, ModifierData *md_dst, int flag)
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ui::Layout * layout
ScrewVertConnect * v_poin
Definition MOD_screw.cc:76
ScrewVertConnect * v_array
Definition MOD_screw.cc:75
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & row(bool align)
#define N_(msgid)