Blender V2.61 - r43446

BKE_mesh.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): (mar-2001 nzc)
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 #ifndef BKE_MESH_H
00028 #define BKE_MESH_H
00029 
00034 /***/
00035 
00036 struct BoundBox;
00037 struct DispList;
00038 struct ListBase;
00039 struct EditMesh;
00040 struct Mesh;
00041 struct MPoly;
00042 struct MLoop;
00043 struct MFace;
00044 struct MEdge;
00045 struct MVert;
00046 struct MDeformVert;
00047 struct MCol;
00048 struct Object;
00049 struct MTFace;
00050 struct VecNor;
00051 struct CustomData;
00052 struct DerivedMesh;
00053 struct Scene;
00054 struct MLoopUV;
00055 
00056 #ifdef __cplusplus
00057 extern "C" {
00058 #endif
00059 
00060 struct EditMesh *BKE_mesh_get_editmesh(struct Mesh *me);
00061 void BKE_mesh_end_editmesh(struct Mesh *me, struct EditMesh *em);
00062 
00063 /* for forwards compat only quad->tri polys to mface, skip ngons.
00064  */
00065 int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata,
00066     struct CustomData *pdata, int totface, int totloop, int totpoly);
00067 
00068 void unlink_mesh(struct Mesh *me);
00069 void free_mesh(struct Mesh *me);
00070 struct Mesh *add_mesh(const char *name);
00071 struct Mesh *copy_mesh(struct Mesh *me);
00072 void mesh_update_customdata_pointers(struct Mesh *me);
00073 void make_local_mesh(struct Mesh *me);
00074 void boundbox_mesh(struct Mesh *me, float *loc, float *size);
00075 void tex_space_mesh(struct Mesh *me);
00076 float *get_mesh_orco_verts(struct Object *ob);
00077 void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert, int invert);
00078 int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr);
00079 struct Mesh *get_mesh(struct Object *ob);
00080 void set_mesh(struct Object *ob, struct Mesh *me);
00081 void mball_to_mesh(struct ListBase *lb, struct Mesh *me);
00082 int nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *_totvert,
00083     struct MEdge **alledge, int *_totedge, struct MFace **allface, int *_totface);
00084 int nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase,
00085     struct MVert **allvert, int *_totvert, struct MEdge **alledge, int *_totedge,
00086     struct MFace **allface, int *_totface);
00087 void nurbs_to_mesh(struct Object *ob);
00088 void mesh_to_curve(struct Scene *scene, struct Object *ob);
00089 void free_dverts(struct MDeformVert *dvert, int totvert);
00090 void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */
00091 void mesh_delete_material_index(struct Mesh *me, short index);
00092 void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth);
00093 
00094 struct BoundBox *mesh_get_bb(struct Object *ob);
00095 void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r);
00096 
00097 /* if old, it converts mface->edcode to edge drawflags */
00098 void make_edges(struct Mesh *me, int old);
00099 
00100 void mesh_strip_loose_faces(struct Mesh *me);
00101 void mesh_strip_loose_edges(struct Mesh *me);
00102 
00103     /* Calculate vertex and face normals, face normals are returned in *faceNors_r if non-NULL
00104      * and vertex normals are stored in actual mverts.
00105      */
00106 void mesh_calc_normals(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]);
00107 
00108     /* Return a newly MEM_malloc'd array of all the mesh vertex locations
00109      * (_numVerts_r_ may be NULL) */
00110 float (*mesh_getVertexCos(struct Mesh *me, int *numVerts_r))[3];
00111 
00112 /* map from uv vertex to face (for select linked, stitch, uv suburf) */
00113 
00114 /* UvVertMap */
00115 
00116 #define STD_UV_CONNECT_LIMIT    0.0001f
00117 
00118 typedef struct UvVertMap {
00119     struct UvMapVert **vert;
00120     struct UvMapVert *buf;
00121 } UvVertMap;
00122 
00123 typedef struct UvMapVert {
00124     struct UvMapVert *next;
00125     unsigned int f;
00126     unsigned char tfindex, separate, flag;
00127 } UvMapVert;
00128 
00129 UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned int totface, unsigned int totvert, int selected, float *limit);
00130 UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v);
00131 void free_uv_vert_map(UvVertMap *vmap);
00132 
00133 /* Connectivity data */
00134 typedef struct IndexNode {
00135     struct IndexNode *next, *prev;
00136     int index;
00137 } IndexNode;
00138 void create_vert_face_map(struct ListBase **map, IndexNode **mem, const struct MFace *mface,
00139                           const int totvert, const int totface);
00140 void create_vert_edge_map(struct ListBase **map, IndexNode **mem, const struct MEdge *medge,
00141                           const int totvert, const int totedge);
00142 
00143 /* functions for making menu's from customdata layers */
00144 int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to work out how many chars to allocate */
00145 void mesh_layers_menu_concat(struct CustomData *data, int type, char *str);
00146 int mesh_layers_menu(struct CustomData *data, int type);
00147 
00148 /* vertex level transformations & checks (no derived mesh) */
00149 
00150 int minmax_mesh(struct Mesh *me, float min[3], float max[3]);
00151 int mesh_center_median(struct Mesh *me, float cent[3]);
00152 int mesh_center_bounds(struct Mesh *me, float cent[3]);
00153 void mesh_translate(struct Mesh *me, float offset[3], int do_keys);
00154 
00155 /* mesh_validate.c */
00156 int BKE_mesh_validate_arrays(
00157         struct Mesh *me,
00158         struct MVert *mverts, unsigned int totvert,
00159         struct MEdge *medges, unsigned int totedge,
00160         struct MFace *mfaces, unsigned int totface,
00161         struct MDeformVert *dverts, /* assume totvert length */
00162         const short do_verbose, const short do_fixes);
00163 int BKE_mesh_validate(struct Mesh *me, int do_verbose);
00164 int BKE_mesh_validate_dm(struct DerivedMesh *dm);
00165 
00166 void BKE_mesh_calc_edges(struct Mesh *mesh, int update);
00167 
00168 void BKE_mesh_ensure_navmesh(struct Mesh *me);
00169 
00170 /*convert a triangle of loop facedata to mface facedata*/
00171 void mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ldata,
00172                                  struct CustomData *pdata, int lindex[4], int findex,
00173                                  const int polyindex, const int mf_len,
00174                                  const int numTex, const int numCol, const int hasWCol);
00175 
00176 #ifdef __cplusplus
00177 }
00178 #endif
00179 
00180 #endif /* BKE_MESH_H */