2012-02-12 14:40:08 +00:00
|
|
|
/*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-04-13 20:31:52 +00:00
|
|
|
#pragma once
|
2009-11-29 00:53:23 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2015-08-01 12:36:14 +10:00
|
|
|
*
|
|
|
|
|
* The \link edmesh EDBM module\endlink is for editmode bmesh stuff.
|
2018-09-24 17:27:41 +02:00
|
|
|
* In contrast, this module is for code shared with blenkernel that's
|
2015-08-01 12:36:14 +10:00
|
|
|
* only concerned with low level operations on the #BMEditMesh structure.
|
2013-09-12 03:02:50 +00:00
|
|
|
*/
|
|
|
|
|
|
2021-07-13 22:21:47 +10:00
|
|
|
#include "DNA_customdata_types.h"
|
2009-05-16 16:18:08 +00:00
|
|
|
#include "bmesh.h"
|
|
|
|
|
|
2020-03-02 15:07:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-09-23 14:36:45 +02:00
|
|
|
struct BMLoop;
|
2021-05-28 18:18:13 +10:00
|
|
|
struct BMPartialUpdate;
|
2021-07-16 11:48:54 +10:00
|
|
|
struct BMesh;
|
2021-06-14 22:56:03 +10:00
|
|
|
struct BMeshCalcTessellation_Params;
|
2019-09-23 14:36:45 +02:00
|
|
|
struct BoundBox;
|
2018-04-06 12:07:27 +02:00
|
|
|
struct Depsgraph;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct Mesh;
|
2020-01-07 17:38:16 +11:00
|
|
|
struct Object;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct Scene;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2015-08-01 12:36:14 +10:00
|
|
|
/**
|
|
|
|
|
* This structure is used for mesh edit-mode.
|
2012-03-03 20:19:11 +00:00
|
|
|
*
|
2021-07-13 20:59:04 +10:00
|
|
|
* Through this, you get access to both the edit #BMesh, its tessellation,
|
|
|
|
|
* and various data that doesn't belong in the #BMesh struct itself
|
|
|
|
|
* (mostly related to mesh evaluation).
|
2012-03-03 20:19:11 +00:00
|
|
|
*
|
2021-07-13 20:59:04 +10:00
|
|
|
* The entire modifier system works with this structure, and not #BMesh.
|
|
|
|
|
* #Mesh.edit_bmesh stores a pointer to this structure. */
|
2009-05-18 08:46:04 +00:00
|
|
|
typedef struct BMEditMesh {
|
2009-05-16 16:18:08 +00:00
|
|
|
struct BMesh *bm;
|
2009-06-18 07:11:55 +00:00
|
|
|
|
2021-07-13 20:59:04 +10:00
|
|
|
/**
|
|
|
|
|
* Face triangulation (tessellation) is stored as triplets of three loops,
|
|
|
|
|
* which each define a triangle.
|
|
|
|
|
*
|
|
|
|
|
* \see #MLoopTri as the documentation gives useful hints that apply to this data too.
|
|
|
|
|
*/
|
2009-05-16 16:18:08 +00:00
|
|
|
struct BMLoop *(*looptris)[3];
|
|
|
|
|
int tottri;
|
|
|
|
|
|
2018-10-09 16:52:46 +11:00
|
|
|
struct Mesh *mesh_eval_final, *mesh_eval_cage;
|
|
|
|
|
|
2021-07-13 20:59:04 +10:00
|
|
|
/** Cached cage bounding box of `mesh_eval_cage` for selection. */
|
2019-09-23 14:36:45 +02:00
|
|
|
struct BoundBox *bb_cage;
|
|
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/** Evaluated mesh data-mask. */
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
CustomData_MeshMasks lastDataMask;
|
2009-05-16 16:18:08 +00:00
|
|
|
|
2021-07-13 20:59:04 +10:00
|
|
|
/** Selection mode (#SCE_SELECT_VERTEX, #SCE_SELECT_EDGE & #SCE_SELECT_FACE). */
|
2011-05-09 04:06:48 +00:00
|
|
|
short selectmode;
|
2021-07-13 20:59:04 +10:00
|
|
|
/** The active material (assigned to newly created faces). */
|
2011-05-09 04:06:48 +00:00
|
|
|
short mat_nr;
|
2009-11-02 06:33:16 +00:00
|
|
|
|
2021-07-13 20:59:04 +10:00
|
|
|
/** Temp variables for x-mirror editing (-1 when the layer does not exist). */
|
|
|
|
|
int mirror_cdlayer;
|
2019-11-07 16:52:03 +11:00
|
|
|
|
2021-09-02 15:39:52 +10:00
|
|
|
/**
|
|
|
|
|
* Enable for evaluated copies, causes the edit-mesh to free the memory, not it's contents.
|
|
|
|
|
*/
|
|
|
|
|
char is_shallow_copy;
|
|
|
|
|
|
2019-11-07 16:52:03 +11:00
|
|
|
/**
|
|
|
|
|
* ID data is older than edit-mode data.
|
|
|
|
|
* Set #Main.is_memfile_undo_flush_needed when enabling.
|
|
|
|
|
*/
|
|
|
|
|
char needs_flush_to_id;
|
|
|
|
|
|
2009-05-18 08:46:04 +00:00
|
|
|
} BMEditMesh;
|
|
|
|
|
|
2013-04-18 01:20:04 +00:00
|
|
|
/* editmesh.c */
|
2021-06-14 22:56:03 +10:00
|
|
|
void BKE_editmesh_looptri_calc_ex(BMEditMesh *em,
|
|
|
|
|
const struct BMeshCalcTessellation_Params *params);
|
2019-08-25 14:32:47 +10:00
|
|
|
void BKE_editmesh_looptri_calc(BMEditMesh *em);
|
2021-06-14 22:56:03 +10:00
|
|
|
void BKE_editmesh_looptri_calc_with_partial_ex(BMEditMesh *em,
|
|
|
|
|
struct BMPartialUpdate *bmpinfo,
|
|
|
|
|
const struct BMeshCalcTessellation_Params *params);
|
2021-05-28 18:18:13 +10:00
|
|
|
void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, struct BMPartialUpdate *bmpinfo);
|
2021-06-14 22:56:03 +10:00
|
|
|
void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em,
|
|
|
|
|
struct BMPartialUpdate *bmpinfo);
|
|
|
|
|
|
|
|
|
|
void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em);
|
2021-05-28 18:18:13 +10:00
|
|
|
|
2021-07-13 15:05:39 +10:00
|
|
|
BMEditMesh *BKE_editmesh_create(BMesh *bm);
|
2013-04-16 05:59:48 +00:00
|
|
|
BMEditMesh *BKE_editmesh_copy(BMEditMesh *em);
|
|
|
|
|
BMEditMesh *BKE_editmesh_from_object(struct Object *ob);
|
2021-07-13 15:05:39 +10:00
|
|
|
void BKE_editmesh_free_derived_caches(BMEditMesh *em);
|
|
|
|
|
void BKE_editmesh_free_data(BMEditMesh *em);
|
2013-04-18 01:20:04 +00:00
|
|
|
|
2020-01-07 13:49:10 +11:00
|
|
|
float (*BKE_editmesh_vert_coords_alloc(struct Depsgraph *depsgraph,
|
|
|
|
|
struct BMEditMesh *em,
|
|
|
|
|
struct Scene *scene,
|
|
|
|
|
struct Object *ob,
|
|
|
|
|
int *r_vert_len))[3];
|
2019-08-22 06:28:35 +10:00
|
|
|
float (*BKE_editmesh_vert_coords_alloc_orco(BMEditMesh *em, int *r_vert_len))[3];
|
2020-10-14 14:49:22 +11:00
|
|
|
const float (*BKE_editmesh_vert_coords_when_deformed(struct Depsgraph *depsgraph,
|
|
|
|
|
struct BMEditMesh *em,
|
|
|
|
|
struct Scene *scene,
|
|
|
|
|
struct Object *obedit,
|
|
|
|
|
int *r_vert_len,
|
|
|
|
|
bool *r_is_alloc))[3];
|
|
|
|
|
|
2020-01-07 14:20:49 +11:00
|
|
|
void BKE_editmesh_lnorspace_update(BMEditMesh *em, struct Mesh *me);
|
|
|
|
|
void BKE_editmesh_ensure_autosmooth(BMEditMesh *em, struct Mesh *me);
|
2019-09-23 14:36:45 +02:00
|
|
|
struct BoundBox *BKE_editmesh_cage_boundbox_get(BMEditMesh *em);
|
2013-04-18 17:09:56 +00:00
|
|
|
|
2020-03-02 15:07:49 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|