Blender  V3.3
Classes | Typedefs | Enumerations | Functions
BKE_DerivedMesh.h File Reference
#include "BLI_compiler_attrs.h"
#include "DNA_customdata_types.h"

Go to the source code of this file.

Classes

struct  DMFlagMat
 
struct  DerivedMesh
 

Typedefs

typedef struct DMFlagMat DMFlagMat
 
typedef enum DerivedMeshType DerivedMeshType
 
typedef struct DerivedMesh DerivedMesh
 

Enumerations

enum  DerivedMeshType { DM_TYPE_CDDM , DM_TYPE_CCGDM }
 

Functions

void DM_init_funcs (DerivedMesh *dm)
 
void DM_init (DerivedMesh *dm, DerivedMeshType type, int numVerts, int numEdges, int numTessFaces, int numLoops, int numPolys)
 
void DM_from_template (DerivedMesh *dm, DerivedMesh *source, DerivedMeshType type, int numVerts, int numEdges, int numTessFaces, int numLoops, int numPolys)
 
bool DM_release (DerivedMesh *dm)
 
void DM_set_only_copy (DerivedMesh *dm, const struct CustomData_MeshMasks *mask)
 
void DM_copy_vert_data (struct DerivedMesh *source, struct DerivedMesh *dest, int source_index, int dest_index, int count)
 
void DM_DupPolys (DerivedMesh *source, DerivedMesh *target)
 
void DM_ensure_looptri_data (DerivedMesh *dm)
 
void DM_interp_vert_data (struct DerivedMesh *source, struct DerivedMesh *dest, int *src_indices, float *weights, int count, int dest_index)
 
void mesh_get_mapped_verts_coords (struct Mesh *me_eval, float(*r_cos)[3], int totcos)
 
struct Mesheditbmesh_get_eval_cage (struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *obedit, struct BMEditMesh *em, const struct CustomData_MeshMasks *dataMask)
 
struct Mesheditbmesh_get_eval_cage_from_orig (struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *obedit, const struct CustomData_MeshMasks *dataMask)
 
float(* editbmesh_vert_coords_alloc (struct BMEditMesh *em, int *r_vert_len))[3]
 
bool editbmesh_modifier_is_enabled (const struct Scene *scene, const struct Object *ob, struct ModifierData *md, bool has_prev_mesh)
 
void makeDerivedMesh (struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
 
Custom Data Layer Access Functions
Returns
pointer to first data layer which matches type (a flat array) if they return NULL, data doesn't exist.
Note
these return pointers - any change modifies the internals of the mesh.
voidDM_get_vert_data_layer (struct DerivedMesh *dm, int type)
 
voidDM_get_edge_data_layer (struct DerivedMesh *dm, int type)
 
voidDM_get_poly_data_layer (struct DerivedMesh *dm, int type)
 
voidDM_get_loop_data_layer (struct DerivedMesh *dm, int type)
 

Detailed Description

Basic design of the DerivedMesh system:

DerivedMesh is a common set of interfaces for mesh systems.

There are three main mesh data structures in Blender: Mesh, CDDerivedMesh and BMesh.

These, and a few others, all implement DerivedMesh interfaces, which contains unified drawing interfaces, a few utility interfaces, and a bunch of read-only interfaces intended mostly for conversion from one format to another.

All Mesh structures in blender make use of CustomData, which is used to store per-element attributes and interpolate them (e.g. uvs, vcols, vgroups, etc).

Mesh is the "serialized" structure, used for storing object-mode mesh data and also for saving stuff to disk. Its interfaces are also what DerivedMesh uses to communicate with.

CDDM is a little mesh library, that uses Mesh data structures in the backend. It's mostly used for modifiers, and has the advantages of not taking much resources.

BMesh is a full-on brep, used for editmode, some modifiers, etc. It's much more capable (if memory-intensive) then CDDM.

DerivedMesh is somewhat hackish. Many places assumes that a DerivedMesh is a CDDM (most of the time by simply copying it and converting it to one). CDDM is the original structure for modifiers, but has since been superseded by BMesh, at least for the foreseeable future.

Definition in file BKE_DerivedMesh.h.

Typedef Documentation

◆ DerivedMesh

typedef struct DerivedMesh DerivedMesh

Definition at line 1 of file BKE_DerivedMesh.h.

◆ DerivedMeshType

◆ DMFlagMat

typedef struct DMFlagMat DMFlagMat

Enumeration Type Documentation

◆ DerivedMeshType

Enumerator
DM_TYPE_CDDM 
DM_TYPE_CCGDM 

Definition at line 81 of file BKE_DerivedMesh.h.

Function Documentation

◆ DM_copy_vert_data()

void DM_copy_vert_data ( struct DerivedMesh source,
struct DerivedMesh dest,
int  source_index,
int  dest_index,
int  count 
)

Custom data copy functions copy count elements from source_index in source to dest_index in dest these copy all layers for which the CD_FLAG_NOCOPY flag is not set.

Definition at line 460 of file DerivedMesh.cc.

References count, CustomData_copy_data(), dest, and DerivedMesh::vertData.

Referenced by set_ccgdm_all_geometry().

◆ DM_DupPolys()

void DM_DupPolys ( DerivedMesh source,
DerivedMesh target 
)

◆ DM_ensure_looptri_data()

void DM_ensure_looptri_data ( DerivedMesh dm)

Ensure the array is large enough.

Note
This function must always be thread-protected by caller. It should only be used by internal code.

Definition at line 362 of file DerivedMesh.cc.

References DerivedMesh::array, DerivedMesh::array_wip, BLI_assert, DerivedMesh::looptris, MEM_malloc_arrayN, MEM_SAFE_FREE, DerivedMesh::num, DerivedMesh::num_alloc, DerivedMesh::numLoopData, DerivedMesh::numPolyData, poly_to_tri_count(), and SWAP.

Referenced by ccgDM_recalcLoopTri(), and cdDM_recalc_looptri().

◆ DM_from_template()

void DM_from_template ( DerivedMesh dm,
DerivedMesh source,
DerivedMeshType  type,
int  numVerts,
int  numEdges,
int  numTessFaces,
int  numLoops,
int  numPolys 
)

◆ DM_get_edge_data_layer()

void* DM_get_edge_data_layer ( struct DerivedMesh dm,
int  type 
)

◆ DM_get_loop_data_layer()

void* DM_get_loop_data_layer ( struct DerivedMesh dm,
int  type 
)

Definition at line 455 of file DerivedMesh.cc.

References CustomData_get_layer(), DerivedMesh::loopData, and type.

Referenced by DM_init_funcs(), and do_multires_bake().

◆ DM_get_poly_data_layer()

void* DM_get_poly_data_layer ( struct DerivedMesh dm,
int  type 
)

◆ DM_get_vert_data_layer()

void* DM_get_vert_data_layer ( struct DerivedMesh dm,
int  type 
)

◆ DM_init()

void DM_init ( DerivedMesh dm,
DerivedMeshType  type,
int  numVerts,
int  numEdges,
int  numTessFaces,
int  numLoops,
int  numPolys 
)

Utility function to initialize a DerivedMesh for the desired number of vertices, edges and faces (doesn't allocate memory for them, just sets up the custom data layers)>

Definition at line 250 of file DerivedMesh.cc.

References CD_NUMTYPES, copy_vn_i(), DM_init_funcs(), DerivedMesh::edgeData, DerivedMesh::faceData, DerivedMesh::loopData, DerivedMesh::needsFree, DerivedMesh::numEdgeData, DerivedMesh::numLoopData, DerivedMesh::numPolyData, DerivedMesh::numTessFaceData, DerivedMesh::numVertData, DerivedMesh::polyData, DerivedMesh::type, type, CustomData::typemap, and DerivedMesh::vertData.

Referenced by cdDM_from_mesh_ex().

◆ DM_init_funcs()

void DM_init_funcs ( DerivedMesh dm)

◆ DM_interp_vert_data()

void DM_interp_vert_data ( struct DerivedMesh source,
struct DerivedMesh dest,
int *  src_indices,
float weights,
int  count,
int  dest_index 
)

Interpolates vertex data from the vertices indexed by src_indices in the source mesh using the given weights and stores the result in the vertex indexed by dest_index in the dest mesh.

Definition at line 466 of file DerivedMesh.cc.

References count, CustomData_interp(), dest, and DerivedMesh::vertData.

Referenced by set_ccgdm_all_geometry().

◆ DM_release()

bool DM_release ( DerivedMesh dm)

◆ DM_set_only_copy()

void DM_set_only_copy ( DerivedMesh dm,
const struct CustomData_MeshMasks mask 
)

set the CD_FLAG_NOCOPY flag in custom data layers where the mask is zero for the layer type, so only layer types specified by the mask will be copied

Referenced by multires_modifier_update_mdisps(), multiresbake_create_hiresdm(), and multiresbake_create_loresdm().

◆ editbmesh_get_eval_cage()

struct Mesh* editbmesh_get_eval_cage ( struct Depsgraph depsgraph,
const struct Scene scene,
struct Object obedit,
struct BMEditMesh em,
const struct CustomData_MeshMasks dataMask 
)

Same as above but won't use render settings.

Referenced by BKE_editmesh_vert_coords_alloc().

◆ editbmesh_get_eval_cage_from_orig()

struct Mesh* editbmesh_get_eval_cage_from_orig ( struct Depsgraph depsgraph,
const struct Scene scene,
struct Object obedit,
const struct CustomData_MeshMasks dataMask 
)

◆ editbmesh_modifier_is_enabled()

bool editbmesh_modifier_is_enabled ( const struct Scene scene,
const struct Object ob,
struct ModifierData md,
bool  has_prev_mesh 
)

◆ editbmesh_vert_coords_alloc()

float(* editbmesh_vert_coords_alloc ( struct BMEditMesh em,
int *  r_vert_len 
) )[3]

◆ makeDerivedMesh()

void makeDerivedMesh ( struct Depsgraph depsgraph,
const struct Scene scene,
struct Object ob,
const struct CustomData_MeshMasks dataMask 
)

◆ mesh_get_mapped_verts_coords()

void mesh_get_mapped_verts_coords ( struct Mesh me_eval,
float(*)  r_cos[3],
int  totcos 
)