diff options
Diffstat (limited to 'source/blender/makesdna/DNA_mesh_types.h')
-rw-r--r-- | source/blender/makesdna/DNA_mesh_types.h | 122 |
1 files changed, 66 insertions, 56 deletions
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 9912ec8ec3b..6b48f1e029f 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -10,8 +10,17 @@ #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 blender +#endif + #ifdef __cplusplus extern "C" { #endif @@ -23,11 +32,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; @@ -166,30 +172,6 @@ typedef struct Mesh { */ 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. */ @@ -201,8 +183,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. @@ -218,18 +198,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. @@ -304,29 +272,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; @@ -345,6 +316,45 @@ 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> vertices() const; + /** Write access to vertex data. */ + blender::MutableSpan<MVert> vertices_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> polygons() const; + /** Write access to polygon data. */ + blender::MutableSpan<MPoly> polygons_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(); + + /** + * 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 */ |