|
Blender V5.0
|
#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 "BLI_math_vector.hh"#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_deform.hh"#include "BKE_lib_id.hh"#include "BKE_lib_query.hh"#include "BKE_mesh.hh"#include "UI_interface_layout.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], blender::float3 *r_size) |
| 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, 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, 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 176 of file MOD_normal_edit.cc.
References add_v3_v3(), dot_v3v3(), faces, IndexMask::from_predicate(), i, blender::bke::mesh_flip_faces(), normalize_v3(), blender::MutableSpan< T >::reverse(), and blender::MutableSpan< T >::slice().
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 582 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 blender::math::abs(), add_v3_v3(), CLAMP_MIN, copy_v3_v3(), diff(), i, INIT_MINMAX, invert_m4_m4(), is_zero_v3(), minmax_v3v3_v3(), mul_v3_m4v3(), negate_v3(), negate_v3_v3(), Object::scale, sub_v3_v3v3(), and Mesh::verts_num.
Referenced by normalEditModifier_do_directional(), and normalEditModifier_do_radial().
|
static |
Definition at line 563 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 589 of file MOD_normal_edit.cc.
References is_valid_target().
|
static |
Definition at line 432 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 443 of file MOD_normal_edit.cc.
References BKE_modifier_set_error(), and is_valid_target().
Referenced by normalEditModifier_do().
Definition at line 634 of file MOD_normal_edit.cc.
References Panel::layout, modifier_panel_get_property_pointers(), modifier_vgroup_ui(), uiLayout::prop(), ptr, RNA_boolean_get(), uiLayout::row(), UI_ITEM_NONE, and uiLayout::use_property_split_set().
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(), i, 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 605 of file MOD_normal_edit.cc.
References normalEditModifier_do(), and ModifierEvalContext::object.
|
static |
Definition at line 452 of file MOD_normal_edit.cc.
References BKE_id_copy_ex(), blender::bke::Corner, Mesh::corners_num, Object::data, NormalEditModifierData::defgrp_name, blender::bke::Edge, blender::bke::Face, faces, blender::bke::SpanAttributeWriter< T >::finish(), NormalEditModifierData::flag, float, Mesh::id, is_valid_target_with_error(), LIB_ID_COPY_LOCALIZE, blender::bke::AttributeAccessor::lookup(), blender::bke::MutableAttributeAccessor::lookup_or_add_for_write_span(), M_PI, 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 331 of file MOD_normal_edit.cc.
References Geometry::attributes, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, copy_v3_v3(), cos, blender::Array< T, InlineBufferCapacity, Allocator >::data(), blender::MutableSpan< T >::data(), blender::bke::Face, faces, faces_check_flip(), NormalEditModifierData::flag, float, generate_vert_coordinates(), i, blender::MutableSpan< T >::index_range(), invert_m4_m4(), blender::MutableSpan< T >::is_empty(), blender::bke::AttributeAccessor::lookup(), MEM_freeN(), MEM_malloc_arrayN(), mix_normals(), MOD_NORMALEDIT_NO_POLYNORS_FIX, MOD_NORMALEDIT_USE_DIRECTION_PARALLEL, mul_m4_m4m4(), normalize_v3(), blender::bke::mesh::normals_corner_custom_set(), NormalEditModifierData::offset, blender::MutableSpan< T >::size(), blender::Span< 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 206 of file MOD_normal_edit.cc.
References Geometry::attributes, b, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, cos, blender::Array< T, InlineBufferCapacity, Allocator >::data(), blender::MutableSpan< T >::data(), blender::bke::Face, faces, faces_check_flip(), NormalEditModifierData::flag, float, generate_vert_coordinates(), i, blender::MutableSpan< T >::index_range(), blender::MutableSpan< T >::is_empty(), blender::bke::AttributeAccessor::lookup(), MEM_freeN(), MEM_malloc_arrayN(), mix_normals(), MOD_NORMALEDIT_NO_POLYNORS_FIX, normalize_v3(), blender::bke::mesh::normals_corner_custom_set(), NormalEditModifierData::offset, blender::MutableSpan< T >::size(), blender::Span< T >::size(), size(), and NormalEditModifierData::target.
Referenced by normalEditModifier_do().
Definition at line 658 of file MOD_normal_edit.cc.
References uiLayout::active_set(), Panel::layout, MOD_NORMALEDIT_MODE_DIRECTIONAL, MOD_NORMALEDIT_MODE_RADIAL, modifier_panel_get_property_pointers(), uiLayout::prop(), ptr, RNA_boolean_get(), RNA_enum_get(), RNA_pointer_get(), RNA_pointer_is_null(), UI_ITEM_NONE, and uiLayout::use_property_split_set().
Referenced by panel_register().
Definition at line 610 of file MOD_normal_edit.cc.
References col, uiLayout::column(), Panel::layout, MOD_NORMALEDIT_MODE_DIRECTIONAL, modifier_error_message_draw(), modifier_panel_get_property_pointers(), uiLayout::prop(), ptr, RNA_enum_get(), UI_ITEM_NONE, UI_ITEM_R_EXPAND, and uiLayout::use_property_split_set().
|
static |
Definition at line 677 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 572 of file MOD_normal_edit.cc.
References CD_MASK_MDEFORMVERT, NormalEditModifierData::defgrp_name, and CustomData_MeshMasks::vmask.
|
static |
Definition at line 596 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 686 of file MOD_normal_edit.cc.