1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 */ 16 17 #pragma once 18 19 /** \file 20 * \ingroup bke 21 * 22 * The \link edmesh EDBM module\endlink is for editmode bmesh stuff. 23 * In contrast, this module is for code shared with blenkernel that's 24 * only concerned with low level operations on the #BMEditMesh structure. 25 */ 26 27 #include "BKE_customdata.h" 28 #include "bmesh.h" 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 struct BMLoop; 35 struct BMesh; 36 struct BoundBox; 37 struct Depsgraph; 38 struct EditMeshData; 39 struct Mesh; 40 struct MeshStatVis; 41 struct Object; 42 struct Scene; 43 44 /** 45 * This structure is used for mesh edit-mode. 46 * 47 * through this, you get access to both the edit #BMesh, 48 * its tessellation, and various stuff that doesn't belong in the BMesh 49 * struct itself. 50 * 51 * the entire derivedmesh and modifier system works with this structure, 52 * and not BMesh. Mesh->edit_bmesh stores a pointer to this structure. */ 53 typedef struct BMEditMesh { 54 struct BMesh *bm; 55 56 /*this is for undoing failed operations*/ 57 struct BMEditMesh *emcopy; 58 int emcopyusers; 59 60 /* we store tessellations as triplets of three loops, 61 * which each define a triangle.*/ 62 struct BMLoop *(*looptris)[3]; 63 int tottri; 64 65 struct Mesh *mesh_eval_final, *mesh_eval_cage; 66 67 /** Cached cage bounding box for selection. */ 68 struct BoundBox *bb_cage; 69 70 /*derivedmesh stuff*/ 71 CustomData_MeshMasks lastDataMask; 72 73 /*selection mode*/ 74 short selectmode; 75 short mat_nr; 76 77 /*temp variables for x-mirror editing*/ 78 int mirror_cdlayer; /* -1 is invalid */ 79 80 /** 81 * ID data is older than edit-mode data. 82 * Set #Main.is_memfile_undo_flush_needed when enabling. 83 */ 84 char needs_flush_to_id; 85 86 } BMEditMesh; 87 88 /* editmesh.c */ 89 void BKE_editmesh_looptri_calc(BMEditMesh *em); 90 BMEditMesh *BKE_editmesh_create(BMesh *bm, const bool do_tessellate); 91 BMEditMesh *BKE_editmesh_copy(BMEditMesh *em); 92 BMEditMesh *BKE_editmesh_from_object(struct Object *ob); 93 void BKE_editmesh_free_derivedmesh(BMEditMesh *em); 94 void BKE_editmesh_free(BMEditMesh *em); 95 96 float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph, 97 struct BMEditMesh *em, 98 struct Scene *scene, 99 struct Object *ob, 100 int *r_vert_len))[3]; 101 float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3]; 102 const float (*BKE_editmesh_vert_coords_when_deformed(struct Depsgraph *depsgraph, 103 struct BMEditMesh *em, 104 struct Scene *scene, 105 struct Object *obedit, 106 int *r_vert_len, 107 bool *r_is_alloc))[3]; 108 109 void BKE_editmesh_lnorspace_update(BMEditMesh *em, struct Mesh *me); 110 void BKE_editmesh_ensure_autosmooth(BMEditMesh *em, struct Mesh *me); 111 struct BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em); 112 113 #ifdef __cplusplus 114 } 115 #endif 116