Blender  V3.3
Functions
mesh_evaluate.cc File Reference
#include <climits>
#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_index_range.hh"
#include "BLI_math.h"
#include "BLI_span.hh"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_multires.h"

Go to the source code of this file.

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 (uint *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])
 
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)
 
static void mesh_flush_select_from_verts (const Span< MVert > verts, const Span< MLoop > loops, MutableSpan< MEdge > edges, MutableSpan< MPoly > polys)
 
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])
 

Detailed Description

Functions to evaluate mesh data.

Definition in file mesh_evaluate.cc.

Function Documentation

◆ BKE_mesh_calc_area()

float BKE_mesh_calc_area ( const Mesh me)

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

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

◆ BKE_mesh_center_bounds()

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

Definition at line 441 of file mesh_evaluate.cc.

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 404 of file mesh_evaluate.cc.

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

◆ 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_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 769 of file mesh_evaluate.cc.

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 
)

◆ BKE_mesh_flush_select_from_verts()

void BKE_mesh_flush_select_from_verts ( Mesh me)

◆ BKE_mesh_mdisp_flip()

void BKE_mesh_mdisp_flip ( struct MDisps md,
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 635 of file mesh_evaluate.cc.

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

void BKE_mesh_poly_edgebitmap_insert ( uint edge_bitmap,
const MPoly mp,
const MLoop mloop 
)

Definition at line 385 of file mesh_evaluate.cc.

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 369 of file mesh_evaluate.cc.

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

◆ BKE_mesh_polygon_flip()

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

Definition at line 714 of file mesh_evaluate.cc.

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

◆ BKE_mesh_polygon_flip_ex()

void BKE_mesh_polygon_flip_ex ( struct MPoly mpoly,
struct MLoop mloop,
struct CustomData ldata,
float(*)  lnors[3],
struct MDisps mdisp,
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 671 of file mesh_evaluate.cc.

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 ( struct MPoly mpoly,
struct MLoop mloop,
struct 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 720 of file mesh_evaluate.cc.

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

◆ 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 146 of file mesh_evaluate.cc.

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_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 313 of file mesh_evaluate.cc.

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

◆ 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 282 of file mesh_evaluate.cc.

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

static void mesh_flush_select_from_verts ( const Span< MVert verts,
const Span< MLoop loops,
MutableSpan< MEdge edges,
MutableSpan< MPoly polys 
)
static