2010-04-11 22:12:30 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Daniel Dunbar
|
|
|
|
* Ton Roosendaal,
|
|
|
|
* Ben Batt,
|
|
|
|
* Brecht Van Lommel,
|
|
|
|
* Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
*/
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2011-02-25 13:57:17 +00:00
|
|
|
/** \file blender/modifiers/intern/MOD_boolean.c
|
|
|
|
* \ingroup modifiers
|
|
|
|
*/
|
|
|
|
|
2015-12-12 01:30:03 +11:00
|
|
|
// #ifdef DEBUG_TIME
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2011-03-05 10:29:10 +00:00
|
|
|
#include <stdio.h>
|
2011-02-25 13:57:17 +00:00
|
|
|
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2016-02-11 20:06:13 +11:00
|
|
|
#include "BLI_math_matrix.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
|
2015-10-08 14:21:11 +02:00
|
|
|
#include "BKE_library_query.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
#include "BKE_modifier.h"
|
|
|
|
|
2011-02-13 14:16:36 +00:00
|
|
|
#include "MOD_util.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2015-12-13 00:34:09 +11:00
|
|
|
#include "BLI_alloca.h"
|
2015-12-11 20:24:39 +11:00
|
|
|
#include "BLI_math_geom.h"
|
2015-12-13 00:34:09 +11:00
|
|
|
#include "BKE_material.h"
|
2017-09-19 18:29:52 +10:00
|
|
|
#include "BKE_global.h" /* only to check G.debug */
|
2018-05-09 14:55:56 +02:00
|
|
|
#include "BKE_mesh.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
2018-05-24 15:26:02 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
|
|
|
|
2015-12-11 20:24:39 +11:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "bmesh.h"
|
|
|
|
#include "bmesh_tools.h"
|
|
|
|
#include "tools/bmesh_intersect.h"
|
|
|
|
|
2015-12-12 01:30:03 +11:00
|
|
|
#ifdef DEBUG_TIME
|
2018-02-07 14:44:59 +01:00
|
|
|
# include "PIL_time.h"
|
|
|
|
# include "PIL_time_utildefines.h"
|
2015-12-12 01:30:03 +11:00
|
|
|
#endif
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2016-07-13 17:45:55 +10:00
|
|
|
static void initData(ModifierData *md)
|
|
|
|
{
|
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
|
|
|
|
|
|
|
bmd->double_threshold = 1e-6f;
|
|
|
|
}
|
|
|
|
|
2013-06-02 03:59:19 +00:00
|
|
|
static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams))
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *) md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
return !bmd->object;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void foreachObjectLink(
|
2012-08-23 16:17:47 +00:00
|
|
|
ModifierData *md, Object *ob,
|
2015-10-05 15:57:10 +02:00
|
|
|
ObjectWalkFunc walk, void *userData)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *) md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2017-01-31 09:47:59 +01:00
|
|
|
walk(userData, ob, &bmd->object, IDWALK_CB_NOP);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 12:54:06 +01:00
|
|
|
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
{
|
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
|
|
|
if (bmd->object != NULL) {
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_relation(ctx->node, bmd->object, DEG_OB_COMP_TRANSFORM, "Boolean Modifier");
|
|
|
|
DEG_add_object_relation(ctx->node, bmd->object, DEG_OB_COMP_GEOMETRY, "Boolean Modifier");
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
}
|
|
|
|
/* We need own transformation as well. */
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Boolean Modifier");
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
}
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
static Mesh *get_quick_mesh(
|
|
|
|
Object *ob_self, Mesh *mesh_self,
|
|
|
|
Object *ob_other, Mesh *mesh_other,
|
2015-12-21 14:37:42 +11:00
|
|
|
int operation)
|
2011-05-29 15:53:38 +00:00
|
|
|
{
|
2018-05-09 14:55:56 +02:00
|
|
|
Mesh *result = NULL;
|
2011-05-29 15:53:38 +00:00
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
if (mesh_self->totpoly == 0 || mesh_other->totpoly == 0) {
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (operation) {
|
2011-05-29 15:53:38 +00:00
|
|
|
case eBooleanModifierOp_Intersect:
|
2018-05-09 14:55:56 +02:00
|
|
|
result = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
|
2011-05-29 15:53:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case eBooleanModifierOp_Union:
|
2018-05-09 14:55:56 +02:00
|
|
|
if (mesh_self->totpoly != 0) {
|
|
|
|
result = mesh_self;
|
2015-12-21 14:37:42 +11:00
|
|
|
}
|
|
|
|
else {
|
2018-05-14 14:34:00 +02:00
|
|
|
BKE_id_copy_ex(NULL, &mesh_other->id, (ID **)&result,
|
|
|
|
LIB_ID_CREATE_NO_MAIN |
|
|
|
|
LIB_ID_CREATE_NO_USER_REFCOUNT |
|
|
|
|
LIB_ID_CREATE_NO_DEG_TAG |
|
|
|
|
LIB_ID_COPY_NO_PREVIEW,
|
|
|
|
false);
|
2015-12-21 14:37:42 +11:00
|
|
|
|
|
|
|
float imat[4][4];
|
|
|
|
float omat[4][4];
|
|
|
|
|
|
|
|
invert_m4_m4(imat, ob_self->obmat);
|
|
|
|
mul_m4_m4m4(omat, imat, ob_other->obmat);
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
const int mverts_len = result->totvert;
|
|
|
|
MVert *mv = result->mvert;
|
2015-12-21 14:37:42 +11:00
|
|
|
|
|
|
|
for (int i = 0; i < mverts_len; i++, mv++) {
|
|
|
|
mul_m4_v3(omat, mv->co);
|
|
|
|
}
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
2015-12-21 14:37:42 +11:00
|
|
|
}
|
2011-05-29 15:53:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eBooleanModifierOp_Difference:
|
2018-05-09 14:55:56 +02:00
|
|
|
result = mesh_self;
|
2011-05-29 15:53:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
|
|
|
|
/* has no meaning for faces, do this so we can tell which face is which */
|
|
|
|
#define BM_FACE_TAG BM_ELEM_DRAW
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compare selected/unselected.
|
|
|
|
*/
|
|
|
|
static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data))
|
|
|
|
{
|
|
|
|
return BM_elem_flag_test(f, BM_FACE_TAG) ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
2015-12-11 20:24:39 +11:00
|
|
|
{
|
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *) md;
|
2018-05-30 11:34:08 +02:00
|
|
|
Mesh *result;
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
Mesh *mesh_other;
|
2018-05-30 11:34:08 +02:00
|
|
|
bool mesh_other_free;
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
if (!bmd->object)
|
2018-05-09 14:55:56 +02:00
|
|
|
return mesh;
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2018-05-30 11:34:08 +02:00
|
|
|
mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(bmd->object, &mesh_other_free);
|
2018-05-09 14:55:56 +02:00
|
|
|
if (mesh_other) {
|
2018-06-01 11:49:24 +02:00
|
|
|
Object *object = ctx->object;
|
|
|
|
Object *other = bmd->object;
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
/* when one of objects is empty (has got no faces) we could speed up
|
|
|
|
* calculation a bit returning one of objects' derived meshes (or empty one)
|
|
|
|
* Returning mesh is depended on modifiers operation (sergey) */
|
2018-06-01 11:49:24 +02:00
|
|
|
result = get_quick_mesh(object, mesh, other, mesh_other, bmd->operation);
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
if (result == NULL) {
|
2018-06-01 11:49:24 +02:00
|
|
|
const bool is_flip = (is_negative_m4(object->obmat) != is_negative_m4(other->obmat));
|
2017-09-16 18:10:25 +10:00
|
|
|
|
2015-12-11 20:24:39 +11:00
|
|
|
BMesh *bm;
|
2018-05-09 14:55:56 +02:00
|
|
|
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_other);
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2015-12-12 01:30:03 +11:00
|
|
|
#ifdef DEBUG_TIME
|
2015-12-11 20:24:39 +11:00
|
|
|
TIMEIT_START(boolean_bmesh);
|
2015-12-12 01:30:03 +11:00
|
|
|
#endif
|
2016-07-13 17:45:55 +10:00
|
|
|
bm = BM_mesh_create(
|
|
|
|
&allocsize,
|
|
|
|
&((struct BMeshCreateParams){.use_toolflags = false,}));
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
BM_mesh_bm_from_me(bm, mesh_other, &((struct BMeshFromMeshParams){.calc_face_normal = true,}));
|
2017-09-16 18:10:25 +10:00
|
|
|
|
|
|
|
if (UNLIKELY(is_flip)) {
|
|
|
|
const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS);
|
|
|
|
BMIter iter;
|
|
|
|
BMFace *efa;
|
|
|
|
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
|
|
|
|
BM_face_normal_flip_ex(bm, efa, cd_loop_mdisp_offset, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
BM_mesh_bm_from_me(bm, mesh, &((struct BMeshFromMeshParams){.calc_face_normal = true,}));
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2015-12-12 15:10:03 +11:00
|
|
|
/* main bmesh intersection setup */
|
|
|
|
{
|
2015-12-11 20:24:39 +11:00
|
|
|
/* create tessface & intersect */
|
|
|
|
const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
|
|
|
|
int tottri;
|
|
|
|
BMLoop *(*looptris)[3];
|
|
|
|
|
2018-01-14 22:14:20 +01:00
|
|
|
looptris = MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__);
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2017-09-14 16:00:27 +10:00
|
|
|
BM_mesh_calc_tessellation_beauty(bm, looptris, &tottri);
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
/* postpone this until after tessellating
|
|
|
|
* so we can use the original normals before the vertex are moved */
|
|
|
|
{
|
|
|
|
BMIter iter;
|
|
|
|
int i;
|
2018-05-09 14:55:56 +02:00
|
|
|
const int i_verts_end = mesh_other->totvert;
|
|
|
|
const int i_faces_end = mesh_other->totpoly;
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
float imat[4][4];
|
|
|
|
float omat[4][4];
|
|
|
|
|
2018-06-01 11:49:24 +02:00
|
|
|
invert_m4_m4(imat, object->obmat);
|
|
|
|
mul_m4_m4m4(omat, imat, other->obmat);
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
BMVert *eve;
|
|
|
|
i = 0;
|
|
|
|
BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) {
|
|
|
|
mul_m4_v3(omat, eve->co);
|
|
|
|
if (++i == i_verts_end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we need face normals because of 'BM_face_split_edgenet'
|
|
|
|
* we could calculate on the fly too (before calling split). */
|
2015-12-13 00:34:09 +11:00
|
|
|
{
|
2017-09-16 18:10:25 +10:00
|
|
|
float nmat[3][3];
|
|
|
|
copy_m3_m4(nmat, omat);
|
|
|
|
invert_m3(nmat);
|
|
|
|
|
|
|
|
if (UNLIKELY(is_flip)) {
|
|
|
|
negate_m3(nmat);
|
|
|
|
}
|
2015-12-13 00:34:09 +11:00
|
|
|
|
2018-06-01 11:49:24 +02:00
|
|
|
const short ob_src_totcol = other->totcol;
|
2015-12-13 00:34:09 +11:00
|
|
|
short *material_remap = BLI_array_alloca(material_remap, ob_src_totcol ? ob_src_totcol : 1);
|
|
|
|
|
2018-05-24 15:56:09 +02:00
|
|
|
/* Using original (not evaluated) object here since we are writing to it. */
|
2018-06-01 11:49:24 +02:00
|
|
|
BKE_material_remap_object_calc(ctx->object, other, material_remap);
|
2015-12-13 00:34:09 +11:00
|
|
|
|
|
|
|
BMFace *efa;
|
|
|
|
i = 0;
|
|
|
|
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
|
2017-09-16 18:10:25 +10:00
|
|
|
mul_transposed_m3_v3(nmat, efa->no);
|
2015-12-13 00:34:09 +11:00
|
|
|
normalize_v3(efa->no);
|
|
|
|
BM_elem_flag_enable(efa, BM_FACE_TAG); /* temp tag to test which side split faces are from */
|
|
|
|
|
|
|
|
/* remap material */
|
|
|
|
if (LIKELY(efa->mat_nr < ob_src_totcol)) {
|
|
|
|
efa->mat_nr = material_remap[efa->mat_nr];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (++i == i_faces_end) {
|
|
|
|
break;
|
|
|
|
}
|
2015-12-11 20:24:39 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not needed, but normals for 'dm' will be invalid,
|
|
|
|
* currently this is ok for 'BM_mesh_intersect' */
|
|
|
|
// BM_mesh_normals_update(bm);
|
|
|
|
|
2016-07-13 17:45:55 +10:00
|
|
|
bool use_separate = false;
|
|
|
|
bool use_dissolve = true;
|
|
|
|
bool use_island_connect = true;
|
|
|
|
|
2017-09-19 18:29:52 +10:00
|
|
|
/* change for testing */
|
|
|
|
if (G.debug & G_DEBUG) {
|
|
|
|
use_separate = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_Separate) != 0;
|
|
|
|
use_dissolve = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoDissolve) == 0;
|
|
|
|
use_island_connect = (bmd->bm_flag & eBooleanModifierBMeshFlag_BMesh_NoConnectRegions) == 0;
|
|
|
|
}
|
|
|
|
|
2015-12-11 20:24:39 +11:00
|
|
|
BM_mesh_intersect(
|
|
|
|
bm,
|
|
|
|
looptris, tottri,
|
|
|
|
bm_face_isect_pair, NULL,
|
|
|
|
false,
|
2016-07-13 17:45:55 +10:00
|
|
|
use_separate,
|
|
|
|
use_dissolve,
|
|
|
|
use_island_connect,
|
2017-03-05 22:23:12 +11:00
|
|
|
false,
|
2015-12-11 20:24:39 +11:00
|
|
|
bmd->operation,
|
2016-07-13 17:45:55 +10:00
|
|
|
bmd->double_threshold);
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
MEM_freeN(looptris);
|
|
|
|
}
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
result = BKE_bmesh_to_mesh_nomain(bm, &((struct BMeshToMeshParams){0}));
|
2015-12-11 20:24:39 +11:00
|
|
|
|
|
|
|
BM_mesh_free(bm);
|
|
|
|
|
2018-05-09 14:55:56 +02:00
|
|
|
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2015-12-12 01:30:03 +11:00
|
|
|
#ifdef DEBUG_TIME
|
2015-12-11 20:24:39 +11:00
|
|
|
TIMEIT_END(boolean_bmesh);
|
2015-12-12 01:30:03 +11:00
|
|
|
#endif
|
2015-12-11 20:24:39 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if new mesh returned, return it; otherwise there was
|
|
|
|
* an error, so delete the modifier object */
|
2018-05-30 11:34:08 +02:00
|
|
|
if (result == NULL)
|
2015-12-11 20:24:39 +11:00
|
|
|
modifier_setError(md, "Cannot execute boolean operation");
|
|
|
|
}
|
|
|
|
|
2018-05-30 11:34:08 +02:00
|
|
|
if (mesh_other != NULL && mesh_other_free) {
|
|
|
|
BKE_id_free(NULL, mesh_other);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2015-12-11 20:24:39 +11:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2010-10-14 06:29:17 +00:00
|
|
|
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2010-10-21 01:55:39 +00:00
|
|
|
CustomDataMask dataMask = CD_MASK_MTFACE | CD_MASK_MEDGE;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2010-10-21 01:55:39 +00:00
|
|
|
dataMask |= CD_MASK_MDEFORMVERT;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
return dataMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
ModifierTypeInfo modifierType_Boolean = {
|
2012-10-24 05:45:54 +00:00
|
|
|
/* name */ "Boolean",
|
|
|
|
/* structName */ "BooleanModifierData",
|
|
|
|
/* structSize */ sizeof(BooleanModifierData),
|
|
|
|
/* type */ eModifierTypeType_Nonconstructive,
|
|
|
|
/* flags */ eModifierTypeFlag_AcceptsMesh |
|
|
|
|
eModifierTypeFlag_UsesPointCache,
|
|
|
|
|
2018-05-08 15:04:10 +02:00
|
|
|
/* copyData */ modifier_copyData_generic,
|
2018-04-18 15:45:54 +02:00
|
|
|
|
|
|
|
/* deformVerts_DM */ NULL,
|
|
|
|
/* deformMatrices_DM */ NULL,
|
|
|
|
/* deformVertsEM_DM */ NULL,
|
|
|
|
/* deformMatricesEM_DM*/NULL,
|
2018-05-09 14:55:56 +02:00
|
|
|
/* applyModifier_DM */ NULL,
|
2018-04-18 15:45:54 +02:00
|
|
|
/* applyModifierEM_DM */NULL,
|
|
|
|
|
2012-10-24 05:45:54 +00:00
|
|
|
/* deformVerts */ NULL,
|
|
|
|
/* deformMatrices */ NULL,
|
|
|
|
/* deformVertsEM */ NULL,
|
|
|
|
/* deformMatricesEM */ NULL,
|
2018-05-09 14:55:56 +02:00
|
|
|
/* applyModifier */ applyModifier,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* applyModifierEM */ NULL,
|
2018-04-18 15:45:54 +02:00
|
|
|
|
2016-07-13 17:45:55 +10:00
|
|
|
/* initData */ initData,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* requiredDataMask */ requiredDataMask,
|
|
|
|
/* freeData */ NULL,
|
|
|
|
/* isDisabled */ isDisabled,
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/* updateDepsgraph */ updateDepsgraph,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* dependsOnTime */ NULL,
|
|
|
|
/* dependsOnNormals */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* foreachObjectLink */ foreachObjectLink,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* foreachIDLink */ NULL,
|
|
|
|
/* foreachTexLink */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|