2010-04-11 22:12:30 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +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
|
2020-05-09 17:14:35 +10:00
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2011-10-23 17:52:20 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup modifiers
|
2011-02-25 13:57:17 +00:00
|
|
|
*/
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
#include <cstdio>
|
2011-02-25 13:57:17 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
#include "BLI_array.hh"
|
|
|
|
#include "BLI_float4x4.hh"
|
2015-12-11 20:24:39 +11:00
|
|
|
#include "BLI_math_geom.h"
|
2019-02-25 11:56:24 +01:00
|
|
|
#include "BLI_math_matrix.h"
|
2021-04-02 00:16:01 -05:00
|
|
|
#include "BLI_vector.hh"
|
2019-02-25 11:56:24 +01:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
#include "DNA_collection_types.h"
|
2020-10-01 09:38:00 -05:00
|
|
|
#include "DNA_defaults.h"
|
2019-02-25 11:56:24 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
2020-09-13 16:57:27 -04:00
|
|
|
#include "DNA_scene_types.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "DNA_screen_types.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
#include "BKE_collection.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BKE_context.h"
|
2017-09-19 18:29:52 +10:00
|
|
|
#include "BKE_global.h" /* only to check G.debug */
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
|
|
|
#include "BKE_lib_query.h"
|
2018-11-07 18:00:24 +01:00
|
|
|
#include "BKE_material.h"
|
|
|
|
#include "BKE_mesh.h"
|
2021-04-02 00:16:01 -05:00
|
|
|
#include "BKE_mesh_boolean_convert.hh"
|
2020-08-07 17:07:30 +02:00
|
|
|
#include "BKE_mesh_wrapper.h"
|
2019-02-25 11:56:24 +01:00
|
|
|
#include "BKE_modifier.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
2018-05-09 14:55:56 +02:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "MOD_ui_common.h"
|
2019-02-25 11:56:24 +01:00
|
|
|
#include "MOD_util.h"
|
2018-05-09 14:55:56 +02:00
|
|
|
|
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"
|
2020-08-28 10:56:44 -04:00
|
|
|
#include "tools/bmesh_boolean.h"
|
2015-12-11 20:24:39 +11:00
|
|
|
#include "tools/bmesh_intersect.h"
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
// #define DEBUG_TIME
|
|
|
|
|
2015-12-12 01:30:03 +11:00
|
|
|
#ifdef DEBUG_TIME
|
2021-04-02 00:16:01 -05:00
|
|
|
# include "BLI_timeit.hh"
|
2015-12-12 01:30:03 +11:00
|
|
|
#endif
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
using blender::Array;
|
|
|
|
using blender::float4x4;
|
|
|
|
using blender::Vector;
|
|
|
|
|
2016-07-13 17:45:55 +10:00
|
|
|
static void initData(ModifierData *md)
|
|
|
|
{
|
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(bmd, modifier));
|
|
|
|
|
|
|
|
MEMCPY_STRUCT_AFTER(bmd, DNA_struct_default_get(BooleanModifierData), modifier);
|
2016-07-13 17:45:55 +10:00
|
|
|
}
|
|
|
|
|
2018-07-10 12:14:08 +02:00
|
|
|
static bool isDisabled(const struct Scene *UNUSED(scene),
|
|
|
|
ModifierData *md,
|
|
|
|
bool UNUSED(useRenderParams))
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
2020-09-13 16:57:27 -04:00
|
|
|
Collection *col = bmd->collection;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
if (bmd->flag & eBooleanModifierFlag_Object) {
|
|
|
|
return !bmd->object || bmd->object->type != OB_MESH;
|
|
|
|
}
|
|
|
|
if (bmd->flag & eBooleanModifierFlag_Collection) {
|
2020-10-10 12:03:48 -04:00
|
|
|
/* The Exact solver tolerates an empty collection. */
|
|
|
|
return !col && bmd->solver != eBooleanModifierSolver_Exact;
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
|
|
|
return false;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
|
|
|
|
{
|
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
|
|
|
|
|
|
|
walk(userData, ob, (ID **)&bmd->collection, IDWALK_CB_NOP);
|
2020-10-01 18:05:23 +02:00
|
|
|
walk(userData, ob, (ID **)&bmd->object, IDWALK_CB_NOP);
|
2020-09-13 16:57:27 -04: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;
|
2021-04-02 00:16:01 -05:00
|
|
|
if ((bmd->flag & eBooleanModifierFlag_Object) && bmd->object != nullptr) {
|
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
|
|
|
}
|
2020-09-13 16:57:27 -04:00
|
|
|
|
|
|
|
Collection *col = bmd->collection;
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
if ((bmd->flag & eBooleanModifierFlag_Collection) && col != nullptr) {
|
2021-04-26 16:35:22 +02:00
|
|
|
DEG_add_collection_geometry_relation(ctx->node, col, "Boolean Modifier");
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
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. */
|
2019-02-12 12:01:17 +01:00
|
|
|
DEG_add_modifier_to_transform_relation(ctx->node, "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(
|
2020-09-13 16:57:27 -04:00
|
|
|
Object *ob_self, Mesh *mesh_self, Object *ob_operand_ob, Mesh *mesh_operand_ob, int operation)
|
2011-05-29 15:53:38 +00:00
|
|
|
{
|
2021-04-02 00:16:01 -05:00
|
|
|
Mesh *result = nullptr;
|
2011-05-29 15:53:38 +00:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
if (mesh_self->totpoly == 0 || mesh_operand_ob->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 {
|
2021-04-02 00:16:01 -05:00
|
|
|
result = (Mesh *)BKE_id_copy_ex(
|
|
|
|
nullptr, &mesh_operand_ob->id, nullptr, LIB_ID_COPY_LOCALIZE);
|
2015-12-21 14:37:42 +11:00
|
|
|
|
|
|
|
float imat[4][4];
|
|
|
|
float omat[4][4];
|
|
|
|
invert_m4_m4(imat, ob_self->obmat);
|
2020-09-13 16:57:27 -04:00
|
|
|
mul_m4_m4m4(omat, imat, ob_operand_ob->obmat);
|
2015-12-21 14:37:42 +11:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
static bool BMD_error_messages(const Object *ob, ModifierData *md)
|
2015-12-11 20:24:39 +11:00
|
|
|
{
|
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
2021-04-02 00:16:01 -05:00
|
|
|
Collection *col = bmd->collection;
|
2018-05-30 11:34:08 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
bool error_returns_result = false;
|
|
|
|
|
|
|
|
const bool operand_collection = (bmd->flag & eBooleanModifierFlag_Collection) != 0;
|
|
|
|
const bool use_exact = bmd->solver == eBooleanModifierSolver_Exact;
|
|
|
|
const bool operation_intersect = bmd->operation == eBooleanModifierOp_Intersect;
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
#ifndef WITH_GMP
|
|
|
|
/* If compiled without GMP, return a error. */
|
|
|
|
if (use_exact) {
|
2020-10-26 17:07:58 +11:00
|
|
|
BKE_modifier_set_error(ob, md, "Compiled without GMP, using fast solver");
|
2020-09-13 16:57:27 -04:00
|
|
|
error_returns_result = false;
|
2018-06-13 16:01:41 +02:00
|
|
|
}
|
2020-09-13 16:57:27 -04:00
|
|
|
#endif
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
/* If intersect is selected using fast solver, return a error. */
|
|
|
|
if (operand_collection && operation_intersect && !use_exact) {
|
2020-10-26 17:07:58 +11:00
|
|
|
BKE_modifier_set_error(ob, md, "Cannot execute, intersect only available using exact solver");
|
2020-09-13 16:57:27 -04:00
|
|
|
error_returns_result = true;
|
|
|
|
}
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
/* If the selected collection is empty and using fast solver, return a error. */
|
|
|
|
if (operand_collection) {
|
|
|
|
if (!use_exact && BKE_collection_is_empty(col)) {
|
2020-10-26 17:07:58 +11:00
|
|
|
BKE_modifier_set_error(ob, md, "Cannot execute, fast solver and empty collection");
|
2020-09-13 16:57:27 -04:00
|
|
|
error_returns_result = true;
|
|
|
|
}
|
2020-08-07 17:11:21 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
/* If the selected collection contain non mesh objects, return a error. */
|
|
|
|
if (col) {
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (col, operand_ob) {
|
|
|
|
if (operand_ob->type != OB_MESH) {
|
|
|
|
BKE_modifier_set_error(
|
2020-10-26 17:07:58 +11:00
|
|
|
ob, md, "Cannot execute, the selected collection contains non mesh objects");
|
2020-09-13 16:57:27 -04:00
|
|
|
error_returns_result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
|
|
|
|
}
|
|
|
|
}
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
return error_returns_result;
|
|
|
|
}
|
2017-09-16 18:10:25 +10:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
static BMesh *BMD_mesh_bm_create(
|
|
|
|
Mesh *mesh, Object *object, Mesh *mesh_operand_ob, Object *operand_ob, bool *r_is_flip)
|
|
|
|
{
|
2021-04-02 00:16:01 -05:00
|
|
|
#ifdef DEBUG_TIME
|
|
|
|
SCOPED_TIMER(__func__)
|
|
|
|
#endif
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
*r_is_flip = (is_negative_m4(object->obmat) != is_negative_m4(operand_ob->obmat));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_operand_ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
BMeshCreateParams bmcp = {false};
|
|
|
|
BMesh *bm = BM_mesh_create(&allocsize, &bmcp);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
BMeshFromMeshParams params{};
|
|
|
|
params.calc_face_normal = true;
|
|
|
|
BM_mesh_bm_from_me(bm, mesh_operand_ob, ¶ms);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
if (UNLIKELY(*r_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);
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
BM_mesh_bm_from_me(bm, mesh, ¶ms);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
return bm;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
static void BMD_mesh_intersection(BMesh *bm,
|
|
|
|
ModifierData *md,
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
Mesh *mesh_operand_ob,
|
|
|
|
Object *object,
|
|
|
|
Object *operand_ob,
|
|
|
|
bool is_flip)
|
|
|
|
{
|
2021-04-02 00:16:01 -05:00
|
|
|
#ifdef DEBUG_TIME
|
|
|
|
SCOPED_TIMER(__func__)
|
|
|
|
#endif
|
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
/* main bmesh intersection setup */
|
|
|
|
/* create tessface & intersect */
|
|
|
|
const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop);
|
2021-04-02 00:16:01 -05:00
|
|
|
BMLoop *(*looptris)[3] = (BMLoop * (*)[3])
|
|
|
|
MEM_malloc_arrayN(looptris_tot, sizeof(*looptris), __func__);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-01 12:49:22 +10:00
|
|
|
BM_mesh_calc_tessellation_beauty(bm, looptris);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
/* postpone this until after tessellating
|
|
|
|
* so we can use the original normals before the vertex are moved */
|
|
|
|
{
|
|
|
|
BMIter iter;
|
|
|
|
int i;
|
|
|
|
const int i_verts_end = mesh_operand_ob->totvert;
|
|
|
|
const int i_faces_end = mesh_operand_ob->totpoly;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
float imat[4][4];
|
|
|
|
float omat[4][4];
|
2021-04-01 16:49:10 -05:00
|
|
|
invert_m4_m4(imat, object->obmat);
|
|
|
|
mul_m4_m4m4(omat, imat, operand_ob->obmat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04: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;
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
/* we need face normals because of 'BM_face_split_edgenet'
|
|
|
|
* we could calculate on the fly too (before calling split). */
|
2021-04-01 16:49:10 -05:00
|
|
|
float nmat[3][3];
|
|
|
|
copy_m3_m4(nmat, omat);
|
|
|
|
invert_m3(nmat);
|
2019-08-14 23:29:46 +10:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
if (UNLIKELY(is_flip)) {
|
|
|
|
negate_m3(nmat);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
Array<short> material_remap(operand_ob->totcol ? operand_ob->totcol : 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
/* Using original (not evaluated) object here since we are writing to it. */
|
|
|
|
/* XXX Pretty sure comment above is fully wrong now with CoW & co ? */
|
2021-04-02 00:16:01 -05:00
|
|
|
BKE_object_material_remap_calc(ctx->object, operand_ob, material_remap.data());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
BMFace *efa;
|
|
|
|
i = 0;
|
|
|
|
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
|
|
|
|
mul_transposed_m3_v3(nmat, efa->no);
|
|
|
|
normalize_v3(efa->no);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
/* Temp tag to test which side split faces are from. */
|
|
|
|
BM_elem_flag_enable(efa, BM_FACE_TAG);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
/* remap material */
|
2021-04-02 00:16:01 -05:00
|
|
|
if (LIKELY(efa->mat_nr < operand_ob->totcol)) {
|
2021-04-01 16:49:10 -05:00
|
|
|
efa->mat_nr = material_remap[efa->mat_nr];
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
if (++i == i_faces_end) {
|
|
|
|
break;
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* not needed, but normals for 'dm' will be invalid,
|
|
|
|
* currently this is ok for 'BM_mesh_intersect' */
|
|
|
|
// BM_mesh_normals_update(bm);
|
|
|
|
|
|
|
|
bool use_separate = false;
|
|
|
|
bool use_dissolve = true;
|
|
|
|
bool use_island_connect = true;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
BM_mesh_intersect(bm,
|
|
|
|
looptris,
|
2021-06-01 12:49:22 +10:00
|
|
|
looptris_tot,
|
2021-04-01 16:49:10 -05:00
|
|
|
bm_face_isect_pair,
|
2021-04-02 00:16:01 -05:00
|
|
|
nullptr,
|
2021-04-01 16:49:10 -05:00
|
|
|
false,
|
|
|
|
use_separate,
|
|
|
|
use_dissolve,
|
|
|
|
use_island_connect,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
bmd->operation,
|
|
|
|
bmd->double_threshold);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
MEM_freeN(looptris);
|
|
|
|
}
|
|
|
|
|
2021-02-21 17:57:03 -05:00
|
|
|
#ifdef WITH_GMP
|
2021-03-14 11:39:56 -04:00
|
|
|
|
|
|
|
/* Get a mapping from material slot numbers in the src_ob to slot numbers in the dst_ob.
|
|
|
|
* If a material doesn't exist in the dst_ob, the mapping just goes to the same slot
|
|
|
|
* or to zero if there aren't enough slots in the destination.
|
2021-04-02 00:16:01 -05:00
|
|
|
* Caller owns the returned array. */
|
|
|
|
static Array<short> get_material_remap(Object *dest_ob, Object *src_ob)
|
2021-03-14 11:39:56 -04:00
|
|
|
{
|
|
|
|
int n = dest_ob->totcol;
|
|
|
|
if (n <= 0) {
|
|
|
|
n = 1;
|
|
|
|
}
|
2021-04-02 00:16:01 -05:00
|
|
|
Array<short> remap(n);
|
|
|
|
BKE_object_material_remap_calc(dest_ob, src_ob, remap.data());
|
2021-03-14 11:39:56 -04:00
|
|
|
return remap;
|
|
|
|
}
|
|
|
|
|
2021-02-21 17:57:03 -05:00
|
|
|
static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
Mesh *mesh)
|
|
|
|
{
|
2021-04-02 00:16:01 -05:00
|
|
|
Vector<const Mesh *> meshes;
|
|
|
|
Vector<float4x4 *> obmats;
|
|
|
|
Vector<Array<short>> material_remaps;
|
2021-02-21 17:57:03 -05:00
|
|
|
|
|
|
|
# ifdef DEBUG_TIME
|
2021-04-02 00:16:01 -05:00
|
|
|
SCOPED_TIMER(__func__)
|
2021-02-21 17:57:03 -05:00
|
|
|
# endif
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
if ((bmd->flag & eBooleanModifierFlag_Object) && bmd->object == nullptr) {
|
2021-03-14 11:39:56 -04:00
|
|
|
return mesh;
|
|
|
|
}
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
meshes.append(mesh);
|
|
|
|
obmats.append((float4x4 *)&ctx->object->obmat);
|
|
|
|
material_remaps.append({});
|
2021-02-21 17:57:03 -05:00
|
|
|
if (bmd->flag & eBooleanModifierFlag_Object) {
|
2021-04-02 00:16:01 -05:00
|
|
|
Mesh *mesh_operand = BKE_modifier_get_evaluated_mesh_from_evaluated_object(bmd->object, false);
|
2021-03-31 09:35:40 -04:00
|
|
|
if (!mesh_operand) {
|
|
|
|
return mesh;
|
|
|
|
}
|
2021-02-21 17:57:03 -05:00
|
|
|
BKE_mesh_wrapper_ensure_mdata(mesh_operand);
|
2021-04-02 00:16:01 -05:00
|
|
|
meshes.append(mesh_operand);
|
|
|
|
obmats.append((float4x4 *)&bmd->object->obmat);
|
|
|
|
material_remaps.append(get_material_remap(ctx->object, bmd->object));
|
2021-02-21 17:57:03 -05:00
|
|
|
}
|
|
|
|
else if (bmd->flag & eBooleanModifierFlag_Collection) {
|
|
|
|
Collection *collection = bmd->collection;
|
2021-04-02 00:16:01 -05:00
|
|
|
/* Allow collection to be empty; then target mesh will just removed self-intersections. */
|
2021-02-21 17:57:03 -05:00
|
|
|
if (collection) {
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (collection, ob) {
|
|
|
|
if (ob->type == OB_MESH && ob != ctx->object) {
|
|
|
|
Mesh *collection_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob, false);
|
2021-03-31 09:35:40 -04:00
|
|
|
if (!collection_mesh) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-02-21 17:57:03 -05:00
|
|
|
BKE_mesh_wrapper_ensure_mdata(collection_mesh);
|
2021-04-02 00:16:01 -05:00
|
|
|
meshes.append(collection_mesh);
|
|
|
|
obmats.append((float4x4 *)&ob->obmat);
|
|
|
|
material_remaps.append(get_material_remap(ctx->object, ob));
|
2021-02-21 17:57:03 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool use_self = (bmd->flag & eBooleanModifierFlag_Self) != 0;
|
2021-03-07 18:13:19 -05:00
|
|
|
const bool hole_tolerant = (bmd->flag & eBooleanModifierFlag_HoleTolerant) != 0;
|
2021-04-02 00:16:01 -05:00
|
|
|
return blender::meshintersect::direct_mesh_boolean(meshes,
|
|
|
|
obmats,
|
|
|
|
*(float4x4 *)&ctx->object->obmat,
|
|
|
|
material_remaps,
|
|
|
|
use_self,
|
|
|
|
hole_tolerant,
|
|
|
|
bmd->operation);
|
2021-02-21 17:57:03 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
|
|
|
{
|
|
|
|
BooleanModifierData *bmd = (BooleanModifierData *)md;
|
|
|
|
Object *object = ctx->object;
|
|
|
|
Mesh *result = mesh;
|
2021-02-21 17:57:03 -05:00
|
|
|
Collection *collection = bmd->collection;
|
2020-09-13 16:57:27 -04:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
/* Return result for certain errors. */
|
|
|
|
if (BMD_error_messages(ctx->object, md)) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
#ifdef WITH_GMP
|
2021-04-01 16:49:10 -05:00
|
|
|
if (bmd->solver == eBooleanModifierSolver_Exact) {
|
2021-02-21 17:57:03 -05:00
|
|
|
return exact_boolean_mesh(bmd, ctx, mesh);
|
|
|
|
}
|
2020-09-13 16:57:27 -04:00
|
|
|
#endif
|
2015-12-11 20:24:39 +11:00
|
|
|
|
2015-12-12 01:30:03 +11:00
|
|
|
#ifdef DEBUG_TIME
|
2021-04-02 00:16:01 -05:00
|
|
|
SCOPED_TIMER(__func__)
|
2015-12-12 01:30:03 +11:00
|
|
|
#endif
|
2020-09-13 16:57:27 -04:00
|
|
|
|
|
|
|
if (bmd->flag & eBooleanModifierFlag_Object) {
|
2021-04-02 00:16:01 -05:00
|
|
|
if (bmd->object == nullptr) {
|
2020-09-13 16:57:27 -04:00
|
|
|
return result;
|
2015-12-11 20:24:39 +11:00
|
|
|
}
|
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
Object *operand_ob = bmd->object;
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
Mesh *mesh_operand_ob = BKE_modifier_get_evaluated_mesh_from_evaluated_object(operand_ob,
|
|
|
|
false);
|
2020-09-13 16:57:27 -04:00
|
|
|
|
|
|
|
if (mesh_operand_ob) {
|
|
|
|
/* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh!
|
|
|
|
* But for 2.90 better not try to be smart here. */
|
|
|
|
BKE_mesh_wrapper_ensure_mdata(mesh_operand_ob);
|
|
|
|
/* 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) */
|
|
|
|
result = get_quick_mesh(object, mesh, operand_ob, mesh_operand_ob, bmd->operation);
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
if (result == nullptr) {
|
|
|
|
bool is_flip;
|
|
|
|
BMesh *bm = BMD_mesh_bm_create(mesh, object, mesh_operand_ob, operand_ob, &is_flip);
|
2020-09-13 16:57:27 -04:00
|
|
|
|
|
|
|
BMD_mesh_intersection(bm, md, ctx, mesh_operand_ob, object, operand_ob, is_flip);
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh);
|
|
|
|
|
2020-09-13 16:57:27 -04:00
|
|
|
BM_mesh_free(bm);
|
|
|
|
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
|
|
|
}
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
if (result == nullptr) {
|
2020-10-26 17:07:58 +11:00
|
|
|
BKE_modifier_set_error(object, md, "Cannot execute boolean operation");
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2015-12-11 20:24:39 +11:00
|
|
|
}
|
2020-09-13 16:57:27 -04:00
|
|
|
else {
|
2021-04-02 00:16:01 -05:00
|
|
|
if (collection == nullptr) {
|
2020-09-13 16:57:27 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN (collection, operand_ob) {
|
|
|
|
if (operand_ob->type == OB_MESH && operand_ob != ctx->object) {
|
2021-04-02 00:16:01 -05:00
|
|
|
Mesh *mesh_operand_ob = BKE_modifier_get_evaluated_mesh_from_evaluated_object(operand_ob,
|
|
|
|
false);
|
2020-09-13 16:57:27 -04:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
if (mesh_operand_ob) {
|
|
|
|
/* XXX This is utterly non-optimal, we may go from a bmesh to a mesh back to a bmesh!
|
|
|
|
* But for 2.90 better not try to be smart here. */
|
|
|
|
BKE_mesh_wrapper_ensure_mdata(mesh_operand_ob);
|
2020-10-31 20:07:00 -04:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
bool is_flip;
|
|
|
|
BMesh *bm = BMD_mesh_bm_create(mesh, object, mesh_operand_ob, operand_ob, &is_flip);
|
2020-10-31 20:07:00 -04:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
BMD_mesh_intersection(bm, md, ctx, mesh_operand_ob, object, operand_ob, is_flip);
|
2020-10-31 20:07:00 -04:00
|
|
|
|
2021-04-01 16:49:10 -05:00
|
|
|
/* Needed for multiple objects to work. */
|
2021-04-02 00:16:01 -05:00
|
|
|
BMeshToMeshParams params{};
|
|
|
|
params.calc_object_remap = false;
|
|
|
|
BM_mesh_bm_to_me(nullptr, bm, mesh, ¶ms);
|
|
|
|
|
|
|
|
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, nullptr, mesh);
|
2021-04-01 16:49:10 -05:00
|
|
|
BM_mesh_free(bm);
|
|
|
|
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-01 16:49:10 -05:00
|
|
|
FOREACH_COLLECTION_OBJECT_RECURSIVE_END;
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
|
|
|
|
2018-05-30 11:34:08 +02:00
|
|
|
return result;
|
2015-12-11 20:24:39 +11:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
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
|
|
|
static void requiredDataMask(Object *UNUSED(ob),
|
|
|
|
ModifierData *UNUSED(md),
|
|
|
|
CustomData_MeshMasks *r_cddata_masks)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
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
|
|
|
r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
|
|
|
|
r_cddata_masks->emask |= CD_MASK_MEDGE;
|
|
|
|
r_cddata_masks->fmask |= CD_MASK_MTFACE;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
uiLayout *layout = panel->layout;
|
2021-04-02 00:16:01 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(layout, ptr, "operation", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(layout, ptr, "operand_type", 0, nullptr, ICON_NONE);
|
2021-04-01 16:49:10 -05:00
|
|
|
if (RNA_enum_get(ptr, "operand_type") == eBooleanModifierFlag_Object) {
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(layout, ptr, "object", 0, nullptr, ICON_NONE);
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
|
|
|
else {
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(layout, ptr, "collection", 0, nullptr, ICON_NONE);
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(layout, ptr, "solver", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
2020-08-28 16:41:13 -05:00
|
|
|
|
2021-03-07 18:13:19 -05:00
|
|
|
modifier_panel_end(layout, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void solver_options_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|
|
|
{
|
|
|
|
uiLayout *layout = panel->layout;
|
2021-04-02 00:16:01 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
2021-03-07 18:13:19 -05:00
|
|
|
|
|
|
|
const bool use_exact = RNA_enum_get(ptr, "solver") == eBooleanModifierSolver_Exact;
|
|
|
|
|
2021-03-08 22:22:16 -05:00
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
|
|
uiLayout *col = uiLayoutColumn(layout, true);
|
2020-09-07 14:26:00 -04:00
|
|
|
if (use_exact) {
|
2020-09-13 16:57:27 -04:00
|
|
|
/* When operand is collection, we always use_self. */
|
2021-04-01 16:49:10 -05:00
|
|
|
if (RNA_enum_get(ptr, "operand_type") == eBooleanModifierFlag_Object) {
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(col, ptr, "use_self", 0, nullptr, ICON_NONE);
|
2020-09-13 16:57:27 -04:00
|
|
|
}
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(col, ptr, "use_hole_tolerant", 0, nullptr, ICON_NONE);
|
2020-09-07 14:26:00 -04:00
|
|
|
}
|
|
|
|
else {
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(col, ptr, "double_threshold", 0, nullptr, ICON_NONE);
|
2020-08-28 10:56:44 -04:00
|
|
|
}
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
if (G.debug) {
|
2021-04-02 00:16:01 -05:00
|
|
|
uiItemR(col, ptr, "debug_options", 0, nullptr, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void panelRegister(ARegionType *region_type)
|
|
|
|
{
|
2021-03-07 18:13:19 -05:00
|
|
|
PanelType *panel = modifier_panel_register(region_type, eModifierType_Boolean, panel_draw);
|
|
|
|
modifier_subpanel_register(
|
2021-04-02 00:16:01 -05:00
|
|
|
region_type, "solver_options", "Solver Options", nullptr, solver_options_panel_draw, panel);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
ModifierTypeInfo modifierType_Boolean = {
|
2012-10-24 05:45:54 +00:00
|
|
|
/* name */ "Boolean",
|
|
|
|
/* structName */ "BooleanModifierData",
|
|
|
|
/* structSize */ sizeof(BooleanModifierData),
|
2020-09-25 12:49:18 +02:00
|
|
|
/* srna */ &RNA_BooleanModifier,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* type */ eModifierTypeType_Nonconstructive,
|
2021-04-02 00:16:01 -05:00
|
|
|
/* flags */
|
|
|
|
(ModifierTypeFlag)(eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode),
|
2020-09-25 12:45:30 +02:00
|
|
|
/* icon */ ICON_MOD_BOOLEAN,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-08 10:14:02 +02:00
|
|
|
/* copyData */ BKE_modifier_copydata_generic,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-02 00:16:01 -05:00
|
|
|
/* deformVerts */ nullptr,
|
|
|
|
/* deformMatrices */ nullptr,
|
|
|
|
/* deformVertsEM */ nullptr,
|
|
|
|
/* deformMatricesEM */ nullptr,
|
2020-04-21 13:09:41 +02:00
|
|
|
/* modifyMesh */ modifyMesh,
|
2021-04-02 00:16:01 -05:00
|
|
|
/* modifyHair */ nullptr,
|
|
|
|
/* modifyGeometrySet */ nullptr,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-07-13 17:45:55 +10:00
|
|
|
/* initData */ initData,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* requiredDataMask */ requiredDataMask,
|
2021-04-02 00:16:01 -05:00
|
|
|
/* freeData */ nullptr,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* 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,
|
2021-04-02 00:16:01 -05:00
|
|
|
/* dependsOnTime */ nullptr,
|
|
|
|
/* dependsOnNormals */ nullptr,
|
2020-09-13 16:57:27 -04:00
|
|
|
/* foreachIDLink */ foreachIDLink,
|
2021-04-02 00:16:01 -05:00
|
|
|
/* foreachTexLink */ nullptr,
|
|
|
|
/* freeRuntimeData */ nullptr,
|
2020-06-05 10:41:03 -04:00
|
|
|
/* panelRegister */ panelRegister,
|
2021-04-02 00:16:01 -05:00
|
|
|
/* blendWrite */ nullptr,
|
|
|
|
/* blendRead */ nullptr,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|