LEFT | RIGHT |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version. | 7 * of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software Foundation, | 15 * along with this program; if not, write to the Free Software Foundation, |
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 * | 17 * |
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. |
19 * All rights reserved. | 19 * All rights reserved. |
20 * | 20 * |
21 * The Original Code is: all of this file. | 21 * The Original Code is: all of this file. |
22 * | 22 * |
23 * Contributor(s): (mar-2001 nzc) | 23 * Contributor(s): (mar-2001 nzc) |
24 * | 24 * |
25 * ***** END GPL LICENSE BLOCK ***** | 25 * ***** END GPL LICENSE BLOCK ***** |
26 */ | 26 */ |
27 #ifndef __BKE_MESH_H__ | 27 #ifndef BKE_MESH_H |
28 #define __BKE_MESH_H__ | 28 #define BKE_MESH_H |
29 | 29 |
30 /** \file BKE_mesh.h | 30 /** \file BKE_mesh.h |
31 * \ingroup bke | 31 * \ingroup bke |
32 */ | 32 */ |
33 | 33 |
34 struct ID; | 34 /***/ |
| 35 |
35 struct BoundBox; | 36 struct BoundBox; |
36 struct DispList; | 37 struct DispList; |
37 struct EdgeHash; | |
38 struct ListBase; | 38 struct ListBase; |
39 struct BMEditMesh; | 39 struct EditMesh; |
40 struct BMesh; | |
41 struct Main; | |
42 struct Mesh; | 40 struct Mesh; |
43 struct MPoly; | 41 struct MPoly; |
44 struct MLoop; | 42 struct MLoop; |
45 struct MFace; | 43 struct MFace; |
46 struct MEdge; | 44 struct MEdge; |
47 struct MVert; | 45 struct MVert; |
48 struct MDeformVert; | 46 struct MDeformVert; |
| 47 struct MCol; |
| 48 struct Object; |
| 49 struct MTFace; |
| 50 struct VecNor; |
49 struct CustomData; | 51 struct CustomData; |
50 struct DerivedMesh; | 52 struct DerivedMesh; |
51 struct Scene; | 53 struct Scene; |
52 | 54 struct MLoopUV; |
| 55 struct UvVertMap; |
| 56 struct UvMapVert; |
| 57 struct UvElementMap; |
| 58 struct UvElement; |
53 #ifdef __cplusplus | 59 #ifdef __cplusplus |
54 extern "C" { | 60 extern "C" { |
| 61 #endif |
| 62 |
| 63 struct EditMesh *BKE_mesh_get_editmesh(struct Mesh *me); |
| 64 void BKE_mesh_end_editmesh(struct Mesh *me, struct EditMesh *em); |
| 65 |
| 66 /* for forwards compat only quad->tri polys to mface, skip ngons. |
| 67 */ |
| 68 int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, |
| 69 struct CustomData *pdata, int totface, int totloop, int totpoly); |
| 70 |
| 71 void unlink_mesh(struct Mesh *me); |
| 72 void free_mesh(struct Mesh *me); |
| 73 struct Mesh *add_mesh(const char *name); |
| 74 struct Mesh *copy_mesh(struct Mesh *me); |
| 75 void mesh_update_customdata_pointers(struct Mesh *me); |
| 76 void make_local_mesh(struct Mesh *me); |
| 77 void boundbox_mesh(struct Mesh *me, float *loc, float *size); |
| 78 void tex_space_mesh(struct Mesh *me); |
| 79 float *get_mesh_orco_verts(struct Object *ob); |
| 80 void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert, i
nt invert); |
| 81 int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex,
int nr); |
| 82 struct Mesh *get_mesh(struct Object *ob); |
| 83 void set_mesh(struct Object *ob, struct Mesh *me); |
| 84 void mball_to_mesh(struct ListBase *lb, struct Mesh *me); |
| 85 int nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *_totvert, |
| 86 struct MEdge **alledge, int *_totedge, struct MFace **allface, int *_tot
face); |
| 87 int nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase, |
| 88 struct MVert **allvert, int *_totvert, struct MEdge **alledge, int *_tot
edge, |
| 89 struct MFace **allface, int *_totface); |
| 90 void nurbs_to_mesh(struct Object *ob); |
| 91 void mesh_to_curve(struct Scene *scene, struct Object *ob); |
| 92 void free_dverts(struct MDeformVert *dvert, int totvert); |
| 93 void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert);
/* __NLA */ |
| 94 void mesh_delete_material_index(struct Mesh *me, short index); |
| 95 void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth); |
| 96 |
| 97 struct BoundBox *mesh_get_bb(struct Object *ob); |
| 98 void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_
r); |
| 99 |
| 100 /* if old, it converts mface->edcode to edge drawflags */ |
| 101 void make_edges(struct Mesh *me, int old); |
| 102 |
| 103 void mesh_strip_loose_faces(struct Mesh *me); |
| 104 void mesh_strip_loose_edges(struct Mesh *me); |
| 105 |
| 106 /* Calculate vertex and face normals, face normals are returned in *face
Nors_r if non-NULL |
| 107 * and vertex normals are stored in actual mverts. |
| 108 */ |
| 109 void mesh_calc_normals(struct MVert *mverts, int numVerts, struct MFace *mfaces,
int numFaces, float (*faceNors_r)[3]); |
| 110 |
| 111 /* Return a newly MEM_malloc'd array of all the mesh vertex locations |
| 112 * (_numVerts_r_ may be NULL) */ |
| 113 float (*mesh_getVertexCos(struct Mesh *me, int *numVerts_r))[3]; |
| 114 |
| 115 /* map from uv vertex to face (for select linked, stitch, uv suburf) */ |
| 116 |
| 117 /* UvVertMap */ |
| 118 |
| 119 #define STD_UV_CONNECT_LIMIT 0.0001f |
| 120 |
| 121 typedef struct UvVertMap { |
| 122 struct UvMapVert **vert; |
| 123 struct UvMapVert *buf; |
| 124 } UvVertMap; |
| 125 |
| 126 typedef struct UvMapVert { |
| 127 struct UvMapVert *next; |
| 128 unsigned int f; |
| 129 unsigned char tfindex, separate, flag; |
| 130 } UvMapVert; |
| 131 |
| 132 typedef struct UvElementMap { |
| 133 /* address UvElements by their vertex */ |
| 134 struct UvElement **vert; |
| 135 /* UvElement Store */ |
| 136 struct UvElement *buf; |
| 137 /* Total number of UVs in the layer. Useful to know */ |
| 138 int totalUVs; |
| 139 /* Number of Islands in the mesh */ |
| 140 int totalIslands; |
| 141 /* Stores the starting index in buf where each island begins */ |
| 142 int *islandIndices; |
| 143 } UvElementMap; |
| 144 |
| 145 typedef struct UvElement { |
| 146 /* Next UvElement corresponding to same vertex */ |
| 147 struct UvElement *next; |
| 148 /* Face the element belongs to */ |
| 149 struct EditFace *face; |
| 150 /* Index in the editFace of the uv */ |
| 151 unsigned char tfindex; |
| 152 /* Whether this element is the first of coincident elements */ |
| 153 unsigned char separate; |
| 154 /* general use flag */ |
| 155 unsigned char flag; |
| 156 /* If generating element map with island sorting, this stores the island
index */ |
| 157 unsigned short island; |
| 158 } UvElement; |
| 159 |
| 160 /* invalid island index is max short. If any one has the patience |
| 161 * to make that many islands, he can bite me :p */ |
| 162 #define INVALID_ISLAND 0xFFFF |
| 163 |
| 164 |
| 165 UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned
int totface, unsigned int totvert, int selected, float *limit); |
| 166 UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v); |
| 167 void free_uv_vert_map(UvVertMap *vmap); |
| 168 |
| 169 /* Connectivity data */ |
| 170 typedef struct IndexNode { |
| 171 struct IndexNode *next, *prev; |
| 172 int index; |
| 173 } IndexNode; |
| 174 void create_vert_face_map(struct ListBase **map, IndexNode **mem, const struct M
Face *mface, |
| 175 const int totvert, const int totface); |
| 176 void create_vert_edge_map(struct ListBase **map, IndexNode **mem, const struct M
Edge *medge, |
| 177 const int totvert, const int totedge); |
| 178 |
| 179 /* functions for making menu's from customdata layers */ |
| 180 int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to
work out how many chars to allocate */ |
| 181 void mesh_layers_menu_concat(struct CustomData *data, int type, char *str); |
| 182 int mesh_layers_menu(struct CustomData *data, int type); |
| 183 |
| 184 /* vertex level transformations & checks (no derived mesh) */ |
| 185 |
| 186 int minmax_mesh(struct Mesh *me, float min[3], float max[3]); |
| 187 int mesh_center_median(struct Mesh *me, float cent[3]); |
| 188 int mesh_center_bounds(struct Mesh *me, float cent[3]); |
| 189 void mesh_translate(struct Mesh *me, float offset[3], int do_keys); |
| 190 |
| 191 /* mesh_validate.c */ |
| 192 int BKE_mesh_validate_arrays( |
| 193 struct Mesh *me, |
| 194 struct MVert *mverts, unsigned int totvert, |
| 195 struct MEdge *medges, unsigned int totedge, |
| 196 struct MFace *mfaces, unsigned int totface, |
| 197 struct MDeformVert *dverts, /* assume totvert length */ |
| 198 const short do_verbose, const short do_fixes); |
| 199 int BKE_mesh_validate(struct Mesh *me, int do_verbose); |
| 200 int BKE_mesh_validate_dm(struct DerivedMesh *dm); |
| 201 |
| 202 void BKE_mesh_calc_edges(struct Mesh *mesh, int update); |
| 203 |
| 204 void BKE_mesh_ensure_navmesh(struct Mesh *me); |
| 205 |
| 206 /*convert a triangle of loop facedata to mface facedata*/ |
| 207 void mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ld
ata, |
| 208 struct CustomData *pdata, int lindex[4], int fi
ndex, |
| 209 const int polyindex, const int mf_len, |
| 210 const int numTex, const int numCol, const int h
asWCol); |
| 211 |
| 212 #ifdef __cplusplus |
| 213 } |
| 214 #endif |
| 215 |
| 216 #endif /* BKE_MESH_H */ |
LEFT | RIGHT |