2012-02-19 18:31:04 +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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bmesh
|
2012-03-08 03:25:53 +00:00
|
|
|
*
|
|
|
|
|
* This file contains functions
|
|
|
|
|
* for converting a Mesh
|
|
|
|
|
* into a Bmesh, and back again.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_key_types.h"
|
2012-02-19 18:31:04 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
2013-01-24 21:57:13 +00:00
|
|
|
#include "BLI_math.h"
|
2012-02-19 18:31:04 +00:00
|
|
|
|
|
|
|
|
#include "bmesh.h"
|
2013-03-25 22:40:11 +00:00
|
|
|
#include "intern/bmesh_operators_private.h"
|
2012-02-19 18:31:04 +00:00
|
|
|
|
2018-06-13 16:29:12 +02:00
|
|
|
#include "BKE_global.h"
|
2012-02-19 18:31:04 +00:00
|
|
|
|
2012-02-28 09:48:00 +00:00
|
|
|
void bmo_mesh_to_bmesh_exec(BMesh *bm, BMOperator *op)
|
2012-02-19 18:31:04 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Object *ob = BMO_slot_ptr_get(op->slots_in, "object");
|
|
|
|
|
Mesh *me = BMO_slot_ptr_get(op->slots_in, "mesh");
|
|
|
|
|
bool set_key = BMO_slot_bool_get(op->slots_in, "use_shapekey");
|
2012-02-19 18:31:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BM_mesh_bm_from_me(bm,
|
|
|
|
|
me,
|
|
|
|
|
(&(struct BMeshFromMeshParams){
|
|
|
|
|
.use_shapekey = set_key,
|
|
|
|
|
.active_shapekey = ob->shapenr,
|
|
|
|
|
}));
|
2012-02-19 18:31:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (me->key && ob->shapenr > me->key->totkey) {
|
|
|
|
|
ob->shapenr = me->key->totkey - 1;
|
|
|
|
|
}
|
2012-02-19 18:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-28 09:48:00 +00:00
|
|
|
void bmo_object_load_bmesh_exec(BMesh *bm, BMOperator *op)
|
2012-02-19 18:31:04 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Object *ob = BMO_slot_ptr_get(op->slots_in, "object");
|
|
|
|
|
/* Scene *scene = BMO_slot_ptr_get(op, "scene"); */
|
|
|
|
|
Mesh *me = ob->data;
|
2012-02-19 18:31:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BMO_op_callf(bm, op->flag, "bmesh_to_mesh mesh=%p object=%p", me, ob);
|
2012-02-19 18:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
2012-02-28 09:48:00 +00:00
|
|
|
void bmo_bmesh_to_mesh_exec(BMesh *bm, BMOperator *op)
|
2012-02-19 18:31:04 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Mesh *me = BMO_slot_ptr_get(op->slots_in, "mesh");
|
|
|
|
|
/* Object *ob = BMO_slot_ptr_get(op, "object"); */
|
2012-02-19 18:31:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BM_mesh_bm_to_me(G.main,
|
|
|
|
|
bm,
|
|
|
|
|
me,
|
|
|
|
|
(&(struct BMeshToMeshParams){
|
|
|
|
|
.calc_object_remap = true,
|
|
|
|
|
}));
|
2012-02-19 18:31:04 +00:00
|
|
|
}
|