Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_screw.cc
- This file was moved from source/blender/modifiers/intern/MOD_screw.c.
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2005 Blender Foundation. All rights reserved. */ | * Copyright 2005 Blender Foundation. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup modifiers | * \ingroup modifiers | ||||
| */ | */ | ||||
| /* Screw modifier: revolves the edges about an axis */ | /* Screw modifier: revolves the edges about an axis */ | ||||
| #include <limits.h> | #include <climits> | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_alloca.h" | |||||
| #include "BLI_bitmap.h" | #include "BLI_bitmap.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "DNA_defaults.h" | #include "DNA_defaults.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| ▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | static void screwvert_iter_init(ScrewVertIter *iter, | ||||
| iter->v = v_init; | iter->v = v_init; | ||||
| if (SV_IS_VALID(v_init)) { | if (SV_IS_VALID(v_init)) { | ||||
| iter->v_poin = &array[v_init]; | iter->v_poin = &array[v_init]; | ||||
| iter->v_other = iter->v_poin->v[dir]; | iter->v_other = iter->v_poin->v[dir]; | ||||
| iter->e = iter->v_poin->e[!dir]; | iter->e = iter->v_poin->e[!dir]; | ||||
| } | } | ||||
| else { | else { | ||||
| iter->v_poin = NULL; | iter->v_poin = nullptr; | ||||
| iter->e = NULL; | iter->e = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| static void screwvert_iter_step(ScrewVertIter *iter) | static void screwvert_iter_step(ScrewVertIter *iter) | ||||
| { | { | ||||
| if (iter->v_poin->v[0] == iter->v_other) { | if (iter->v_poin->v[0] == iter->v_other) { | ||||
| iter->v_other = iter->v; | iter->v_other = iter->v; | ||||
| iter->v = iter->v_poin->v[1]; | iter->v = iter->v_poin->v[1]; | ||||
| } | } | ||||
| else if (iter->v_poin->v[1] == iter->v_other) { | else if (iter->v_poin->v[1] == iter->v_other) { | ||||
| iter->v_other = iter->v; | iter->v_other = iter->v; | ||||
| iter->v = iter->v_poin->v[0]; | iter->v = iter->v_poin->v[0]; | ||||
| } | } | ||||
| if (SV_IS_VALID(iter->v)) { | if (SV_IS_VALID(iter->v)) { | ||||
| iter->v_poin = &iter->v_array[iter->v]; | iter->v_poin = &iter->v_array[iter->v]; | ||||
| iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)]; | iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)]; | ||||
| } | } | ||||
| else { | else { | ||||
| iter->e = NULL; | iter->e = nullptr; | ||||
| iter->v_poin = NULL; | iter->v_poin = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| static Mesh *mesh_remove_doubles_on_axis(Mesh *result, | static Mesh *mesh_remove_doubles_on_axis(Mesh *result, | ||||
| MVert *mvert_new, | MVert *mvert_new, | ||||
| const uint totvert, | const uint totvert, | ||||
| const uint step_tot, | const uint step_tot, | ||||
| const float axis_vec[3], | const float axis_vec[3], | ||||
| const float axis_offset[3], | const float axis_offset[3], | ||||
| const float merge_threshold) | const float merge_threshold) | ||||
| { | { | ||||
| BLI_bitmap *vert_tag = BLI_BITMAP_NEW(totvert, __func__); | BLI_bitmap *vert_tag = BLI_BITMAP_NEW(totvert, __func__); | ||||
| const float merge_threshold_sq = square_f(merge_threshold); | const float merge_threshold_sq = square_f(merge_threshold); | ||||
| const bool use_offset = axis_offset != NULL; | const bool use_offset = axis_offset != nullptr; | ||||
| uint tot_doubles = 0; | uint tot_doubles = 0; | ||||
| for (uint i = 0; i < totvert; i += 1) { | for (uint i = 0; i < totvert; i += 1) { | ||||
| float axis_co[3]; | float axis_co[3]; | ||||
| if (use_offset) { | if (use_offset) { | ||||
| float offset_co[3]; | float offset_co[3]; | ||||
| sub_v3_v3v3(offset_co, mvert_new[i].co, axis_offset); | sub_v3_v3v3(offset_co, mvert_new[i].co, axis_offset); | ||||
| project_v3_v3v3_normalized(axis_co, offset_co, axis_vec); | project_v3_v3v3_normalized(axis_co, offset_co, axis_vec); | ||||
| add_v3_v3(axis_co, axis_offset); | add_v3_v3(axis_co, axis_offset); | ||||
| } | } | ||||
| else { | else { | ||||
| project_v3_v3v3_normalized(axis_co, mvert_new[i].co, axis_vec); | project_v3_v3v3_normalized(axis_co, mvert_new[i].co, axis_vec); | ||||
| } | } | ||||
| const float dist_sq = len_squared_v3v3(axis_co, mvert_new[i].co); | const float dist_sq = len_squared_v3v3(axis_co, mvert_new[i].co); | ||||
| if (dist_sq <= merge_threshold_sq) { | if (dist_sq <= merge_threshold_sq) { | ||||
| BLI_BITMAP_ENABLE(vert_tag, i); | BLI_BITMAP_ENABLE(vert_tag, i); | ||||
| tot_doubles += 1; | tot_doubles += 1; | ||||
| copy_v3_v3(mvert_new[i].co, axis_co); | copy_v3_v3(mvert_new[i].co, axis_co); | ||||
| } | } | ||||
| } | } | ||||
| if (tot_doubles != 0) { | if (tot_doubles != 0) { | ||||
| uint tot = totvert * step_tot; | uint tot = totvert * step_tot; | ||||
| int *full_doubles_map = MEM_malloc_arrayN(tot, sizeof(int), __func__); | int *full_doubles_map = static_cast<int *>(MEM_malloc_arrayN(tot, sizeof(int), __func__)); | ||||
| copy_vn_i(full_doubles_map, (int)tot, -1); | copy_vn_i(full_doubles_map, int(tot), -1); | ||||
| uint tot_doubles_left = tot_doubles; | uint tot_doubles_left = tot_doubles; | ||||
| for (uint i = 0; i < totvert; i += 1) { | for (uint i = 0; i < totvert; i += 1) { | ||||
| if (BLI_BITMAP_TEST(vert_tag, i)) { | if (BLI_BITMAP_TEST(vert_tag, i)) { | ||||
| int *doubles_map = &full_doubles_map[totvert + i]; | int *doubles_map = &full_doubles_map[totvert + i]; | ||||
| for (uint step = 1; step < step_tot; step += 1) { | for (uint step = 1; step < step_tot; step += 1) { | ||||
| *doubles_map = (int)i; | *doubles_map = int(i); | ||||
| doubles_map += totvert; | doubles_map += totvert; | ||||
| } | } | ||||
| tot_doubles_left -= 1; | tot_doubles_left -= 1; | ||||
| if (tot_doubles_left == 0) { | if (tot_doubles_left == 0) { | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| result = BKE_mesh_merge_verts(result, | result = BKE_mesh_merge_verts(result, | ||||
| full_doubles_map, | full_doubles_map, | ||||
| (int)(tot_doubles * (step_tot - 1)), | int(tot_doubles * (step_tot - 1)), | ||||
| MESH_MERGE_VERTS_DUMP_IF_MAPPED); | MESH_MERGE_VERTS_DUMP_IF_MAPPED); | ||||
| MEM_freeN(full_doubles_map); | MEM_freeN(full_doubles_map); | ||||
| } | } | ||||
| MEM_freeN(vert_tag); | MEM_freeN(vert_tag); | ||||
| return result; | return result; | ||||
| } | } | ||||
| Show All 21 Lines | static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *meshData) | ||||
| const int quad_ord_ofs[4] = { | const int quad_ord_ofs[4] = { | ||||
| do_flip ? 2 : 0, | do_flip ? 2 : 0, | ||||
| 1, | 1, | ||||
| do_flip ? 0 : 2, | do_flip ? 0 : 2, | ||||
| 3, | 3, | ||||
| }; | }; | ||||
| uint maxVerts = 0, maxEdges = 0, maxPolys = 0; | uint maxVerts = 0, maxEdges = 0, maxPolys = 0; | ||||
| const uint totvert = (uint)mesh->totvert; | const uint totvert = uint(mesh->totvert); | ||||
| const uint totedge = (uint)mesh->totedge; | const uint totedge = uint(mesh->totedge); | ||||
| const uint totpoly = (uint)mesh->totpoly; | const uint totpoly = uint(mesh->totpoly); | ||||
| uint *edge_poly_map = NULL; /* orig edge to orig poly */ | uint *edge_poly_map = nullptr; /* orig edge to orig poly */ | ||||
| uint *vert_loop_map = NULL; /* orig vert to orig loop */ | uint *vert_loop_map = nullptr; /* orig vert to orig loop */ | ||||
| /* UV Coords */ | /* UV Coords */ | ||||
| const uint mloopuv_layers_tot = (uint)CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV); | const uint mloopuv_layers_tot = uint(CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV)); | ||||
| MLoopUV **mloopuv_layers = BLI_array_alloca(mloopuv_layers, mloopuv_layers_tot); | blender::Array<MLoopUV *> mloopuv_layers(mloopuv_layers_tot); | ||||
| float uv_u_scale; | float uv_u_scale; | ||||
| float uv_v_minmax[2] = {FLT_MAX, -FLT_MAX}; | float uv_v_minmax[2] = {FLT_MAX, -FLT_MAX}; | ||||
| float uv_v_range_inv; | float uv_v_range_inv; | ||||
| float uv_axis_plane[4]; | float uv_axis_plane[4]; | ||||
| char axis_char = 'X'; | char axis_char = 'X'; | ||||
| bool close; | bool close; | ||||
| float angle = ltmd->angle; | float angle = ltmd->angle; | ||||
| Show All 14 Lines | static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *meshData) | ||||
| MPoly *mp_new; | MPoly *mp_new; | ||||
| MLoop *ml_new; | MLoop *ml_new; | ||||
| MEdge *med_new, *med_new_firstloop; | MEdge *med_new, *med_new_firstloop; | ||||
| MVert *mv_new, *mv_new_base; | MVert *mv_new, *mv_new_base; | ||||
| const MVert *mv_orig; | const MVert *mv_orig; | ||||
| Object *ob_axis = ltmd->ob_axis; | Object *ob_axis = ltmd->ob_axis; | ||||
| ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL; | ScrewVertConnect *vc, *vc_tmp, *vert_connect = nullptr; | ||||
| const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0; | const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0; | ||||
| /* don't do anything? */ | /* don't do anything? */ | ||||
| if (!totvert) { | if (!totvert) { | ||||
| return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0); | return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0); | ||||
| } | } | ||||
| Show All 9 Lines | switch (ltmd->axis) { | ||||
| default: /* 2, use default to quiet warnings */ | default: /* 2, use default to quiet warnings */ | ||||
| other_axis_1 = 0; | other_axis_1 = 0; | ||||
| other_axis_2 = 1; | other_axis_2 = 1; | ||||
| break; | break; | ||||
| } | } | ||||
| axis_vec[ltmd->axis] = 1.0f; | axis_vec[ltmd->axis] = 1.0f; | ||||
| if (ob_axis != NULL) { | if (ob_axis != nullptr) { | ||||
| /* Calculate the matrix relative to the axis object. */ | /* Calculate the matrix relative to the axis object. */ | ||||
| invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world); | invert_m4_m4(mtx_tmp_a, ctx->object->object_to_world); | ||||
| copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world); | copy_m4_m4(mtx_tx_inv, ob_axis->object_to_world); | ||||
| mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv); | mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv); | ||||
| /* Calculate the axis vector. */ | /* Calculate the axis vector. */ | ||||
| mul_mat3_m4_v3(mtx_tx, axis_vec); /* only rotation component */ | mul_mat3_m4_v3(mtx_tx, axis_vec); /* only rotation component */ | ||||
| normalize_v3(axis_vec); | normalize_v3(axis_vec); | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) { | ||||
| if (len_v3v3(axis_tmp, axis_vec) > 1.0f) { | if (len_v3v3(axis_tmp, axis_vec) > 1.0f) { | ||||
| angle = -angle; | angle = -angle; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| } | } | ||||
| else { | else { | ||||
| axis_char = (char)(axis_char + ltmd->axis); /* 'X' + axis */ | axis_char = char(axis_char + ltmd->axis); /* 'X' + axis */ | ||||
| /* Useful to be able to use the axis vector in some cases still. */ | /* Useful to be able to use the axis vector in some cases still. */ | ||||
| zero_v3(axis_vec); | zero_v3(axis_vec); | ||||
| axis_vec[ltmd->axis] = 1.0f; | axis_vec[ltmd->axis] = 1.0f; | ||||
| } | } | ||||
| /* apply the multiplier */ | /* apply the multiplier */ | ||||
| angle *= (float)ltmd->iter; | angle *= float(ltmd->iter); | ||||
| screw_ofs *= (float)ltmd->iter; | screw_ofs *= float(ltmd->iter); | ||||
| uv_u_scale = 1.0f / (float)(step_tot); | uv_u_scale = 1.0f / float(step_tot); | ||||
| /* multiplying the steps is a bit tricky, this works best */ | /* multiplying the steps is a bit tricky, this works best */ | ||||
| step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1); | step_tot = ((step_tot + 1) * ltmd->iter) - (ltmd->iter - 1); | ||||
| /* Will the screw be closed? | /* Will the screw be closed? | ||||
| * NOTE: smaller than `FLT_EPSILON * 100` | * NOTE: smaller than `FLT_EPSILON * 100` | ||||
| * gives problems with float precision so its never closed. */ | * gives problems with float precision so its never closed. */ | ||||
| if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) && | if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) && | ||||
| fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f) && step_tot > 3) { | fabsf(fabsf(angle) - (float(M_PI) * 2.0f)) <= (FLT_EPSILON * 100.0f) && step_tot > 3) { | ||||
| close = 1; | close = 1; | ||||
| step_tot--; | step_tot--; | ||||
| maxVerts = totvert * step_tot; /* -1 because we're joining back up */ | maxVerts = totvert * step_tot; /* -1 because we're joining back up */ | ||||
| maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ | maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ | ||||
| (totedge * step_tot); /* -1 because vert edges join */ | (totedge * step_tot); /* -1 because vert edges join */ | ||||
| maxPolys = totedge * step_tot; | maxPolys = totedge * step_tot; | ||||
| screw_ofs = 0.0f; | screw_ofs = 0.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| close = 0; | close = 0; | ||||
| if (step_tot < 2) { | if (step_tot < 2) { | ||||
| step_tot = 2; | step_tot = 2; | ||||
| } | } | ||||
| maxVerts = totvert * step_tot; /* -1 because we're joining back up */ | maxVerts = totvert * step_tot; /* -1 because we're joining back up */ | ||||
| maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */ | maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */ | ||||
| (totedge * step_tot); /* -1 because vert edges join */ | (totedge * step_tot); /* -1 because vert edges join */ | ||||
| maxPolys = totedge * (step_tot - 1); | maxPolys = totedge * (step_tot - 1); | ||||
| } | } | ||||
| if ((ltmd->flag & MOD_SCREW_UV_STRETCH_U) == 0) { | if ((ltmd->flag & MOD_SCREW_UV_STRETCH_U) == 0) { | ||||
| uv_u_scale = (uv_u_scale / (float)ltmd->iter) * (angle / ((float)M_PI * 2.0f)); | uv_u_scale = (uv_u_scale / float(ltmd->iter)) * (angle / (float(M_PI) * 2.0f)); | ||||
| } | } | ||||
| /* The `screw_ofs` cannot change from now on. */ | /* The `screw_ofs` cannot change from now on. */ | ||||
| const bool do_remove_doubles = (ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f); | const bool do_remove_doubles = (ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f); | ||||
| result = BKE_mesh_new_nomain_from_template( | result = BKE_mesh_new_nomain_from_template( | ||||
| mesh, (int)maxVerts, (int)maxEdges, 0, (int)maxPolys * 4, (int)maxPolys); | mesh, int(maxVerts), int(maxEdges), 0, int(maxPolys) * 4, int(maxPolys)); | ||||
| const MVert *mvert_orig = BKE_mesh_verts(mesh); | const MVert *mvert_orig = BKE_mesh_verts(mesh); | ||||
| const MEdge *medge_orig = BKE_mesh_edges(mesh); | const MEdge *medge_orig = BKE_mesh_edges(mesh); | ||||
| const MPoly *mpoly_orig = BKE_mesh_polys(mesh); | const MPoly *mpoly_orig = BKE_mesh_polys(mesh); | ||||
| const MLoop *mloop_orig = BKE_mesh_loops(mesh); | const MLoop *mloop_orig = BKE_mesh_loops(mesh); | ||||
| MVert *mvert_new = BKE_mesh_verts_for_write(result); | MVert *mvert_new = BKE_mesh_verts_for_write(result); | ||||
| MEdge *medge_new = BKE_mesh_edges_for_write(result); | MEdge *medge_new = BKE_mesh_edges_for_write(result); | ||||
| MPoly *mpoly_new = BKE_mesh_polys_for_write(result); | MPoly *mpoly_new = BKE_mesh_polys_for_write(result); | ||||
| MLoop *mloop_new = BKE_mesh_loops_for_write(result); | MLoop *mloop_new = BKE_mesh_loops_for_write(result); | ||||
| if (!CustomData_has_layer(&result->pdata, CD_ORIGINDEX)) { | if (!CustomData_has_layer(&result->pdata, CD_ORIGINDEX)) { | ||||
| CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, NULL, (int)maxPolys); | CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, int(maxPolys)); | ||||
| } | } | ||||
| int *origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX); | int *origindex = static_cast<int *>(CustomData_get_layer(&result->pdata, CD_ORIGINDEX)); | ||||
| CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)totvert); | CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, int(totvert)); | ||||
| if (mloopuv_layers_tot) { | if (mloopuv_layers_tot) { | ||||
| const float zero_co[3] = {0}; | const float zero_co[3] = {0}; | ||||
| plane_from_point_normal_v3(uv_axis_plane, zero_co, axis_vec); | plane_from_point_normal_v3(uv_axis_plane, zero_co, axis_vec); | ||||
| } | } | ||||
| if (mloopuv_layers_tot) { | if (mloopuv_layers_tot) { | ||||
| uint uv_lay; | uint uv_lay; | ||||
| for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) { | for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) { | ||||
| mloopuv_layers[uv_lay] = CustomData_get_layer_n(&result->ldata, CD_MLOOPUV, (int)uv_lay); | mloopuv_layers[uv_lay] = static_cast<MLoopUV *>( | ||||
| CustomData_get_layer_n(&result->ldata, CD_MLOOPUV, int(uv_lay))); | |||||
| } | } | ||||
| if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) { | if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) { | ||||
| for (i = 0, mv_orig = mvert_orig; i < totvert; i++, mv_orig++) { | for (i = 0, mv_orig = mvert_orig; i < totvert; i++, mv_orig++) { | ||||
| const float v = dist_signed_squared_to_plane_v3(mv_orig->co, uv_axis_plane); | const float v = dist_signed_squared_to_plane_v3(mv_orig->co, uv_axis_plane); | ||||
| uv_v_minmax[0] = min_ff(v, uv_v_minmax[0]); | uv_v_minmax[0] = min_ff(v, uv_v_minmax[0]); | ||||
| uv_v_minmax[1] = max_ff(v, uv_v_minmax[1]); | uv_v_minmax[1] = max_ff(v, uv_v_minmax[1]); | ||||
| } | } | ||||
| Show All 18 Lines | for (i = 0; i < totedge; i++, med_orig++, med_new++) { | ||||
| med_new->v2 = med_orig->v2; | med_new->v2 = med_orig->v2; | ||||
| med_new->flag = med_orig->flag; | med_new->flag = med_orig->flag; | ||||
| } | } | ||||
| /* build polygon -> edge map */ | /* build polygon -> edge map */ | ||||
| if (totpoly) { | if (totpoly) { | ||||
| const MPoly *mp_orig; | const MPoly *mp_orig; | ||||
| edge_poly_map = MEM_malloc_arrayN(totedge, sizeof(*edge_poly_map), __func__); | edge_poly_map = static_cast<uint *>( | ||||
| MEM_malloc_arrayN(totedge, sizeof(*edge_poly_map), __func__)); | |||||
| memset(edge_poly_map, 0xff, sizeof(*edge_poly_map) * totedge); | memset(edge_poly_map, 0xff, sizeof(*edge_poly_map) * totedge); | ||||
| vert_loop_map = MEM_malloc_arrayN(totvert, sizeof(*vert_loop_map), __func__); | vert_loop_map = static_cast<uint *>( | ||||
| MEM_malloc_arrayN(totvert, sizeof(*vert_loop_map), __func__)); | |||||
| memset(vert_loop_map, 0xff, sizeof(*vert_loop_map) * totvert); | memset(vert_loop_map, 0xff, sizeof(*vert_loop_map) * totvert); | ||||
| for (i = 0, mp_orig = mpoly_orig; i < totpoly; i++, mp_orig++) { | for (i = 0, mp_orig = mpoly_orig; i < totpoly; i++, mp_orig++) { | ||||
| uint loopstart = (uint)mp_orig->loopstart; | uint loopstart = uint(mp_orig->loopstart); | ||||
| uint loopend = loopstart + (uint)mp_orig->totloop; | uint loopend = loopstart + uint(mp_orig->totloop); | ||||
| const MLoop *ml_orig = &mloop_orig[loopstart]; | const MLoop *ml_orig = &mloop_orig[loopstart]; | ||||
| uint k; | uint k; | ||||
| for (k = loopstart; k < loopend; k++, ml_orig++) { | for (k = loopstart; k < loopend; k++, ml_orig++) { | ||||
| edge_poly_map[ml_orig->e] = i; | edge_poly_map[ml_orig->e] = i; | ||||
| vert_loop_map[ml_orig->v] = k; | vert_loop_map[ml_orig->v] = k; | ||||
| /* also order edges based on faces */ | /* also order edges based on faces */ | ||||
| Show All 21 Lines | if (ltmd->flag & MOD_SCREW_NORMAL_CALC) { | ||||
| * at the moment there is no chance of that being a problem, | * at the moment there is no chance of that being a problem, | ||||
| * unless #MVert becomes half its current size. | * unless #MVert becomes half its current size. | ||||
| * | * | ||||
| * once the edges are ordered, vert_connect is not needed and it can be used for verts | * once the edges are ordered, vert_connect is not needed and it can be used for verts | ||||
| * | * | ||||
| * This makes the modifier faster with one less allocate. | * This makes the modifier faster with one less allocate. | ||||
| */ | */ | ||||
| vert_connect = MEM_malloc_arrayN(totvert, sizeof(ScrewVertConnect), __func__); | vert_connect = static_cast<ScrewVertConnect *>( | ||||
| MEM_malloc_arrayN(totvert, sizeof(ScrewVertConnect), __func__)); | |||||
| /* skip the first slice of verts. */ | /* skip the first slice of verts. */ | ||||
| // vert_connect = (ScrewVertConnect *) &medge_new[totvert]; | // vert_connect = (ScrewVertConnect *) &medge_new[totvert]; | ||||
| vc = vert_connect; | vc = vert_connect; | ||||
| /* Copy Vert Locations */ | /* Copy Vert Locations */ | ||||
| if (totedge != 0) { | if (totedge != 0) { | ||||
| // printf("\n\n\n\n\nStarting Modifier\n"); | // printf("\n\n\n\n\nStarting Modifier\n"); | ||||
| /* set edge users */ | /* set edge users */ | ||||
| med_new = medge_new; | med_new = medge_new; | ||||
| mv_new = mvert_new; | mv_new = mvert_new; | ||||
| if (ob_axis != NULL) { | if (ob_axis != nullptr) { | ||||
| /* `mtx_tx` is initialized early on. */ | /* `mtx_tx` is initialized early on. */ | ||||
| for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { | for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { | ||||
| vc->co[0] = mv_new->co[0] = mv_orig->co[0]; | vc->co[0] = mv_new->co[0] = mv_orig->co[0]; | ||||
| vc->co[1] = mv_new->co[1] = mv_orig->co[1]; | vc->co[1] = mv_new->co[1] = mv_orig->co[1]; | ||||
| vc->co[2] = mv_new->co[2] = mv_orig->co[2]; | vc->co[2] = mv_new->co[2] = mv_orig->co[2]; | ||||
| vc->flag = 0; | vc->flag = 0; | ||||
| vc->e[0] = vc->e[1] = NULL; | vc->e[0] = vc->e[1] = nullptr; | ||||
| vc->v[0] = vc->v[1] = SV_UNUSED; | vc->v[0] = vc->v[1] = SV_UNUSED; | ||||
| mul_m4_v3(mtx_tx, vc->co); | mul_m4_v3(mtx_tx, vc->co); | ||||
| /* Length in 2D, don't `sqrt` because this is only for comparison. */ | /* Length in 2D, don't `sqrt` because this is only for comparison. */ | ||||
| vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] + | vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] + | ||||
| vc->co[other_axis_2] * vc->co[other_axis_2]; | vc->co[other_axis_2] * vc->co[other_axis_2]; | ||||
| // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq); | // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { | for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { | ||||
| vc->co[0] = mv_new->co[0] = mv_orig->co[0]; | vc->co[0] = mv_new->co[0] = mv_orig->co[0]; | ||||
| vc->co[1] = mv_new->co[1] = mv_orig->co[1]; | vc->co[1] = mv_new->co[1] = mv_orig->co[1]; | ||||
| vc->co[2] = mv_new->co[2] = mv_orig->co[2]; | vc->co[2] = mv_new->co[2] = mv_orig->co[2]; | ||||
| vc->flag = 0; | vc->flag = 0; | ||||
| vc->e[0] = vc->e[1] = NULL; | vc->e[0] = vc->e[1] = nullptr; | ||||
| vc->v[0] = vc->v[1] = SV_UNUSED; | vc->v[0] = vc->v[1] = SV_UNUSED; | ||||
| /* Length in 2D, don't sqrt because this is only for comparison. */ | /* Length in 2D, don't sqrt because this is only for comparison. */ | ||||
| vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] + | vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] + | ||||
| vc->co[other_axis_2] * vc->co[other_axis_2]; | vc->co[other_axis_2] * vc->co[other_axis_2]; | ||||
| // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq); | // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | #endif | ||||
| /* done with edge connectivity based normal flipping */ | /* done with edge connectivity based normal flipping */ | ||||
| /* Add Faces */ | /* Add Faces */ | ||||
| for (step = 1; step < step_tot; step++) { | for (step = 1; step < step_tot; step++) { | ||||
| const uint varray_stride = totvert * step; | const uint varray_stride = totvert * step; | ||||
| float step_angle; | float step_angle; | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| /* Rotation Matrix */ | /* Rotation Matrix */ | ||||
| step_angle = (angle / (float)(step_tot - (!close))) * (float)step; | step_angle = (angle / float(step_tot - (!close))) * float(step); | ||||
| if (ob_axis != NULL) { | if (ob_axis != nullptr) { | ||||
| axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle); | axis_angle_normalized_to_mat3(mat3, axis_vec, step_angle); | ||||
| } | } | ||||
| else { | else { | ||||
| axis_angle_to_mat3_single(mat3, axis_char, step_angle); | axis_angle_to_mat3_single(mat3, axis_char, step_angle); | ||||
| } | } | ||||
| copy_m4_m3(mat, mat3); | copy_m4_m3(mat, mat3); | ||||
| if (screw_ofs) { | if (screw_ofs) { | ||||
| madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot - 1))); | madd_v3_v3fl(mat[3], axis_vec, screw_ofs * (float(step) / float(step_tot - 1))); | ||||
| } | } | ||||
| /* copy a slice */ | /* copy a slice */ | ||||
| CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)varray_stride, (int)totvert); | CustomData_copy_data(&mesh->vdata, &result->vdata, 0, int(varray_stride), int(totvert)); | ||||
| mv_new_base = mvert_new; | mv_new_base = mvert_new; | ||||
| mv_new = &mvert_new[varray_stride]; /* advance to the next slice */ | mv_new = &mvert_new[varray_stride]; /* advance to the next slice */ | ||||
| for (j = 0; j < totvert; j++, mv_new_base++, mv_new++) { | for (j = 0; j < totvert; j++, mv_new_base++, mv_new++) { | ||||
| /* set location */ | /* set location */ | ||||
| copy_v3_v3(mv_new->co, mv_new_base->co); | copy_v3_v3(mv_new->co, mv_new_base->co); | ||||
| /* only need to set these if using non cleared memory */ | /* only need to set these if using non cleared memory */ | ||||
| // mv_new->mat_nr = mv_new->flag = 0; | // mv_new->mat_nr = mv_new->flag = 0; | ||||
| if (ob_axis != NULL) { | if (ob_axis != nullptr) { | ||||
| sub_v3_v3(mv_new->co, mtx_tx[3]); | sub_v3_v3(mv_new->co, mtx_tx[3]); | ||||
| mul_m4_v3(mat, mv_new->co); | mul_m4_v3(mat, mv_new->co); | ||||
| add_v3_v3(mv_new->co, mtx_tx[3]); | add_v3_v3(mv_new->co, mtx_tx[3]); | ||||
| } | } | ||||
| else { | else { | ||||
| mul_m4_v3(mat, mv_new->co); | mul_m4_v3(mat, mv_new->co); | ||||
| } | } | ||||
| /* add the new edge */ | /* add the new edge */ | ||||
| med_new->v1 = varray_stride + j; | med_new->v1 = varray_stride + j; | ||||
| med_new->v2 = med_new->v1 - totvert; | med_new->v2 = med_new->v1 - totvert; | ||||
| med_new->flag = ME_EDGEDRAW; | med_new->flag = ME_EDGEDRAW; | ||||
| med_new++; | med_new++; | ||||
| } | } | ||||
| } | } | ||||
| /* we can avoid if using vert alloc trick */ | /* we can avoid if using vert alloc trick */ | ||||
| if (vert_connect) { | if (vert_connect) { | ||||
| MEM_freeN(vert_connect); | MEM_freeN(vert_connect); | ||||
| vert_connect = NULL; | vert_connect = nullptr; | ||||
| } | } | ||||
| if (close) { | if (close) { | ||||
| /* last loop of edges, previous loop doesn't account for the last set of edges */ | /* last loop of edges, previous loop doesn't account for the last set of edges */ | ||||
| const uint varray_stride = (step_tot - 1) * totvert; | const uint varray_stride = (step_tot - 1) * totvert; | ||||
| for (i = 0; i < totvert; i++) { | for (i = 0; i < totvert; i++) { | ||||
| med_new->v1 = i; | med_new->v1 = i; | ||||
| Show All 27 Lines | for (i = 0; i < totedge; i++, med_new_firstloop++) { | ||||
| int mat_nr; | int mat_nr; | ||||
| /* for each edge, make a cylinder of quads */ | /* for each edge, make a cylinder of quads */ | ||||
| i1 = med_new_firstloop->v1; | i1 = med_new_firstloop->v1; | ||||
| i2 = med_new_firstloop->v2; | i2 = med_new_firstloop->v2; | ||||
| if (has_mpoly_orig) { | if (has_mpoly_orig) { | ||||
| mat_nr = src_material_index == NULL ? 0 : src_material_index[mpoly_index_orig]; | mat_nr = src_material_index == nullptr ? 0 : src_material_index[mpoly_index_orig]; | ||||
| } | } | ||||
| else { | else { | ||||
| mat_nr = 0; | mat_nr = 0; | ||||
| } | } | ||||
| if (has_mloop_orig == false && mloopuv_layers_tot) { | if (has_mloop_orig == false && mloopuv_layers_tot) { | ||||
| uv_v_offset_a = dist_signed_to_plane_v3(mvert_new[medge_new[i].v1].co, uv_axis_plane); | uv_v_offset_a = dist_signed_to_plane_v3(mvert_new[medge_new[i].v1].co, uv_axis_plane); | ||||
| uv_v_offset_b = dist_signed_to_plane_v3(mvert_new[medge_new[i].v2].co, uv_axis_plane); | uv_v_offset_b = dist_signed_to_plane_v3(mvert_new[medge_new[i].v2].co, uv_axis_plane); | ||||
| if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) { | if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) { | ||||
| uv_v_offset_a = (uv_v_offset_a - uv_v_minmax[0]) * uv_v_range_inv; | uv_v_offset_a = (uv_v_offset_a - uv_v_minmax[0]) * uv_v_range_inv; | ||||
| uv_v_offset_b = (uv_v_offset_b - uv_v_minmax[0]) * uv_v_range_inv; | uv_v_offset_b = (uv_v_offset_b - uv_v_minmax[0]) * uv_v_range_inv; | ||||
| } | } | ||||
| } | } | ||||
| for (step = 0; step <= step_last; step++) { | for (step = 0; step <= step_last; step++) { | ||||
| /* Polygon */ | /* Polygon */ | ||||
| if (has_mpoly_orig) { | if (has_mpoly_orig) { | ||||
| CustomData_copy_data( | CustomData_copy_data( | ||||
| &mesh->pdata, &result->pdata, (int)mpoly_index_orig, (int)mpoly_index, 1); | &mesh->pdata, &result->pdata, int(mpoly_index_orig), int(mpoly_index), 1); | ||||
| origindex[mpoly_index] = (int)mpoly_index_orig; | origindex[mpoly_index] = int(mpoly_index_orig); | ||||
| } | } | ||||
| else { | else { | ||||
| origindex[mpoly_index] = ORIGINDEX_NONE; | origindex[mpoly_index] = ORIGINDEX_NONE; | ||||
| dst_material_index[mpoly_index] = mat_nr; | dst_material_index[mpoly_index] = mat_nr; | ||||
| mp_new->flag = mpoly_flag; | mp_new->flag = mpoly_flag; | ||||
| } | } | ||||
| mp_new->loopstart = mpoly_index * 4; | mp_new->loopstart = mpoly_index * 4; | ||||
| mp_new->totloop = 4; | mp_new->totloop = 4; | ||||
| /* Loop-Custom-Data */ | /* Loop-Custom-Data */ | ||||
| if (has_mloop_orig) { | if (has_mloop_orig) { | ||||
| int l_index = (int)(ml_new - mloop_new); | int l_index = int(ml_new - mloop_new); | ||||
| CustomData_copy_data( | CustomData_copy_data( | ||||
| &mesh->ldata, &result->ldata, (int)mloop_index_orig[0], l_index + 0, 1); | &mesh->ldata, &result->ldata, int(mloop_index_orig[0]), l_index + 0, 1); | ||||
| CustomData_copy_data( | CustomData_copy_data( | ||||
| &mesh->ldata, &result->ldata, (int)mloop_index_orig[1], l_index + 1, 1); | &mesh->ldata, &result->ldata, int(mloop_index_orig[1]), l_index + 1, 1); | ||||
| CustomData_copy_data( | CustomData_copy_data( | ||||
| &mesh->ldata, &result->ldata, (int)mloop_index_orig[1], l_index + 2, 1); | &mesh->ldata, &result->ldata, int(mloop_index_orig[1]), l_index + 2, 1); | ||||
| CustomData_copy_data( | CustomData_copy_data( | ||||
| &mesh->ldata, &result->ldata, (int)mloop_index_orig[0], l_index + 3, 1); | &mesh->ldata, &result->ldata, int(mloop_index_orig[0]), l_index + 3, 1); | ||||
| if (mloopuv_layers_tot) { | if (mloopuv_layers_tot) { | ||||
| uint uv_lay; | uint uv_lay; | ||||
| const float uv_u_offset_a = (float)(step)*uv_u_scale; | const float uv_u_offset_a = float(step) * uv_u_scale; | ||||
| const float uv_u_offset_b = (float)(step + 1) * uv_u_scale; | const float uv_u_offset_b = float(step + 1) * uv_u_scale; | ||||
| for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) { | for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) { | ||||
| MLoopUV *mluv = &mloopuv_layers[uv_lay][l_index]; | MLoopUV *mluv = &mloopuv_layers[uv_lay][l_index]; | ||||
| mluv[quad_ord[0]].uv[0] += uv_u_offset_a; | mluv[quad_ord[0]].uv[0] += uv_u_offset_a; | ||||
| mluv[quad_ord[1]].uv[0] += uv_u_offset_a; | mluv[quad_ord[1]].uv[0] += uv_u_offset_a; | ||||
| mluv[quad_ord[2]].uv[0] += uv_u_offset_b; | mluv[quad_ord[2]].uv[0] += uv_u_offset_b; | ||||
| mluv[quad_ord[3]].uv[0] += uv_u_offset_b; | mluv[quad_ord[3]].uv[0] += uv_u_offset_b; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (mloopuv_layers_tot) { | if (mloopuv_layers_tot) { | ||||
| int l_index = (int)(ml_new - mloop_new); | int l_index = int(ml_new - mloop_new); | ||||
| uint uv_lay; | uint uv_lay; | ||||
| const float uv_u_offset_a = (float)(step)*uv_u_scale; | const float uv_u_offset_a = float(step) * uv_u_scale; | ||||
| const float uv_u_offset_b = (float)(step + 1) * uv_u_scale; | const float uv_u_offset_b = float(step + 1) * uv_u_scale; | ||||
| for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) { | for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) { | ||||
| MLoopUV *mluv = &mloopuv_layers[uv_lay][l_index]; | MLoopUV *mluv = &mloopuv_layers[uv_lay][l_index]; | ||||
| copy_v2_fl2(mluv[quad_ord[0]].uv, uv_u_offset_a, uv_v_offset_a); | copy_v2_fl2(mluv[quad_ord[0]].uv, uv_u_offset_a, uv_v_offset_a); | ||||
| copy_v2_fl2(mluv[quad_ord[1]].uv, uv_u_offset_a, uv_v_offset_b); | copy_v2_fl2(mluv[quad_ord[1]].uv, uv_u_offset_a, uv_v_offset_b); | ||||
| copy_v2_fl2(mluv[quad_ord[2]].uv, uv_u_offset_b, uv_v_offset_b); | copy_v2_fl2(mluv[quad_ord[2]].uv, uv_u_offset_b, uv_v_offset_b); | ||||
| copy_v2_fl2(mluv[quad_ord[3]].uv, uv_u_offset_b, uv_v_offset_a); | copy_v2_fl2(mluv[quad_ord[3]].uv, uv_u_offset_b, uv_v_offset_a); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | #endif | ||||
| } | } | ||||
| if (do_remove_doubles) { | if (do_remove_doubles) { | ||||
| result = mesh_remove_doubles_on_axis(result, | result = mesh_remove_doubles_on_axis(result, | ||||
| mvert_new, | mvert_new, | ||||
| totvert, | totvert, | ||||
| step_tot, | step_tot, | ||||
| axis_vec, | axis_vec, | ||||
| ob_axis != NULL ? mtx_tx[3] : NULL, | ob_axis != nullptr ? mtx_tx[3] : nullptr, | ||||
| ltmd->merge_dist); | ltmd->merge_dist); | ||||
| } | } | ||||
| return result; | return result; | ||||
| } | } | ||||
| static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) | static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) | ||||
| { | { | ||||
| ScrewModifierData *ltmd = (ScrewModifierData *)md; | ScrewModifierData *ltmd = (ScrewModifierData *)md; | ||||
| if (ltmd->ob_axis != NULL) { | if (ltmd->ob_axis != nullptr) { | ||||
| DEG_add_object_relation(ctx->node, ltmd->ob_axis, DEG_OB_COMP_TRANSFORM, "Screw Modifier"); | DEG_add_object_relation(ctx->node, ltmd->ob_axis, DEG_OB_COMP_TRANSFORM, "Screw Modifier"); | ||||
| DEG_add_depends_on_transform_relation(ctx->node, "Screw Modifier"); | DEG_add_depends_on_transform_relation(ctx->node, "Screw Modifier"); | ||||
| } | } | ||||
| } | } | ||||
| static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) | static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) | ||||
| { | { | ||||
| ScrewModifierData *ltmd = (ScrewModifierData *)md; | ScrewModifierData *ltmd = (ScrewModifierData *)md; | ||||
| walk(userData, ob, (ID **)<md->ob_axis, IDWALK_CB_NOP); | walk(userData, ob, (ID **)<md->ob_axis, IDWALK_CB_NOP); | ||||
| } | } | ||||
| static void panel_draw(const bContext *UNUSED(C), Panel *panel) | static void panel_draw(const bContext * /*C*/, Panel *panel) | ||||
| { | { | ||||
| uiLayout *sub, *row, *col; | uiLayout *sub, *row, *col; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE; | int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); | ||||
| PointerRNA screw_obj_ptr = RNA_pointer_get(ptr, "object"); | PointerRNA screw_obj_ptr = RNA_pointer_get(ptr, "object"); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); | uiItemR(col, ptr, "angle", 0, nullptr, ICON_NONE); | ||||
| row = uiLayoutRow(col, false); | row = uiLayoutRow(col, false); | ||||
| uiLayoutSetActive(row, | uiLayoutSetActive(row, | ||||
| RNA_pointer_is_null(&screw_obj_ptr) || | RNA_pointer_is_null(&screw_obj_ptr) || | ||||
| !RNA_boolean_get(ptr, "use_object_screw_offset")); | !RNA_boolean_get(ptr, "use_object_screw_offset")); | ||||
| uiItemR(row, ptr, "screw_offset", 0, NULL, ICON_NONE); | uiItemR(row, ptr, "screw_offset", 0, nullptr, ICON_NONE); | ||||
| uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE); | uiItemR(col, ptr, "iterations", 0, nullptr, ICON_NONE); | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| row = uiLayoutRow(col, false); | row = uiLayoutRow(col, false); | ||||
| uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | ||||
| uiItemR(col, ptr, "object", 0, IFACE_("Axis Object"), ICON_NONE); | uiItemR(col, ptr, "object", 0, IFACE_("Axis Object"), ICON_NONE); | ||||
| sub = uiLayoutColumn(col, false); | sub = uiLayoutColumn(col, false); | ||||
| uiLayoutSetActive(sub, !RNA_pointer_is_null(&screw_obj_ptr)); | uiLayoutSetActive(sub, !RNA_pointer_is_null(&screw_obj_ptr)); | ||||
| uiItemR(sub, ptr, "use_object_screw_offset", 0, NULL, ICON_NONE); | uiItemR(sub, ptr, "use_object_screw_offset", 0, nullptr, ICON_NONE); | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| col = uiLayoutColumn(layout, true); | col = uiLayoutColumn(layout, true); | ||||
| uiItemR(col, ptr, "steps", 0, IFACE_("Steps Viewport"), ICON_NONE); | uiItemR(col, ptr, "steps", 0, IFACE_("Steps Viewport"), ICON_NONE); | ||||
| uiItemR(col, ptr, "render_steps", 0, IFACE_("Render"), ICON_NONE); | uiItemR(col, ptr, "render_steps", 0, IFACE_("Render"), ICON_NONE); | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| row = uiLayoutRowWithHeading(layout, true, IFACE_("Merge")); | row = uiLayoutRowWithHeading(layout, true, IFACE_("Merge")); | ||||
| uiItemR(row, ptr, "use_merge_vertices", 0, "", ICON_NONE); | uiItemR(row, ptr, "use_merge_vertices", 0, "", ICON_NONE); | ||||
| sub = uiLayoutRow(row, true); | sub = uiLayoutRow(row, true); | ||||
| uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_merge_vertices")); | uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_merge_vertices")); | ||||
| uiItemR(sub, ptr, "merge_threshold", 0, "", ICON_NONE); | uiItemR(sub, ptr, "merge_threshold", 0, "", ICON_NONE); | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| row = uiLayoutRowWithHeading(layout, true, IFACE_("Stretch UVs")); | row = uiLayoutRowWithHeading(layout, true, IFACE_("Stretch UVs")); | ||||
| uiItemR(row, ptr, "use_stretch_u", toggles_flag, IFACE_("U"), ICON_NONE); | uiItemR(row, ptr, "use_stretch_u", toggles_flag, IFACE_("U"), ICON_NONE); | ||||
| uiItemR(row, ptr, "use_stretch_v", toggles_flag, IFACE_("V"), ICON_NONE); | uiItemR(row, ptr, "use_stretch_v", toggles_flag, IFACE_("V"), ICON_NONE); | ||||
| modifier_panel_end(layout, ptr); | modifier_panel_end(layout, ptr); | ||||
| } | } | ||||
| static void normals_panel_draw(const bContext *UNUSED(C), Panel *panel) | static void normals_panel_draw(const bContext * /*C*/, Panel *panel) | ||||
| { | { | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiItemR(col, ptr, "use_smooth_shade", 0, NULL, ICON_NONE); | uiItemR(col, ptr, "use_smooth_shade", 0, nullptr, ICON_NONE); | ||||
| uiItemR(col, ptr, "use_normal_calculate", 0, NULL, ICON_NONE); | uiItemR(col, ptr, "use_normal_calculate", 0, nullptr, ICON_NONE); | ||||
| uiItemR(col, ptr, "use_normal_flip", 0, NULL, ICON_NONE); | uiItemR(col, ptr, "use_normal_flip", 0, nullptr, ICON_NONE); | ||||
| } | } | ||||
| static void panelRegister(ARegionType *region_type) | static void panelRegister(ARegionType *region_type) | ||||
| { | { | ||||
| PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Screw, panel_draw); | PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Screw, panel_draw); | ||||
| modifier_subpanel_register( | modifier_subpanel_register( | ||||
| region_type, "normals", "Normals", NULL, normals_panel_draw, panel_type); | region_type, "normals", "Normals", nullptr, normals_panel_draw, panel_type); | ||||
| } | } | ||||
| ModifierTypeInfo modifierType_Screw = { | ModifierTypeInfo modifierType_Screw = { | ||||
| /* name */ N_("Screw"), | /* name */ N_("Screw"), | ||||
| /* structName */ "ScrewModifierData", | /* structName */ "ScrewModifierData", | ||||
| /* structSize */ sizeof(ScrewModifierData), | /* structSize */ sizeof(ScrewModifierData), | ||||
| /* srna */ &RNA_ScrewModifier, | /* srna */ &RNA_ScrewModifier, | ||||
| /* type */ eModifierTypeType_Constructive, | /* type */ eModifierTypeType_Constructive, | ||||
| /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_AcceptsCVs | | /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_AcceptsCVs | | ||||
| eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode, | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode, | ||||
| /* icon */ ICON_MOD_SCREW, | /* icon */ ICON_MOD_SCREW, | ||||
| /* copyData */ BKE_modifier_copydata_generic, | /* copyData */ BKE_modifier_copydata_generic, | ||||
| /* deformVerts */ NULL, | /* deformVerts */ nullptr, | ||||
| /* deformMatrices */ NULL, | /* deformMatrices */ nullptr, | ||||
| /* deformVertsEM */ NULL, | /* deformVertsEM */ nullptr, | ||||
| /* deformMatricesEM */ NULL, | /* deformMatricesEM */ nullptr, | ||||
| /* modifyMesh */ modifyMesh, | /* modifyMesh */ modifyMesh, | ||||
| /* modifyGeometrySet */ NULL, | /* modifyGeometrySet */ nullptr, | ||||
| /* initData */ initData, | /* initData */ initData, | ||||
| /* requiredDataMask */ NULL, | /* requiredDataMask */ nullptr, | ||||
| /* freeData */ NULL, | /* freeData */ nullptr, | ||||
| /* isDisabled */ NULL, | /* isDisabled */ nullptr, | ||||
| /* updateDepsgraph */ updateDepsgraph, | /* updateDepsgraph */ updateDepsgraph, | ||||
| /* dependsOnTime */ NULL, | /* dependsOnTime */ nullptr, | ||||
| /* dependsOnNormals */ NULL, | /* dependsOnNormals */ nullptr, | ||||
| /* foreachIDLink */ foreachIDLink, | /* foreachIDLink */ foreachIDLink, | ||||
| /* foreachTexLink */ NULL, | /* foreachTexLink */ nullptr, | ||||
| /* freeRuntimeData */ NULL, | /* freeRuntimeData */ nullptr, | ||||
| /* panelRegister */ panelRegister, | /* panelRegister */ panelRegister, | ||||
| /* blendWrite */ NULL, | /* blendWrite */ nullptr, | ||||
| /* blendRead */ NULL, | /* blendRead */ nullptr, | ||||
| }; | }; | ||||