Blender V4.3
mesh_wrapper.cc File Reference
#include "MEM_guardedalloc.h"
#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "BLI_ghash.h"
#include "BLI_math_matrix.h"
#include "BLI_math_vector.h"
#include "BLI_math_vector.hh"
#include "BLI_task.hh"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_editmesh.hh"
#include "BKE_editmesh_cache.hh"
#include "BKE_lib_id.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_subdiv.hh"
#include "BKE_subdiv_mesh.hh"
#include "BKE_subdiv_modifier.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"

Go to the source code of this file.

Functions

MeshBKE_mesh_wrapper_from_editmesh (std::shared_ptr< BMEditMesh > em, const CustomData_MeshMasks *cd_mask_extra, const Mesh *me_settings)
 
void BKE_mesh_wrapper_ensure_mdata (Mesh *mesh)
 
Mesh Coordinate Access
Span< float3BKE_mesh_wrapper_vert_coords (const Mesh *mesh)
 
Span< float3BKE_mesh_wrapper_face_normals (Mesh *mesh)
 
void BKE_mesh_wrapper_tag_positions_changed (Mesh *mesh)
 
void BKE_mesh_wrapper_vert_coords_copy (const Mesh *mesh, blender::MutableSpan< float3 > positions)
 
void BKE_mesh_wrapper_vert_coords_copy_with_mat4 (const Mesh *mesh, float(*vert_coords)[3], int vert_coords_len, const float mat[4][4])
 
Mesh Array Length Access
int BKE_mesh_wrapper_vert_len (const Mesh *mesh)
 
int BKE_mesh_wrapper_edge_len (const Mesh *mesh)
 
int BKE_mesh_wrapper_loop_len (const Mesh *mesh)
 
int BKE_mesh_wrapper_face_len (const Mesh *mesh)
 
CPU Subdivision Evaluation
static Meshmesh_wrapper_ensure_subdivision (Mesh *mesh)
 
MeshBKE_mesh_wrapper_ensure_subdivision (Mesh *mesh)
 

Detailed Description

The primary purpose of this API is to avoid unnecessary mesh conversion for the final output of a modified mesh.

This API handles the case when the modifier stack outputs a mesh which does not have Mesh data (#Mesh::faces(), corner verts, corner edges, edges, etc). Currently this is used so the resulting mesh can have BMEditMesh data, postponing the converting until it's needed or avoiding conversion entirely which can be an expensive operation. Once converted, the meshes type changes to ME_WRAPPER_TYPE_MDATA, although the edit mesh is not cleared.

This API exposes functions that abstract over the different kinds of internal data, as well as supporting converting the mesh into regular mesh.

Definition in file mesh_wrapper.cc.

Function Documentation

◆ BKE_mesh_wrapper_edge_len()

int BKE_mesh_wrapper_edge_len ( const Mesh * mesh)

◆ BKE_mesh_wrapper_ensure_mdata()

◆ BKE_mesh_wrapper_ensure_subdivision()

◆ BKE_mesh_wrapper_face_len()

int BKE_mesh_wrapper_face_len ( const Mesh * mesh)

◆ BKE_mesh_wrapper_face_normals()

Span< float3 > BKE_mesh_wrapper_face_normals ( Mesh * mesh)

Return a contiguous array of face normal values, if available. Otherwise, normals are stored in BMesh faces and this returns null.

Definition at line 161 of file mesh_wrapper.cc.

References BKE_editmesh_cache_ensure_face_normals(), BLI_assert_unreachable, ME_WRAPPER_TYPE_BMESH, ME_WRAPPER_TYPE_MDATA, and ME_WRAPPER_TYPE_SUBD.

Referenced by DRW_text_edit_mesh_measure_stats().

◆ BKE_mesh_wrapper_from_editmesh()

◆ BKE_mesh_wrapper_loop_len()

int BKE_mesh_wrapper_loop_len ( const Mesh * mesh)

◆ BKE_mesh_wrapper_tag_positions_changed()

void BKE_mesh_wrapper_tag_positions_changed ( Mesh * mesh)

◆ BKE_mesh_wrapper_vert_coords()

Span< float3 > BKE_mesh_wrapper_vert_coords ( const Mesh * mesh)

Return a contiguous array of vertex position values, if available. Otherwise, vertex positions are stored in BMesh vertices and this returns null.

Definition at line 148 of file mesh_wrapper.cc.

References BLI_assert_unreachable, ME_WRAPPER_TYPE_BMESH, ME_WRAPPER_TYPE_MDATA, and ME_WRAPPER_TYPE_SUBD.

Referenced by BKE_editmesh_vert_coords_when_deformed(), BKE_object_foreach_display_point(), DRW_text_edit_mesh_measure_stats(), EDBM_unified_findnearest_from_raycast(), gizmo_preselect_elem_test_select(), and blender::bke::mesh_get_mapped_verts_coords().

◆ BKE_mesh_wrapper_vert_coords_copy()

◆ BKE_mesh_wrapper_vert_coords_copy_with_mat4()

◆ BKE_mesh_wrapper_vert_len()

◆ mesh_wrapper_ensure_subdivision()