4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2006 Blender Foundation.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): Ben Batt <benbatt@gmail.com>
27 * ***** END GPL LICENSE BLOCK *****
30 /* CDDerivedMesh interface.
31 * CDDerivedMesh (CD = Custom Data) is a DerivedMesh backend which stores
32 * mesh elements (vertices, edges and faces) as layers of custom element data.
35 #ifndef BKE_CDDERIVEDMESH_H
36 #define BKE_CDDERIVEDMESH_H
38 #include "BKE_DerivedMesh.h"
45 /* creates a new CDDerivedMesh */
46 struct DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces);
48 /* creates a CDDerivedMesh from the given Mesh, this will reference the
49 original data in Mesh, but it is safe to apply vertex coordinates or
50 calculate normals as those functions will automtically create new
51 data to not overwrite the original */
52 struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob);
54 /* creates a CDDerivedMesh from the given EditMesh */
55 struct DerivedMesh *CDDM_from_editmesh(struct EditMesh *em, struct Mesh *me);
57 /* Copies the given DerivedMesh with verts, faces & edges stored as
58 * custom element data.
60 struct DerivedMesh *CDDM_copy(struct DerivedMesh *dm);
62 /* creates a CDDerivedMesh with the same layer stack configuration as the
63 * given DerivedMesh and containing the requested numbers of elements.
64 * elements are initialised to all zeros
66 struct DerivedMesh *CDDM_from_template(struct DerivedMesh *source,
67 int numVerts, int numEdges, int numFaces);
69 /* applies vertex coordinates or normals to a CDDerivedMesh. if the MVert
70 * layer is a referenced layer, it will be duplicate to not overwrite the
73 void CDDM_apply_vert_coords(struct DerivedMesh *cddm, float (*vertCoords)[3]);
74 void CDDM_apply_vert_normals(struct DerivedMesh *cddm, short (*vertNormals)[3]);
76 /* recalculates vertex and face normals for a CDDerivedMesh
78 void CDDM_calc_normals(struct DerivedMesh *dm);
80 /* calculates edges for a CDDerivedMesh (from face data)
81 * this completely replaces the current edge data in the DerivedMesh
83 void CDDM_calc_edges(struct DerivedMesh *dm);
85 /* lowers the number of vertices/edges/faces in a CDDerivedMesh
86 * the layer data stays the same size
88 void CDDM_lower_num_verts(struct DerivedMesh *dm, int numVerts);
89 void CDDM_lower_num_edges(struct DerivedMesh *dm, int numEdges);
90 void CDDM_lower_num_faces(struct DerivedMesh *dm, int numFaces);
92 /* vertex/edge/face access functions
93 * should always succeed if index is within bounds
94 * note these return pointers - any change modifies the internals of the mesh
96 struct MVert *CDDM_get_vert(struct DerivedMesh *dm, int index);
97 struct MEdge *CDDM_get_edge(struct DerivedMesh *dm, int index);
98 struct MFace *CDDM_get_face(struct DerivedMesh *dm, int index);
100 /* vertex/edge/face array access functions - return the array holding the
102 * should always succeed
103 * note these return pointers - any change modifies the internals of the mesh
105 struct MVert *CDDM_get_verts(struct DerivedMesh *dm);
106 struct MEdge *CDDM_get_edges(struct DerivedMesh *dm);
107 struct MFace *CDDM_get_faces(struct DerivedMesh *dm);