Blender V5.0
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.h"
14
15#include "BLI_bitmap.h"
16#include "BLI_math_geom.h"
17#include "BLI_math_matrix.h"
18#include "BLI_math_rotation.h"
19#include "BLI_math_vector.h"
20#include "BLI_span.hh"
21
22#include "BLT_translation.hh"
23
24#include "DNA_defaults.h"
25#include "DNA_mesh_types.h"
26#include "DNA_object_types.h"
27#include "DNA_screen_types.h"
28
29#include "BKE_attribute.hh"
30#include "BKE_customdata.hh"
31#include "BKE_lib_id.hh"
32#include "BKE_lib_query.hh"
33#include "BKE_mesh.hh"
34
36#include "UI_resources.hh"
37
38#include "RNA_access.hh"
39#include "RNA_prototypes.hh"
40
42
43#include "MEM_guardedalloc.h"
44
45#include "MOD_modifiertypes.hh"
46#include "MOD_ui_common.hh"
47
49
50#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
51
52using namespace blender;
53
62
66 float dist_sq;
68 float co[3];
70 uint v[2];
73 char flag;
74};
75
82
83#define SV_UNUSED (UINT_MAX)
84#define SV_INVALID ((UINT_MAX) - 1)
85#define SV_IS_VALID(v) ((v) < SV_INVALID)
86
89 uint v_init,
90 uint dir)
91{
92 iter->v_array = array;
93 iter->v = v_init;
94
95 if (SV_IS_VALID(v_init)) {
96 iter->v_poin = &array[v_init];
97 iter->v_other = iter->v_poin->v[dir];
98 iter->e = iter->v_poin->e[!dir];
99 }
100 else {
101 iter->v_poin = nullptr;
102 iter->e = nullptr;
103 }
104}
105
107{
108 if (iter->v_poin->v[0] == iter->v_other) {
109 iter->v_other = iter->v;
110 iter->v = iter->v_poin->v[1];
111 }
112 else if (iter->v_poin->v[1] == iter->v_other) {
113 iter->v_other = iter->v;
114 iter->v = iter->v_poin->v[0];
115 }
116 if (SV_IS_VALID(iter->v)) {
117 iter->v_poin = &iter->v_array[iter->v];
118 iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)];
119 }
120 else {
121 iter->e = nullptr;
122 iter->v_poin = nullptr;
123 }
124}
125
127 blender::MutableSpan<blender::float3> vert_positions_new,
128 const uint totvert,
129 const uint step_tot,
130 const float axis_vec[3],
131 const float axis_offset[3],
132 const float merge_threshold)
133{
134 BLI_bitmap *vert_tag = BLI_BITMAP_NEW(totvert, __func__);
135
136 const float merge_threshold_sq = square_f(merge_threshold);
137 const bool use_offset = axis_offset != nullptr;
138 uint tot_doubles = 0;
139 for (uint i = 0; i < totvert; i += 1) {
140 float axis_co[3];
141 if (use_offset) {
142 float offset_co[3];
143 sub_v3_v3v3(offset_co, vert_positions_new[i], axis_offset);
144 project_v3_v3v3_normalized(axis_co, offset_co, axis_vec);
145 add_v3_v3(axis_co, axis_offset);
146 }
147 else {
148 project_v3_v3v3_normalized(axis_co, vert_positions_new[i], axis_vec);
149 }
150 const float dist_sq = len_squared_v3v3(axis_co, vert_positions_new[i]);
151 if (dist_sq <= merge_threshold_sq) {
152 BLI_BITMAP_ENABLE(vert_tag, i);
153 tot_doubles += 1;
154 copy_v3_v3(vert_positions_new[i], axis_co);
155 }
156 }
157
158 if (tot_doubles != 0) {
159 uint tot = totvert * step_tot;
160 int *full_doubles_map = MEM_malloc_arrayN<int>(tot, __func__);
161 copy_vn_i(full_doubles_map, int(tot), -1);
162
163 uint tot_doubles_left = tot_doubles;
164 for (uint i = 0; i < totvert; i += 1) {
165 if (BLI_BITMAP_TEST(vert_tag, i)) {
166 int *doubles_map = &full_doubles_map[totvert + i];
167 for (uint step = 1; step < step_tot; step += 1) {
168 *doubles_map = int(i);
169 doubles_map += totvert;
170 }
171 tot_doubles_left -= 1;
172 if (tot_doubles_left == 0) {
173 break;
174 }
175 }
176 }
177
178 Mesh *tmp = result;
179
180 /* TODO(mano-wii): Polygons with all vertices merged are the ones that form duplicates.
181 * Therefore the duplicate face test can be skipped. */
183 MutableSpan<int>{full_doubles_map, result->verts_num},
184 int(tot_doubles * (step_tot - 1)),
185 false);
186
187 BKE_id_free(nullptr, tmp);
188 MEM_freeN(full_doubles_map);
189 }
190
191 MEM_freeN(vert_tag);
192
193 return result;
194}
195
196static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *meshData)
197{
198 using namespace blender;
199 const Mesh *mesh = meshData;
200 Mesh *result;
202 const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER) != 0;
203
204 int face_index = 0;
205 uint step;
206 uint j;
207 uint i1, i2;
208 uint step_tot = use_render_params ? ltmd->render_steps : ltmd->steps;
209 const bool do_flip = (ltmd->flag & MOD_SCREW_NORMAL_FLIP) != 0;
210
211 const int quad_ord[4] = {
212 do_flip ? 3 : 0,
213 do_flip ? 2 : 1,
214 do_flip ? 1 : 2,
215 do_flip ? 0 : 3,
216 };
217 const int quad_ord_ofs[4] = {
218 do_flip ? 2 : 0,
219 1,
220 do_flip ? 0 : 2,
221 3,
222 };
223
224 uint maxVerts = 0, maxEdges = 0, maxPolys = 0;
225 const uint totvert = uint(mesh->verts_num);
226 const uint totedge = uint(mesh->edges_num);
227 const uint faces_num = uint(mesh->faces_num);
228
229 uint *edge_face_map = nullptr; /* orig edge to orig face */
230 uint *vert_loop_map = nullptr; /* orig vert to orig loop */
231
232 /* UV Coords */
233 const uint uv_map_layers_tot = uint(
235 blender::Array<blender::float2 *> uv_map_layers(uv_map_layers_tot);
236 float uv_u_scale;
237 float uv_v_minmax[2] = {FLT_MAX, -FLT_MAX};
238 float uv_v_range_inv;
239 float uv_axis_plane[4];
240
241 char axis_char = 'X';
242 bool close;
243 float angle = ltmd->angle;
244 float screw_ofs = ltmd->screw_ofs;
245 float axis_vec[3] = {0.0f, 0.0f, 0.0f};
246 float tmp_vec1[3], tmp_vec2[3];
247 float mat3[3][3];
248 /* transform the coords by an object relative to this objects transformation */
249 float mtx_tx[4][4];
250 float mtx_tx_inv[4][4]; /* inverted */
251 float mtx_tmp_a[4][4];
252
253 uint vc_tot_linked = 0;
254 short other_axis_1, other_axis_2;
255 const float *tmpf1, *tmpf2;
256
257 uint edge_offset;
258
259 blender::int2 *edge_new, *med_new_firstloop;
260 Object *ob_axis = ltmd->ob_axis;
261
262 ScrewVertConnect *vc, *vc_tmp, *vert_connect = nullptr;
263
264 const bool use_flat_shading = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) == 0;
265
266 /* don't do anything? */
267 if (!totvert) {
268 return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0);
269 }
270
271 switch (ltmd->axis) {
272 case 0:
273 other_axis_1 = 1;
274 other_axis_2 = 2;
275 break;
276 case 1:
277 other_axis_1 = 0;
278 other_axis_2 = 2;
279 break;
280 default: /* 2, use default to quiet warnings */
281 other_axis_1 = 0;
282 other_axis_2 = 1;
283 break;
284 }
285
286 axis_vec[ltmd->axis] = 1.0f;
287
288 if (ob_axis != nullptr) {
289 /* Calculate the matrix relative to the axis object. */
290 invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world().ptr());
291 copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world().ptr());
292 mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv);
293
294 /* Calculate the axis vector. */
295 mul_mat3_m4_v3(mtx_tx, axis_vec); /* only rotation component */
296 normalize_v3(axis_vec);
297
298 /* screw */
299 if (ltmd->flag & MOD_SCREW_OBJECT_OFFSET) {
300 /* Find the offset along this axis relative to this objects matrix. */
301 float totlen = len_v3(mtx_tx[3]);
302
303 if (totlen != 0.0f) {
304 const float zero[3] = {0.0f, 0.0f, 0.0f};
305 float cp[3];
306 screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec);
307 }
308 else {
309 screw_ofs = 0.0f;
310 }
311 }
312
313 /* angle */
314
315#if 0 /* can't include this, not predictable enough, though quite fun. */
316 if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) {
317 float mtx3_tx[3][3];
318 copy_m3_m4(mtx3_tx, mtx_tx);
319
320 float vec[3] = {0, 1, 0};
321 float cross1[3];
322 float cross2[3];
323 cross_v3_v3v3(cross1, vec, axis_vec);
324
325 mul_v3_m3v3(cross2, mtx3_tx, cross1);
326 {
327 float c1[3];
328 float c2[3];
329 float axis_tmp[3];
330
331 cross_v3_v3v3(c1, cross2, axis_vec);
332 cross_v3_v3v3(c2, axis_vec, c1);
333
334 angle = angle_v3v3(cross1, c2);
335
336 cross_v3_v3v3(axis_tmp, cross1, c2);
337 normalize_v3(axis_tmp);
338
339 if (len_v3v3(axis_tmp, axis_vec) > 1.0f) {
340 angle = -angle;
341 }
342 }
343 }
344#endif
345 }
346 else {
347 axis_char = char(axis_char + ltmd->axis); /* 'X' + axis */
348
349 /* Useful to be able to use the axis vector in some cases still. */
350 zero_v3(axis_vec);
351 axis_vec[ltmd->axis] = 1.0f;
352 }
353
354 /* apply the multiplier */
355 angle *= float(ltmd->iter);
356 screw_ofs *= float(ltmd->iter);
357 uv_u_scale = 1.0f / float(step_tot);
358
359 /* multiplying the steps is a bit tricky, this works best */
360 step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1);
361
362 /* Will the screw be closed?
363 * NOTE: smaller than `FLT_EPSILON * 100`
364 * gives problems with float precision so its never closed. */
365 if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) &&
366 fabsf(fabsf(angle) - (float(M_PI) * 2.0f)) <= (FLT_EPSILON * 100.0f) && step_tot > 3)
367 {
368 close = true;
369 step_tot--;
370
371 maxVerts = totvert * step_tot; /* -1 because we're joining back up */
372 maxEdges = (totvert * step_tot) + /* these are the edges between new verts */
373 (totedge * step_tot); /* -1 because vert edges join */
374 maxPolys = totedge * step_tot;
375
376 screw_ofs = 0.0f;
377 }
378 else {
379 close = false;
380 step_tot = std::max<uint>(step_tot, 2);
381
382 maxVerts = totvert * step_tot; /* -1 because we're joining back up */
383 maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */
384 (totedge * step_tot); /* -1 because vert edges join */
385 maxPolys = totedge * (step_tot - 1);
386 }
387
388 if ((ltmd->flag & MOD_SCREW_UV_STRETCH_U) == 0) {
389 uv_u_scale = (uv_u_scale / float(ltmd->iter)) * (angle / (float(M_PI) * 2.0f));
390 }
391
392 /* The `screw_ofs` cannot change from now on. */
393 const bool do_remove_doubles = (ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f);
394
396 mesh, int(maxVerts), int(maxEdges), int(maxPolys), int(maxPolys) * 4);
397 /* The modifier doesn't support original index mapping on the edge or face domains. Remove
398 * original index layers, since otherwise edges aren't displayed at all in wireframe view. */
401
402 const blender::Span<float3> vert_positions_orig = mesh->vert_positions();
403 const blender::Span<int2> edges_orig = mesh->edges();
404 const OffsetIndices faces_orig = mesh->faces();
405 const blender::Span<int> corner_verts_orig = mesh->corner_verts();
406 const blender::Span<int> corner_edges_orig = mesh->corner_edges();
407
408 blender::MutableSpan<float3> vert_positions_new = result->vert_positions_for_write();
409 blender::MutableSpan<int2> edges_new = result->edges_for_write();
410 MutableSpan<int> face_offests_new = result->face_offsets_for_write();
411 blender::MutableSpan<int> corner_verts_new = result->corner_verts_for_write();
412 blender::MutableSpan<int> corner_edges_new = result->corner_edges_for_write();
413 bke::MutableAttributeAccessor attributes = result->attributes_for_write();
415 "sharp_face", bke::AttrDomain::Face);
416
417 if (!CustomData_has_layer(&result->face_data, CD_ORIGINDEX)) {
418 CustomData_add_layer(&result->face_data, CD_ORIGINDEX, CD_SET_DEFAULT, int(maxPolys));
419 }
420
421 int *origindex = static_cast<int *>(
422 CustomData_get_layer_for_write(&result->face_data, CD_ORIGINDEX, result->faces_num));
423
424 CustomData_copy_data(&mesh->vert_data, &result->vert_data, 0, 0, int(totvert));
425
426 if (uv_map_layers_tot) {
427 const float zero_co[3] = {0};
428 plane_from_point_normal_v3(uv_axis_plane, zero_co, axis_vec);
429 }
430
431 if (uv_map_layers_tot) {
432 uint uv_lay;
433 for (uv_lay = 0; uv_lay < uv_map_layers_tot; uv_lay++) {
434 uv_map_layers[uv_lay] = static_cast<blender::float2 *>(CustomData_get_layer_n_for_write(
435 &result->corner_data, CD_PROP_FLOAT2, int(uv_lay), result->corners_num));
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 blender::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_malloc_arrayN<uint>(totedge, __func__);
465 memset(edge_face_map, 0xff, sizeof(*edge_face_map) * totedge);
466
467 vert_loop_map = MEM_malloc_arrayN<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_malloc_arrayN<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 */
780 &mesh->vert_data, &result->vert_data, 0, int(varray_stride), int(totvert));
781
782 /* set location */
783 for (j = 0; j < totvert; j++) {
784 const int vert_new = int(varray_stride) + int(j);
785
786 copy_v3_v3(vert_positions_new[vert_new], vert_positions_new[j]);
787
788 /* only need to set these if using non cleared memory */
789 // mv_new->mat_nr = mv_new->flag = 0;
790
791 if (ob_axis != nullptr) {
792 sub_v3_v3(vert_positions_new[vert_new], mtx_tx[3]);
793
794 mul_m4_v3(mat, vert_positions_new[vert_new]);
795
796 add_v3_v3(vert_positions_new[vert_new], mtx_tx[3]);
797 }
798 else {
799 mul_m4_v3(mat, vert_positions_new[vert_new]);
800 }
801
802 /* add the new edge */
803 (*edge_new)[0] = int(varray_stride + j);
804 (*edge_new)[1] = (*edge_new)[0] - int(totvert);
805 edge_new++;
806 }
807 }
808
809 /* we can avoid if using vert alloc trick */
810 if (vert_connect) {
811 MEM_freeN(vert_connect);
812 vert_connect = nullptr;
813 }
814
815 if (close) {
816 /* last loop of edges, previous loop doesn't account for the last set of edges */
817 const uint varray_stride = (step_tot - 1) * totvert;
818
819 for (uint i = 0; i < totvert; i++) {
820 (*edge_new)[0] = int(i);
821 (*edge_new)[1] = int(varray_stride + i);
822 edge_new++;
823 }
824 }
825
826 int new_loop_index = 0;
827 med_new_firstloop = edges_new.data();
828
829 /* more of an offset in this case */
830 edge_offset = totedge + (totvert * (step_tot - (close ? 0 : 1)));
831
832 const bke::AttributeAccessor src_attributes = mesh->attributes();
833 const VArraySpan src_material_index = *src_attributes.lookup<int>("material_index",
835
836 bke::MutableAttributeAccessor dst_attributes = result->attributes_for_write();
837 bke::SpanAttributeWriter dst_material_index = dst_attributes.lookup_or_add_for_write_span<int>(
838 "material_index", bke::AttrDomain::Face);
839
840 for (uint i = 0; i < totedge; i++, med_new_firstloop++) {
841 const uint step_last = step_tot - (close ? 1 : 2);
842 const uint face_index_orig = faces_num ? edge_face_map[i] : UINT_MAX;
843 const bool has_mpoly_orig = (face_index_orig != UINT_MAX);
844 float uv_v_offset_a, uv_v_offset_b;
845
846 const uint mloop_index_orig[2] = {
847 vert_loop_map ? vert_loop_map[edges_new[i][0]] : UINT_MAX,
848 vert_loop_map ? vert_loop_map[edges_new[i][1]] : UINT_MAX,
849 };
850 const bool has_mloop_orig = mloop_index_orig[0] != UINT_MAX;
851
852 int mat_nr;
853
854 /* for each edge, make a cylinder of quads */
855 i1 = uint((*med_new_firstloop)[0]);
856 i2 = uint((*med_new_firstloop)[1]);
857
858 if (has_mpoly_orig) {
859 mat_nr = src_material_index.is_empty() ? 0 : src_material_index[face_index_orig];
860 }
861 else {
862 mat_nr = 0;
863 }
864
865 if (has_mloop_orig == false && uv_map_layers_tot) {
866 uv_v_offset_a = dist_signed_to_plane_v3(vert_positions_new[edges_new[i][0]], uv_axis_plane);
867 uv_v_offset_b = dist_signed_to_plane_v3(vert_positions_new[edges_new[i][1]], uv_axis_plane);
868
869 if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) {
870 uv_v_offset_a = (uv_v_offset_a - uv_v_minmax[0]) * uv_v_range_inv;
871 uv_v_offset_b = (uv_v_offset_b - uv_v_minmax[0]) * uv_v_range_inv;
872 }
873 }
874
875 for (step = 0; step <= step_last; step++) {
876
877 /* Polygon */
878 if (has_mpoly_orig) {
880 &mesh->face_data, &result->face_data, 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
894 &result->corner_data,
895 int(mloop_index_orig[0]),
896 new_loop_index + 0,
897 1);
899 &result->corner_data,
900 int(mloop_index_orig[1]),
901 new_loop_index + 1,
902 1);
904 &result->corner_data,
905 int(mloop_index_orig[1]),
906 new_loop_index + 2,
907 1);
909 &result->corner_data,
910 int(mloop_index_orig[0]),
911 new_loop_index + 3,
912 1);
913
914 if (uv_map_layers_tot) {
915 uint uv_lay;
916 const float uv_u_offset_a = float(step) * uv_u_scale;
917 const float uv_u_offset_b = float(step + 1) * uv_u_scale;
918 for (uv_lay = 0; uv_lay < uv_map_layers_tot; uv_lay++) {
919 blender::float2 *mluv = &uv_map_layers[uv_lay][new_loop_index];
920
921 mluv[quad_ord[0]][0] += uv_u_offset_a;
922 mluv[quad_ord[1]][0] += uv_u_offset_a;
923 mluv[quad_ord[2]][0] += uv_u_offset_b;
924 mluv[quad_ord[3]][0] += uv_u_offset_b;
925 }
926 }
927 }
928 else {
929 if (uv_map_layers_tot) {
930 uint uv_lay;
931 const float uv_u_offset_a = float(step) * uv_u_scale;
932 const float uv_u_offset_b = float(step + 1) * uv_u_scale;
933 for (uv_lay = 0; uv_lay < uv_map_layers_tot; uv_lay++) {
934 blender::float2 *mluv = &uv_map_layers[uv_lay][new_loop_index];
935
936 copy_v2_fl2(mluv[quad_ord[0]], uv_u_offset_a, uv_v_offset_a);
937 copy_v2_fl2(mluv[quad_ord[1]], uv_u_offset_a, uv_v_offset_b);
938 copy_v2_fl2(mluv[quad_ord[2]], uv_u_offset_b, uv_v_offset_b);
939 copy_v2_fl2(mluv[quad_ord[3]], uv_u_offset_b, uv_v_offset_a);
940 }
941 }
942 }
943
944 /* Loop-Data */
945 if (!(close && step == step_last)) {
946 /* regular segments */
947 corner_verts_new[new_loop_index + quad_ord[0]] = int(i1);
948 corner_verts_new[new_loop_index + quad_ord[1]] = int(i2);
949 corner_verts_new[new_loop_index + quad_ord[2]] = int(i2 + totvert);
950 corner_verts_new[new_loop_index + quad_ord[3]] = int(i1 + totvert);
951
952 corner_edges_new[new_loop_index + quad_ord_ofs[0]] = int(
953 step == 0 ? i : (edge_offset + step + (i * (step_tot - 1))) - 1);
954 corner_edges_new[new_loop_index + quad_ord_ofs[1]] = int(totedge + i2);
955 corner_edges_new[new_loop_index + quad_ord_ofs[2]] = int(edge_offset + step +
956 (i * (step_tot - 1)));
957 corner_edges_new[new_loop_index + quad_ord_ofs[3]] = int(totedge + i1);
958
959 /* new vertical edge */
960 if (step) { /* The first set is already done */
961 (*edge_new)[0] = int(i1);
962 (*edge_new)[1] = int(i2);
963 edge_new++;
964 }
965 i1 += totvert;
966 i2 += totvert;
967 }
968 else {
969 /* last segment */
970 corner_verts_new[new_loop_index + quad_ord[0]] = int(i1);
971 corner_verts_new[new_loop_index + quad_ord[1]] = int(i2);
972 corner_verts_new[new_loop_index + quad_ord[2]] = int((*med_new_firstloop)[1]);
973 corner_verts_new[new_loop_index + quad_ord[3]] = int((*med_new_firstloop)[0]);
974
975 corner_edges_new[new_loop_index + quad_ord_ofs[0]] = int(
976 (edge_offset + step + (i * (step_tot - 1))) - 1);
977 corner_edges_new[new_loop_index + quad_ord_ofs[1]] = int(totedge + i2);
978 corner_edges_new[new_loop_index + quad_ord_ofs[2]] = int(i);
979 corner_edges_new[new_loop_index + quad_ord_ofs[3]] = int(totedge + i1);
980 }
981
982 new_loop_index += 4;
983 face_index++;
984 }
985
986 /* new vertical edge */
987 (*edge_new)[0] = int(i1);
988 (*edge_new)[1] = int(i2);
989 edge_new++;
990 }
991
992/* validate loop edges */
993#if 0
994 {
995 uint i = 0;
996 printf("\n");
997 for (; i < maxPolys * 4; i += 4) {
998 uint ii;
999 ml_new = mloop_new + i;
1000 ii = findEd(edges_new, maxEdges, ml_new[0].v, ml_new[1].v);
1001 printf("%d %d -- ", ii, ml_new[0].e);
1002 ml_new[0].e = ii;
1003
1004 ii = findEd(edges_new, maxEdges, ml_new[1].v, ml_new[2].v);
1005 printf("%d %d -- ", ii, ml_new[1].e);
1006 ml_new[1].e = ii;
1007
1008 ii = findEd(edges_new, maxEdges, ml_new[2].v, ml_new[3].v);
1009 printf("%d %d -- ", ii, ml_new[2].e);
1010 ml_new[2].e = ii;
1011
1012 ii = findEd(edges_new, maxEdges, ml_new[3].v, ml_new[0].v);
1013 printf("%d %d\n", ii, ml_new[3].e);
1014 ml_new[3].e = ii;
1015 }
1016 }
1017#endif
1018
1019 sharp_faces.finish();
1020 dst_material_index.finish();
1021
1022 if (edge_face_map) {
1023 MEM_freeN(edge_face_map);
1024 }
1025
1026 if (vert_loop_map) {
1027 MEM_freeN(vert_loop_map);
1028 }
1029
1030 if (do_remove_doubles) {
1032 vert_positions_new,
1033 totvert,
1034 step_tot,
1035 axis_vec,
1036 ob_axis != nullptr ? mtx_tx[3] : nullptr,
1037 ltmd->merge_dist);
1038 }
1039
1040 return result;
1041}
1042
1044{
1046 if (ltmd->ob_axis != nullptr) {
1047 DEG_add_object_relation(ctx->node, ltmd->ob_axis, DEG_OB_COMP_TRANSFORM, "Screw Modifier");
1048 DEG_add_depends_on_transform_relation(ctx->node, "Screw Modifier");
1049 }
1050}
1051
1052static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
1053{
1055
1056 walk(user_data, ob, (ID **)&ltmd->ob_axis, IDWALK_CB_NOP);
1057}
1058
1059static void panel_draw(const bContext * /*C*/, Panel *panel)
1060{
1061 uiLayout *sub, *row, *col;
1062 uiLayout *layout = panel->layout;
1064
1066
1067 PointerRNA screw_obj_ptr = RNA_pointer_get(ptr, "object");
1068
1069 layout->use_property_split_set(true);
1070
1071 col = &layout->column(false);
1072 col->prop(ptr, "angle", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1073 row = &col->row(false);
1074 row->active_set(RNA_pointer_is_null(&screw_obj_ptr) ||
1075 !RNA_boolean_get(ptr, "use_object_screw_offset"));
1076 row->prop(ptr, "screw_offset", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1077 col->prop(ptr, "iterations", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1078
1079 layout->separator();
1080 col = &layout->column(false);
1081 row = &col->row(false);
1082 row->prop(ptr, "axis", UI_ITEM_R_EXPAND, std::nullopt, ICON_NONE);
1083 col->prop(ptr, "object", UI_ITEM_NONE, IFACE_("Axis Object"), ICON_NONE);
1084 sub = &col->column(false);
1085 sub->active_set(!RNA_pointer_is_null(&screw_obj_ptr));
1086 sub->prop(ptr, "use_object_screw_offset", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1087
1088 layout->separator();
1089
1090 col = &layout->column(true);
1091 col->prop(ptr, "steps", UI_ITEM_NONE, IFACE_("Steps Viewport"), ICON_NONE);
1092 col->prop(ptr, "render_steps", UI_ITEM_NONE, IFACE_("Render"), ICON_NONE);
1093
1094 layout->separator();
1095
1096 row = &layout->row(true, IFACE_("Merge"));
1097 row->prop(ptr, "use_merge_vertices", UI_ITEM_NONE, "", ICON_NONE);
1098 sub = &row->row(true);
1099 sub->active_set(RNA_boolean_get(ptr, "use_merge_vertices"));
1100 sub->prop(ptr, "merge_threshold", UI_ITEM_NONE, "", ICON_NONE);
1101
1102 layout->separator();
1103
1104 row = &layout->row(true, IFACE_("Stretch UVs"));
1105 row->prop(ptr, "use_stretch_u", toggles_flag, IFACE_("U"), ICON_NONE);
1106 row->prop(ptr, "use_stretch_v", toggles_flag, IFACE_("V"), ICON_NONE);
1107
1109}
1110
1111static void normals_panel_draw(const bContext * /*C*/, Panel *panel)
1112{
1113 uiLayout *col;
1114 uiLayout *layout = panel->layout;
1115
1117
1118 layout->use_property_split_set(true);
1119
1120 col = &layout->column(false);
1121 col->prop(ptr, "use_smooth_shade", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1122 col->prop(ptr, "use_normal_calculate", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1123 col->prop(ptr, "use_normal_flip", UI_ITEM_NONE, std::nullopt, ICON_NONE);
1124}
1125
1126static void panel_register(ARegionType *region_type)
1127{
1130 region_type, "normals", "Normals", nullptr, normals_panel_draw, panel_type);
1131}
1132
1134 /*idname*/ "Screw",
1135 /*name*/ N_("Screw"),
1136 /*struct_name*/ "ScrewModifierData",
1137 /*struct_size*/ sizeof(ScrewModifierData),
1138 /*srna*/ &RNA_ScrewModifier,
1140
1143 /*icon*/ ICON_MOD_SCREW,
1144
1145 /*copy_data*/ BKE_modifier_copydata_generic,
1146
1147 /*deform_verts*/ nullptr,
1148 /*deform_matrices*/ nullptr,
1149 /*deform_verts_EM*/ nullptr,
1150 /*deform_matrices_EM*/ nullptr,
1151 /*modify_mesh*/ modify_mesh,
1152 /*modify_geometry_set*/ nullptr,
1153
1154 /*init_data*/ init_data,
1155 /*required_data_mask*/ nullptr,
1156 /*free_data*/ nullptr,
1157 /*is_disabled*/ nullptr,
1158 /*update_depsgraph*/ update_depsgraph,
1159 /*depends_on_time*/ nullptr,
1160 /*depends_on_normals*/ nullptr,
1161 /*foreach_ID_link*/ foreach_ID_link,
1162 /*foreach_tex_link*/ nullptr,
1163 /*free_runtime_data*/ nullptr,
1164 /*panel_register*/ panel_register,
1165 /*blend_write*/ nullptr,
1166 /*blend_read*/ nullptr,
1167 /*foreach_cache*/ nullptr,
1168 /*foreach_working_space_color*/ nullptr,
1169};
CustomData interface, see also DNA_customdata_types.h.
@ CD_SET_DEFAULT
void CustomData_free_layers(CustomData *data, eCustomDataType type)
#define ORIGINDEX_NONE
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
void CustomData_copy_data(const CustomData *source, CustomData *dest, int source_index, int dest_index, int count)
bool CustomData_has_layer(const CustomData *data, eCustomDataType type)
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
int CustomData_number_of_layers(const CustomData *data, eCustomDataType type)
void * CustomData_get_layer_n_for_write(CustomData *data, eCustomDataType type, int n, int totelem)
void BKE_id_free(Main *bmain, void *idv)
@ IDWALK_CB_NOP
Mesh * BKE_mesh_new_nomain_from_template(const Mesh *me_src, int verts_num, int edges_num, int faces_num, int corners_num)
void(*)(void *user_data, Object *ob, ID **idpoin, LibraryForeachIDCallbackFlag cb_flag) IDWalkFunc
void BKE_modifier_copydata_generic(const ModifierData *md, ModifierData *md_dst, int flag)
@ eModifierTypeFlag_AcceptsCVs
@ eModifierTypeFlag_EnableInEditmode
@ eModifierTypeFlag_SupportsEditmode
@ eModifierTypeFlag_AcceptsMesh
@ MOD_APPLY_RENDER
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_BITMAP_NEW(_num, _alloc_string)
Definition BLI_bitmap.h:37
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition BLI_bitmap.h:61
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition BLI_bitmap.h:78
unsigned int BLI_bitmap
Definition BLI_bitmap.h:13
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE float square_f(float a)
MINLINE float sqrtf_signed(float f)
#define M_PI
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
Definition math_geom.cc:217
float dist_signed_to_plane_v3(const float p[3], const float plane[4])
Definition math_geom.cc:495
float closest_to_line_v3(float r_close[3], const float p[3], const float l1[3], const float l2[3])
float dist_signed_squared_to_plane_v3(const float p[3], const float plane[4])
Definition math_geom.cc:463
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void axis_angle_to_mat3_single(float R[3][3], char axis, float angle)
void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], float angle)
float angle_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void project_v3_v3v3_normalized(float out[3], const float p[3], const float v_proj[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void copy_vn_i(int *array_tar, int size, int val)
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
unsigned int uint
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
#define IFACE_(msgid)
void DEG_add_depends_on_transform_relation(DepsNodeHandle *node_handle, const char *description)
void DEG_add_object_relation(DepsNodeHandle *node_handle, Object *object, eDepsObjectComponentType component, const char *description)
@ DEG_OB_COMP_TRANSFORM
@ CD_PROP_FLOAT2
#define DNA_struct_default_get(struct_name)
@ eModifierType_Screw
@ MOD_SCREW_NORMAL_CALC
@ MOD_SCREW_SMOOTH_SHADING
@ MOD_SCREW_UV_STRETCH_V
@ MOD_SCREW_MERGE
@ MOD_SCREW_UV_STRETCH_U
@ MOD_SCREW_NORMAL_FLIP
@ MOD_SCREW_OBJECT_OFFSET
Object is a sort of wrapper for general info.
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:117
Read Guarded memory(de)allocation.
static void init_data(ModifierData *md)
static void panel_register(ARegionType *region_type)
static void panel_draw(const bContext *, Panel *panel)
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
static Mesh * modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
Definition MOD_array.cc:862
static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, uint v_init, uint dir)
Definition MOD_screw.cc:87
#define SV_INVALID
Definition MOD_screw.cc:84
#define SV_UNUSED
Definition MOD_screw.cc:83
static void normals_panel_draw(const bContext *, Panel *panel)
static Mesh * mesh_remove_doubles_on_axis(Mesh *result, blender::MutableSpan< blender::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:126
ModifierTypeInfo modifierType_Screw
static void screwvert_iter_step(ScrewVertIter *iter)
Definition MOD_screw.cc:106
#define SV_IS_VALID(v)
Definition MOD_screw.cc:85
PanelType * modifier_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
void modifier_error_message_draw(uiLayout *layout, PointerRNA *ptr)
@ UI_ITEM_R_TOGGLE
@ UI_ITEM_R_FORCE_BLANK_DECORATE
@ UI_ITEM_R_EXPAND
#define UI_ITEM_NONE
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
long long int int64_t
AttributeSet attributes
constexpr T * data() const
Definition BLI_span.hh:539
constexpr const T * data() const
Definition BLI_span.hh:215
constexpr bool is_empty() const
Definition BLI_span.hh:260
GSpanAttributeWriter lookup_or_add_for_write_span(StringRef attribute_id, AttrDomain domain, AttrType data_type, const AttributeInit &initializer=AttributeInitDefaultValue())
nullptr float
uint col
#define printf(...)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
static void update_depsgraph(tGraphSliderOp *gso)
#define UINT_MAX
Definition hash_md5.cc:44
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
Definition mallocn.cc:133
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
Mesh * mesh_merge_verts(const Mesh &mesh, MutableSpan< int > vert_dest_map, int vert_dest_map_len, const bool do_mix_data)
static void init_data(ModifierData *md)
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
static void panel_draw(const bContext *C, Panel *panel)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
static void panel_register(ARegionType *region_type)
static Mesh * modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
#define fabsf
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
bool RNA_pointer_is_null(const PointerRNA *ptr)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
#define FLT_MAX
Definition stdcycles.h:14
Definition DNA_ID.h:414
int edges_num
CustomData corner_data
CustomData face_data
CustomData vert_data
int faces_num
int verts_num
ModifierApplyFlag flag
struct uiLayout * layout
struct Object * ob_axis
blender::int2 * e[2]
Definition MOD_screw.cc:72
blender::int2 * e
Definition MOD_screw.cc:80
ScrewVertConnect * v_array
Definition MOD_screw.cc:77
ScrewVertConnect * v_poin
Definition MOD_screw.cc:78
uiLayout & column(bool align)
void active_set(bool active)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
uiLayout & row(bool align)
void use_property_split_set(bool value)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
i
Definition text_draw.cc:230
#define N_(msgid)
PointerRNA * ptr
Definition wm_files.cc:4238