|
Blender
V2.93
|
#include <string.h>#include "MEM_guardedalloc.h"#include "BLI_utildefines.h"#include "BLI_bitmap.h"#include "BLI_math.h"#include "BLT_translation.h"#include "DNA_defaults.h"#include "DNA_mesh_types.h"#include "DNA_meshdata_types.h"#include "DNA_object_types.h"#include "DNA_screen_types.h"#include "BKE_context.h"#include "BKE_deform.h"#include "BKE_lib_id.h"#include "BKE_lib_query.h"#include "BKE_mesh.h"#include "BKE_screen.h"#include "UI_interface.h"#include "UI_resources.h"#include "RNA_access.h"#include "DEG_depsgraph_query.h"#include "MOD_ui_common.h"#include "MOD_util.h"Go to the source code of this file.
Functions | |
| static void | generate_vert_coordinates (Mesh *mesh, Object *ob, Object *ob_center, const float offset[3], const int num_verts, float(*r_cos)[3], float r_size[3]) |
| static void | mix_normals (const float mix_factor, MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, const float mix_limit, const short mix_mode, const int num_verts, MLoop *mloop, float(*nos_old)[3], float(*nos_new)[3], const int num_loops) |
| static bool | polygons_check_flip (MLoop *mloop, float(*nos)[3], CustomData *ldata, MPoly *mpoly, float(*polynors)[3], const int num_polys) |
| static void | normalEditModifier_do_radial (NormalEditModifierData *enmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, short(*clnors)[2], float(*loopnors)[3], float(*polynors)[3], const short mix_mode, const float mix_factor, const float mix_limit, MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) |
| static void | normalEditModifier_do_directional (NormalEditModifierData *enmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, short(*clnors)[2], float(*loopnors)[3], float(*polynors)[3], const short mix_mode, const float mix_factor, const float mix_limit, MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) |
| static bool | is_valid_target (NormalEditModifierData *enmd) |
| static bool | is_valid_target_with_error (const Object *ob, NormalEditModifierData *enmd) |
| static Mesh * | normalEditModifier_do (NormalEditModifierData *enmd, const ModifierEvalContext *ctx, Object *ob, Mesh *mesh) |
| static void | initData (ModifierData *md) |
| static void | requiredDataMask (Object *UNUSED(ob), ModifierData *md, CustomData_MeshMasks *r_cddata_masks) |
| static bool | dependsOnNormals (ModifierData *UNUSED(md)) |
| static void | foreachIDLink (ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) |
| static bool | isDisabled (const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams)) |
| static void | updateDepsgraph (ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) |
| static Mesh * | modifyMesh (ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) |
| static void | panel_draw (const bContext *UNUSED(C), Panel *panel) |
| static void | mix_mode_panel_draw (const bContext *UNUSED(C), Panel *panel) |
| static void | offset_panel_draw (const bContext *UNUSED(C), Panel *panel) |
| static void | panelRegister (ARegionType *region_type) |
Variables | |
| ModifierTypeInfo | modifierType_NormalEdit |
|
static |
Definition at line 678 of file MOD_normal_edit.c.
|
static |
Definition at line 683 of file MOD_normal_edit.c.
References IDWALK_CB_NOP, and NormalEditModifierData::target.
|
static |
Definition at line 55 of file MOD_normal_edit.c.
References abs_v3_v3(), add_v3_v3(), CLAMP_MIN, copy_v3_v3(), KDL::diff(), INIT_MINMAX, invert_m4_m4(), is_zero_v3(), mesh, minmax_v3v3_v3(), mul_v3_m4v3(), Mesh::mvert, negate_v3(), negate_v3_v3(), NULL, Object::obmat, Object::scale, sub_v3_v3v3(), and Mesh::totvert.
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 655 of file MOD_normal_edit.c.
References BLI_assert, DNA_struct_default_get, MEMCMP_STRUCT_AFTER_IS_ZERO, and MEMCPY_STRUCT_AFTER.
|
static |
Definition at line 471 of file MOD_normal_edit.c.
References MOD_NORMALEDIT_MODE_DIRECTIONAL, MOD_NORMALEDIT_MODE_RADIAL, NormalEditModifierData::mode, and NormalEditModifierData::target.
Referenced by is_valid_target_with_error(), and isDisabled().
|
static |
Definition at line 482 of file MOD_normal_edit.c.
References BKE_modifier_set_error(), and is_valid_target().
Referenced by normalEditModifier_do().
|
static |
Definition at line 690 of file MOD_normal_edit.c.
References is_valid_target().
Definition at line 737 of file MOD_normal_edit.c.
References Panel::layout, modifier_panel_get_property_pointers(), modifier_vgroup_ui(), NULL, ptr, RNA_boolean_get(), uiItemR(), uiLayoutRow(), and uiLayoutSetPropSep().
Referenced by panelRegister().
|
static |
Definition at line 132 of file MOD_normal_edit.c.
References add_v3_v3(), angle_v3v3(), BKE_defvert_extract_vgroup_to_loopweights(), float(), interp_v3_v3v3_slerp_safe(), M_PI, MEM_malloc_arrayN, MEM_SAFE_FREE, min_ff(), MOD_NORMALEDIT_MIX_ADD, MOD_NORMALEDIT_MIX_COPY, MOD_NORMALEDIT_MIX_MUL, MOD_NORMALEDIT_MIX_SUB, mul_v3_v3(), normalize_v3(), NULL, and sub_v3_v3().
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 708 of file MOD_normal_edit.c.
References mesh, normalEditModifier_do(), and ModifierEvalContext::object.
|
static |
Definition at line 491 of file MOD_normal_edit.c.
References BKE_id_copy_ex(), BKE_mesh_calc_normals_poly(), BKE_mesh_normals_loop_split(), BKE_modifier_set_error(), CD_CALLOC, CD_CUSTOMLOOPNORMAL, CD_FLAG_TEMPORARY, CD_MASK_NORMAL, CD_NORMAL, CustomData_add_layer(), CustomData_duplicate_referenced_layer(), CustomData_free_layers(), CustomData_get_layer(), CustomData_set_layer_flag(), Object::data, NormalEditModifierData::defgrp_name, Mesh::flag, NormalEditModifierData::flag, float(), Mesh::id, is_valid_target_with_error(), LIB_ID_COPY_LOCALIZE, M_PI, ME_AUTOSMOOTH, Mesh::medge, MEM_malloc_arrayN, MEM_SAFE_FREE, mesh, NormalEditModifierData::mix_factor, NormalEditModifierData::mix_limit, NormalEditModifierData::mix_mode, MOD_get_vgroup(), MOD_NORMALEDIT_INVERT_VGROUP, MOD_NORMALEDIT_MIX_COPY, MOD_NORMALEDIT_MODE_DIRECTIONAL, MOD_NORMALEDIT_MODE_RADIAL, NormalEditModifierData::mode, normalEditModifier_do_directional(), normalEditModifier_do_radial(), NULL, ModifierEvalContext::object, result, and Mesh::totloop.
Referenced by modifyMesh().
|
static |
Definition at line 361 of file MOD_normal_edit.c.
References BKE_mesh_normals_loop_custom_set(), BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, Mesh_Runtime::cd_dirty_vert, CD_MASK_NORMAL, copy_v3_v3(), KDL::cos(), NormalEditModifierData::flag, float(), generate_vert_coordinates(), invert_m4_m4(), Mesh::ldata, MEM_freeN, MEM_malloc_arrayN, mesh, mix_normals(), MOD_NORMALEDIT_NO_POLYNORS_FIX, MOD_NORMALEDIT_USE_DIRECTION_PARALLEL, mul_m4_m4m4(), normalize_v3(), NULL, Object::obmat, NormalEditModifierData::offset, polygons_check_flip(), Mesh::runtime, sub_v3_v3v3(), NormalEditModifierData::target, and MLoop::v.
Referenced by normalEditModifier_do().
|
static |
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).
Ellipsoid basic equation: (x^2/a^2) + (y^2/b^2) + (z^2/c^2) = 1. Since we want to find (a, b, c) matching this equation and proportional to (A, B, C), we can do:
m = B / A
n = C / A
hence:
(x^2/a^2) + (y^2/b^2) + (z^2/c^2) = 1
-> b^2*c^2*x^2 + a^2*c^2*y^2 + a^2*b^2*z^2 = a^2*b^2*c^2
b = ma
c = na
-> m^2*a^2*n^2*a^2*x^2 + a^2*n^2*a^2*y^2 + a^2*m^2*a^2*z^2 = a^2*m^2*a^2*n^2*a^2
-> m^2*n^2*a^4*x^2 + n^2*a^4*y^2 + m^2*a^4*z^2 = m^2*n^2*a^6
-> a^2 = (m^2*n^2*x^2 + n^2y^2 + m^2z^2) / (m^2*n^2) = x^2 + (y^2 / m^2) + (z^2 / n^2)
-> b^2 = (m^2*n^2*x^2 + n^2y^2 + m^2z^2) / (n^2) = (m^2 * x^2) + y^2 + (m^2 * z^2 / n^2)
-> c^2 = (m^2*n^2*x^2 + n^2y^2 + m^2z^2) / (m^2) = (n^2 * x^2) + (n^2 * y^2 / m^2) + z^2
All we have to do now is compute normal of the spheroid at that point:
n = (x / a^2, y / b^2, z / c^2)
And we are done!
Definition at line 224 of file MOD_normal_edit.c.
References Freestyle::a, BKE_mesh_calc_normals(), BKE_mesh_normals_loop_custom_set(), BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, Freestyle::c, copy_v3_v3(), KDL::cos(), NormalEditModifierData::flag, float(), generate_vert_coordinates(), Mesh::ldata, MEM_freeN, MEM_malloc_arrayN, mesh, mix_normals(), MOD_NORMALEDIT_NO_POLYNORS_FIX, normalize_v3(), NormalEditModifierData::offset, polygons_check_flip(), size(), NormalEditModifierData::target, MLoop::v, and x2.
Referenced by normalEditModifier_do().
Definition at line 762 of file MOD_normal_edit.c.
References Panel::layout, MOD_NORMALEDIT_MODE_DIRECTIONAL, MOD_NORMALEDIT_MODE_RADIAL, modifier_panel_get_property_pointers(), NULL, ptr, RNA_boolean_get(), RNA_enum_get(), RNA_pointer_get(), RNA_pointer_is_null(), uiItemR(), uiLayoutSetActive(), and uiLayoutSetPropSep().
Referenced by panelRegister().
Definition at line 713 of file MOD_normal_edit.c.
References col, Panel::layout, MOD_NORMALEDIT_MODE_DIRECTIONAL, modifier_panel_end(), modifier_panel_get_property_pointers(), NULL, ptr, RNA_enum_get(), UI_ITEM_R_EXPAND, uiItemR(), uiLayoutColumn(), uiLayoutSetActive(), and uiLayoutSetPropSep().
Referenced by panelRegister().
|
static |
Definition at line 781 of file MOD_normal_edit.c.
References eModifierType_NormalEdit, mix_mode_panel_draw(), modifier_panel_register(), modifier_subpanel_register(), NULL, offset_panel_draw(), and panel_draw().
|
static |
Definition at line 188 of file MOD_normal_edit.c.
References add_v3_v3(), BKE_mesh_polygon_flip_ex(), CD_MDISPS, CustomData_get_layer(), dot_v3v3(), float(), MPoly::loopstart, negate_v3(), and normalize_v3().
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 664 of file MOD_normal_edit.c.
References CD_MASK_CUSTOMLOOPNORMAL, CD_MASK_MDEFORMVERT, NormalEditModifierData::defgrp_name, CustomData_MeshMasks::lmask, and CustomData_MeshMasks::vmask.
|
static |
Definition at line 699 of file MOD_normal_edit.c.
References DEG_add_modifier_to_transform_relation(), DEG_add_object_relation(), DEG_OB_COMP_TRANSFORM, ModifierUpdateDepsgraphContext::node, and NormalEditModifierData::target.
| ModifierTypeInfo modifierType_NormalEdit |
Definition at line 789 of file MOD_normal_edit.c.