Blender  V2.93
Classes | Macros | Functions | Variables
mesh_evaluate.c File Reference
#include <limits.h>
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "BLI_alloca.h"
#include "BLI_bitmap.h"
#include "BLI_edgehash.h"
#include "BLI_linklist.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_polyfill_2d.h"
#include "BLI_stack.h"
#include "BLI_task.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
#include "BKE_editmesh_cache.h"
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"
#include "BKE_report.h"
#include "BLI_strict_flags.h"
#include "atomic_ops.h"
#include "mikktspace.h"
#include "PIL_time.h"

Go to the source code of this file.

Classes

struct  MeshCalcNormalsData
 
struct  LoopSplitTaskData
 
struct  LoopSplitTaskDataCommon
 

Macros

#define USE_TESSFACE_SPEEDUP
 
#define USE_TESSFACE_QUADS   /* NEEDS FURTHER TESTING */
 
#define TESSFACE_IS_QUAD   1
 
#define ML_TO_MF(i1, i2, i3)
 
#define ML_TO_MF_QUAD()
 
#define USE_TESSFACE_SPEEDUP
 
#define ML_TO_MLT(i1, i2, i3)
 
#define ME_FGON   (1 << 3)
 
#define ML(v1, v2)
 

Functions

void BKE_mesh_mdisp_flip (MDisps *md, const bool use_loop_mdisp_flip)
 
void BKE_mesh_polygon_flip_ex (MPoly *mpoly, MLoop *mloop, CustomData *ldata, float(*lnors)[3], MDisps *mdisp, const bool use_loop_mdisp_flip)
 
void BKE_mesh_polygon_flip (MPoly *mpoly, MLoop *mloop, CustomData *ldata)
 
void BKE_mesh_polygons_flip (MPoly *mpoly, MLoop *mloop, CustomData *ldata, int totpoly)
 
Polygon Calculations
static void mesh_calc_ngon_normal (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvert, float normal[3])
 
void BKE_mesh_calc_poly_normal (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray, float r_no[3])
 
static void mesh_calc_ngon_normal_coords (const MPoly *mpoly, const MLoop *loopstart, const float(*vertex_coords)[3], float r_normal[3])
 
void BKE_mesh_calc_poly_normal_coords (const MPoly *mpoly, const MLoop *loopstart, const float(*vertex_coords)[3], float r_no[3])
 
static void mesh_calc_ngon_center (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvert, float cent[3])
 
void BKE_mesh_calc_poly_center (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray, float r_cent[3])
 
float BKE_mesh_calc_poly_area (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray)
 
float BKE_mesh_calc_area (const Mesh *me)
 
float BKE_mesh_calc_poly_uv_area (const MPoly *mpoly, const MLoopUV *uv_array)
 
static float UNUSED_FUNCTION() mesh_calc_poly_volume_centroid (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray, float r_cent[3])
 
static float mesh_calc_poly_volume_centroid_with_reference_center (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray, const float reference_center[3], float r_cent[3])
 
static float mesh_calc_poly_area_centroid (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray, float r_cent[3])
 
void BKE_mesh_calc_poly_angles (const MPoly *mpoly, const MLoop *loopstart, const MVert *mvarray, float angles[])
 
void BKE_mesh_poly_edgehash_insert (EdgeHash *ehash, const MPoly *mp, const MLoop *mloop)
 
void BKE_mesh_poly_edgebitmap_insert (unsigned int *edge_bitmap, const MPoly *mp, const MLoop *mloop)
 
Mesh Center Calculation
bool BKE_mesh_center_median (const Mesh *me, float r_cent[3])
 
bool BKE_mesh_center_median_from_polys (const Mesh *me, float r_cent[3])
 
bool BKE_mesh_center_bounds (const Mesh *me, float r_cent[3])
 
bool BKE_mesh_center_of_surface (const Mesh *me, float r_cent[3])
 
bool BKE_mesh_center_of_volume (const Mesh *me, float r_cent[3])
 
Mesh Volume Calculation
static bool mesh_calc_center_centroid_ex (const MVert *mverts, int UNUSED(mverts_num), const MLoopTri *looptri, int looptri_num, const MLoop *mloop, float r_center[3])
 
void BKE_mesh_calc_volume (const MVert *mverts, const int mverts_num, const MLoopTri *looptri, const int looptri_num, const MLoop *mloop, float *r_volume, float r_center[3])
 
NGon Tessellation (NGon/Tessface Conversion)
void BKE_mesh_loops_to_mface_corners (CustomData *fdata, CustomData *ldata, CustomData *UNUSED(pdata), unsigned int lindex[4], int findex, const int UNUSED(polyindex), const int mf_len, const int numUV, const int numCol, const bool hasPCol, const bool hasOrigSpace, const bool hasLNor)
 
void BKE_mesh_loops_to_tessdata (CustomData *fdata, CustomData *ldata, MFace *mface, const int *polyindices, unsigned int(*loopindices)[4], const int num_faces)
 
void BKE_mesh_tangent_loops_to_tessdata (CustomData *fdata, CustomData *ldata, MFace *mface, const int *polyindices, unsigned int(*loopindices)[4], const int num_faces, const char *layer_name)
 
int BKE_mesh_tessface_calc_ex (CustomData *fdata, CustomData *ldata, CustomData *pdata, MVert *mvert, int totface, int totloop, int totpoly, const bool do_face_nor_copy)
 
void BKE_mesh_recalc_looptri (const MLoop *mloop, const MPoly *mpoly, const MVert *mvert, int totloop, int totpoly, MLoopTri *mlooptri)
 
static void bm_corners_to_loops_ex (ID *id, CustomData *fdata, CustomData *ldata, MFace *mface, int totloop, int findex, int loopstart, int numTex, int numCol)
 
void BKE_mesh_convert_mfaces_to_mpolys (Mesh *mesh)
 
void BKE_mesh_do_versions_convert_mfaces_to_mpolys (Mesh *mesh)
 
void BKE_mesh_convert_mfaces_to_mpolys_ex (ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata, int totedge_i, int totface_i, int totloop_i, int totpoly_i, MEdge *medge, MFace *mface, int *r_totloop, int *r_totpoly, MLoop **r_mloop, MPoly **r_mpoly)
 
Mesh Flag Flushing
void BKE_mesh_flush_hidden_from_verts_ex (const MVert *mvert, const MLoop *mloop, MEdge *medge, const int totedge, MPoly *mpoly, const int totpoly)
 
void BKE_mesh_flush_hidden_from_verts (Mesh *me)
 
void BKE_mesh_flush_hidden_from_polys_ex (MVert *mvert, const MLoop *mloop, MEdge *medge, const int UNUSED(totedge), const MPoly *mpoly, const int totpoly)
 
void BKE_mesh_flush_hidden_from_polys (Mesh *me)
 
void BKE_mesh_flush_select_from_polys_ex (MVert *mvert, const int totvert, const MLoop *mloop, MEdge *medge, const int totedge, const MPoly *mpoly, const int totpoly)
 
void BKE_mesh_flush_select_from_polys (Mesh *me)
 
void BKE_mesh_flush_select_from_verts_ex (const MVert *mvert, const int UNUSED(totvert), const MLoop *mloop, MEdge *medge, const int totedge, MPoly *mpoly, const int totpoly)
 
void BKE_mesh_flush_select_from_verts (Mesh *me)
 
Mesh Spatial Calculation
void BKE_mesh_calc_relative_deform (const MPoly *mpoly, const int totpoly, const MLoop *mloop, const int totvert, const float(*vert_cos_src)[3], const float(*vert_cos_dst)[3], const float(*vert_cos_org)[3], float(*vert_cos_new)[3])
 

Variables

static CLG_LogRef LOG = {"bke.mesh_evaluate"}
 

Mesh Normal Calculation

#define LNOR_SPACE_TRIGO_THRESHOLD   (1.0f - 1e-4f)
 
#define LOOP_SPLIT_TASK_BLOCK_SIZE   1024
 
#define INDEX_UNSET   INT_MIN
 
#define INDEX_INVALID   -1
 
#define IS_EDGE_SHARP(_e2l)   (ELEM((_e2l)[1], INDEX_UNSET, INDEX_INVALID))
 
typedef struct MeshCalcNormalsData MeshCalcNormalsData
 
typedef struct LoopSplitTaskData LoopSplitTaskData
 
typedef struct LoopSplitTaskDataCommon LoopSplitTaskDataCommon
 
static void mesh_calc_normals_vert_fallback (MVert *mverts, int numVerts)
 
void BKE_mesh_calc_normals_mapping_simple (struct Mesh *mesh)
 
void BKE_mesh_calc_normals_mapping (MVert *mverts, int numVerts, const MLoop *mloop, const MPoly *mpolys, int numLoops, int numPolys, float(*r_polyNors)[3], const MFace *mfaces, int numFaces, const int *origIndexFace, float(*r_faceNors)[3])
 
void BKE_mesh_calc_normals_mapping_ex (MVert *mverts, int numVerts, const MLoop *mloop, const MPoly *mpolys, int numLoops, int numPolys, float(*r_polyNors)[3], const MFace *mfaces, int numFaces, const int *origIndexFace, float(*r_faceNors)[3], const bool only_face_normals)
 
static void mesh_calc_normals_poly_cb (void *__restrict userdata, const int pidx, const TaskParallelTLS *__restrict UNUSED(tls))
 
static void mesh_calc_normals_poly_prepare_cb (void *__restrict userdata, const int pidx, const TaskParallelTLS *__restrict UNUSED(tls))
 
static void mesh_calc_normals_poly_finalize_cb (void *__restrict userdata, const int vidx, const TaskParallelTLS *__restrict UNUSED(tls))
 
void BKE_mesh_calc_normals_poly (MVert *mverts, float(*r_vertnors)[3], int numVerts, const MLoop *mloop, const MPoly *mpolys, int numLoops, int numPolys, float(*r_polynors)[3], const bool only_face_normals)
 
void BKE_mesh_ensure_normals (Mesh *mesh)
 
void BKE_mesh_ensure_normals_for_display (Mesh *mesh)
 
void BKE_mesh_calc_normals (Mesh *mesh)
 
void BKE_mesh_calc_normals_looptri (MVert *mverts, int numVerts, const MLoop *mloop, const MLoopTri *looptri, int looptri_num, float(*r_tri_nors)[3])
 
void BKE_lnor_spacearr_init (MLoopNorSpaceArray *lnors_spacearr, const int numLoops, const char data_type)
 
void BKE_lnor_spacearr_clear (MLoopNorSpaceArray *lnors_spacearr)
 
void BKE_lnor_spacearr_free (MLoopNorSpaceArray *lnors_spacearr)
 
MLoopNorSpaceBKE_lnor_space_create (MLoopNorSpaceArray *lnors_spacearr)
 
void BKE_lnor_space_define (MLoopNorSpace *lnor_space, const float lnor[3], float vec_ref[3], float vec_other[3], BLI_Stack *edge_vectors)
 
void BKE_lnor_space_add_loop (MLoopNorSpaceArray *lnors_spacearr, MLoopNorSpace *lnor_space, const int ml_index, void *bm_loop, const bool is_single)
 
MINLINE float unit_short_to_float (const short val)
 
MINLINE short unit_float_to_short (const float val)
 
void BKE_lnor_space_custom_data_to_normal (MLoopNorSpace *lnor_space, const short clnor_data[2], float r_custom_lnor[3])
 
void BKE_lnor_space_custom_normal_to_data (MLoopNorSpace *lnor_space, const float custom_lnor[3], short r_clnor_data[2])
 
static void mesh_edges_sharp_tag (LoopSplitTaskDataCommon *data, const bool check_angle, const float split_angle, const bool do_sharp_edges_tag)
 
void BKE_edges_sharp_from_angle_set (const struct MVert *mverts, const int UNUSED(numVerts), struct MEdge *medges, const int numEdges, struct MLoop *mloops, const int numLoops, struct MPoly *mpolys, const float(*polynors)[3], const int numPolys, const float split_angle)
 
void BKE_mesh_loop_manifold_fan_around_vert_next (const MLoop *mloops, const MPoly *mpolys, const int *loop_to_poly, const int *e2lfan_curr, const uint mv_pivot_index, const MLoop **r_mlfan_curr, int *r_mlfan_curr_index, int *r_mlfan_vert_index, int *r_mpfan_curr_index)
 
static void split_loop_nor_single_do (LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
 
static void split_loop_nor_fan_do (LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data)
 
static void loop_split_worker_do (LoopSplitTaskDataCommon *common_data, LoopSplitTaskData *data, BLI_Stack *edge_vectors)
 
static void loop_split_worker (TaskPool *__restrict pool, void *taskdata)
 
static bool loop_split_generator_check_cyclic_smooth_fan (const MLoop *mloops, const MPoly *mpolys, const int(*edge_to_loops)[2], const int *loop_to_poly, const int *e2l_prev, BLI_bitmap *skip_loops, const MLoop *ml_curr, const MLoop *ml_prev, const int ml_curr_index, const int ml_prev_index, const int mp_curr_index)
 
static void loop_split_generator (TaskPool *pool, LoopSplitTaskDataCommon *common_data)
 
void BKE_mesh_normals_loop_split (const MVert *mverts, const int UNUSED(numVerts), MEdge *medges, const int numEdges, MLoop *mloops, float(*r_loopnors)[3], const int numLoops, MPoly *mpolys, const float(*polynors)[3], const int numPolys, const bool use_split_normals, const float split_angle, MLoopNorSpaceArray *r_lnors_spacearr, short(*clnors_data)[2], int *r_loop_to_poly)
 
static void mesh_normals_loop_custom_set (const MVert *mverts, const int numVerts, MEdge *medges, const int numEdges, MLoop *mloops, float(*r_custom_loopnors)[3], const int numLoops, MPoly *mpolys, const float(*polynors)[3], const int numPolys, short(*r_clnors_data)[2], const bool use_vertices)
 
void BKE_mesh_normals_loop_custom_set (const MVert *mverts, const int numVerts, MEdge *medges, const int numEdges, MLoop *mloops, float(*r_custom_loopnors)[3], const int numLoops, MPoly *mpolys, const float(*polynors)[3], const int numPolys, short(*r_clnors_data)[2])
 
void BKE_mesh_normals_loop_custom_from_vertices_set (const MVert *mverts, float(*r_custom_vertnors)[3], const int numVerts, MEdge *medges, const int numEdges, MLoop *mloops, const int numLoops, MPoly *mpolys, const float(*polynors)[3], const int numPolys, short(*r_clnors_data)[2])
 
static void mesh_set_custom_normals (Mesh *mesh, float(*r_custom_nors)[3], const bool use_vertices)
 
void BKE_mesh_set_custom_normals (Mesh *mesh, float(*r_custom_loopnors)[3])
 
void BKE_mesh_set_custom_normals_from_vertices (Mesh *mesh, float(*r_custom_vertnors)[3])
 
void BKE_mesh_normals_loop_to_vertex (const int numVerts, const MLoop *mloops, const int numLoops, const float(*clnors)[3], float(*r_vert_clnors)[3])
 

Detailed Description

Functions to evaluate mesh data.

Definition in file mesh_evaluate.c.

Macro Definition Documentation

◆ INDEX_INVALID

#define INDEX_INVALID   -1

Definition at line 819 of file mesh_evaluate.c.

◆ INDEX_UNSET

#define INDEX_UNSET   INT_MIN

Definition at line 818 of file mesh_evaluate.c.

◆ IS_EDGE_SHARP

#define IS_EDGE_SHARP (   _e2l)    (ELEM((_e2l)[1], INDEX_UNSET, INDEX_INVALID))

Definition at line 821 of file mesh_evaluate.c.

◆ LNOR_SPACE_TRIGO_THRESHOLD

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

Definition at line 565 of file mesh_evaluate.c.

◆ LOOP_SPLIT_TASK_BLOCK_SIZE

#define LOOP_SPLIT_TASK_BLOCK_SIZE   1024

Definition at line 773 of file mesh_evaluate.c.

◆ ME_FGON

#define ME_FGON   (1 << 3)

◆ ML

#define ML (   v1,
  v2 
)
Value:
{ \
ml->v = mf->v1; \
ml->e = POINTER_AS_UINT(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); \
ml++; \
j++; \
} \
(void)0
void * BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1) ATTR_WARN_UNUSED_RESULT
Definition: edgehash.c:325
#define POINTER_AS_UINT(i)

◆ ML_TO_MF

#define ML_TO_MF (   i1,
  i2,
  i3 
)
Value:
mface_to_poly_map[mface_index] = poly_index; \
mf = &mface[mface_index]; \
lidx = lindices[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
l1 = mp_loopstart + i1; \
l2 = mp_loopstart + i2; \
l3 = mp_loopstart + i3; \
mf->v1 = mloop[l1].v; \
mf->v2 = mloop[l2].v; \
mf->v3 = mloop[l3].v; \
mf->v4 = 0; \
lidx[0] = l1; \
lidx[1] = l2; \
lidx[2] = l3; \
lidx[3] = 0; \
mf->mat_nr = mp->mat_nr; \
mf->flag = mp->flag; \
mf->edcode = 0; \
(void)0
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1

◆ ML_TO_MF_QUAD

#define ML_TO_MF_QUAD ( )
Value:
mface_to_poly_map[mface_index] = poly_index; \
mf = &mface[mface_index]; \
lidx = lindices[mface_index]; \
/* set loop indices, transformed to vert indices later */ \
l1 = mp_loopstart + 0; /* EXCEPTION */ \
l2 = mp_loopstart + 1; /* EXCEPTION */ \
l3 = mp_loopstart + 2; /* EXCEPTION */ \
l4 = mp_loopstart + 3; /* EXCEPTION */ \
mf->v1 = mloop[l1].v; \
mf->v2 = mloop[l2].v; \
mf->v3 = mloop[l3].v; \
mf->v4 = mloop[l4].v; \
lidx[0] = l1; \
lidx[1] = l2; \
lidx[2] = l3; \
lidx[3] = l4; \
mf->mat_nr = mp->mat_nr; \
mf->flag = mp->flag; \
mf->edcode = TESSFACE_IS_QUAD; \
(void)0
#define TESSFACE_IS_QUAD

◆ ML_TO_MLT

#define ML_TO_MLT (   i1,
  i2,
  i3 
)
Value:
{ \
mlt = &mlooptri[mlooptri_index]; \
l1 = mp_loopstart + i1; \
l2 = mp_loopstart + i2; \
l3 = mp_loopstart + i3; \
ARRAY_SET_ITEMS(mlt->tri, l1, l2, l3); \
mlt->poly = (unsigned int)poly_index; \
} \
((void)0)

◆ TESSFACE_IS_QUAD

#define TESSFACE_IS_QUAD   1

◆ USE_TESSFACE_QUADS

#define USE_TESSFACE_QUADS   /* NEEDS FURTHER TESTING */

◆ USE_TESSFACE_SPEEDUP [1/2]

#define USE_TESSFACE_SPEEDUP

◆ USE_TESSFACE_SPEEDUP [2/2]

#define USE_TESSFACE_SPEEDUP

Typedef Documentation

◆ LoopSplitTaskData

◆ LoopSplitTaskDataCommon

◆ MeshCalcNormalsData

Function Documentation

◆ BKE_edges_sharp_from_angle_set()

void BKE_edges_sharp_from_angle_set ( const struct MVert mverts,
const int   UNUSEDnumVerts,
struct MEdge medges,
const int  numEdges,
struct MLoop mloops,
const int  numLoops,
struct MPoly mpolys,
const float(*)  polynors[3],
const int  numPolys,
const 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 autosmooth!

Definition at line 936 of file mesh_evaluate.c.

References M_PI, MEM_calloc_arrayN, MEM_freeN, MEM_malloc_arrayN, mesh_edges_sharp_tag(), and LoopSplitTaskDataCommon::mverts.

◆ BKE_lnor_space_add_loop()

void BKE_lnor_space_add_loop ( MLoopNorSpaceArray lnors_spacearr,
MLoopNorSpace lnor_space,
const int  ml_index,
void *  bm_loop,
const bool  is_single 
)

Add a new given loop to given lnor_space. Depending on lnor_space->data_type, we expect bm_loop to be a pointer to BMLoop struct (in case of BMLOOP_PTR), or NULL (in case of LOOP_INDEX), loop index is then stored in pointer. If is_single is set, the BMLoop or loop index is directly stored in lnor_space->loops pointer (since there is only one loop in this fan), else it is added to the linked list of loops in the fan.

Definition at line 652 of file mesh_evaluate.c.

References BLI_assert, BLI_linklist_prepend_nlink(), MLoopNorSpaceArray::data_type, MLoopNorSpace::flags, MLoopNorSpace::loops, MLoopNorSpaceArray::loops_pool, MLoopNorSpaceArray::lspacearr, MLNOR_SPACE_IS_SINGLE, MLNOR_SPACEARR_BMLOOP_PTR, MLNOR_SPACEARR_LOOP_INDEX, NULL, and POINTER_FROM_INT.

Referenced by bm_mesh_loops_calc_normals(), split_loop_nor_fan_do(), and split_loop_nor_single_do().

◆ BKE_lnor_space_create()

MLoopNorSpace* BKE_lnor_space_create ( MLoopNorSpaceArray lnors_spacearr)

◆ BKE_lnor_space_custom_data_to_normal()

void BKE_lnor_space_custom_data_to_normal ( MLoopNorSpace lnor_space,
const short  clnor_data[2],
float  r_custom_lnor[3] 
)

◆ BKE_lnor_space_custom_normal_to_data()

void BKE_lnor_space_custom_normal_to_data ( MLoopNorSpace lnor_space,
const float  custom_lnor[3],
short  r_clnor_data[2] 
)

◆ BKE_lnor_space_define()

void BKE_lnor_space_define ( MLoopNorSpace lnor_space,
const float  lnor[3],
float  vec_ref[3],
float  vec_other[3],
BLI_Stack edge_vectors 
)

◆ BKE_lnor_spacearr_clear()

void BKE_lnor_spacearr_clear ( MLoopNorSpaceArray lnors_spacearr)

◆ BKE_lnor_spacearr_free()

void BKE_lnor_spacearr_free ( MLoopNorSpaceArray lnors_spacearr)

◆ BKE_lnor_spacearr_init()

void BKE_lnor_spacearr_init ( MLoopNorSpaceArray lnors_spacearr,
const int  numLoops,
const char  data_type 
)

◆ BKE_mesh_calc_area()

float BKE_mesh_calc_area ( const Mesh me)

◆ BKE_mesh_calc_normals()

void BKE_mesh_calc_normals ( Mesh mesh)

◆ BKE_mesh_calc_normals_looptri()

void BKE_mesh_calc_normals_looptri ( MVert mverts,
int  numVerts,
const MLoop mloop,
const MLoopTri looptri,
int  looptri_num,
float(*)  r_tri_nors[3] 
)

◆ BKE_mesh_calc_normals_mapping()

void BKE_mesh_calc_normals_mapping ( MVert mverts,
int  numVerts,
const MLoop mloop,
const MPoly mpolys,
int  numLoops,
int  numPolys,
float(*)  r_polyNors[3],
const MFace mfaces,
int  numFaces,
const int *  origIndexFace,
float(*)  r_faceNors[3] 
)

Definition at line 111 of file mesh_evaluate.c.

References BKE_mesh_calc_normals_mapping_ex().

◆ BKE_mesh_calc_normals_mapping_ex()

void BKE_mesh_calc_normals_mapping_ex ( MVert mverts,
int  numVerts,
const MLoop mloop,
const MPoly mpolys,
int  numLoops,
int  numPolys,
float(*)  r_polyNors[3],
const MFace mfaces,
int  numFaces,
const int *  origIndexFace,
float(*)  r_faceNors[3],
const bool  only_face_normals 
)

◆ BKE_mesh_calc_normals_mapping_simple()

void BKE_mesh_calc_normals_mapping_simple ( struct Mesh mesh)

◆ BKE_mesh_calc_normals_poly()

void BKE_mesh_calc_normals_poly ( MVert mverts,
float(*)  r_vertnors[3],
int  numVerts,
const MLoop mloop,
const MPoly mpolys,
int  numLoops,
int  numPolys,
float(*)  r_polynors[3],
const bool  only_face_normals 
)

◆ BKE_mesh_calc_poly_angles()

void BKE_mesh_calc_poly_angles ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvarray,
float  angles[] 
)

◆ BKE_mesh_calc_poly_area()

float BKE_mesh_calc_poly_area ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvarray 
)

◆ BKE_mesh_calc_poly_center()

void BKE_mesh_calc_poly_center ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvarray,
float  r_cent[3] 
)

◆ BKE_mesh_calc_poly_normal()

void BKE_mesh_calc_poly_normal ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvarray,
float  r_no[3] 
)

◆ BKE_mesh_calc_poly_normal_coords()

void BKE_mesh_calc_poly_normal_coords ( const MPoly mpoly,
const MLoop loopstart,
const float(*)  vertex_coords[3],
float  r_no[3] 
)

◆ BKE_mesh_calc_poly_uv_area()

float BKE_mesh_calc_poly_uv_area ( const MPoly mpoly,
const MLoopUV uv_array 
)

◆ BKE_mesh_calc_relative_deform()

void BKE_mesh_calc_relative_deform ( const MPoly mpoly,
const int  totpoly,
const MLoop mloop,
const int  totvert,
const float(*)  vert_cos_src[3],
const float(*)  vert_cos_dst[3],
const float(*)  vert_cos_org[3],
float(*)  vert_cos_new[3] 
)

This function takes the difference between 2 vertex-coord-arrays (vert_cos_src, vert_cos_dst), and applies the difference to vert_cos_new relative to vert_cos_org.

Parameters
vert_cos_srcreference deform source.
vert_cos_dstreference deform destination.
vert_cos_orgreference for the output location.
vert_cos_newresulting coords.

Definition at line 4007 of file mesh_evaluate.c.

References add_v3_v3(), copy_v3_v3(), MPoly::loopstart, MEM_calloc_arrayN, MEM_freeN, mul_v3_fl(), MPoly::totloop, transform_point_by_tri_v3(), and MLoop::v.

◆ BKE_mesh_calc_volume()

void BKE_mesh_calc_volume ( const MVert mverts,
const int  mverts_num,
const MLoopTri looptri,
const int  looptri_num,
const MLoop mloop,
float r_volume,
float  r_center[3] 
)

Calculate the volume and center.

Parameters
r_volumeVolume (unsigned).
r_centerCenter of mass.

Definition at line 2720 of file mesh_evaluate.c.

References center, BMVert::co, MVert::co, fabsf, madd_v3_v3fl(), mesh_calc_center_centroid_ex(), mul_v3_fl(), MLoopTri::tri, MLoop::v, v1, v2, volume_tetrahedron_signed_v3(), and zero_v3().

◆ BKE_mesh_center_bounds()

bool BKE_mesh_center_bounds ( const Mesh me,
float  r_cent[3] 
)

Definition at line 2583 of file mesh_evaluate.c.

References BKE_mesh_minmax(), INIT_MINMAX, max, mid_v3_v3v3(), and min.

◆ BKE_mesh_center_median()

bool BKE_mesh_center_median ( const Mesh me,
float  r_cent[3] 
)

Definition at line 2542 of file mesh_evaluate.c.

References add_v3_v3(), MVert::co, mul_v3_fl(), Mesh::mvert, Mesh::totvert, and zero_v3().

Referenced by BKE_mesh_center_of_surface().

◆ BKE_mesh_center_median_from_polys()

bool BKE_mesh_center_median_from_polys ( const Mesh me,
float  r_cent[3] 
)

Calculate the center from polygons, use when we want to ignore vertex locations that don't have connected faces.

Definition at line 2561 of file mesh_evaluate.c.

References add_v3_v3(), MPoly::loopstart, Mesh::mloop, Mesh::mpoly, mul_v3_fl(), Mesh::mvert, MPoly::totloop, Mesh::totpoly, v, and zero_v3().

Referenced by BKE_mesh_center_of_volume().

◆ BKE_mesh_center_of_surface()

bool BKE_mesh_center_of_surface ( const Mesh me,
float  r_cent[3] 
)

◆ BKE_mesh_center_of_volume()

bool BKE_mesh_center_of_volume ( const Mesh me,
float  r_cent[3] 
)

◆ BKE_mesh_convert_mfaces_to_mpolys()

void BKE_mesh_convert_mfaces_to_mpolys ( Mesh mesh)

◆ BKE_mesh_convert_mfaces_to_mpolys_ex()

void BKE_mesh_convert_mfaces_to_mpolys_ex ( ID id,
CustomData fdata,
CustomData ldata,
CustomData pdata,
int  totedge_i,
int  totface_i,
int  totloop_i,
int  totpoly_i,
MEdge medge,
MFace mface,
int *  r_totloop,
int *  r_totpoly,
MLoop **  r_mloop,
MPoly **  r_mpoly 
)

◆ BKE_mesh_do_versions_convert_mfaces_to_mpolys()

void BKE_mesh_do_versions_convert_mfaces_to_mpolys ( Mesh mesh)

The same as BKE_mesh_convert_mfaces_to_mpolys but oriented to be used in do_versions from readfile.c the difference is how active/render/clone/stencil indices are handled here

normally thay're being set from pdata which totally makes sense for meshes which are already converted to bmesh structures, but when loading older files indices shall be updated in other way around, so newly added pdata and ldata would have this indices set based on fdata layer

this is normally only needed when reading older files, in all other cases BKE_mesh_convert_mfaces_to_mpolys shall be always used

Definition at line 3555 of file mesh_evaluate.c.

References BKE_mesh_convert_mfaces_to_mpolys_ex(), BKE_mesh_update_customdata_pointers(), CustomData_bmesh_do_versions_update_active_layers(), Mesh::fdata, Mesh::id, Mesh::ldata, Mesh::medge, mesh, Mesh::mface, Mesh::mloop, Mesh::mpoly, Mesh::totedge, Mesh::totface, Mesh::totloop, and Mesh::totpoly.

Referenced by do_versions_after_linking_280().

◆ BKE_mesh_ensure_normals()

void BKE_mesh_ensure_normals ( Mesh mesh)

◆ BKE_mesh_ensure_normals_for_display()

void BKE_mesh_ensure_normals_for_display ( Mesh mesh)

◆ BKE_mesh_flush_hidden_from_polys()

void BKE_mesh_flush_hidden_from_polys ( Mesh me)

◆ BKE_mesh_flush_hidden_from_polys_ex()

void BKE_mesh_flush_hidden_from_polys_ex ( MVert mvert,
const MLoop mloop,
MEdge medge,
const int   UNUSEDtotedge,
const MPoly mpoly,
const int  totpoly 
)

Definition at line 3854 of file mesh_evaluate.c.

References MLoop::e, MVert::flag, MEdge::flag, ME_HIDE, and MLoop::v.

Referenced by BKE_mesh_flush_hidden_from_polys().

◆ BKE_mesh_flush_hidden_from_verts()

void BKE_mesh_flush_hidden_from_verts ( Mesh me)

◆ BKE_mesh_flush_hidden_from_verts_ex()

void BKE_mesh_flush_hidden_from_verts_ex ( const MVert mvert,
const MLoop mloop,
MEdge medge,
const int  totedge,
MPoly mpoly,
const int  totpoly 
)

◆ BKE_mesh_flush_select_from_polys()

void BKE_mesh_flush_select_from_polys ( Mesh me)

◆ BKE_mesh_flush_select_from_polys_ex()

void BKE_mesh_flush_select_from_polys_ex ( MVert mvert,
const int  totvert,
const MLoop mloop,
MEdge medge,
const int  totedge,
const MPoly mpoly,
const int  totpoly 
)

simple poly -> vert/edge selection.

Definition at line 3894 of file mesh_evaluate.c.

References MLoop::e, MVert::flag, MEdge::flag, MPoly::flag, MPoly::loopstart, ME_FACE_SEL, SELECT, MPoly::totloop, and MLoop::v.

Referenced by BKE_mesh_flush_select_from_polys().

◆ BKE_mesh_flush_select_from_verts()

void BKE_mesh_flush_select_from_verts ( Mesh me)

◆ BKE_mesh_flush_select_from_verts_ex()

void BKE_mesh_flush_select_from_verts_ex ( const MVert mvert,
const int   UNUSEDtotvert,
const MLoop mloop,
MEdge medge,
const int  totedge,
MPoly mpoly,
const int  totpoly 
)

◆ BKE_mesh_loop_manifold_fan_around_vert_next()

void BKE_mesh_loop_manifold_fan_around_vert_next ( const MLoop mloops,
const MPoly mpolys,
const int *  loop_to_poly,
const int *  e2lfan_curr,
const uint  mv_pivot_index,
const MLoop **  r_mlfan_curr,
int *  r_mlfan_curr_index,
int *  r_mlfan_vert_index,
int *  r_mpfan_curr_index 
)

◆ BKE_mesh_loops_to_mface_corners()

void BKE_mesh_loops_to_mface_corners ( CustomData fdata,
CustomData ldata,
CustomData UNUSEDpdata,
unsigned int  lindex[4],
int  findex,
const int   UNUSEDpolyindex,
const int  mf_len,
const int  numUV,
const int  numCol,
const bool  hasPCol,
const bool  hasOrigSpace,
const bool  hasLNor 
)

◆ BKE_mesh_loops_to_tessdata()

void BKE_mesh_loops_to_tessdata ( CustomData fdata,
CustomData ldata,
MFace mface,
const int *  polyindices,
unsigned int(*)  loopindices[4],
const int  num_faces 
)

Convert all CD layers from loop/poly to tessface data.

Parameters
loopindicesis an array of an int[4] per tessface, mapping tessface's verts to loops indices.
Note
when mface is not NULL, mface[face_index].v4 is used to test quads, else, loopindices[face_index][3] is used.

Definition at line 2872 of file mesh_evaluate.c.

References CD_MCOL, CD_MLOOPCOL, CD_MLOOPUV, CD_MTFACE, CD_NORMAL, CD_ORIGSPACE, CD_ORIGSPACE_MLOOP, CD_PREVIEW_MCOL, CD_PREVIEW_MLOOPCOL, CD_TANGENT, CD_TESSLOOPNORMAL, copy_v2_v2(), copy_v4_v4(), CustomData_get_layer(), CustomData_get_layer_n(), CustomData_has_layer(), CustomData_number_of_layers(), float(), MESH_MLOOPCOL_TO_MCOL, normal_float_to_short_v3(), MLoopUV::uv, OrigSpaceLoop::uv, OrigSpaceFace::uv, MTFace::uv, and MFace::v4.

Referenced by BKE_mesh_tessface_calc_ex().

◆ BKE_mesh_mdisp_flip()

void BKE_mesh_mdisp_flip ( MDisps md,
const bool  use_loop_mdisp_flip 
)

Flip a single MLoop's MDisps structure, low level function to be called from face-flipping code which re-arranged the mdisps themselves.

Definition at line 3705 of file mesh_evaluate.c.

References MDisps::disps, float(), sqrt(), SWAP, swap_v3_v3(), MDisps::totdisp, UNLIKELY, x, and y.

Referenced by BKE_mesh_polygon_flip_ex(), and bmesh_kernel_loop_reverse().

◆ BKE_mesh_normals_loop_custom_from_vertices_set()

void BKE_mesh_normals_loop_custom_from_vertices_set ( const MVert mverts,
float(*)  r_custom_vertnors[3],
const int  numVerts,
MEdge medges,
const int  numEdges,
MLoop mloops,
const int  numLoops,
MPoly mpolys,
const float(*)  polynors[3],
const int  numPolys,
short(*)  r_clnors_data[2] 
)

Definition at line 2020 of file mesh_evaluate.c.

References mesh_normals_loop_custom_set().

◆ BKE_mesh_normals_loop_custom_set()

void BKE_mesh_normals_loop_custom_set ( const MVert mverts,
const int  numVerts,
MEdge medges,
const int  numEdges,
MLoop mloops,
float(*)  r_custom_loopnors[3],
const int  numLoops,
MPoly mpolys,
const float(*)  polynors[3],
const int  numPolys,
short(*)  r_clnors_data[2] 
)

Definition at line 1994 of file mesh_evaluate.c.

References mesh_normals_loop_custom_set().

◆ BKE_mesh_normals_loop_split()

void BKE_mesh_normals_loop_split ( const MVert mverts,
const int   UNUSEDnumVerts,
MEdge medges,
const int  numEdges,
MLoop mloops,
float(*)  r_loopnors[3],
const int  numLoops,
MPoly mpolys,
const float(*)  polynors[3],
const int  numPolys,
const bool  use_split_normals,
const float  split_angle,
MLoopNorSpaceArray r_lnors_spacearr,
short(*)  clnors_data[2],
int *  r_loop_to_poly 
)

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

Mapping edge -> loops. If that edge is used by more than two loops (polys), it is always sharp (and tagged as such, see below). We also use the second loop index as a kind of flag:

  • smooth edge: > 0.
  • sharp edge: < 0 (INDEX_INVALID || INDEX_UNSET).
  • unset: INDEX_UNSET.

Note that currently we only have two values for second loop of sharp edges. However, if needed, we can store the negated value of loop index instead of INDEX_INVALID to retrieve the real value later in code). Note also that loose edges always have both values set to 0!

Definition at line 1604 of file mesh_evaluate.c.

References BKE_lnor_spacearr_free(), BKE_lnor_spacearr_init(), BLI_assert, BLI_task_pool_create(), BLI_task_pool_free(), BLI_task_pool_work_and_wait(), copy_v3_v3(), MPoly::flag, float(), LoopSplitTaskDataCommon::lnors_spacearr, loop_split_generator(), LOOP_SPLIT_TASK_BLOCK_SIZE, MPoly::loopstart, M_PI, ME_SMOOTH, MEM_calloc_arrayN, MEM_freeN, MEM_malloc_arrayN, mesh_edges_sharp_tag(), MLNOR_SPACEARR_LOOP_INDEX, normal_short_to_float_v3(), NULL, task_pool, TASK_PRIORITY_HIGH, TIMEIT_END_AVERAGED, TIMEIT_START_AVERAGED, MPoly::totloop, and v.

Referenced by mesh_normals_loop_custom_set().

◆ BKE_mesh_normals_loop_to_vertex()

void BKE_mesh_normals_loop_to_vertex ( const int  numVerts,
const MLoop mloops,
const int  numLoops,
const float(*)  clnors[3],
float(*)  r_vert_clnors[3] 
)

Computes average per-vertex normals from given custom loop normals.

Parameters
clnorsThe computed custom loop normals.
r_vert_clnorsThe (already allocated) array where to store averaged per-vertex normals.

Definition at line 2123 of file mesh_evaluate.c.

References add_v3_v3(), copy_vn_fl(), MEM_calloc_arrayN, MEM_freeN, mul_v3_fl(), v, and MLoop::v.

◆ BKE_mesh_poly_edgebitmap_insert()

void BKE_mesh_poly_edgebitmap_insert ( unsigned int *  edge_bitmap,
const MPoly mp,
const MLoop mloop 
)

Definition at line 2521 of file mesh_evaluate.c.

References BLI_BITMAP_ENABLE, MLoop::e, and MPoly::totloop.

◆ BKE_mesh_poly_edgehash_insert()

void BKE_mesh_poly_edgehash_insert ( EdgeHash ehash,
const MPoly mp,
const MLoop mloop 
)

Definition at line 2505 of file mesh_evaluate.c.

References BLI_edgehash_reinsert(), NULL, MPoly::totloop, and MLoop::v.

◆ BKE_mesh_polygon_flip()

void BKE_mesh_polygon_flip ( MPoly mpoly,
MLoop mloop,
CustomData ldata 
)

Definition at line 3792 of file mesh_evaluate.c.

References BKE_mesh_polygon_flip_ex(), CD_MDISPS, CustomData_get_layer(), and NULL.

◆ BKE_mesh_polygon_flip_ex()

void BKE_mesh_polygon_flip_ex ( MPoly mpoly,
MLoop mloop,
CustomData ldata,
float(*)  lnors[3],
MDisps mdisp,
const bool  use_loop_mdisp_flip 
)

Flip (invert winding of) the given mpoly, i.e. reverse order of its loops (keeping the same vertex as 'start point').

Parameters
mpolythe polygon to flip.
mloopthe full loops array.
ldatathe loops custom data.

Definition at line 3749 of file mesh_evaluate.c.

References BKE_mesh_mdisp_flip(), CD_MLOOP, CustomData_get_layer(), CustomData_swap(), e, MLoop::e, MPoly::loopstart, SWAP, swap_v3_v3(), and MPoly::totloop.

Referenced by BKE_mesh_polygon_flip(), BKE_mesh_polygons_flip(), and polygons_check_flip().

◆ BKE_mesh_polygons_flip()

void BKE_mesh_polygons_flip ( MPoly mpoly,
MLoop mloop,
CustomData ldata,
int  totpoly 
)

Flip (invert winding of) all polygons (used to inverse their normals).

Note
Invalidates tessellation, caller must handle that.

Definition at line 3803 of file mesh_evaluate.c.

References BKE_mesh_polygon_flip_ex(), CD_MDISPS, CustomData_get_layer(), and NULL.

◆ BKE_mesh_recalc_looptri()

void BKE_mesh_recalc_looptri ( const MLoop mloop,
const MPoly mpoly,
const MVert mvert,
int  totloop,
int  totpoly,
MLoopTri mlooptri 
)

◆ BKE_mesh_set_custom_normals()

void BKE_mesh_set_custom_normals ( Mesh mesh,
float(*)  r_custom_loopnors[3] 
)

Higher level functions hiding most of the code needed around call to BKE_mesh_normals_loop_custom_set().

Parameters
r_custom_loopnorsis not const, since code will replace zero_v3 normals there with automatically computed vectors.

Definition at line 2100 of file mesh_evaluate.c.

References mesh, and mesh_set_custom_normals().

Referenced by modifyMesh(), blender::io::alembic::process_loop_normals(), and triangulate_mesh().

◆ BKE_mesh_set_custom_normals_from_vertices()

void BKE_mesh_set_custom_normals_from_vertices ( Mesh mesh,
float(*)  r_custom_vertnors[3] 
)

Higher level functions hiding most of the code needed around call to BKE_mesh_normals_loop_custom_from_vertices_set().

Parameters
r_custom_vertnorsis not const, since code will replace zero_v3 normals there with automatically computed vectors.

Definition at line 2112 of file mesh_evaluate.c.

References mesh, and mesh_set_custom_normals().

Referenced by blender::io::alembic::process_vertex_normals().

◆ BKE_mesh_tangent_loops_to_tessdata()

void BKE_mesh_tangent_loops_to_tessdata ( CustomData fdata,
CustomData ldata,
MFace mface,
const int *  polyindices,
unsigned int(*)  loopindices[4],
const int  num_faces,
const char *  layer_name 
)

◆ BKE_mesh_tessface_calc_ex()

int BKE_mesh_tessface_calc_ex ( CustomData fdata,
CustomData ldata,
CustomData pdata,
MVert mvert,
int  totface,
int  totloop,
int  totpoly,
const bool  do_face_nor_copy 
)

◆ bm_corners_to_loops_ex()

static void bm_corners_to_loops_ex ( ID id,
CustomData fdata,
CustomData ldata,
MFace mface,
int  totloop,
int  findex,
int  loopstart,
int  numTex,
int  numCol 
)
static

◆ loop_split_generator()

static void loop_split_generator ( TaskPool pool,
LoopSplitTaskDataCommon common_data 
)
static

◆ loop_split_generator_check_cyclic_smooth_fan()

static bool loop_split_generator_check_cyclic_smooth_fan ( const MLoop mloops,
const MPoly mpolys,
const int(*)  edge_to_loops[2],
const int *  loop_to_poly,
const int *  e2l_prev,
BLI_bitmap skip_loops,
const MLoop ml_curr,
const MLoop ml_prev,
const int  ml_curr_index,
const int  ml_prev_index,
const int  mp_curr_index 
)
static

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 1352 of file mesh_evaluate.c.

References BKE_mesh_loop_manifold_fan_around_vert_next(), BLI_assert, BLI_BITMAP_ENABLE, BLI_BITMAP_TEST, MLoop::e, IS_EDGE_SHARP, and MLoop::v.

Referenced by loop_split_generator().

◆ loop_split_worker()

static void loop_split_worker ( TaskPool *__restrict  pool,
void *  taskdata 
)
static

◆ loop_split_worker_do()

static void loop_split_worker_do ( LoopSplitTaskDataCommon common_data,
LoopSplitTaskData data,
BLI_Stack edge_vectors 
)
static

◆ mesh_calc_center_centroid_ex()

static bool mesh_calc_center_centroid_ex ( const MVert mverts,
int   UNUSEDmverts_num,
const MLoopTri looptri,
int  looptri_num,
const MLoop mloop,
float  r_center[3] 
)
static

◆ mesh_calc_ngon_center()

static void mesh_calc_ngon_center ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvert,
float  cent[3] 
)
static

Definition at line 2264 of file mesh_evaluate.c.

References float(), madd_v3_v3fl(), MPoly::totloop, v, w(), and zero_v3().

Referenced by BKE_mesh_calc_poly_center().

◆ mesh_calc_ngon_normal()

static void mesh_calc_ngon_normal ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvert,
float  normal[3] 
)
static

◆ mesh_calc_ngon_normal_coords()

static void mesh_calc_ngon_normal_coords ( const MPoly mpoly,
const MLoop loopstart,
const float(*)  vertex_coords[3],
float  r_normal[3] 
)
static

◆ mesh_calc_normals_poly_cb()

static void mesh_calc_normals_poly_cb ( void *__restrict  userdata,
const int  pidx,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

Definition at line 218 of file mesh_evaluate.c.

References BKE_mesh_calc_poly_normal(), data, and MPoly::loopstart.

Referenced by BKE_mesh_calc_normals_poly().

◆ mesh_calc_normals_poly_finalize_cb()

static void mesh_calc_normals_poly_finalize_cb ( void *__restrict  userdata,
const int  vidx,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

◆ mesh_calc_normals_poly_prepare_cb()

static void mesh_calc_normals_poly_prepare_cb ( void *__restrict  userdata,
const int  pidx,
const TaskParallelTLS *__restrict   UNUSEDtls 
)
static

◆ mesh_calc_normals_vert_fallback()

static void mesh_calc_normals_vert_fallback ( MVert mverts,
int  numVerts 
)
static

Call when there are no polygons.

Definition at line 76 of file mesh_evaluate.c.

References normal_float_to_short_v3(), and normalize_v3_v3().

Referenced by BKE_mesh_calc_normals_mapping_ex().

◆ mesh_calc_poly_area_centroid()

static float mesh_calc_poly_area_centroid ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvarray,
float  r_cent[3] 
)
static
Note
  • Results won't be correct if polygon is non-planar.
  • This has the advantage over mesh_calc_poly_volume_centroid that it doesn't depend on solid geometry, instead it weights the surface by volume.

Definition at line 2449 of file mesh_evaluate.c.

References area_tri_signed_v3(), BKE_mesh_calc_poly_normal(), copy_v3_v3(), madd_v3_v3fl(), mid_v3_v3v3v3(), mul_v3_fl(), normal, MPoly::totloop, v, v1, v2, and zero_v3().

Referenced by BKE_mesh_center_of_surface().

◆ mesh_calc_poly_volume_centroid()

static float UNUSED_FUNCTION() mesh_calc_poly_volume_centroid ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvarray,
float  r_cent[3] 
)
static

Calculate the volume and volume-weighted centroid of the volume formed by the polygon and the origin. Results will be negative if the origin is "outside" the polygon (+ve normal side), but the polygon may be non-planar with no effect.

Method from:

Note
  • Volume is 6x actual volume, and centroid is 4x actual volume-weighted centroid (so division can be done once at the end).
  • Results will have bias if polygon is non-planar.
  • The resulting volume will only be correct if the mesh is manifold and has consistent face winding (non-contiguous face normals or holes in the mesh surface).

Definition at line 2376 of file mesh_evaluate.c.

References MPoly::totloop, MLoop::v, volume_tri_tetrahedron_signed_v3_6x(), and zero_v3().

◆ mesh_calc_poly_volume_centroid_with_reference_center()

static float mesh_calc_poly_volume_centroid_with_reference_center ( const MPoly mpoly,
const MLoop loopstart,
const MVert mvarray,
const float  reference_center[3],
float  r_cent[3] 
)
static

A version of mesh_calc_poly_volume_centroid that takes an initial reference center, use this to increase numeric stability as the quality of the result becomes very low quality as the value moves away from 0.0, see: T65986.

Definition at line 2418 of file mesh_evaluate.c.

References copy_v3_v3(), sub_v3_v3v3(), MPoly::totloop, v, volume_tri_tetrahedron_signed_v3_6x(), and zero_v3().

Referenced by BKE_mesh_center_of_volume().

◆ mesh_edges_sharp_tag()

static void mesh_edges_sharp_tag ( LoopSplitTaskDataCommon data,
const bool  check_angle,
const float  split_angle,
const bool  do_sharp_edges_tag 
)
static

◆ mesh_normals_loop_custom_set()

static void mesh_normals_loop_custom_set ( const MVert mverts,
const int  numVerts,
MEdge medges,
const int  numEdges,
MLoop mloops,
float(*)  r_custom_loopnors[3],
const int  numLoops,
MPoly mpolys,
const float(*)  polynors[3],
const int  numPolys,
short(*)  r_clnors_data[2],
const bool  use_vertices 
)
static

Compute internal representation of given custom normals (as an array of float[2]). It also makes sure the mesh matches those custom normals, by setting sharp edges flag as needed to get a same custom lnor for all loops sharing a same smooth fan. If use_vertices if true, r_custom_loopnors is assumed to be per-vertex, not per-loop (this allows to set whole vert's normals at once, useful in some cases). r_custom_loopnors is expected to have normalized normals, or zero ones, in which case they will be replaced by default loop/vertex normal.

Definition at line 1756 of file mesh_evaluate.c.

References add_v3_v3(), BKE_lnor_space_custom_normal_to_data(), BKE_lnor_spacearr_clear(), BKE_lnor_spacearr_free(), BKE_mesh_normals_loop_split(), BLI_assert, BLI_BITMAP_DISABLE, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, BLI_bitmap_set_all(), BLI_BITMAP_TEST, BLI_BITMAP_TEST_BOOL, BLI_SMALLSTACK_DECLARE, BLI_SMALLSTACK_POP, BLI_SMALLSTACK_PUSH, copy_v3_v3(), MLoopNorSpaceArray::data_type, dot_v3v3(), MLoop::e, MEdge::flag, MLoopNorSpace::flags, float(), G, G_DEBUG, is_zero_v3(), LinkNode::link, LNOR_SPACE_TRIGO_THRESHOLD, MLoopNorSpace::loops, MPoly::loopstart, MLoopNorSpaceArray::lspacearr, M_PI, ME_SHARP, MEM_calloc_arrayN, MEM_freeN, MEM_malloc_arrayN, MLNOR_SPACE_IS_SINGLE, MLNOR_SPACEARR_LOOP_INDEX, mul_v3_fl(), LinkNode::next, nor, normal_short_to_float_v3(), NULL, POINTER_AS_INT, MPoly::totloop, v, and zero_v3().

Referenced by BKE_mesh_normals_loop_custom_from_vertices_set(), BKE_mesh_normals_loop_custom_set(), and mesh_set_custom_normals().

◆ mesh_set_custom_normals()

static void mesh_set_custom_normals ( Mesh mesh,
float(*)  r_custom_nors[3],
const bool  use_vertices 
)
static

◆ split_loop_nor_fan_do()

static void split_loop_nor_fan_do ( LoopSplitTaskDataCommon common_data,
LoopSplitTaskData data 
)
static

◆ split_loop_nor_single_do()

static void split_loop_nor_single_do ( LoopSplitTaskDataCommon common_data,
LoopSplitTaskData data 
)
static

◆ unit_float_to_short()

MINLINE short unit_float_to_short ( const float  val)

Definition at line 681 of file mesh_evaluate.c.

References floorf.

Referenced by BKE_lnor_space_custom_normal_to_data().

◆ unit_short_to_float()

MINLINE float unit_short_to_float ( const short  val)

Definition at line 676 of file mesh_evaluate.c.

References float().

Referenced by BKE_lnor_space_custom_data_to_normal().

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"bke.mesh_evaluate"}
static

Definition at line 67 of file mesh_evaluate.c.

Referenced by BKE_mesh_calc_normals_mapping_ex().