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
|
|
|
*/
|
|
|
|
|
2012-04-25 03:44:01 +00:00
|
|
|
#include "BKE_customdata.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;
|
2019-09-27 12:45:54 +10:00
|
|
|
struct BMesh;
|
2021-05-28 18:18:13 +10:00
|
|
|
struct BMPartialUpdate;
|
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
|
|
|
*
|
2015-08-01 12:36:14 +10:00
|
|
|
* through this, you get access to both the edit #BMesh,
|
2012-03-03 20:19:11 +00:00
|
|
|
* its tessellation, and various stuff that doesn't belong in the BMesh
|
|
|
|
* struct itself.
|
|
|
|
*
|
|
|
|
* the entire derivedmesh and 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
|
|
|
|
|
|
|
/*this is for undoing failed operations*/
|
|
|
|
struct BMEditMesh *emcopy;
|
2009-09-09 06:28:58 +00:00
|
|
|
int emcopyusers;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-03-03 20:19:11 +00:00
|
|
|
/* we store tessellations as triplets of three loops,
|
|
|
|
* which each define a triangle.*/
|
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;
|
|
|
|
|
2019-09-23 14:36:45 +02:00
|
|
|
/** Cached cage bounding box for selection. */
|
|
|
|
struct BoundBox *bb_cage;
|
|
|
|
|
2009-05-16 16:18:08 +00:00
|
|
|
/*derivedmesh stuff*/
|
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
|
|
|
|
|
|
|
/*selection mode*/
|
2011-05-09 04:06:48 +00:00
|
|
|
short selectmode;
|
|
|
|
short mat_nr;
|
2009-11-02 06:33:16 +00:00
|
|
|
|
2010-03-11 05:30:01 +00:00
|
|
|
/*temp variables for x-mirror editing*/
|
2011-10-28 06:23:12 +00:00
|
|
|
int mirror_cdlayer; /* -1 is invalid */
|
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
|
|
|
|
2013-04-16 05:59:48 +00:00
|
|
|
BMEditMesh *BKE_editmesh_create(BMesh *bm, const bool do_tessellate);
|
|
|
|
BMEditMesh *BKE_editmesh_copy(BMEditMesh *em);
|
|
|
|
BMEditMesh *BKE_editmesh_from_object(struct Object *ob);
|
2014-02-28 20:02:30 +11:00
|
|
|
void BKE_editmesh_free_derivedmesh(BMEditMesh *em);
|
2013-04-16 05:59:48 +00:00
|
|
|
void BKE_editmesh_free(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
|