Blender  V3.3
Classes | Macros
bmesh_mesh_normals.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "BLI_bitmap.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_stack.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "intern/bmesh_private.h"

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
 

Functions

Update Vertex & Face Normals (Partial Updates)
static void bm_partial_faces_parallel_range_calc_normals_cb (void *userdata, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
 
static void bm_partial_verts_parallel_range_calc_normal_cb (void *userdata, const int iter, const TaskParallelTLS *__restrict UNUSED(tls))
 
void BM_mesh_normals_update_with_partial_ex (BMesh *UNUSED(bm), const BMPartialUpdate *bmpinfo, const struct 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 float(*fnos)[3], const float(*vcos)[3], float(*vnos)[3])
 BMesh Compute Normals from/to external data. More...
 
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 float(*fnos)[3], 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 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)
 
BMLoopNorEditDataArrayBM_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
 
typedef struct BMVertsCalcNormalsWithCoordsData BMVertsCalcNormalsWithCoordsData
 
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 *UNUSED(userdata), MempoolIterData *mp_v, const TaskParallelTLS *__restrict UNUSED(tls))
 
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 UNUSED(tls))
 
static void bm_mesh_verts_calc_normals (BMesh *bm, const float(*fnos)[3], const float(*vcos)[3], float(*vnos)[3])
 
static void bm_face_calc_normals_cb (void *UNUSED(userdata), MempoolIterData *mp_f, const TaskParallelTLS *__restrict UNUSED(tls))
 
void BM_mesh_normals_update_ex (BMesh *bm, const struct BMeshNormalsUpdate_Params *params)
 BMesh Compute Normals. More...
 
void BM_mesh_normals_update (BMesh *bm)
 

Loop Normals Calculation API

#define LNOR_SPACE_TRIGO_THRESHOLD   (1.0f - 1e-4f)
 
typedef struct BMLoopsCalcNormalsWithCoordsData BMLoopsCalcNormalsWithCoordsData
 
typedef struct BMLoopsCalcNormalsWithCoords_TLS BMLoopsCalcNormalsWithCoords_TLS
 
static void bm_edge_tag_from_smooth_and_set_sharp (const float(*fnos)[3], BMEdge *e, const float split_angle_cos)
 
static void bm_edge_tag_from_smooth (const float(*fnos)[3], 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 float(*vcos)[3], const float(*fnos)[3], const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool has_clnors, BLI_Stack *edge_vectors, BMLoop *l_curr, float(*r_lnos)[3], 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 float(*vcos)[3], const float(*fnos)[3], float(*r_lnos)[3], const short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild, const float split_angle_cos, MLoopNorSpaceArray *r_lnors_spacearr, BLI_Stack *edge_vectors, BMVert *v)
 
static void bm_mesh_loops_calc_normals_for_vert_without_clnors (BMesh *bm, const float(*vcos)[3], const float(*fnos)[3], float(*r_lnos)[3], const bool do_rebuild, const float split_angle_cos, MLoopNorSpaceArray *r_lnors_spacearr, BLI_Stack *edge_vectors, BMVert *v)
 
static void bm_mesh_loops_calc_normals__single_threaded (BMesh *bm, const float(*vcos)[3], const float(*fnos)[3], float(*r_lnos)[3], 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 UNUSED(chunk_join), 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 float(*vcos)[3], const float(*fnos)[3], float(*r_lnos)[3], 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 float(*vcos)[3], const float(*fnos)[3], float(*r_lnos)[3], 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 float(*vcos)[3], const float(*fnos)[3], 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 float(*vnos)[3], const float(*fnos)[3], float(*r_lnos)[3])
 
void BM_loops_calc_normal_vcos (BMesh *bm, const float(*vcos)[3], const float(*vnos)[3], const float(*fnos)[3], const bool use_split_normals, const float split_angle, float(*r_lnos)[3], MLoopNorSpaceArray *r_lnors_spacearr, short(*clnors_data)[2], const int cd_loop_clnors_offset, const bool do_rebuild)
 BMesh Compute Loop Normals from/to external data. More...
 

Loop Normal Space API

#define CLEAR_SPACEARRAY_THRESHOLD(x)   ((x) / 2)
 
void BM_lnorspacearr_store (BMesh *bm, float(*r_lnors)[3])
 
void BM_lnorspace_invalidate (BMesh *bm, const bool do_invalidate_all)
 
void BM_lnorspace_rebuild (BMesh *bm, bool preserve_clnor)
 
void BM_lnorspace_update (BMesh *bm)
 

Detailed Description

BM mesh normal calculation functions.

See also
mesh_normals.cc for the equivalent Mesh functionality.

Definition in file bmesh_mesh_normals.c.

Macro Definition Documentation

◆ BM_LNORSPACE_UPDATE

#define BM_LNORSPACE_UPDATE   _FLAG_MF

Helpers for BM_mesh_normals_update and BM_verts_calc_normal_vcos

Definition at line 49 of file bmesh_mesh_normals.c.

◆ CLEAR_SPACEARRAY_THRESHOLD

#define CLEAR_SPACEARRAY_THRESHOLD (   x)    ((x) / 2)

Definition at line 1744 of file bmesh_mesh_normals.c.

◆ EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS

#define EDGE_TAG_FROM_SPLIT_ANGLE_BYPASS   -FLT_MAX

Definition at line 30 of file bmesh_mesh_normals.c.

◆ LNOR_SPACE_TRIGO_THRESHOLD

#define LNOR_SPACE_TRIGO_THRESHOLD   (1.0f - 1e-4f)

Definition at line 1376 of file bmesh_mesh_normals.c.

Typedef Documentation

◆ BMLoopsCalcNormalsWithCoords_TLS

◆ BMLoopsCalcNormalsWithCoordsData

◆ BMVertsCalcNormalsWithCoordsData

Function Documentation

◆ BM_custom_loop_normals_from_vector_layer()

void BM_custom_loop_normals_from_vector_layer ( BMesh bm,
bool  add_sharp_edges 
)

◆ BM_custom_loop_normals_to_vector_layer()

bool BM_custom_loop_normals_to_vector_layer ( struct BMesh bm)

◆ bm_edge_is_smooth_no_angle_test()

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:

  • The angle between both its polygons normals is below split_angle value.
  • The edge is tagged as smooth.
  • The faces of the edge are tagged as smooth.
  • The faces of the edge have compatible (non-flipped) topological normal (winding), i.e. both loops on the same edge do not share the same vertex.

Definition at line 776 of file bmesh_mesh_normals.c.

References BLI_assert, 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().

◆ bm_edge_tag_from_smooth()

static void bm_edge_tag_from_smooth ( const float(*)  fnos[3],
BMEdge e,
const float  split_angle_cos 
)
static

◆ bm_edge_tag_from_smooth_and_set_sharp()

static void bm_edge_tag_from_smooth_and_set_sharp ( const float(*)  fnos[3],
BMEdge e,
const float  split_angle_cos 
)
static

A version of bm_edge_tag_from_smooth that sets sharp edges when they would be considered smooth but exceed the split angle .

Note
This doesn't have the same atomic requirement as bm_edge_tag_from_smooth since it isn't run from multiple threads at once.

Definition at line 831 of file bmesh_mesh_normals.c.

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_v3v3(), e, BMLoop::f, l_b, BMFace::no, NULL, and BMLoop::radial_next.

Referenced by bm_mesh_edges_sharp_tag().

◆ BM_edges_sharp_from_angle_set()

void BM_edges_sharp_from_angle_set ( BMesh bm,
float  split_angle 
)

Define sharp edges as needed to mimic 'autosmooth' from angle threshold.

Used when defining an empty custom loop normals data layer, to keep same shading as with auto-smooth!

Definition at line 409 of file bmesh_mesh_normals.c.

References bm, bm_mesh_edges_sharp_tag(), cosf, M_PI, and NULL.

Referenced by bevel_harden_normals(), BKE_editmesh_lnorspace_update(), and mesh_customdata_custom_splitnormals_add_exec().

◆ bm_face_calc_normals_cb()

static void bm_face_calc_normals_cb ( void UNUSEDuserdata,
MempoolIterData mp_f,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

Definition at line 227 of file bmesh_mesh_normals.c.

References BM_face_calc_normal(), and BMFace::no.

Referenced by BM_mesh_normals_update_ex().

◆ BM_lnorspace_err()

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 1920 of file bmesh_mesh_normals.c.

References BKE_lnor_spacearr_free(), BKE_lnor_spacearr_init(), BLI_assert, bm, BM_loops_calc_normal_vcos(), BM_SPACEARR_DIRTY_ALL, CD_CUSTOMLOOPNORMAL, clear(), compare_ff(), compare_v3v3(), CustomData_get_offset(), float(), BMesh::ldata, BMesh::lnor_spacearr, MLoopNorSpaceArray::lspacearr, M_PI, MEM_callocN, MEM_freeN, MLNOR_SPACEARR_BMLOOP_PTR, NULL, MLoopNorSpace::ref_alpha, MLoopNorSpace::ref_beta, BMesh::spacearr_dirty, BMesh::totloop, MLoopNorSpace::vec_lnor, MLoopNorSpace::vec_ortho, and MLoopNorSpace::vec_ref.

Referenced by BM_lnorspace_rebuild().

◆ BM_lnorspace_invalidate()

void BM_lnorspace_invalidate ( BMesh bm,
const bool  do_invalidate_all 
)

◆ BM_lnorspace_rebuild()

void BM_lnorspace_rebuild ( BMesh bm,
bool  preserve_clnor 
)

◆ BM_lnorspace_update()

void BM_lnorspace_update ( BMesh bm)

◆ BM_lnorspacearr_store()

void BM_lnorspacearr_store ( BMesh bm,
float(*)  r_lnors[3] 
)

◆ BM_loop_check_cyclic_smooth_fan()

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 425 of file bmesh_mesh_normals.c.

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().

◆ bm_loop_index_cmp()

static int bm_loop_index_cmp ( const void a,
const void b 
)
static

◆ BM_loop_normal_editdata_array_free()

void BM_loop_normal_editdata_array_free ( BMLoopNorEditDataArray lnors_ed_arr)

◆ BM_loop_normal_editdata_array_init()

BMLoopNorEditDataArray* BM_loop_normal_editdata_array_init ( BMesh bm,
const bool  do_all_loops_of_vert 
)

◆ bm_loop_normal_mark_indiv()

static int bm_loop_normal_mark_indiv ( BMesh bm,
BLI_bitmap loops,
const bool  do_all_loops_of_vert 
)
static

◆ bm_loop_normal_mark_indiv_do_loop()

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

◆ BM_loops_calc_normal_vcos()

void BM_loops_calc_normal_vcos ( BMesh bm,
const float(*)  vcos[3],
const float(*)  vnos[3],
const float(*)  fnos[3],
bool  use_split_normals,
float  split_angle,
float(*)  r_lnos[3],
struct MLoopNorSpaceArray r_lnors_spacearr,
short(*)  clnors_data[2],
int  cd_loop_clnors_offset,
bool  do_rebuild 
)

BMesh Compute Loop Normals from/to external data.

Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals'). Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry (splitting edges).

Definition at line 1683 of file bmesh_mesh_normals.c.

References BLI_assert, bm, bm_mesh_loops_calc_normals(), bm_mesh_loops_calc_normals_no_autosmooth(), and cosf.

Referenced by BM_lnorspace_err(), BM_lnorspace_rebuild(), BM_lnorspacearr_store(), and mesh_render_data_update_normals().

◆ bm_mesh_edges_sharp_tag()

static void bm_mesh_edges_sharp_tag ( BMesh bm,
const float(*)  fnos[3],
float  split_angle_cos,
const bool  do_sharp_edges_tag 
)
static

◆ bm_mesh_loops_assign_normal_data()

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

◆ bm_mesh_loops_calc_normals()

static void bm_mesh_loops_calc_normals ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3],
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

◆ bm_mesh_loops_calc_normals__multi_threaded()

static void bm_mesh_loops_calc_normals__multi_threaded ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3],
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

◆ bm_mesh_loops_calc_normals__single_threaded()

static void bm_mesh_loops_calc_normals__single_threaded ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3],
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

◆ bm_mesh_loops_calc_normals_for_loop()

static int bm_mesh_loops_calc_normals_for_loop ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
const short(*)  clnors_data[2],
const int  cd_loop_clnors_offset,
const bool  has_clnors,
BLI_Stack edge_vectors,
BMLoop l_curr,
float(*)  r_lnos[3],
MLoopNorSpaceArray r_lnors_spacearr 
)
static

Called for all faces loops.

  • All loops must have BM_ELEM_TAG cleared.
  • Loop indices must be valid.
Note
When custom normals are present, the order of loops can be important. Loops with lower indices must be passed before loops with higher indices (for each vertex). This is needed since the first loop sets the reference point for the custom normal offsets.
Returns
The number of loops that were handled (for early exit when all have been handled).

Definition at line 469 of file bmesh_mesh_normals.c.

References 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, BLI_stack_is_empty(), BLI_stack_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(), BMVert::co, copy_v3_v3(), dot_v3v3(), BMLoop::e, BMesh::elem_index_dirty, BMLoop::f, LIKELY, madd_v3_v3fl(), BMLoop::next, BMFace::no, nor, normal, normalize_v3(), NULL, BMLoop::prev, saacos(), 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().

◆ bm_mesh_loops_calc_normals_for_vert_free_fn()

static void bm_mesh_loops_calc_normals_for_vert_free_fn ( const void *__restrict  userdata,
void *__restrict  chunk 
)
static

◆ bm_mesh_loops_calc_normals_for_vert_init_fn()

static void bm_mesh_loops_calc_normals_for_vert_init_fn ( const void *__restrict  userdata,
void *__restrict  chunk 
)
static

◆ bm_mesh_loops_calc_normals_for_vert_reduce_fn()

static void bm_mesh_loops_calc_normals_for_vert_reduce_fn ( const void *__restrict  userdata,
void *__restrict   UNUSEDchunk_join,
void *__restrict  chunk 
)
static

◆ bm_mesh_loops_calc_normals_for_vert_with_clnors()

static void bm_mesh_loops_calc_normals_for_vert_with_clnors ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3],
const short(*)  clnors_data[2],
const int  cd_loop_clnors_offset,
const bool  do_rebuild,
const float  split_angle_cos,
MLoopNorSpaceArray r_lnors_spacearr,
BLI_Stack edge_vectors,
BMVert v 
)
static

◆ bm_mesh_loops_calc_normals_for_vert_with_clnors_fn()

static void bm_mesh_loops_calc_normals_for_vert_with_clnors_fn ( void userdata,
MempoolIterData mp_v,
const TaskParallelTLS *__restrict  tls 
)
static

◆ bm_mesh_loops_calc_normals_for_vert_without_clnors()

static void bm_mesh_loops_calc_normals_for_vert_without_clnors ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3],
const bool  do_rebuild,
const float  split_angle_cos,
MLoopNorSpaceArray r_lnors_spacearr,
BLI_Stack edge_vectors,
BMVert v 
)
static

◆ bm_mesh_loops_calc_normals_for_vert_without_clnors_fn()

static void bm_mesh_loops_calc_normals_for_vert_without_clnors_fn ( void userdata,
MempoolIterData mp_v,
const TaskParallelTLS *__restrict  tls 
)
static

◆ bm_mesh_loops_calc_normals_no_autosmooth()

static void bm_mesh_loops_calc_normals_no_autosmooth ( BMesh bm,
const float(*)  vnos[3],
const float(*)  fnos[3],
float(*)  r_lnos[3] 
)
static

◆ bm_mesh_loops_custom_normals_set()

static void bm_mesh_loops_custom_normals_set ( BMesh bm,
const float(*)  vcos[3],
const float(*)  fnos[3],
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

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 1563 of file bmesh_mesh_normals.c.

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(), is_zero_v3(), l, MEM_freeN, MEM_mallocN, normal, normalize_v3(), NULL, and BMesh::totloop.

Referenced by BM_custom_loop_normals_from_vector_layer().

◆ bm_mesh_loops_split_lnor_fans()

static bool bm_mesh_loops_split_lnor_fans ( BMesh bm,
MLoopNorSpaceArray lnors_spacearr,
const float(*)  new_lnors[3] 
)
static

◆ BM_mesh_normals_update()

void BM_mesh_normals_update ( BMesh bm)

◆ BM_mesh_normals_update_ex()

void BM_mesh_normals_update_ex ( BMesh bm,
const struct BMeshNormalsUpdate_Params param 
)

◆ BM_mesh_normals_update_with_partial()

void BM_mesh_normals_update_with_partial ( BMesh bm,
const BMPartialUpdate bmpinfo 
)

Definition at line 308 of file bmesh_mesh_normals.c.

References bm, and BM_mesh_normals_update_with_partial_ex().

◆ BM_mesh_normals_update_with_partial_ex()

void BM_mesh_normals_update_with_partial_ex ( BMesh UNUSEDbm,
const BMPartialUpdate bmpinfo,
const struct BMeshNormalsUpdate_Params params 
)

◆ bm_mesh_verts_calc_normals()

static void bm_mesh_verts_calc_normals ( BMesh bm,
const float(*)  fnos[3],
const float(*)  vcos[3],
float(*)  vnos[3] 
)
static

◆ BM_normals_loops_edges_tag()

void BM_normals_loops_edges_tag ( BMesh bm,
const bool  do_edges 
)

◆ bm_partial_faces_parallel_range_calc_normals_cb()

static void bm_partial_faces_parallel_range_calc_normals_cb ( void userdata,
const int  iter,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

Definition at line 265 of file bmesh_mesh_normals.c.

References BM_face_calc_normal(), and BMFace::no.

Referenced by BM_mesh_normals_update_with_partial_ex().

◆ bm_partial_verts_parallel_range_calc_normal_cb()

static void bm_partial_verts_parallel_range_calc_normal_cb ( void userdata,
const int  iter,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

Definition at line 272 of file bmesh_mesh_normals.c.

References bm_vert_calc_normals_impl(), and v.

Referenced by BM_mesh_normals_update_with_partial_ex().

◆ bm_vert_calc_normals_accum_loop()

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] 
)

◆ bm_vert_calc_normals_cb()

static void bm_vert_calc_normals_cb ( void UNUSEDuserdata,
MempoolIterData mp_v,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

Definition at line 142 of file bmesh_mesh_normals.c.

References bm_vert_calc_normals_impl(), and v.

Referenced by bm_mesh_verts_calc_normals().

◆ bm_vert_calc_normals_impl()

static void bm_vert_calc_normals_impl ( BMVert v)
static

◆ bm_vert_calc_normals_with_coords()

static void bm_vert_calc_normals_with_coords ( BMVert v,
BMVertsCalcNormalsWithCoordsData data 
)
static

◆ bm_vert_calc_normals_with_coords_cb()

static void bm_vert_calc_normals_with_coords_cb ( void userdata,
MempoolIterData mp_v,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

Definition at line 193 of file bmesh_mesh_normals.c.

References bm_vert_calc_normals_with_coords(), data, and v.

Referenced by bm_mesh_verts_calc_normals().

◆ BM_verts_calc_normal_vcos()

void BM_verts_calc_normal_vcos ( BMesh bm,
const float(*)  fnos[3],
const float(*)  vcos[3],
float(*)  vnos[3] 
)

BMesh Compute Normals from/to external data.

Computes the vertex normals of a mesh into vnos, using given vertex coordinates (vcos) and polygon normals (fnos).

Definition at line 323 of file bmesh_mesh_normals.c.

References bm, and bm_mesh_verts_calc_normals().

Referenced by BKE_editmesh_cache_ensure_vert_normals().

◆ loop_normal_editdata_init()

static void loop_normal_editdata_init ( BMesh bm,
BMLoopNorEditData lnor_ed,
BMVert v,
BMLoop l,
const int  offset 
)
static