Data Structures

Blender uses two main data structures for meshes:

  • Mesh: The main data structure associated with the ID_ME data-block type. Focuses on performance with many elements.
  • BMesh: Edit mode data structure that prioritizes implementation of small topology-changing operations (mainly documented here).


Meshes use data structures oriented around a struct of arrays paradigm. One idea behind that design is to decrease the amount of memory accessed in hot loops that generally only deal with a few data elements at a time. It also allows using generic algorithms that aren't necessarily only designed for mesh. For more background on the SoA paradigm in meshes, see the design task.

Meshes support all generic attribute types.

Lazily Calculated Caches

In order to defer calculation of some runtime data until it's actually needed without duplicating work, there are a few lazily calculated caches stored on meshes. Some examples are:

  • Bounds: (BKE_mesh_minmax) The min and max position of the mesh
  • Vertex Normals: (Mesh.vert_normals()) The normal of every vertex. The same as the surrounding face normals mixed together, weighted by the corner angle.
  • Face Normals: (Mesh.poly_normals()) The normal direction of each face according to its winding direction.
  • Loose Edges: (Mesh.loose_edges()) Whether each edge is loose, and the total number of loose edges.

When a mesh is changed, these caches need to be removed or tagged dirty. Generally this is possible with functions like BKE_mesh_tag_coords_changed.