|
Blender V5.0
|
#include "MEM_guardedalloc.h"#include "DNA_scene_types.h"#include "BLI_array.hh"#include "BLI_bitmap.h"#include "BLI_linklist_stack.h"#include "BLI_listbase.h"#include "BLI_math_base.hh"#include "BLI_math_vector.h"#include "BLI_task.h"#include "BLI_task.hh"#include "BLI_utildefines.h"#include "BLI_vector.hh"#include "BKE_customdata.hh"#include "BKE_editmesh.hh"#include "BKE_global.hh"#include "BKE_mesh.hh"#include "intern/bmesh_private.hh"Go to the source code of this file.
Classes | |
| struct | BMVertsCalcNormalsWithCoordsData |
| struct | BMLoopsCalcNormalsWithCoordsData |
| struct | BMLoopsCalcNormalsWithCoords_TLS |
Macros | |
| #define | EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS -FLT_MAX |
Typedefs | |
| using | float3 |
Functions | |
Update Vertex & Face Normals (Partial Updates) | |
| void | BM_mesh_normals_update_with_partial_ex (BMesh *, const BMPartialUpdate *bmpinfo, const BMeshNormalsUpdate_Params *params) |
| void | BM_mesh_normals_update_with_partial (BMesh *bm, const BMPartialUpdate *bmpinfo) |
Update Vertex & Face Normals (Custom Coords) | |
| void | BM_verts_calc_normal_vcos (BMesh *bm, const Span< float3 > fnos, const Span< float3 > vcos, MutableSpan< float3 > vnos) |
Tagging Utility Functions | |
| void | BM_normals_loops_edges_tag (BMesh *bm, const bool do_edges) |
| static void | bm_mesh_edges_sharp_tag (BMesh *bm, const Span< float3 > fnos, float split_angle_cos, const bool do_sharp_edges_tag) |
| void | BM_edges_sharp_from_angle_set (BMesh *bm, const float split_angle) |
Loop Normal Edit Data Array API | |
Utilities for creating/freeing BMLoopNorEditDataArray. | |
| void | BM_lnorspace_err (BMesh *bm) |
| static void | bm_loop_normal_mark_indiv_do_loop (BMLoop *l, BLI_bitmap *loops, MLoopNorSpaceArray *lnor_spacearr, int *totloopsel, const bool do_all_loops_of_vert) |
| static void | bm_loop_normal_mark_verts_impl (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert, int *totloopsel_p) |
| static void | bm_loop_normal_mark_edges_impl (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert, int *totloopsel_p) |
| static void | bm_loop_normal_mark_faces_impl (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert, int *totloopsel_p) |
| static int | bm_loop_normal_mark_verts (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert) |
| static int | bm_loop_normal_mark_edges (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert) |
| static int | bm_loop_normal_mark_faces (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert) |
| static int | bm_loop_normal_mark_indiv (BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert) |
| static void | loop_normal_editdata_init (BMesh *bm, BMLoopNorEditData *lnor_ed, BMVert *v, BMLoop *l, const int offset) |
| BMLoopNorEditDataArray * | BM_loop_normal_editdata_array_init_with_htype (BMesh *bm, const bool do_all_loops_of_vert, const char htype_override) |
| BMLoopNorEditDataArray * | BM_loop_normal_editdata_array_init (BMesh *bm, const bool do_all_loops_of_vert) |
| void | BM_loop_normal_editdata_array_free (BMLoopNorEditDataArray *lnors_ed_arr) |
Custom Normals / Vector Layer Conversion | |
| bool | BM_custom_loop_normals_to_vector_layer (BMesh *bm) |
| void | BM_custom_loop_normals_from_vector_layer (BMesh *bm, bool add_sharp_edges) |
Update Vertex & Face Normals | |
| #define | BM_LNORSPACE_UPDATE _FLAG_MF |
| BLI_INLINE void | bm_vert_calc_normals_accum_loop (const BMLoop *l_iter, const float e1diff[3], const float e2diff[3], const float f_no[3], float v_no[3]) |
| static void | bm_vert_calc_normals_impl (BMVert *v) |
| static void | bm_vert_calc_normals_cb (void *, MempoolIterData *mp_v, const TaskParallelTLS *__restrict) |
| static void | bm_vert_calc_normals_with_coords (BMVert *v, BMVertsCalcNormalsWithCoordsData *data) |
| static void | bm_vert_calc_normals_with_coords_cb (void *userdata, MempoolIterData *mp_v, const TaskParallelTLS *__restrict) |
| static void | bm_mesh_verts_calc_normals (BMesh *bm, const Span< float3 > fnos, const Span< float3 > vcos, MutableSpan< float3 > vnos) |
| static void | bm_face_calc_normals_cb (void *, MempoolIterData *mp_f, const TaskParallelTLS *__restrict) |
| void | BM_mesh_normals_update_ex (BMesh *bm, const BMeshNormalsUpdate_Params *params) |
| BMesh Compute Normals. | |
| void | BM_mesh_normals_update (BMesh *bm) |
Loop Normals Calculation API | |
| #define | LNOR_SPACE_TRIGO_THRESHOLD (1.0f - 1e-4f) |
| static void | bm_edge_tag_from_smooth_and_set_sharp (Span< float3 > fnos, BMEdge *e, const float split_angle_cos) |
| static void | bm_edge_tag_from_smooth (Span< float3 > fnos, BMEdge *e, const float split_angle_cos) |
| bool | BM_loop_check_cyclic_smooth_fan (BMLoop *l_curr) |
| static int | bm_mesh_loops_calc_normals_for_loop (BMesh *bm, const Span< float3 > vcos, const Span< float3 > fnos, const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool has_clnors, blender::Vector< blender::float3, 16 > *edge_vectors, BMLoop *l_curr, MutableSpan< float3 > r_lnos, MLoopNorSpaceArray *r_lnors_spacearr) |
| static int | bm_loop_index_cmp (const void *a, const void *b) |
| BLI_INLINE bool | bm_edge_is_smooth_no_angle_test (const BMEdge *e, const BMLoop *l_a, const BMLoop *l_b) |
| static void | bm_mesh_loops_calc_normals_for_vert_with_clnors (BMesh *bm, const Span< float3 > vcos, const Span< float3 > fnos, MutableSpan< float3 > r_lnos, const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild, const float split_angle_cos, MLoopNorSpaceArray *r_lnors_spacearr, blender::Vector< blender::float3, 16 > *edge_vectors, BMVert *v) |
| static void | bm_mesh_loops_calc_normals_for_vert_without_clnors (BMesh *bm, const Span< float3 > vcos, const Span< float3 > fnos, MutableSpan< float3 > r_lnos, const bool do_rebuild, const float split_angle_cos, MLoopNorSpaceArray *r_lnors_spacearr, blender::Vector< blender::float3, 16 > *edge_vectors, BMVert *v) |
| static void | bm_mesh_loops_calc_normals__single_threaded (BMesh *bm, const Span< float3 > vcos, const Span< float3 > fnos, MutableSpan< float3 > r_lnos, MLoopNorSpaceArray *r_lnors_spacearr, const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild, const float split_angle_cos) |
| static void | bm_mesh_loops_calc_normals_for_vert_init_fn (const void *__restrict userdata, void *__restrict chunk) |
| static void | bm_mesh_loops_calc_normals_for_vert_reduce_fn (const void *__restrict userdata, void *__restrict, void *__restrict chunk) |
| static void | bm_mesh_loops_calc_normals_for_vert_free_fn (const void *__restrict userdata, void *__restrict chunk) |
| static void | bm_mesh_loops_calc_normals_for_vert_with_clnors_fn (void *userdata, MempoolIterData *mp_v, const TaskParallelTLS *__restrict tls) |
| static void | bm_mesh_loops_calc_normals_for_vert_without_clnors_fn (void *userdata, MempoolIterData *mp_v, const TaskParallelTLS *__restrict tls) |
| static void | bm_mesh_loops_calc_normals__multi_threaded (BMesh *bm, const Span< float3 > vcos, const Span< float3 > fnos, MutableSpan< float3 > r_lnos, MLoopNorSpaceArray *r_lnors_spacearr, const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild, const float split_angle_cos) |
| static void | bm_mesh_loops_calc_normals (BMesh *bm, const Span< float3 > vcos, const Span< float3 > fnos, MutableSpan< float3 > r_lnos, MLoopNorSpaceArray *r_lnors_spacearr, const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild, const float split_angle_cos) |
| static bool | bm_mesh_loops_split_lnor_fans (BMesh *bm, MLoopNorSpaceArray *lnors_spacearr, const float(*new_lnors)[3]) |
| static void | bm_mesh_loops_assign_normal_data (BMesh *bm, MLoopNorSpaceArray *lnors_spacearr, short(*r_clnors_data)[2], const int cd_loop_clnors_offset, const float(*new_lnors)[3]) |
| static void | bm_mesh_loops_custom_normals_set (BMesh *bm, const Span< float3 > vcos, const Span< float3 > fnos, MLoopNorSpaceArray *r_lnors_spacearr, short(*r_clnors_data)[2], const int cd_loop_clnors_offset, float(*new_lnors)[3], const int cd_new_lnors_offset, bool do_split_fans) |
| static void | bm_mesh_loops_calc_normals_no_autosmooth (BMesh *bm, const Span< float3 > vnos, const Span< float3 > fnos, MutableSpan< float3 > r_lnos) |
| void | BM_loops_calc_normal_vcos (BMesh *bm, const Span< float3 > vcos, const Span< float3 > vnos, const Span< float3 > fnos, const bool use_split_normals, MutableSpan< float3 > r_lnos, MLoopNorSpaceArray *r_lnors_spacearr, short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild) |
Loop Normal Space API | |
| #define | CLEAR_SPACEARRAY_THRESHOLD(x) |
| void | BM_lnorspacearr_store (BMesh *bm, MutableSpan< float3 > r_lnors) |
| void | BM_lnorspace_invalidate (BMesh *bm, const bool do_invalidate_all) |
| void | BM_lnorspace_rebuild (BMesh *bm, bool preserve_clnor) |
| static void | bm_lnorspace_ensure_from_free_normals (BMesh *bm) |
| void | BM_lnorspace_update (BMesh *bm) |
BM mesh normal calculation functions.
Definition in file bmesh_mesh_normals.cc.
| #define BM_LNORSPACE_UPDATE _FLAG_MF |
Helpers for BM_mesh_normals_update and BM_verts_calc_normal_vcos
Definition at line 59 of file bmesh_mesh_normals.cc.
Referenced by BM_lnorspace_invalidate(), BM_lnorspace_rebuild(), bm_mesh_loops_calc_normals__single_threaded(), bm_mesh_loops_calc_normals_for_vert_with_clnors(), and bm_mesh_loops_calc_normals_for_vert_without_clnors().
| #define CLEAR_SPACEARRAY_THRESHOLD | ( | x | ) |
Definition at line 1740 of file bmesh_mesh_normals.cc.
Referenced by BM_lnorspace_invalidate().
| #define EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS -FLT_MAX |
Definition at line 42 of file bmesh_mesh_normals.cc.
Referenced by bm_mesh_loops_calc_normals__single_threaded(), bm_mesh_loops_calc_normals_for_vert_with_clnors(), bm_mesh_loops_calc_normals_for_vert_without_clnors(), and bm_mesh_loops_custom_normals_set().
| #define LNOR_SPACE_TRIGO_THRESHOLD (1.0f - 1e-4f) |
Definition at line 1380 of file bmesh_mesh_normals.cc.
| using blender::float3 |
Definition at line 619 of file BLI_math_vector_types.hh.
| void BM_custom_loop_normals_from_vector_layer | ( | BMesh * | bm, |
| bool | add_sharp_edges ) |
Definition at line 2367 of file bmesh_mesh_normals.cc.
References bm, bm_mesh_loops_custom_normals_set(), BM_SPACEARR_DIRTY, BM_SPACEARR_DIRTY_ALL, CD_NORMAL, CD_PROP_INT16_2D, CustomData_get_offset(), CustomData_get_offset_named(), and MEM_callocN().
Referenced by edbm_connect_vert_pair(), edbm_delete_exec(), edbm_dissolve_edges_exec(), edbm_dissolve_faces_exec(), edbm_dissolve_limited_exec(), edbm_dissolve_verts_exec(), edbm_edge_split_selected_edges(), edbm_edge_split_selected_verts(), edbm_merge_exec(), edbm_quads_convert_to_tris_exec(), edbm_remove_doubles_exec(), edbm_rip_invoke(), edbm_split_exec(), edbm_tris_convert_to_quads_exec(), edbm_vert_connect_path_exec(), and mesh_separate_arrays().
| bool BM_custom_loop_normals_to_vector_layer | ( | BMesh * | bm | ) |
Definition at line 2328 of file bmesh_mesh_normals.cc.
References BKE_lnor_space_custom_data_to_normal(), bm, BM_data_layer_add(), BM_ELEM_CD_GET_VOID_P, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_lnorspace_update(), BM_LOOPS_OF_FACE, CD_FLAG_TEMPORARY, CD_NORMAL, CD_PROP_INT16_2D, CustomData_get_offset(), CustomData_get_offset_named(), CustomData_has_layer(), CustomData_has_layer_named(), CustomData_set_layer_flag(), and l.
Referenced by edbm_connect_vert_pair(), edbm_delete_exec(), edbm_dissolve_edges_exec(), edbm_dissolve_faces_exec(), edbm_dissolve_limited_exec(), edbm_dissolve_verts_exec(), edbm_edge_split_selected_edges(), edbm_edge_split_selected_verts(), edbm_merge_exec(), edbm_quads_convert_to_tris_exec(), edbm_remove_doubles_exec(), edbm_rip_invoke(), edbm_split_exec(), edbm_tris_convert_to_quads_exec(), edbm_vert_connect_path_exec(), and mesh_separate_loose().
| BLI_INLINE bool bm_edge_is_smooth_no_angle_test | ( | const BMEdge * | e, |
| const BMLoop * | l_a, | ||
| const BMLoop * | l_b ) |
We only tag edges that are really smooth when the following conditions are met:
Definition at line 776 of file bmesh_mesh_normals.cc.
References BLI_assert, BLI_INLINE, BM_elem_flag_test, BM_ELEM_SMOOTH, e, BMLoop::f, l_b, BMLoop::radial_next, and BMLoop::v.
Referenced by bm_edge_tag_from_smooth(), and bm_edge_tag_from_smooth_and_set_sharp().
|
static |
Definition at line 792 of file bmesh_mesh_normals.cc.
References BLI_assert, bm_edge_is_smooth_no_angle_test(), BM_elem_index_get, BM_ELEM_TAG, dot(), dot_v3v3(), e, BMLoop::f, blender::Span< T >::is_empty(), l_b, BMFace::no, and BMLoop::radial_next.
Referenced by bm_mesh_edges_sharp_tag(), bm_mesh_loops_calc_normals_for_vert_with_clnors(), and bm_mesh_loops_calc_normals_for_vert_without_clnors().
|
static |
A version of bm_edge_tag_from_smooth that sets sharp edges when they would be considered smooth but exceed the split angle .
Definition at line 833 of file bmesh_mesh_normals.cc.
References BLI_assert, bm_edge_is_smooth_no_angle_test(), BM_elem_flag_disable, BM_elem_flag_set, BM_elem_index_get, BM_ELEM_SMOOTH, BM_ELEM_TAG, dot(), dot_v3v3(), e, BMLoop::f, blender::Span< T >::is_empty(), l_b, BMFace::no, and BMLoop::radial_next.
Referenced by bm_mesh_edges_sharp_tag().
Define sharp edges as needed to mimic auto-smooth from angle threshold.
Used when defining an empty custom loop normals data layer, to keep same shading as with auto-smooth!
Definition at line 401 of file bmesh_mesh_normals.cc.
References bm, bm_mesh_edges_sharp_tag(), cosf, and M_PI.
|
static |
Definition at line 237 of file bmesh_mesh_normals.cc.
References BM_face_calc_normal(), and BMFace::no.
Referenced by BM_mesh_normals_update_ex().
|
static |
Make sure the corner fan (tangent space) style custom normals exist on the BMesh. If free vector custom normals exist, they'll be converted. This is often necessary for BMesh editing tools that don't (yet) support free normals.
Definition at line 1885 of file bmesh_mesh_normals.cc.
References bm, BM_data_layer_free_named(), BM_ELEM_CD_GET_FLOAT_P, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_lnorspacearr_store(), BM_LOOPS_OF_FACE, CD_PROP_FLOAT3, CustomData_get_offset_named(), and l.
Referenced by BM_lnorspace_update().
| void BM_lnorspace_err | ( | BMesh * | bm | ) |
Auxiliary function only used by rebuild to detect if any spaces were not marked as invalid. Reports error if any of the lnor spaces change after rebuilding, meaning that all the possible lnor spaces to be rebuilt were not correctly marked.
Definition at line 1967 of file bmesh_mesh_normals.cc.
References BKE_lnor_spacearr_free(), BKE_lnor_spacearr_init(), BLI_assert, bm, BM_loops_calc_normal_vcos(), BM_SPACEARR_DIRTY_ALL, CD_PROP_INT16_2D, clear(), compare_ff(), compare_v3v3(), CustomData_get_offset_named(), i, MLoopNorSpaceArray::lspacearr, MEM_callocN(), MEM_freeN(), MLNOR_SPACEARR_BMLOOP_PTR, MLoopNorSpace::ref_alpha, MLoopNorSpace::ref_beta, MLoopNorSpace::vec_lnor, MLoopNorSpace::vec_ortho, and MLoopNorSpace::vec_ref.
Referenced by BM_lnorspace_rebuild().
| void BM_lnorspace_invalidate | ( | BMesh * | bm, |
| const bool | do_invalidate_all ) |
Definition at line 1742 of file bmesh_mesh_normals.cc.
References BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, bm, BM_ELEM_API_FLAG_ENABLE, BM_elem_flag_test, BM_elem_index_get, BM_ELEM_SELECT, BM_ITER_ELEM, BM_ITER_MESH, BM_LNORSPACE_UPDATE, BM_LOOPS_OF_VERT, BM_mesh_elem_index_ensure(), BM_SPACEARR_DIRTY, BM_SPACEARR_DIRTY_ALL, BM_VERT, BM_VERTS_OF_MESH, CLEAR_SPACEARRAY_THRESHOLD, l, MEM_freeN(), BMLoop::v, and v.
Referenced by EDBM_update(), and blender::ed::transform::initTransform().
| void BM_lnorspace_rebuild | ( | BMesh * | bm, |
| bool | preserve_clnor ) |
Definition at line 1812 of file bmesh_mesh_normals.cc.
References BKE_lnor_space_custom_data_to_normal(), BKE_lnor_space_custom_normal_to_data(), BKE_lnor_spacearr_clear(), BLI_assert, bm, BM_ELEM_API_FLAG_DISABLE, BM_ELEM_API_FLAG_TEST, BM_ELEM_CD_GET_VOID_P, BM_elem_index_get, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_lnorspace_err(), BM_LNORSPACE_UPDATE, BM_LOOP, BM_loops_calc_normal_vcos(), BM_LOOPS_OF_FACE, BM_mesh_elem_index_ensure(), BM_SPACEARR_DIRTY, BM_SPACEARR_DIRTY_ALL, CD_PROP_INT16_2D, CustomData_get_offset_named(), and l.
Referenced by BM_lnorspace_update(), and blender::ed::transform::transformEnd().
| void BM_lnorspace_update | ( | BMesh * | bm | ) |
Definition at line 1940 of file bmesh_mesh_normals.cc.
References bm, bm_lnorspace_ensure_from_free_normals(), BM_lnorspace_rebuild(), BM_SPACEARR_DIRTY, BM_SPACEARR_DIRTY_ALL, and MEM_callocN().
Referenced by bevel_harden_normals(), BKE_editmesh_lnorspace_update(), BM_custom_loop_normals_to_vector_layer(), edbm_flip_normals_custom_loop_normals(), flip_custom_normals(), and flip_custom_normals_init_data().
| void BM_lnorspacearr_store | ( | BMesh * | bm, |
| MutableSpan< float3 > | r_lnors ) |
Definition at line 1726 of file bmesh_mesh_normals.cc.
References BLI_assert, bm, BM_data_layer_ensure_named(), BM_loops_calc_normal_vcos(), BM_SPACEARR_DIRTY, BM_SPACEARR_DIRTY_ALL, CD_PROP_INT16_2D, and CustomData_get_offset_named().
Referenced by bm_lnorspace_ensure_from_free_normals().
| bool BM_loop_check_cyclic_smooth_fan | ( | BMLoop * | l_curr | ) |
Check whether given loop is part of an unknown-so-far cyclic smooth fan, or not. Needed because cyclic smooth fans have no obvious 'entry point', and yet we need to walk them once, and only once.
Definition at line 417 of file bmesh_mesh_normals.cc.
References BLI_assert, BM_elem_flag_enable, BM_elem_flag_test, BM_ELEM_TAG, BM_vert_step_fan_loop(), and BMLoop::e.
Referenced by bm_mesh_loops_calc_normals_for_loop(), edbm_average_normals_exec(), and normals_split().
|
static |
Definition at line 759 of file bmesh_mesh_normals.cc.
References b, BLI_assert, and BM_elem_index_get.
Referenced by bm_mesh_loops_calc_normals_for_vert_with_clnors().
| void BM_loop_normal_editdata_array_free | ( | BMLoopNorEditDataArray * | lnors_ed_arr | ) |
Definition at line 2315 of file bmesh_mesh_normals.cc.
References BMLoopNorEditDataArray::lidx_to_lnor_editdata, BMLoopNorEditDataArray::lnor_editdata, MEM_freeN(), and MEM_SAFE_FREE.
Referenced by edbm_fill_grid_split_join_finish(), edbm_flip_normals_custom_loop_normals(), edbm_flip_normals_face_winding(), edbm_normals_make_consistent_exec(), edbm_normals_tools_exec(), edbm_smooth_normals_exec(), flip_custom_normals(), blender::ed::transform::freeCustomNormalArray(), normals_split_merge(), and point_normals_free().
| BMLoopNorEditDataArray * BM_loop_normal_editdata_array_init | ( | BMesh * | bm, |
| const bool | do_all_loops_of_vert ) |
Definition at line 2309 of file bmesh_mesh_normals.cc.
References bm, and BM_loop_normal_editdata_array_init_with_htype().
Referenced by edbm_flip_normals_custom_loop_normals(), edbm_normals_tools_exec(), edbm_smooth_normals_exec(), normals_split_merge(), point_normals_init(), and blender::ed::transform::storeCustomLNorValue().
| BMLoopNorEditDataArray * BM_loop_normal_editdata_array_init_with_htype | ( | BMesh * | bm, |
| bool | do_all_loops_of_vert, | ||
| char | htype_override ) |
Initialize loop data based on a type, overriding the BMesh::selectmode of bm. This can be useful if a single types selection is preferred, instead of using mixed modes and the selection history.
Definition at line 2243 of file bmesh_mesh_normals.cc.
References BLI_assert, BLI_BITMAP_NEW, BLI_BITMAP_TEST, bm, BM_data_layer_ensure_named(), BM_EDGE, BM_elem_index_get, BM_FACE, BM_ITER_ELEM, BM_ITER_MESH, BM_LOOP, bm_loop_normal_mark_edges(), bm_loop_normal_mark_faces(), bm_loop_normal_mark_indiv(), bm_loop_normal_mark_verts(), BM_LOOPS_OF_VERT, BM_mesh_elem_index_ensure(), BM_VERT, BM_VERTS_OF_MESH, BMLoopNorEditDataArray::cd_custom_normal_offset, CD_PROP_INT16_2D, CustomData_get_offset_named(), ELEM, l, BMLoopNorEditDataArray::lidx_to_lnor_editdata, BMLoopNorEditDataArray::lnor_editdata, loop_normal_editdata_init(), MEM_calloc_arrayN(), MEM_callocN(), MEM_freeN(), MEM_malloc_arrayN(), BMLoopNorEditDataArray::totloop, and v.
Referenced by BM_loop_normal_editdata_array_init(), flip_custom_normals(), and flip_custom_normals_init_data().
|
static |
Definition at line 2131 of file bmesh_mesh_normals.cc.
References BLI_assert, bm, BM_LOOP, bm_loop_normal_mark_edges_impl(), BM_mesh_elem_index_ensure(), and MLNOR_SPACEARR_BMLOOP_PTR.
Referenced by BM_loop_normal_editdata_array_init_with_htype().
|
static |
Definition at line 2072 of file bmesh_mesh_normals.cc.
References BLI_assert, bm, BM_EDGES_OF_MESH, BM_elem_flag_test, BM_ELEM_SELECT, BM_ITER_ELEM, BM_ITER_MESH, bm_loop_normal_mark_indiv_do_loop(), BM_LOOPS_OF_EDGE, BM_vert_in_edge(), e, and l.
Referenced by bm_loop_normal_mark_edges(), and bm_loop_normal_mark_indiv().
|
static |
Definition at line 2141 of file bmesh_mesh_normals.cc.
References BLI_assert, bm, BM_LOOP, bm_loop_normal_mark_faces_impl(), BM_mesh_elem_index_ensure(), and MLNOR_SPACEARR_BMLOOP_PTR.
Referenced by BM_loop_normal_editdata_array_init_with_htype().
|
static |
Definition at line 2102 of file bmesh_mesh_normals.cc.
References bm, BM_elem_flag_test, BM_ELEM_SELECT, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, bm_loop_normal_mark_indiv_do_loop(), BM_LOOPS_OF_FACE, and l.
Referenced by bm_loop_normal_mark_faces(), and bm_loop_normal_mark_indiv().
|
static |
Definition at line 2152 of file bmesh_mesh_normals.cc.
References BLI_assert, bm, BM_EDGE, BM_FACE, BM_face_vert_share_loop(), BM_LOOP, bm_loop_normal_mark_edges_impl(), bm_loop_normal_mark_faces_impl(), bm_loop_normal_mark_indiv_do_loop(), bm_loop_normal_mark_verts_impl(), BM_mesh_elem_index_ensure(), BM_VERT, e, LISTBASE_FOREACH_BACKWARD, MLNOR_SPACEARR_BMLOOP_PTR, BMEditSelection::prev, SCE_SELECT_EDGE, SCE_SELECT_FACE, and SCE_SELECT_VERTEX.
Referenced by BM_loop_normal_editdata_array_init_with_htype().
|
static |
Definition at line 2009 of file bmesh_mesh_normals.cc.
References BLI_BITMAP_ENABLE, BLI_BITMAP_TEST, BM_elem_index_get, BM_ITER_ELEM, BM_LOOPS_OF_VERT, MLoopNorSpace::flags, l, MLoopNorSpace::loops, MLoopNorSpaceArray::lspacearr, MLNOR_SPACE_IS_SINGLE, and LinkNode::next.
Referenced by bm_loop_normal_mark_edges_impl(), bm_loop_normal_mark_faces_impl(), bm_loop_normal_mark_indiv(), and bm_loop_normal_mark_verts_impl().
|
static |
Definition at line 2121 of file bmesh_mesh_normals.cc.
References BLI_assert, bm, BM_LOOP, bm_loop_normal_mark_verts_impl(), BM_mesh_elem_index_ensure(), and MLNOR_SPACEARR_BMLOOP_PTR.
Referenced by BM_loop_normal_editdata_array_init_with_htype().
|
static |
Definition at line 2053 of file bmesh_mesh_normals.cc.
References bm, BM_elem_flag_test, BM_ELEM_SELECT, BM_ITER_ELEM, BM_ITER_MESH, bm_loop_normal_mark_indiv_do_loop(), BM_LOOPS_OF_VERT, BM_VERTS_OF_MESH, l, and v.
Referenced by bm_loop_normal_mark_indiv(), and bm_loop_normal_mark_verts().
| void BM_loops_calc_normal_vcos | ( | BMesh * | bm, |
| const Span< float3 > | vcos, | ||
| const Span< float3 > | vnos, | ||
| const Span< float3 > | fnos, | ||
| const bool | use_split_normals, | ||
| MutableSpan< float3 > | r_lnos, | ||
| MLoopNorSpaceArray * | r_lnors_spacearr, | ||
| short(*) | clnors_data[2], | ||
| const int | cd_loop_clnors_offset, | ||
| const bool | do_rebuild ) |
Definition at line 1691 of file bmesh_mesh_normals.cc.
References BLI_assert, bm, bm_mesh_loops_calc_normals(), and bm_mesh_loops_calc_normals_no_autosmooth().
Referenced by BM_lnorspace_err(), BM_lnorspace_rebuild(), BM_lnorspacearr_store(), and blender::draw::mesh_render_data_update_corner_normals().
|
static |
Helpers for #BM_mesh_loop_normals_update and BM_loops_calc_normal_vcos
Definition at line 368 of file bmesh_mesh_normals.cc.
References bm, BM_EDGE, bm_edge_tag_from_smooth(), bm_edge_tag_from_smooth_and_set_sharp(), BM_EDGES_OF_MESH, BM_elem_index_set, BM_FACE, BM_ITER_MESH_INDEX, BM_mesh_elem_index_ensure(), e, i, and blender::Span< T >::is_empty().
Referenced by BM_edges_sharp_from_angle_set(), bm_mesh_loops_calc_normals__single_threaded(), and bm_mesh_loops_custom_normals_set().
|
static |
Assign custom normal data from given normal vectors, averaging normals from one smooth fan as necessary.
Definition at line 1482 of file bmesh_mesh_normals.cc.
References add_v3_v3(), BKE_lnor_space_custom_normal_to_data(), BLI_assert, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, BLI_SMALLSTACK_DECLARE, BLI_SMALLSTACK_POP, BLI_SMALLSTACK_PUSH, bm, BM_ELEM_CD_GET_VOID_P, BM_elem_index_get, MLoopNorSpaceArray::data_type, MLoopNorSpace::flags, G, G_DEBUG, i, LinkNode::link, MLoopNorSpace::loops, MLoopNorSpaceArray::lspacearr, MEM_freeN(), MLNOR_SPACE_IS_SINGLE, MLNOR_SPACEARR_BMLOOP_PTR, mul_v3_fl(), LinkNode::next, nor, printf, and zero_v3().
Referenced by bm_mesh_loops_custom_normals_set().
|
static |
Definition at line 1345 of file bmesh_mesh_normals.cc.
References bm, bm_mesh_loops_calc_normals__multi_threaded(), bm_mesh_loops_calc_normals__single_threaded(), and BM_THREAD_LIMIT.
Referenced by BM_loops_calc_normal_vcos(), and bm_mesh_loops_custom_normals_set().
|
static |
Definition at line 1270 of file bmesh_mesh_normals.cc.
References BKE_lnor_spacearr_free(), BKE_lnor_spacearr_init(), BLI_parallel_mempool_settings_defaults(), bm, BM_FACE, BM_LOOP, BM_mesh_elem_index_ensure(), bm_mesh_loops_calc_normals_for_vert_free_fn(), bm_mesh_loops_calc_normals_for_vert_init_fn(), bm_mesh_loops_calc_normals_for_vert_reduce_fn(), bm_mesh_loops_calc_normals_for_vert_with_clnors_fn(), bm_mesh_loops_calc_normals_for_vert_without_clnors_fn(), BM_VERT, BM_VERTS_OF_MESH, data, TaskParallelSettings::func_free, TaskParallelSettings::func_init, TaskParallelSettings::func_reduce, blender::Span< T >::is_empty(), MLNOR_SPACEARR_BMLOOP_PTR, TaskParallelSettings::userdata_chunk, and TaskParallelSettings::userdata_chunk_size.
Referenced by bm_mesh_loops_calc_normals().
|
static |
BMesh version of bke::mesh::normals_calc_corners() in mesh_evaluate.cc Will use first clnors_data array, and fallback to cd_loop_clnors_offset (use nullptr and -1 to not use clnors).
Definition at line 1068 of file bmesh_mesh_normals.cc.
References BKE_lnor_spacearr_free(), BKE_lnor_spacearr_init(), bm, BM_ELEM_API_FLAG_TEST, BM_elem_flag_disable, BM_elem_index_set, BM_ELEM_TAG, BM_FACE, BM_FACE_FIRST_LOOP, BM_FACES_OF_MESH, BM_ITER_MESH, BM_ITER_MESH_INDEX, BM_LNORSPACE_UPDATE, BM_LOOP, bm_mesh_edges_sharp_tag(), BM_mesh_elem_index_ensure(), bm_mesh_loops_calc_normals_for_loop(), BM_SPACEARR_DIRTY_ALL, BM_VERT, EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS, blender::Span< T >::is_empty(), MLNOR_SPACEARR_BMLOOP_PTR, and BMLoop::next.
Referenced by bm_mesh_loops_calc_normals().
|
static |
Called for all faces loops.
Definition at line 461 of file bmesh_mesh_normals.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BKE_lnor_space_add_loop(), BKE_lnor_space_create(), BKE_lnor_space_custom_data_to_normal(), BKE_lnor_space_define(), BLI_assert, BLI_SMALLSTACK_DECLARE, BLI_SMALLSTACK_POP, BLI_SMALLSTACK_PUSH, bm, BM_edge_other_vert(), BM_ELEM_CD_GET_VOID_P, BM_elem_flag_enable, BM_elem_flag_test, BM_elem_index_get, BM_ELEM_TAG, BM_FACE, BM_LOOP, BM_loop_check_cyclic_smooth_fan(), BM_VERT, BM_vert_step_fan_loop(), blender::Vector< T, InlineBufferCapacity, Allocator >::clear(), BMVert::co, copy_v3_v3(), dot_v3v3(), BMLoop::e, BMLoop::f, blender::Span< T >::is_empty(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), LIKELY, madd_v3_v3fl(), BMLoop::next, BMFace::no, nor, normalize_v3(), BMLoop::prev, blender::math::safe_acos_approx(), sub_v3_v3v3(), UNLIKELY, UNUSED_VARS_NDEBUG, and BMLoop::v.
Referenced by bm_mesh_loops_calc_normals__single_threaded(), bm_mesh_loops_calc_normals_for_vert_with_clnors(), and bm_mesh_loops_calc_normals_for_vert_without_clnors().
|
static |
Definition at line 1211 of file bmesh_mesh_normals.cc.
References data.
Referenced by bm_mesh_loops_calc_normals__multi_threaded().
|
static |
Definition at line 1184 of file bmesh_mesh_normals.cc.
References BKE_lnor_spacearr_tls_init(), and data.
Referenced by bm_mesh_loops_calc_normals__multi_threaded().
|
static |
Definition at line 1199 of file bmesh_mesh_normals.cc.
References BKE_lnor_spacearr_tls_join(), and data.
Referenced by bm_mesh_loops_calc_normals__multi_threaded().
|
static |
Operate on all vertices loops. operating on vertices this is needed for multi-threading so there is a guarantee that each thread has isolated loops.
Definition at line 868 of file bmesh_mesh_normals.cc.
References BLI_assert, BLI_linklist_prepend_alloca, BLI_linklist_sort(), bm, BM_DISK_EDGE_NEXT, bm_edge_tag_from_smooth(), BM_ELEM_API_FLAG_TEST, BM_elem_flag_disable, BM_elem_index_get, BM_ELEM_TAG, BM_LNORSPACE_UPDATE, bm_loop_index_cmp(), bm_mesh_loops_calc_normals_for_loop(), BM_SPACEARR_DIRTY_ALL, EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS, BMEdge::l, LinkNode::link, LinkNode::next, BMLoop::radial_next, UINT_MAX, UNLIKELY, BMLoop::v, and v.
Referenced by bm_mesh_loops_calc_normals_for_vert_with_clnors_fn().
|
static |
Definition at line 1222 of file bmesh_mesh_normals.cc.
References bm_mesh_loops_calc_normals_for_vert_with_clnors(), data, and v.
Referenced by bm_mesh_loops_calc_normals__multi_threaded().
|
static |
A simplified version of bm_mesh_loops_calc_normals_for_vert_with_clnors that can operate on loops in any order.
Definition at line 990 of file bmesh_mesh_normals.cc.
References bm, BM_DISK_EDGE_NEXT, bm_edge_tag_from_smooth(), BM_ELEM_API_FLAG_TEST, BM_elem_flag_disable, BM_ELEM_TAG, BM_LNORSPACE_UPDATE, bm_mesh_loops_calc_normals_for_loop(), BM_SPACEARR_DIRTY_ALL, EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS, BMEdge::l, BMLoop::radial_next, BMLoop::v, and v.
Referenced by bm_mesh_loops_calc_normals_for_vert_without_clnors_fn().
|
static |
Definition at line 1247 of file bmesh_mesh_normals.cc.
References bm_mesh_loops_calc_normals_for_vert_without_clnors(), data, and v.
Referenced by bm_mesh_loops_calc_normals__multi_threaded().
|
static |
Definition at line 1656 of file bmesh_mesh_normals.cc.
References bm, BM_elem_flag_test, BM_elem_index_get, BM_ELEM_SMOOTH, BM_FACE, BM_FACE_FIRST_LOOP, BM_FACES_OF_MESH, BM_ITER_MESH, BM_LOOP, BM_mesh_elem_index_ensure(), BM_VERT, copy_v3_v3(), blender::Span< T >::is_empty(), BMLoop::next, BMFace::no, BMVert::no, and BMLoop::v.
Referenced by BM_loops_calc_normal_vcos().
|
static |
Compute internal representation of given custom normals (as an array of float[2] or data layer).
It also makes sure the mesh matches those custom normals, by marking new sharp edges to split the smooth fans when loop normals for the same vertex are different, or averaging the normals instead, depending on the do_split_fans parameter.
Definition at line 1570 of file bmesh_mesh_normals.cc.
References BKE_lnor_spacearr_clear(), bm, BM_ELEM_CD_GET_VOID_P, BM_elem_index_get, BM_FACES_OF_MESH, BM_ITER_ELEM, BM_ITER_MESH, BM_LOOPS_OF_FACE, bm_mesh_edges_sharp_tag(), bm_mesh_loops_assign_normal_data(), bm_mesh_loops_calc_normals(), bm_mesh_loops_split_lnor_fans(), copy_v3_v3(), EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS, float, i, is_zero_v3(), l, MEM_freeN(), MEM_mallocN(), and normalize_v3().
Referenced by BM_custom_loop_normals_from_vector_layer().
|
static |
Check each current smooth fan (one lnor space per smooth fan!), and if all its matching custom lnors are not (enough) equal, add sharp edges as needed.
Definition at line 1386 of file bmesh_mesh_normals.cc.
References BLI_assert, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_BITMAP_TEST, bm, BM_elem_flag_disable, BM_elem_index_get, BM_ELEM_SMOOTH, BM_ELEM_TAG, MLoopNorSpaceArray::data_type, dot_v3v3(), BMLoop::e, e, MLoopNorSpace::flags, G, G_DEBUG, i, LinkNode::link, LNOR_SPACE_TRIGO_THRESHOLD, MLoopNorSpace::loops, MLoopNorSpaceArray::lspacearr, MEM_freeN(), MLNOR_SPACE_IS_SINGLE, MLNOR_SPACEARR_BMLOOP_PTR, LinkNode::next, nor, BMLoop::prev, and printf.
Referenced by bm_mesh_loops_custom_normals_set().
| void BM_mesh_normals_update | ( | BMesh * | bm | ) |
Definition at line 261 of file bmesh_mesh_normals.cc.
References bm, BM_mesh_normals_update_ex(), and params.
Referenced by bevel_harden_normals(), BKE_mesh_remesh_voxel_fix_poles(), bmesh_edit_begin(), bmesh_edit_end(), blender::ed::sculpt_paint::undo::bmesh_restore_generic(), bpy_bmesh_normal_update(), ED_transverts_update_obedit(), blender::ed::sculpt_paint::dyntopo::enable_ex(), ensure_non_lazy_normals(), mesh_separate_tagged(), and slice_paint_mask().
| void BM_mesh_normals_update_ex | ( | BMesh * | bm, |
| const BMeshNormalsUpdate_Params * | param ) |
BMesh Compute Normals.
Updates the normals of a mesh.
Definition at line 246 of file bmesh_mesh_normals.cc.
References BLI_parallel_mempool_settings_defaults(), bm, bm_face_calc_normals_cb(), BM_FACES_OF_MESH, bm_mesh_verts_calc_normals(), BM_THREAD_LIMIT, params, and TaskParallelSettings::use_threading.
Referenced by BKE_editmesh_looptris_and_normals_calc(), BM_mesh_normals_update(), and EDBM_mesh_normals_update_ex().
| void BM_mesh_normals_update_with_partial | ( | BMesh * | bm, |
| const BMPartialUpdate * | bmpinfo ) |
Definition at line 302 of file bmesh_mesh_normals.cc.
References bm, BM_mesh_normals_update_with_partial_ex(), and params.
| void BM_mesh_normals_update_with_partial_ex | ( | BMesh * | bm, |
| const BMPartialUpdate * | bmpinfo, | ||
| const BMeshNormalsUpdate_Params * | param ) |
A version of BM_mesh_normals_update that updates a subset of geometry, used to avoid the overhead of updating everything.
Definition at line 274 of file bmesh_mesh_normals.cc.
References BLI_assert, BMPartialUpdate_Params::do_normals, BMPartialUpdate::faces, Vector< T, InlineBufferCapacity, Allocator >::index_range(), Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::threading::parallel_for(), BMPartialUpdate::params, params, UNLIKELY, and BMPartialUpdate::verts.
Referenced by BKE_editmesh_looptris_and_normals_calc_with_partial(), BM_mesh_normals_update_with_partial(), and blender::ed::transform::mesh_partial_update().
|
static |
Definition at line 213 of file bmesh_mesh_normals.cc.
References BLI_assert, BLI_parallel_mempool_settings_defaults(), bm, BM_FACE, BM_mesh_elem_index_ensure(), BM_THREAD_LIMIT, BM_VERT, bm_vert_calc_normals_cb(), bm_vert_calc_normals_with_coords_cb(), BM_VERTS_OF_MESH, data, blender::MutableSpan< T >::is_empty(), blender::Span< T >::is_empty(), and TaskParallelSettings::use_threading.
Referenced by BM_mesh_normals_update_ex(), and BM_verts_calc_normal_vcos().
| void BM_normals_loops_edges_tag | ( | BMesh * | bm, |
| const bool | do_edges ) |
Definition at line 330 of file bmesh_mesh_normals.cc.
References bm, BM_EDGE, BM_edge_loop_pair(), BM_EDGES_OF_MESH, BM_elem_flag_disable, BM_elem_flag_enable, BM_elem_flag_test, BM_elem_index_set, BM_ELEM_SMOOTH, BM_ELEM_TAG, BM_FACE, BM_FACE_FIRST_LOOP, BM_FACES_OF_MESH, BM_ITER_MESH_INDEX, BM_LOOP, e, l_b, BMLoop::next, and BMLoop::v.
Referenced by edbm_average_normals_exec(), normals_merge(), and normals_split().
| BLI_INLINE void bm_vert_calc_normals_accum_loop | ( | const BMLoop * | l_iter, |
| const float | e1diff[3], | ||
| const float | e2diff[3], | ||
| const float | f_no[3], | ||
| float | v_no[3] ) |
Definition at line 70 of file bmesh_mesh_normals.cc.
References BLI_assert, BLI_INLINE, dot_v3v3(), BMLoop::e, isnan, madd_v3_v3fl(), BMLoop::prev, blender::math::safe_acos_approx(), BMLoop::v, and BMEdge::v1.
Referenced by bm_vert_calc_normals_impl(), and bm_vert_calc_normals_with_coords().
|
static |
Definition at line 152 of file bmesh_mesh_normals.cc.
References bm_vert_calc_normals_impl(), and v.
Referenced by bm_mesh_verts_calc_normals().
|
static |
Definition at line 89 of file bmesh_mesh_normals.cc.
References BM_DISK_EDGE_NEXT, bm_vert_calc_normals_accum_loop(), BMVert::co, BMLoop::e, BMLoop::f, BMEdge::l, LIKELY, BMFace::no, normalize_v3(), normalize_v3_v3(), BMLoop::prev, BMLoop::radial_next, sub_v3_v3v3(), BMLoop::v, v, BMEdge::v1, BMEdge::v2, and zero_v3().
Referenced by bm_vert_calc_normals_cb().
|
static |
Definition at line 160 of file bmesh_mesh_normals.cc.
References BM_DISK_EDGE_NEXT, BM_elem_index_get, bm_vert_calc_normals_accum_loop(), data, BMLoop::e, BMLoop::f, BMEdge::l, LIKELY, normalize_v3(), normalize_v3_v3(), BMLoop::prev, BMLoop::radial_next, sub_v3_v3v3(), BMLoop::v, v, BMEdge::v1, BMEdge::v2, and zero_v3().
Referenced by bm_vert_calc_normals_with_coords_cb().
|
static |
Definition at line 203 of file bmesh_mesh_normals.cc.
References bm_vert_calc_normals_with_coords(), data, and v.
Referenced by bm_mesh_verts_calc_normals().
| void BM_verts_calc_normal_vcos | ( | BMesh * | bm, |
| const Span< float3 > | fnos, | ||
| const Span< float3 > | vcos, | ||
| MutableSpan< float3 > | vnos ) |
Definition at line 315 of file bmesh_mesh_normals.cc.
References bm, and bm_mesh_verts_calc_normals().
Referenced by BKE_editmesh_cache_ensure_vert_normals().
|
static |
Definition at line 2220 of file bmesh_mesh_normals.cc.
References BKE_lnor_space_custom_data_to_normal(), BLI_assert, bm, BM_ELEM_CD_GET_VOID_P, BM_elem_index_get, BMLoopNorEditData::clnors_data, copy_v3_v3(), l, BMLoopNorEditData::loc, BMLoopNorEditData::loop, BMLoopNorEditData::loop_index, BMLoopNorEditData::niloc, BMLoopNorEditData::nloc, and v.
Referenced by BM_loop_normal_editdata_array_init_with_htype().