|
Blender V4.3
|
#include <cstring>#include "MEM_guardedalloc.h"#include "BLI_utildefines.h"#include "BLI_bitmap.h"#include "BLI_math_matrix.h"#include "BLI_math_vector.h"#include "BLT_translation.hh"#include "DNA_defaults.h"#include "DNA_mesh_types.h"#include "DNA_object_types.h"#include "DNA_screen_types.h"#include "BKE_attribute.hh"#include "BKE_customdata.hh"#include "BKE_deform.hh"#include "BKE_lib_id.hh"#include "BKE_lib_query.hh"#include "BKE_mesh.hh"#include "UI_interface.hh"#include "UI_resources.hh"#include "RNA_access.hh"#include "RNA_prototypes.hh"#include "MOD_ui_common.hh"#include "MOD_util.hh"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 verts_num, float(*r_cos)[3], float r_size[3]) |
| static void | mix_normals (const float mix_factor, const MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, const float mix_limit, const short mix_mode, const int verts_num, const blender::Span< int > corner_verts, blender::float3 *nos_old, blender::float3 *nos_new) |
| static void | faces_check_flip (Mesh &mesh, blender::MutableSpan< blender::float3 > nos, const blender::Span< blender::float3 > face_normals) |
| static void | normalEditModifier_do_radial (NormalEditModifierData *enmd, const ModifierEvalContext *, Object *ob, Mesh *mesh, blender::MutableSpan< blender::short2 > clnors, blender::MutableSpan< blender::float3 > corner_normals, const short mix_mode, const float mix_factor, const float mix_limit, const MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, blender::Span< blender::float3 > vert_positions, const blender::Span< blender::int2 > edges, blender::MutableSpan< bool > sharp_edges, blender::MutableSpan< int > corner_verts, blender::MutableSpan< int > corner_edges, const blender::OffsetIndices< int > faces) |
| static void | normalEditModifier_do_directional (NormalEditModifierData *enmd, const ModifierEvalContext *, Object *ob, Mesh *mesh, blender::MutableSpan< blender::short2 > clnors, blender::MutableSpan< blender::float3 > corner_normals, const short mix_mode, const float mix_factor, const float mix_limit, const MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, const blender::Span< blender::float3 > positions, const blender::Span< blender::int2 > edges, blender::MutableSpan< bool > sharp_edges, blender::MutableSpan< int > corner_verts, blender::MutableSpan< int > corner_edges, const blender::OffsetIndices< int > faces) |
| 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 | init_data (ModifierData *md) |
| static void | required_data_mask (ModifierData *md, CustomData_MeshMasks *r_cddata_masks) |
| static void | foreach_ID_link (ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data) |
| static bool | is_disabled (const Scene *, ModifierData *md, bool) |
| static void | update_depsgraph (ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) |
| static Mesh * | modify_mesh (ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh) |
| static void | panel_draw (const bContext *, Panel *panel) |
| static void | mix_mode_panel_draw (const bContext *, Panel *panel) |
| static void | offset_panel_draw (const bContext *, Panel *panel) |
| static void | panel_register (ARegionType *region_type) |
Variables | |
| ModifierTypeInfo | modifierType_NormalEdit |
|
static |
Definition at line 182 of file MOD_normal_edit.cc.
References add_v3_v3(), dot_v3v3(), normalize_v3(), blender::MutableSpan< T >::reverse(), and blender::MutableSpan< T >::slice().
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 604 of file MOD_normal_edit.cc.
References IDWALK_CB_NOP, and NormalEditModifierData::target.
|
static |
Definition at line 42 of file MOD_normal_edit.cc.
References abs_v3_v3(), add_v3_v3(), CLAMP_MIN, copy_v3_v3(), diff(), INIT_MINMAX, invert_m4_m4(), is_zero_v3(), minmax_v3v3_v3(), mul_v3_m4v3(), negate_v3(), negate_v3_v3(), Object::scale, and sub_v3_v3v3().
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 583 of file MOD_normal_edit.cc.
References BLI_assert, DNA_struct_default_get, MEMCMP_STRUCT_AFTER_IS_ZERO, and MEMCPY_STRUCT_AFTER.
|
static |
Definition at line 611 of file MOD_normal_edit.cc.
References is_valid_target().
|
static |
Definition at line 442 of file MOD_normal_edit.cc.
References MOD_NORMALEDIT_MODE_DIRECTIONAL, MOD_NORMALEDIT_MODE_RADIAL, NormalEditModifierData::mode, and NormalEditModifierData::target.
Referenced by is_disabled(), and is_valid_target_with_error().
|
static |
Definition at line 453 of file MOD_normal_edit.cc.
References BKE_modifier_set_error(), and is_valid_target().
Referenced by normalEditModifier_do().
Definition at line 656 of file MOD_normal_edit.cc.
References Panel::layout, modifier_panel_get_property_pointers(), modifier_vgroup_ui(), ptr, RNA_boolean_get(), UI_ITEM_NONE, uiItemR(), uiLayoutRow(), and uiLayoutSetPropSep().
Referenced by panel_register().
|
static |
Definition at line 120 of file MOD_normal_edit.cc.
References add_v3_v3(), angle_v3v3(), BKE_defvert_extract_vgroup_to_loopweights(), blender::Span< T >::data(), 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(), blender::Span< T >::size(), and sub_v3_v3().
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 627 of file MOD_normal_edit.cc.
References normalEditModifier_do(), and ModifierEvalContext::object.
|
static |
Definition at line 462 of file MOD_normal_edit.cc.
References BKE_id_copy_ex(), CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, CustomData_add_layer(), CustomData_get_layer_for_write(), Object::data, NormalEditModifierData::defgrp_name, faces, blender::bke::SpanAttributeWriter< T >::finish(), NormalEditModifierData::flag, is_valid_target_with_error(), LIB_ID_COPY_LOCALIZE, M_PI, 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(), blender::bke::mesh::normals_calc_corners(), ModifierEvalContext::object, blender::Array< T, InlineBufferCapacity, Allocator >::reinitialize(), result, blender::MutableSpan< T >::size(), and blender::bke::SpanAttributeWriter< T >::span.
Referenced by modify_mesh().
|
static |
Definition at line 339 of file MOD_normal_edit.cc.
References BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, copy_v3_v3(), cos(), blender::Array< T, InlineBufferCapacity, Allocator >::data(), blender::MutableSpan< T >::data(), faces_check_flip(), NormalEditModifierData::flag, float, generate_vert_coordinates(), blender::MutableSpan< T >::index_range(), invert_m4_m4(), blender::MutableSpan< T >::is_empty(), MEM_freeN(), MEM_malloc_arrayN, mix_normals(), MOD_NORMALEDIT_NO_POLYNORS_FIX, MOD_NORMALEDIT_USE_DIRECTION_PARALLEL, mul_m4_m4m4(), normalize_v3(), NormalEditModifierData::offset, blender::MutableSpan< T >::size(), sub_v3_v3v3(), and NormalEditModifierData::target.
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 212 of file MOD_normal_edit.cc.
References b, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, cos(), blender::Array< T, InlineBufferCapacity, Allocator >::data(), blender::MutableSpan< T >::data(), faces_check_flip(), NormalEditModifierData::flag, float, generate_vert_coordinates(), blender::MutableSpan< T >::index_range(), blender::MutableSpan< T >::is_empty(), MEM_freeN(), MEM_malloc_arrayN, mix_normals(), MOD_NORMALEDIT_NO_POLYNORS_FIX, normalize_v3(), NormalEditModifierData::offset, blender::MutableSpan< T >::size(), blender::Span< T >::size(), and NormalEditModifierData::target.
Referenced by normalEditModifier_do().
Definition at line 681 of file MOD_normal_edit.cc.
References Panel::layout, MOD_NORMALEDIT_MODE_DIRECTIONAL, MOD_NORMALEDIT_MODE_RADIAL, modifier_panel_get_property_pointers(), ptr, RNA_boolean_get(), RNA_enum_get(), RNA_pointer_get(), RNA_pointer_is_null(), UI_ITEM_NONE, uiItemR(), uiLayoutSetActive(), and uiLayoutSetPropSep().
Referenced by panel_register().
Definition at line 632 of file MOD_normal_edit.cc.
References col, Panel::layout, MOD_NORMALEDIT_MODE_DIRECTIONAL, modifier_panel_end(), modifier_panel_get_property_pointers(), ptr, RNA_enum_get(), UI_ITEM_NONE, UI_ITEM_R_EXPAND, uiItemR(), uiLayoutColumn(), uiLayoutSetActive(), and uiLayoutSetPropSep().
Referenced by panel_register().
|
static |
Definition at line 700 of file MOD_normal_edit.cc.
References eModifierType_NormalEdit, mix_mode_panel_draw(), modifier_panel_register(), modifier_subpanel_register(), offset_panel_draw(), and panel_draw().
|
static |
Definition at line 592 of file MOD_normal_edit.cc.
References CD_MASK_CUSTOMLOOPNORMAL, CD_MASK_MDEFORMVERT, NormalEditModifierData::defgrp_name, CustomData_MeshMasks::lmask, and CustomData_MeshMasks::vmask.
|
static |
Definition at line 618 of file MOD_normal_edit.cc.
References DEG_add_depends_on_transform_relation(), DEG_add_object_relation(), DEG_OB_COMP_TRANSFORM, ModifierUpdateDepsgraphContext::node, and NormalEditModifierData::target.
| ModifierTypeInfo modifierType_NormalEdit |
Definition at line 709 of file MOD_normal_edit.cc.