Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_normal_edit.cc
- This file was moved from source/blender/modifiers/intern/MOD_normal_edit.c.
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | static void generate_vert_coordinates(Mesh *mesh, | ||||
| float diff[3]; | float diff[3]; | ||||
| bool do_diff = false; | bool do_diff = false; | ||||
| INIT_MINMAX(min_co, max_co); | INIT_MINMAX(min_co, max_co); | ||||
| const MVert *mv = BKE_mesh_verts(mesh); | const MVert *mv = BKE_mesh_verts(mesh); | ||||
| for (int i = 0; i < mesh->totvert; i++, mv++) { | for (int i = 0; i < mesh->totvert; i++, mv++) { | ||||
| copy_v3_v3(r_cos[i], mv->co); | copy_v3_v3(r_cos[i], mv->co); | ||||
| if (r_size != NULL && ob_center == NULL) { | if (r_size != nullptr && ob_center == nullptr) { | ||||
| minmax_v3v3_v3(min_co, max_co, r_cos[i]); | minmax_v3v3_v3(min_co, max_co, r_cos[i]); | ||||
| } | } | ||||
| } | } | ||||
| /* Get size (i.e. deformation of the spheroid generating normals), | /* Get size (i.e. deformation of the spheroid generating normals), | ||||
| * either from target object, or own geometry. */ | * either from target object, or own geometry. */ | ||||
| if (r_size != NULL) { | if (r_size != nullptr) { | ||||
| if (ob_center != NULL) { | if (ob_center != nullptr) { | ||||
| /* Using 'scale' as 'size' here. The input object is typically an empty | /* Using 'scale' as 'size' here. The input object is typically an empty | ||||
| * who's scale is used to define an ellipsoid instead of a simple sphere. */ | * who's scale is used to define an ellipsoid instead of a simple sphere. */ | ||||
| /* Not we are not interested in signs here - they are even troublesome actually, | /* Not we are not interested in signs here - they are even troublesome actually, | ||||
| * due to security clamping! */ | * due to security clamping! */ | ||||
| abs_v3_v3(r_size, ob_center->scale); | abs_v3_v3(r_size, ob_center->scale); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Set size. */ | /* Set size. */ | ||||
| sub_v3_v3v3(r_size, max_co, min_co); | sub_v3_v3v3(r_size, max_co, min_co); | ||||
| } | } | ||||
| /* Error checks - we do not want one or more of our sizes to be null! */ | /* Error checks - we do not want one or more of our sizes to be null! */ | ||||
| if (is_zero_v3(r_size)) { | if (is_zero_v3(r_size)) { | ||||
| r_size[0] = r_size[1] = r_size[2] = 1.0f; | r_size[0] = r_size[1] = r_size[2] = 1.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| CLAMP_MIN(r_size[0], FLT_EPSILON); | CLAMP_MIN(r_size[0], FLT_EPSILON); | ||||
| CLAMP_MIN(r_size[1], FLT_EPSILON); | CLAMP_MIN(r_size[1], FLT_EPSILON); | ||||
| CLAMP_MIN(r_size[2], FLT_EPSILON); | CLAMP_MIN(r_size[2], FLT_EPSILON); | ||||
| } | } | ||||
| } | } | ||||
| if (ob_center != NULL) { | if (ob_center != nullptr) { | ||||
| float inv_obmat[4][4]; | float inv_obmat[4][4]; | ||||
| /* Translate our coordinates so that center of ob_center is at (0, 0, 0). */ | /* Translate our coordinates so that center of ob_center is at (0, 0, 0). */ | ||||
| /* Get ob_center (world) coordinates in ob local coordinates. | /* Get ob_center (world) coordinates in ob local coordinates. | ||||
| * No need to take into account ob_center's space here, see T44027. */ | * No need to take into account ob_center's space here, see T44027. */ | ||||
| invert_m4_m4(inv_obmat, ob->obmat); | invert_m4_m4(inv_obmat, ob->obmat); | ||||
| mul_v3_m4v3(diff, inv_obmat, ob_center->obmat[3]); | mul_v3_m4v3(diff, inv_obmat, ob_center->obmat[3]); | ||||
| negate_v3(diff); | negate_v3(diff); | ||||
| do_diff = true; | do_diff = true; | ||||
| } | } | ||||
| else if (offset != NULL && !is_zero_v3(offset)) { | else if (offset != nullptr && !is_zero_v3(offset)) { | ||||
| negate_v3_v3(diff, offset); | negate_v3_v3(diff, offset); | ||||
| do_diff = true; | do_diff = true; | ||||
| } | } | ||||
| /* Else, no need to change coordinates! */ | /* Else, no need to change coordinates! */ | ||||
| if (do_diff) { | if (do_diff) { | ||||
| int i = verts_num; | int i = verts_num; | ||||
| Show All 12 Lines | static void mix_normals(const float mix_factor, | ||||
| const short mix_mode, | const short mix_mode, | ||||
| const int verts_num, | const int verts_num, | ||||
| const MLoop *mloop, | const MLoop *mloop, | ||||
| float (*nos_old)[3], | float (*nos_old)[3], | ||||
| float (*nos_new)[3], | float (*nos_new)[3], | ||||
| const int loops_num) | const int loops_num) | ||||
| { | { | ||||
| /* Mix with org normals... */ | /* Mix with org normals... */ | ||||
| float *facs = NULL, *wfac; | float *facs = nullptr, *wfac; | ||||
| float(*no_new)[3], (*no_old)[3]; | float(*no_new)[3], (*no_old)[3]; | ||||
| int i; | int i; | ||||
| if (dvert) { | if (dvert) { | ||||
| facs = MEM_malloc_arrayN((size_t)loops_num, sizeof(*facs), __func__); | facs = static_cast<float *>(MEM_malloc_arrayN(size_t(loops_num), sizeof(*facs), __func__)); | ||||
| BKE_defvert_extract_vgroup_to_loopweights( | BKE_defvert_extract_vgroup_to_loopweights( | ||||
| dvert, defgrp_index, verts_num, mloop, loops_num, use_invert_vgroup, facs); | dvert, defgrp_index, verts_num, mloop, loops_num, use_invert_vgroup, facs); | ||||
| } | } | ||||
| for (i = loops_num, no_new = nos_new, no_old = nos_old, wfac = facs; i--; | for (i = loops_num, no_new = nos_new, no_old = nos_old, wfac = facs; i--; | ||||
| no_new++, no_old++, wfac++) { | no_new++, no_old++, wfac++) { | ||||
| const float fac = facs ? *wfac * mix_factor : mix_factor; | const float fac = facs ? *wfac * mix_factor : mix_factor; | ||||
| Show All 13 Lines | switch (mix_mode) { | ||||
| case MOD_NORMALEDIT_MIX_COPY: | case MOD_NORMALEDIT_MIX_COPY: | ||||
| break; | break; | ||||
| } | } | ||||
| interp_v3_v3v3_slerp_safe( | interp_v3_v3v3_slerp_safe( | ||||
| *no_new, | *no_new, | ||||
| *no_old, | *no_old, | ||||
| *no_new, | *no_new, | ||||
| (mix_limit < (float)M_PI) ? min_ff(fac, mix_limit / angle_v3v3(*no_new, *no_old)) : fac); | (mix_limit < float(M_PI)) ? min_ff(fac, mix_limit / angle_v3v3(*no_new, *no_old)) : fac); | ||||
| } | } | ||||
| MEM_SAFE_FREE(facs); | MEM_SAFE_FREE(facs); | ||||
| } | } | ||||
| /* Check poly normals and new loop normals are compatible, otherwise flip polygons | /* Check poly normals and new loop normals are compatible, otherwise flip polygons | ||||
| * (and invert matching poly normals). */ | * (and invert matching poly normals). */ | ||||
| static bool polygons_check_flip(MLoop *mloop, | static bool polygons_check_flip(MLoop *mloop, | ||||
| float (*nos)[3], | float (*nos)[3], | ||||
| CustomData *ldata, | CustomData *ldata, | ||||
| const MPoly *mpoly, | const MPoly *mpoly, | ||||
| float (*polynors)[3], | float (*polynors)[3], | ||||
| const int polys_num) | const int polys_num) | ||||
| { | { | ||||
| const MPoly *mp; | const MPoly *mp; | ||||
| MDisps *mdisp = CustomData_get_layer(ldata, CD_MDISPS); | MDisps *mdisp = static_cast<MDisps *>(CustomData_get_layer(ldata, CD_MDISPS)); | ||||
| int i; | int i; | ||||
| bool flipped = false; | bool flipped = false; | ||||
| for (i = 0, mp = mpoly; i < polys_num; i++, mp++) { | for (i = 0, mp = mpoly; i < polys_num; i++, mp++) { | ||||
| float norsum[3] = {0.0f}; | float norsum[3] = {0.0f}; | ||||
| float(*no)[3]; | float(*no)[3]; | ||||
| int j; | int j; | ||||
| Show All 38 Lines | static void normalEditModifier_do_radial(NormalEditModifierData *enmd, | ||||
| const MPoly *mpoly, | const MPoly *mpoly, | ||||
| const int polys_num) | const int polys_num) | ||||
| { | { | ||||
| Object *ob_target = enmd->target; | Object *ob_target = enmd->target; | ||||
| const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; | const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; | ||||
| int i; | int i; | ||||
| float(*cos)[3] = MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__); | float(*cos)[3] = static_cast<float(*)[3]>( | ||||
| float(*nos)[3] = MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__); | MEM_malloc_arrayN(size_t(verts_num), sizeof(*cos), __func__)); | ||||
| float(*nos)[3] = static_cast<float(*)[3]>( | |||||
| MEM_malloc_arrayN(size_t(loops_num), sizeof(*nos), __func__)); | |||||
| float size[3]; | float size[3]; | ||||
| BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)verts_num, __func__); | BLI_bitmap *done_verts = BLI_BITMAP_NEW(size_t(verts_num), __func__); | ||||
| generate_vert_coordinates(mesh, ob, ob_target, enmd->offset, verts_num, cos, size); | generate_vert_coordinates(mesh, ob, ob_target, enmd->offset, verts_num, cos, size); | ||||
| /** | /** | ||||
| * size gives us our spheroid coefficients `(A, B, C)`. | * size gives us our spheroid coefficients `(A, B, C)`. | ||||
| * Then, we want to find out for each vert its (a, b, c) triple (proportional to (A, B, C) one). | * Then, we want to find out for each vert its (a, b, c) triple (proportional to (A, B, C) one). | ||||
| * | * | ||||
| * Ellipsoid basic equation: `(x^2/a^2) + (y^2/b^2) + (z^2/c^2) = 1`. | * Ellipsoid basic equation: `(x^2/a^2) + (y^2/b^2) + (z^2/c^2) = 1`. | ||||
| ▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | static void normalEditModifier_do_directional(NormalEditModifierData *enmd, | ||||
| const MPoly *mpoly, | const MPoly *mpoly, | ||||
| const int polys_num) | const int polys_num) | ||||
| { | { | ||||
| Object *ob_target = enmd->target; | Object *ob_target = enmd->target; | ||||
| const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; | const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; | ||||
| const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0; | const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0; | ||||
| float(*nos)[3] = MEM_malloc_arrayN((size_t)loops_num, sizeof(*nos), __func__); | float(*nos)[3] = static_cast<float(*)[3]>( | ||||
| MEM_malloc_arrayN(size_t(loops_num), sizeof(*nos), __func__)); | |||||
| float target_co[3]; | float target_co[3]; | ||||
| int i; | int i; | ||||
| /* Get target's center coordinates in ob local coordinates. */ | /* Get target's center coordinates in ob local coordinates. */ | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| invert_m4_m4(mat, ob->obmat); | invert_m4_m4(mat, ob->obmat); | ||||
| mul_m4_m4m4(mat, mat, ob_target->obmat); | mul_m4_m4m4(mat, mat, ob_target->obmat); | ||||
| copy_v3_v3(target_co, mat[3]); | copy_v3_v3(target_co, mat[3]); | ||||
| if (use_parallel_normals) { | if (use_parallel_normals) { | ||||
| float no[3]; | float no[3]; | ||||
| sub_v3_v3v3(no, target_co, enmd->offset); | sub_v3_v3v3(no, target_co, enmd->offset); | ||||
| normalize_v3(no); | normalize_v3(no); | ||||
| for (i = loops_num; i--;) { | for (i = loops_num; i--;) { | ||||
| copy_v3_v3(nos[i], no); | copy_v3_v3(nos[i], no); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| float(*cos)[3] = MEM_malloc_arrayN((size_t)verts_num, sizeof(*cos), __func__); | float(*cos)[3] = static_cast<float(*)[3]>( | ||||
| generate_vert_coordinates(mesh, ob, ob_target, NULL, verts_num, cos, NULL); | MEM_malloc_arrayN(size_t(verts_num), sizeof(*cos), __func__)); | ||||
| generate_vert_coordinates(mesh, ob, ob_target, nullptr, verts_num, cos, nullptr); | |||||
| BLI_bitmap *done_verts = BLI_BITMAP_NEW((size_t)verts_num, __func__); | BLI_bitmap *done_verts = BLI_BITMAP_NEW(size_t(verts_num), __func__); | ||||
| const MLoop *ml; | const MLoop *ml; | ||||
| float(*no)[3]; | float(*no)[3]; | ||||
| /* We reuse cos to now store the 'to target' normal of the verts! */ | /* We reuse cos to now store the 'to target' normal of the verts! */ | ||||
| for (i = loops_num, no = nos, ml = mloop; i--; no++, ml++) { | for (i = loops_num, no = nos, ml = mloop; i--; no++, ml++) { | ||||
| const int vidx = ml->v; | const int vidx = ml->v; | ||||
| float *co = cos[vidx]; | float *co = cos[vidx]; | ||||
| ▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | |||||
| static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, | static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, | ||||
| const ModifierEvalContext *ctx, | const ModifierEvalContext *ctx, | ||||
| Object *ob, | Object *ob, | ||||
| Mesh *mesh) | Mesh *mesh) | ||||
| { | { | ||||
| const bool use_invert_vgroup = ((enmd->flag & MOD_NORMALEDIT_INVERT_VGROUP) != 0); | const bool use_invert_vgroup = ((enmd->flag & MOD_NORMALEDIT_INVERT_VGROUP) != 0); | ||||
| const bool use_current_clnors = !((enmd->mix_mode == MOD_NORMALEDIT_MIX_COPY) && | const bool use_current_clnors = !((enmd->mix_mode == MOD_NORMALEDIT_MIX_COPY) && | ||||
| (enmd->mix_factor == 1.0f) && (enmd->defgrp_name[0] == '\0') && | (enmd->mix_factor == 1.0f) && (enmd->defgrp_name[0] == '\0') && | ||||
| (enmd->mix_limit == (float)M_PI)); | (enmd->mix_limit == float(M_PI))); | ||||
| /* Do not run that modifier at all if autosmooth is disabled! */ | /* Do not run that modifier at all if autosmooth is disabled! */ | ||||
| if (!is_valid_target_with_error(ctx->object, enmd) || mesh->totloop == 0) { | if (!is_valid_target_with_error(ctx->object, enmd) || mesh->totloop == 0) { | ||||
| return mesh; | return mesh; | ||||
| } | } | ||||
| /* XXX TODO(Rohan Rathi): | /* XXX TODO(Rohan Rathi): | ||||
| * Once we fully switch to Mesh evaluation of modifiers, | * Once we fully switch to Mesh evaluation of modifiers, | ||||
| Show All 11 Lines | #endif | ||||
| return mesh; | return mesh; | ||||
| } | } | ||||
| Mesh *result; | Mesh *result; | ||||
| if (BKE_mesh_edges(mesh) == BKE_mesh_edges((Mesh *)ob->data)) { | if (BKE_mesh_edges(mesh) == BKE_mesh_edges((Mesh *)ob->data)) { | ||||
| /* We need to duplicate data here, otherwise setting custom normals | /* We need to duplicate data here, otherwise setting custom normals | ||||
| * (which may also affect sharp edges) could | * (which may also affect sharp edges) could | ||||
| * modify original mesh, see T43671. */ | * modify original mesh, see T43671. */ | ||||
| result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE); | result = (Mesh *)BKE_id_copy_ex(nullptr, &mesh->id, nullptr, LIB_ID_COPY_LOCALIZE); | ||||
| } | } | ||||
| else { | else { | ||||
| result = mesh; | result = mesh; | ||||
| } | } | ||||
| const int verts_num = result->totvert; | const int verts_num = result->totvert; | ||||
| const int edges_num = result->totedge; | const int edges_num = result->totedge; | ||||
| const int loops_num = result->totloop; | const int loops_num = result->totloop; | ||||
| const int polys_num = result->totpoly; | const int polys_num = result->totpoly; | ||||
| const MVert *verts = BKE_mesh_verts(result); | const MVert *verts = BKE_mesh_verts(result); | ||||
| MEdge *edges = BKE_mesh_edges_for_write(result); | MEdge *edges = BKE_mesh_edges_for_write(result); | ||||
| const MPoly *polys = BKE_mesh_polys(result); | const MPoly *polys = BKE_mesh_polys(result); | ||||
| MLoop *loops = BKE_mesh_loops_for_write(result); | MLoop *loops = BKE_mesh_loops_for_write(result); | ||||
| int defgrp_index; | int defgrp_index; | ||||
| const MDeformVert *dvert; | const MDeformVert *dvert; | ||||
| float(*loopnors)[3] = NULL; | float(*loopnors)[3] = nullptr; | ||||
| CustomData *ldata = &result->ldata; | CustomData *ldata = &result->ldata; | ||||
| const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(result); | const float(*vert_normals)[3] = BKE_mesh_vertex_normals_ensure(result); | ||||
| const float(*poly_normals)[3] = BKE_mesh_poly_normals_ensure(result); | const float(*poly_normals)[3] = BKE_mesh_poly_normals_ensure(result); | ||||
| short(*clnors)[2] = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL); | short(*clnors)[2] = static_cast<short(*)[2]>(CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL)); | ||||
| if (use_current_clnors) { | if (use_current_clnors) { | ||||
| clnors = CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, loops_num); | clnors = static_cast<short(*)[2]>( | ||||
| loopnors = MEM_malloc_arrayN((size_t)loops_num, sizeof(*loopnors), __func__); | CustomData_duplicate_referenced_layer(ldata, CD_CUSTOMLOOPNORMAL, loops_num)); | ||||
| loopnors = static_cast<float(*)[3]>( | |||||
| MEM_malloc_arrayN(size_t(loops_num), sizeof(*loopnors), __func__)); | |||||
| BKE_mesh_normals_loop_split(verts, | BKE_mesh_normals_loop_split(verts, | ||||
| vert_normals, | vert_normals, | ||||
| verts_num, | verts_num, | ||||
| edges, | edges, | ||||
| edges_num, | edges_num, | ||||
| loops, | loops, | ||||
| loopnors, | loopnors, | ||||
| loops_num, | loops_num, | ||||
| polys, | polys, | ||||
| poly_normals, | poly_normals, | ||||
| polys_num, | polys_num, | ||||
| true, | true, | ||||
| result->smoothresh, | result->smoothresh, | ||||
| NULL, | nullptr, | ||||
| clnors, | clnors, | ||||
| NULL); | nullptr); | ||||
| } | } | ||||
| if (clnors == NULL) { | if (clnors == nullptr) { | ||||
| clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, loops_num); | clnors = static_cast<short(*)[2]>( | ||||
| CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, loops_num)); | |||||
| } | } | ||||
| MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index); | MOD_get_vgroup(ob, result, enmd->defgrp_name, &dvert, &defgrp_index); | ||||
| if (enmd->mode == MOD_NORMALEDIT_MODE_RADIAL) { | if (enmd->mode == MOD_NORMALEDIT_MODE_RADIAL) { | ||||
| normalEditModifier_do_radial(enmd, | normalEditModifier_do_radial(enmd, | ||||
| ctx, | ctx, | ||||
| ob, | ob, | ||||
| ▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | static void panel_draw(const bContext *UNUSED(C), Panel *panel) | ||||
| uiLayout *col; | uiLayout *col; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA ob_ptr; | PointerRNA ob_ptr; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | ||||
| int mode = RNA_enum_get(ptr, "mode"); | int mode = RNA_enum_get(ptr, "mode"); | ||||
| uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "target", 0, nullptr, ICON_NONE); | ||||
| col = uiLayoutColumn(layout, false); | col = uiLayoutColumn(layout, false); | ||||
| uiLayoutSetActive(col, mode == MOD_NORMALEDIT_MODE_DIRECTIONAL); | uiLayoutSetActive(col, mode == MOD_NORMALEDIT_MODE_DIRECTIONAL); | ||||
| uiItemR(col, ptr, "use_direction_parallel", 0, NULL, ICON_NONE); | uiItemR(col, ptr, "use_direction_parallel", 0, nullptr, ICON_NONE); | ||||
| modifier_panel_end(layout, ptr); | modifier_panel_end(layout, ptr); | ||||
| } | } | ||||
| /* This panel could be open by default, but it isn't currently. */ | /* This panel could be open by default, but it isn't currently. */ | ||||
| static void mix_mode_panel_draw(const bContext *UNUSED(C), Panel *panel) | static void mix_mode_panel_draw(const bContext *UNUSED(C), Panel *panel) | ||||
| { | { | ||||
| uiLayout *row; | uiLayout *row; | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA ob_ptr; | PointerRNA ob_ptr; | ||||
| PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| uiItemR(layout, ptr, "mix_mode", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "mix_mode", 0, nullptr, ICON_NONE); | ||||
| uiItemR(layout, ptr, "mix_factor", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "mix_factor", 0, nullptr, ICON_NONE); | ||||
| modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL); | modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr); | ||||
| row = uiLayoutRow(layout, true); | row = uiLayoutRow(layout, true); | ||||
| uiItemR(row, ptr, "mix_limit", 0, NULL, ICON_NONE); | uiItemR(row, ptr, "mix_limit", 0, nullptr, ICON_NONE); | ||||
| uiItemR(row, | uiItemR(row, | ||||
| ptr, | ptr, | ||||
| "no_polynors_fix", | "no_polynors_fix", | ||||
| 0, | 0, | ||||
| "", | "", | ||||
| (RNA_boolean_get(ptr, "no_polynors_fix") ? ICON_LOCKED : ICON_UNLOCKED)); | (RNA_boolean_get(ptr, "no_polynors_fix") ? ICON_LOCKED : ICON_UNLOCKED)); | ||||
| } | } | ||||
| static void offset_panel_draw(const bContext *UNUSED(C), Panel *panel) | static void offset_panel_draw(const bContext *UNUSED(C), Panel *panel) | ||||
| { | { | ||||
| 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); | ||||
| int mode = RNA_enum_get(ptr, "mode"); | int mode = RNA_enum_get(ptr, "mode"); | ||||
| PointerRNA target_ptr = RNA_pointer_get(ptr, "target"); | PointerRNA target_ptr = RNA_pointer_get(ptr, "target"); | ||||
| bool needs_object_offset = (mode == MOD_NORMALEDIT_MODE_RADIAL && | bool needs_object_offset = (mode == MOD_NORMALEDIT_MODE_RADIAL && | ||||
| RNA_pointer_is_null(&target_ptr)) || | RNA_pointer_is_null(&target_ptr)) || | ||||
| (mode == MOD_NORMALEDIT_MODE_DIRECTIONAL && | (mode == MOD_NORMALEDIT_MODE_DIRECTIONAL && | ||||
| RNA_boolean_get(ptr, "use_direction_parallel")); | RNA_boolean_get(ptr, "use_direction_parallel")); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| uiLayoutSetActive(layout, needs_object_offset); | uiLayoutSetActive(layout, needs_object_offset); | ||||
| uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "offset", 0, nullptr, ICON_NONE); | ||||
| } | } | ||||
| static void panelRegister(ARegionType *region_type) | static void panelRegister(ARegionType *region_type) | ||||
| { | { | ||||
| PanelType *panel_type = modifier_panel_register( | PanelType *panel_type = modifier_panel_register( | ||||
| region_type, eModifierType_NormalEdit, panel_draw); | region_type, eModifierType_NormalEdit, panel_draw); | ||||
| modifier_subpanel_register(region_type, "mix", "Mix", NULL, mix_mode_panel_draw, panel_type); | modifier_subpanel_register(region_type, "mix", "Mix", nullptr, mix_mode_panel_draw, panel_type); | ||||
| modifier_subpanel_register(region_type, "offset", "Offset", NULL, offset_panel_draw, panel_type); | modifier_subpanel_register( | ||||
| region_type, "offset", "Offset", nullptr, offset_panel_draw, panel_type); | |||||
| } | } | ||||
| ModifierTypeInfo modifierType_NormalEdit = { | ModifierTypeInfo modifierType_NormalEdit = { | ||||
| /* name */ N_("NormalEdit"), | /* name */ N_("NormalEdit"), | ||||
| /* structName */ "NormalEditModifierData", | /* structName */ "NormalEditModifierData", | ||||
| /* structSize */ sizeof(NormalEditModifierData), | /* structSize */ sizeof(NormalEditModifierData), | ||||
| /* srna */ &RNA_NormalEditModifier, | /* srna */ &RNA_NormalEditModifier, | ||||
| /* type */ eModifierTypeType_Constructive, | /* type */ eModifierTypeType_Constructive, | ||||
| /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping | | /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsMapping | | ||||
| eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode, | eModifierTypeFlag_SupportsEditmode | eModifierTypeFlag_EnableInEditmode, | ||||
| /* icon */ ICON_MOD_NORMALEDIT, | /* icon */ ICON_MOD_NORMALEDIT, | ||||
| /* 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 */ requiredDataMask, | /* requiredDataMask */ requiredDataMask, | ||||
| /* freeData */ NULL, | /* freeData */ nullptr, | ||||
| /* isDisabled */ isDisabled, | /* isDisabled */ isDisabled, | ||||
| /* updateDepsgraph */ updateDepsgraph, | /* updateDepsgraph */ updateDepsgraph, | ||||
| /* dependsOnTime */ NULL, | /* dependsOnTime */ nullptr, | ||||
| /* dependsOnNormals */ dependsOnNormals, | /* dependsOnNormals */ dependsOnNormals, | ||||
| /* foreachIDLink */ foreachIDLink, | /* foreachIDLink */ foreachIDLink, | ||||
| /* foreachTexLink */ NULL, | /* foreachTexLink */ nullptr, | ||||
| /* freeRuntimeData */ NULL, | /* freeRuntimeData */ nullptr, | ||||
| /* panelRegister */ panelRegister, | /* panelRegister */ panelRegister, | ||||
| /* blendWrite */ NULL, | /* blendWrite */ nullptr, | ||||
| /* blendRead */ NULL, | /* blendRead */ nullptr, | ||||
| }; | }; | ||||