diff options
Diffstat (limited to 'source/blender/makesdna/DNA_mesh_types.h')
-rw-r--r-- | source/blender/makesdna/DNA_mesh_types.h | 136 |
1 files changed, 78 insertions, 58 deletions
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 2eca84959b8..cbefbf021a9 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -10,8 +10,21 @@ #include "DNA_ID.h" #include "DNA_customdata_types.h" #include "DNA_defs.h" +#include "DNA_meshdata_types.h" #include "DNA_session_uuid_types.h" +/** Workaround to forward-declare C++ type in C header. */ +#ifdef __cplusplus +namespace blender { +template<typename T> class Span; +template<typename T> class MutableSpan; +namespace bke { +class AttributeAccessor; +class MutableAttributeAccessor; +} // namespace bke +} // namespace blender +#endif + #ifdef __cplusplus extern "C" { #endif @@ -23,11 +36,8 @@ struct Key; struct MCol; struct MEdge; struct MFace; -struct MLoop; struct MLoopCol; struct MLoopTri; -struct MLoopUV; -struct MPoly; struct MVert; struct Material; struct Mesh; @@ -112,7 +122,7 @@ typedef struct Mesh_Runtime { * (most #eModifierTypeType_NonGeometrical modifiers). Otherwise the edit-mesh * data will be used for drawing, missing changes from modifiers. See T79517. */ - char is_original; + char is_original_bmesh; /** #eMeshWrapperType and others. */ char wrapper_type; @@ -161,34 +171,11 @@ typedef struct Mesh { /** * An array of materials, with length #totcol. These can be overridden by material slots - * on #Object. Indices in #MPoly.mat_nr control which material is used for every face. + * on #Object. Indices in the "material_index" attribute control which material is used for every + * face. */ struct Material **mat; - /** - * Array of vertices. Edges and faces are defined by indices into this array. - * \note This pointer is for convenient access to the #CD_MVERT layer in #vdata. - */ - struct MVert *mvert; - /** - * Array of edges, containing vertex indices. For simple triangle or quad meshes, edges could be - * calculated from the #MPoly and #MLoop arrays, however, edges need to be stored explicitly to - * edge domain attributes and to support loose edges that aren't connected to faces. - * \note This pointer is for convenient access to the #CD_MEDGE layer in #edata. - */ - struct MEdge *medge; - /** - * Face topology storage of the size and offset of each face's section of the #mloop face corner - * array. Also stores various flags and the `material_index` attribute. - * \note This pointer is for convenient access to the #CD_MPOLY layer in #pdata. - */ - struct MPoly *mpoly; - /** - * The vertex and edge index at each face corner. - * \note This pointer is for convenient access to the #CD_MLOOP layer in #ldata. - */ - struct MLoop *mloop; - /** The number of vertices (#MVert) in the mesh, and the size of #vdata. */ int totvert; /** The number of edges (#MEdge) in the mesh, and the size of #edata. */ @@ -200,8 +187,6 @@ typedef struct Mesh { CustomData vdata, edata, pdata, ldata; - /** "Vertex group" vertices. */ - struct MDeformVert *dvert; /** * List of vertex group (#bDeformGroup) names and flags only. Actual weights are stored in dvert. * \note This pointer is for convenient access to the #CD_MDEFORMVERT layer in #vdata. @@ -217,18 +202,6 @@ typedef struct Mesh { int attributes_active_index; /** - * 2D vector data used for UVs. "UV" data can also be stored as generic attributes in #ldata. - * \note This pointer is for convenient access to the #CD_MLOOPUV layer in #ldata. - */ - struct MLoopUV *mloopuv; - /** - * The active vertex corner color layer, if it exists. Also called "Vertex Color" in Blender's - * UI, even though it is stored per face corner. - * \note This pointer is for convenient access to the #CD_PROP_BYTE_COLOR layer in #ldata. - */ - struct MLoopCol *mloopcol; - - /** * Runtime storage of the edit mode mesh. If it exists, it generally has the most up-to-date * information about the mesh. * \note When the object is available, the preferred access method is #BKE_editmesh_from_object. @@ -303,29 +276,32 @@ typedef struct Mesh { char subdivr DNA_DEPRECATED; char subsurftype DNA_DEPRECATED; - /** - * Deprecated. Store of runtime data for tessellation face UVs and texture. - * - * \note This would be marked deprecated, however the particles still use this at run-time - * for placing particles on the mesh (something which should be eventually upgraded). - */ - struct MTFace *mtface; + /** Deprecated pointer to mesh polygons, kept for forward compatibility. */ + struct MPoly *mpoly DNA_DEPRECATED; + /** Deprecated pointer to face corners, kept for forward compatibility. */ + struct MLoop *mloop DNA_DEPRECATED; + + /** Deprecated array of mesh vertices, kept for reading old files, now stored in #CustomData. */ + struct MVert *mvert DNA_DEPRECATED; + /** Deprecated array of mesh edges, kept for reading old files, now stored in #CustomData. */ + struct MEdge *medge DNA_DEPRECATED; + /** Deprecated "Vertex group" data. Kept for reading old files, now stored in #CustomData. */ + struct MDeformVert *dvert DNA_DEPRECATED; + /** Deprecated runtime data for tessellation face UVs and texture, kept for reading old files. */ + struct MTFace *mtface DNA_DEPRECATED; /** Deprecated, use mtface. */ struct TFace *tface DNA_DEPRECATED; - - /* Deprecated. Array of colors for the tessellated faces, must be number of tessellated - * faces * 4 in length. This is stored in #fdata, and deprecated. */ - struct MCol *mcol; + /** Deprecated array of colors for the tessellated faces, kept for reading old files. */ + struct MCol *mcol DNA_DEPRECATED; + /** Deprecated face storage (quads & triangles only). Kept for reading old files. */ + struct MFace *mface DNA_DEPRECATED; /** - * Deprecated face storage (quads & triangles only); - * faces are now pointed to by #Mesh.mpoly and #Mesh.mloop. + * Deprecated storage of old faces (only triangles or quads). * * \note This would be marked deprecated, however the particles still use this at run-time * for placing particles on the mesh (something which should be eventually upgraded). */ - struct MFace *mface; - /* Deprecated storage of old faces (only triangles or quads). */ CustomData fdata; /* Deprecated size of #fdata. */ int totface; @@ -344,6 +320,48 @@ typedef struct Mesh { void *_pad2; Mesh_Runtime runtime; +#ifdef __cplusplus + /** + * Array of vertex positions (and various other data). Edges and faces are defined by indices + * into this array. + */ + blender::Span<MVert> verts() const; + /** Write access to vertex data. */ + blender::MutableSpan<MVert> verts_for_write(); + /** + * Array of edges, containing vertex indices. For simple triangle or quad meshes, edges could be + * calculated from the #MPoly and #MLoop arrays, however, edges need to be stored explicitly to + * edge domain attributes and to support loose edges that aren't connected to faces. + */ + blender::Span<MEdge> edges() const; + /** Write access to edge data. */ + blender::MutableSpan<MEdge> edges_for_write(); + /** + * Face topology storage of the size and offset of each face's section of the face corners. + */ + blender::Span<MPoly> polys() const; + /** Write access to polygon data. */ + blender::MutableSpan<MPoly> polys_for_write(); + /** + * Mesh face corners that "loop" around each face, storing the vertex index and the index of the + * subsequent edge. + */ + blender::Span<MLoop> loops() const; + /** Write access to loop data. */ + blender::MutableSpan<MLoop> loops_for_write(); + + blender::bke::AttributeAccessor attributes() const; + blender::bke::MutableAttributeAccessor attributes_for_write(); + + /** + * Vertex group data, encoded as an array of indices and weights for every vertex. + * \warning: May be empty. + */ + blender::Span<MDeformVert> deform_verts() const; + /** Write access to vertex group data. */ + blender::MutableSpan<MDeformVert> deform_verts_for_write(); + +#endif } Mesh; /* deprecated by MTFace, only here for file reading */ @@ -422,8 +440,10 @@ enum { /** #Mesh.cd_flag */ enum { +#ifdef DNA_DEPRECATED_ALLOW ME_CDFLAG_VERT_BWEIGHT = 1 << 0, ME_CDFLAG_EDGE_BWEIGHT = 1 << 1, +#endif ME_CDFLAG_EDGE_CREASE = 1 << 2, ME_CDFLAG_VERT_CREASE = 1 << 3, }; |