Blender  V3.3
Classes
DNA_meshdata_types.h File Reference
#include "DNA_customdata_types.h"
#include "DNA_listBase.h"

Go to the source code of this file.

Classes

struct  MVert
 
struct  MEdge
 
struct  MPoly
 
struct  MLoop
 
struct  MSelect
 
struct  MLoopTri
 
struct  MVertTri
 
struct  MFloatProperty
 
struct  MIntProperty
 
struct  MStringProperty
 
struct  MBoolProperty
 
struct  MInt8Property
 
struct  MDeformWeight
 
struct  MDeformVert
 
struct  MVertSkin
 
struct  MLoopUV
 
struct  MLoopCol
 
struct  MPropCol
 
struct  MDisps
 
struct  GridPaintMask
 
struct  OrigSpaceFace
 
struct  OrigSpaceLoop
 
struct  FreestyleEdge
 
struct  FreestyleFace
 
struct  MFace
 
struct  MTFace
 
struct  MCol
 
struct  MRecast
 

Macros

Utility Macros
#define ME_POLY_LOOP_PREV(mloop, mp, i)    (&(mloop)[(mp)->loopstart + (((i) + (mp)->totloop - 1) % (mp)->totloop)])
 
#define ME_POLY_LOOP_NEXT(mloop, mp, i)   (&(mloop)[(mp)->loopstart + (((i) + 1) % (mp)->totloop)])
 
#define ME_POLY_TRI_TOT(mp)   ((mp)->totloop - 2)
 
#define ME_MAT_NR_TEST(mat_nr, totmat)
 

Typedefs

Loop Tessellation Runtime Data
typedef struct MLoopTri MLoopTri
 
typedef struct MVertTri MVertTri
 
Custom Data (Generic)
typedef struct MFloatProperty MFloatProperty
 
typedef struct MIntProperty MIntProperty
 
typedef struct MStringProperty MStringProperty
 
typedef struct MBoolProperty MBoolProperty
 
typedef struct MInt8Property MInt8Property
 
Custom Data (Original Space for Poly, Face)
typedef struct OrigSpaceFace OrigSpaceFace
 
typedef struct OrigSpaceLoop OrigSpaceLoop
 

Deprecated Structs

#define MESH_MLOOPCOL_FROM_MCOL(_mloopcol, _mcol)
 
#define MESH_MLOOPCOL_TO_MCOL(_mloopcol, _mcol)
 
enum  {
  ME_V1V2 = (1 << 0) , ME_V2V3 = (1 << 1) , ME_V3V1 = (1 << 2) , ME_V3V4 = ME_V3V1 ,
  ME_V4V1 = (1 << 3)
}
 
typedef struct MFace MFace
 
typedef struct MTFace MTFace
 
typedef struct MCol MCol
 
typedef struct MRecast MRecast
 

Geometry Elements

enum  { ME_HIDE = (1 << 4) }
 
enum  {
  ME_EDGEDRAW = (1 << 1) , ME_SEAM = (1 << 2) , ME_EDGERENDER = (1 << 5) , ME_LOOSEEDGE = (1 << 7) ,
  ME_EDGE_TMP_TAG = (1 << 8) , ME_SHARP = (1 << 9)
}
 
enum  { ME_SMOOTH = (1 << 0) , ME_FACE_SEL = (1 << 1) }
 
typedef struct MVert MVert
 
typedef struct MEdge MEdge
 
typedef struct MPoly MPoly
 
typedef struct MLoop MLoop
 

Ordered Selection Storage

enum  { ME_VSEL = 0 , ME_ESEL = 1 , ME_FSEL = 2 }
 
typedef struct MSelect MSelect
 

Custom Data (Vertex)

enum  eMVertSkinFlag { MVERT_SKIN_ROOT = 1 , MVERT_SKIN_LOOSE = 2 }
 
typedef struct MDeformWeight MDeformWeight
 
typedef struct MDeformVert MDeformVert
 
typedef struct MVertSkin MVertSkin
 
typedef enum eMVertSkinFlag eMVertSkinFlag
 

Custom Data (Loop)

enum  { MLOOPUV_EDGESEL = (1 << 0) , MLOOPUV_VERTSEL = (1 << 1) , MLOOPUV_PINNED = (1 << 2) }
 
typedef struct MLoopUV MLoopUV
 
typedef struct MLoopCol MLoopCol
 
typedef struct MPropCol MPropCol
 
typedef struct MDisps MDisps
 
typedef struct GridPaintMask GridPaintMask
 

Custom Data (FreeStyle for Edge, Face)

enum  { FREESTYLE_EDGE_MARK = 1 }
 
enum  { FREESTYLE_FACE_MARK = 1 }
 
typedef struct FreestyleEdge FreestyleEdge
 
typedef struct FreestyleFace FreestyleFace
 

Macro Definition Documentation

◆ ME_MAT_NR_TEST

#define ME_MAT_NR_TEST (   mat_nr,
  totmat 
)
Value:
(CHECK_TYPE_ANY(mat_nr, short, const short), \
CHECK_TYPE_ANY(totmat, short, const short), \
(LIKELY(mat_nr < totmat) ? mat_nr : 0))
#define CHECK_TYPE_ANY(...)
#define LIKELY(x)

Check out-of-bounds material, note that this is nearly always prevented, yet its still possible in rare cases. So usage such as array lookup needs to check.

Definition at line 443 of file DNA_meshdata_types.h.

◆ ME_POLY_LOOP_NEXT

#define ME_POLY_LOOP_NEXT (   mloop,
  mp,
 
)    (&(mloop)[(mp)->loopstart + (((i) + 1) % (mp)->totloop)])

Definition at line 433 of file DNA_meshdata_types.h.

◆ ME_POLY_LOOP_PREV

#define ME_POLY_LOOP_PREV (   mloop,
  mp,
 
)     (&(mloop)[(mp)->loopstart + (((i) + (mp)->totloop - 1) % (mp)->totloop)])

Definition at line 431 of file DNA_meshdata_types.h.

◆ ME_POLY_TRI_TOT

#define ME_POLY_TRI_TOT (   mp)    ((mp)->totloop - 2)

Number of tri's that make up this polygon once tessellated.

Definition at line 436 of file DNA_meshdata_types.h.

◆ MESH_MLOOPCOL_FROM_MCOL

#define MESH_MLOOPCOL_FROM_MCOL (   _mloopcol,
  _mcol 
)
Value:
{ \
MLoopCol *mloopcol__tmp = _mloopcol; \
const MCol *mcol__tmp = _mcol; \
mloopcol__tmp->r = mcol__tmp->b; \
mloopcol__tmp->g = mcol__tmp->g; \
mloopcol__tmp->b = mcol__tmp->r; \
mloopcol__tmp->a = mcol__tmp->a; \
} \
(void)0
SyclQueue void void size_t num_bytes void
unsigned char r

Definition at line 488 of file DNA_meshdata_types.h.

◆ MESH_MLOOPCOL_TO_MCOL

#define MESH_MLOOPCOL_TO_MCOL (   _mloopcol,
  _mcol 
)
Value:
{ \
const MLoopCol *mloopcol__tmp = _mloopcol; \
MCol *mcol__tmp = _mcol; \
mcol__tmp->b = mloopcol__tmp->r; \
mcol__tmp->g = mloopcol__tmp->g; \
mcol__tmp->r = mloopcol__tmp->b; \
mcol__tmp->a = mloopcol__tmp->a; \
} \
(void)0
unsigned char b

Definition at line 499 of file DNA_meshdata_types.h.

Typedef Documentation

◆ eMVertSkinFlag

◆ FreestyleEdge

typedef struct FreestyleEdge FreestyleEdge

◆ FreestyleFace

typedef struct FreestyleFace FreestyleFace

◆ GridPaintMask

typedef struct GridPaintMask GridPaintMask

Multi-Resolution grid loop data.

◆ MBoolProperty

typedef struct MBoolProperty MBoolProperty

◆ MCol

typedef struct MCol MCol

Tessellation vertex color data.

Note
The red and blue are swapped for historical reasons.

◆ MDeformVert

typedef struct MDeformVert MDeformVert

Stores all of an element's vertex groups, and their weight values.

◆ MDeformWeight

typedef struct MDeformWeight MDeformWeight

Vertex group index and weight for MDeformVert.dw

◆ MDisps

typedef struct MDisps MDisps

Multi-Resolution loop data.

◆ MEdge

typedef struct MEdge MEdge

Mesh Edges.

Typically accessed from Mesh.medge

◆ MFace

typedef struct MFace MFace

Used in Blender pre 2.63, See MLoop, MPoly for face data stored in the blend file. Use for reading old files and in a handful of cases which should be removed eventually.

◆ MFloatProperty

Custom Data Properties

◆ MInt8Property

typedef struct MInt8Property MInt8Property

◆ MIntProperty

typedef struct MIntProperty MIntProperty

◆ MLoop

typedef struct MLoop MLoop

Mesh Face Corners. "Loop" is an internal name for the corner of a polygon (MPoly).

Typically accessed from Mesh.mloop.

◆ MLoopCol

typedef struct MLoopCol MLoopCol
Note
While alpha is not currently in the 3D Viewport, this may eventually be added back, keep this value set to 255.

◆ MLoopTri

typedef struct MLoopTri MLoopTri

MLoopTri's are lightweight triangulation data, for functionality that doesn't support ngons (MPoly). This is cache data created from (MPoly, MLoop & MVert arrays). There is no attempt to maintain this data's validity over time, any changes to the underlying mesh invalidate the MLoopTri array, which will need to be re-calculated.

Users normally access this via BKE_mesh_runtime_looptri_ensure. In rare cases its calculated directly, with BKE_mesh_recalc_looptri.

Typical usage includes:

  • OpenGL drawing.
  • BVHTree creation.
  • Physics/collision detection.

Storing loop indices (instead of vertex indices) allows us to directly access UV's, vertex-colors as well as vertices. The index of the source polygon is stored as well, giving access to materials and polygon normals.

Note
This data is runtime only, never written to disk.

Usage examples:

// access original material.
short mat_nr = mpoly[lt->poly].mat_nr;
// access vertex locations.
float *vtri_co[3] = {
mvert[mloop[lt->tri[0]].v].co,
mvert[mloop[lt->tri[1]].v].co,
mvert[mloop[lt->tri[2]].v].co,
};
// access UV coordinates (works for all loop data, vertex colors... etc).
float *uvtri_co[3] = {
mloopuv[lt->tri[0]].uv,
mloopuv[lt->tri[1]].uv,
mloopuv[lt->tri[2]].uv,
};

MLoopTri's are allocated in an array, where each polygon's MLoopTri's are stored contiguously, the number of triangles for each polygon is guaranteed to be (MPoly.totloop - 2), even for degenerate geometry. See ME_POLY_TRI_TOT macro.

It's also possible to perform a reverse lookup (find all MLoopTri's for any given MPoly).

// loop over all looptri's for a given polygon: i
MPoly *mp = &mpoly[i];
MLoopTri *lt = &looptri[poly_to_tri_count(i, mp->loopstart)];
int j, lt_tot = ME_POLY_TRI_TOT(mp);
for (j = 0; j < lt_tot; j++, lt++) {
unsigned int vtri[3] = {
mloop[lt->tri[0]].v,
mloop[lt->tri[1]].v,
mloop[lt->tri[2]].v,
};
printf("tri %u %u %u\n", vtri[0], vtri[1], vtri[2]);
};
MINLINE int poly_to_tri_count(int poly_count, int corner_count)
#define ME_POLY_TRI_TOT(mp)
unsigned int tri[3]

It may also be useful to check whether or not two vertices of a triangle form an edge in the underlying mesh.

This can be done by checking the edge of the referenced loop (MLoop.e), the winding of the MLoopTri and the MLoop's will always match, however the order of vertices in the edge is undefined.

// print real edges from an MLoopTri: lt
int j, j_next;
for (j = 2, j_next = 0; j_next < 3; j = j_next++) {
MEdge *ed = &medge[mloop[lt->tri[j]].e];
unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
if (((ed->v1 == tri_edge[0]) && (ed->v2 == tri_edge[1])) ||
((ed->v1 == tri_edge[1]) && (ed->v2 == tri_edge[0])))
{
printf("real edge found %u %u\n", tri_edge[0], tri_edge[1]);
}
}
unsigned int v1
unsigned int v2

See BKE_mesh_looptri_get_real_edges for a utility that does this.

Note
A MLoopTri may be in the middle of an ngon and not reference any edges.

◆ MLoopUV

typedef struct MLoopUV MLoopUV

UV coordinate for a polygon face & flag for selection & other options.

◆ MPoly

typedef struct MPoly MPoly

Mesh Faces This only stores the polygon size & flags, the vertex & edge indices are stored in the MLoop.

Typically accessed from Mesh.mpoly.

◆ MPropCol

typedef struct MPropCol MPropCol

◆ MRecast

typedef struct MRecast MRecast

Old game engine recast navigation data, while unused 2.7x files may contain this.

◆ MSelect

typedef struct MSelect MSelect

Optionally store the order of selected elements. This won't always be set since only some selection operations have an order.

Typically accessed from Mesh.mselect

◆ MStringProperty

◆ MTFace

typedef struct MTFace MTFace

Tessellation uv face data.

◆ MVert

typedef struct MVert MVert

Mesh Vertices.

Typically accessed from Mesh.mvert

◆ MVertSkin

typedef struct MVertSkin MVertSkin

◆ MVertTri

typedef struct MVertTri MVertTri

◆ OrigSpaceFace

typedef struct OrigSpaceFace OrigSpaceFace

Original space within a face (similar to UV coordinates), however they are used to determine the original position in a face.

Unlike UV's these are not user editable and always start out using a fixed 0-1 range. Currently only used for particle placement.

◆ OrigSpaceLoop

typedef struct OrigSpaceLoop OrigSpaceLoop

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

MVert.flag

Enumerator
ME_HIDE 

Definition at line 33 of file DNA_meshdata_types.h.

◆ anonymous enum

anonymous enum

MEdge.flag

Enumerator
ME_EDGEDRAW 
ME_SEAM 
ME_EDGERENDER 
ME_LOOSEEDGE 
ME_EDGE_TMP_TAG 
ME_SHARP 

Definition at line 51 of file DNA_meshdata_types.h.

◆ anonymous enum

anonymous enum

MPoly.flag

Enumerator
ME_SMOOTH 
ME_FACE_SEL 

Definition at line 78 of file DNA_meshdata_types.h.

◆ anonymous enum

anonymous enum

MSelect.type

Enumerator
ME_VSEL 
ME_ESEL 
ME_FSEL 

Definition at line 117 of file DNA_meshdata_types.h.

◆ anonymous enum

anonymous enum

MLoopUV.flag

Enumerator
MLOOPUV_EDGESEL 
MLOOPUV_VERTSEL 
MLOOPUV_PINNED 

Definition at line 328 of file DNA_meshdata_types.h.

◆ anonymous enum

anonymous enum

FreestyleEdge.flag

Enumerator
FREESTYLE_EDGE_MARK 

Definition at line 412 of file DNA_meshdata_types.h.

◆ anonymous enum

anonymous enum

FreestyleFace.flag

Enumerator
FREESTYLE_FACE_MARK 

Definition at line 421 of file DNA_meshdata_types.h.

◆ anonymous enum

anonymous enum

MFace.edcode

Enumerator
ME_V1V2 
ME_V2V3 
ME_V3V1 
ME_V3V4 
ME_V4V1 

Definition at line 466 of file DNA_meshdata_types.h.

◆ eMVertSkinFlag

Enumerator
MVERT_SKIN_ROOT 

Marks a vertex as the edge-graph root, used for calculating rotations for all connected edges (recursively). Also used to choose a root when generating an armature.

MVERT_SKIN_LOOSE 

Marks a branch vertex (vertex with more than two connected edges), so that its neighbors are directly hulled together, rather than the default of generating intermediate frames.

Definition at line 301 of file DNA_meshdata_types.h.