**Empty Slot Fix** Currently the boolean modifier transfers the default material from meshes with no materials and empty material slots to the faces on the base mesh. I added this ina2d59b2dacfor the sake of consistency, but the behavior is actually not useful at all. The default empty material isn't chosen by users, it just signifies "nothing," so when it replaces a material chosen by users, it feels like a bug. This commit corrects that behavior by only transferring materials from non-empty material slots. The implementation is now consistent between exact mode of the boolean modifier and the geometry node. **Index-Based Option** "Index-based" is the new default material method for the boolean modifier, to access the old behavior from before the breaking commit.a2d59b2dacactually broke some Boolean workflows fundamentally, since it was important to set up matching slot indices on each operand. That isn't the cleanest workflow, and it breaks when materials change procedurally, but historically that hasn't been a problem. The "transfer" behavior transfers all materials except for empty slots, but the fundamental problem is that there isn't a good way to specify the result materials besides using the slot indices. Even then, the transfer option is a bit more intuitive and useful for some simpler situations, and it allows accessing the behavior that has been in 3.2 and 3.3 for a long time, so it's also left in as an option. The geometry node doesn't get this new option, in the hope that we'll find a better solution in the future. Differential Revision: https://developer.blender.org/D16187
39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Copyright 2019 Blender Foundation. All rights reserved. */
|
|
|
|
#pragma once
|
|
|
|
/** \file
|
|
* \ingroup bke
|
|
*/
|
|
|
|
#include "BLI_array.hh"
|
|
#include "BLI_float4x4.hh"
|
|
#include "BLI_mesh_boolean.hh"
|
|
#include "BLI_span.hh"
|
|
|
|
struct Mesh;
|
|
|
|
namespace blender::meshintersect {
|
|
|
|
/**
|
|
* Do a mesh boolean operation directly on meshes (without going back and forth from BMesh).
|
|
* \param transforms: An array of pointers to transform matrices used for each mesh's positions.
|
|
* It is allowed for the pointers to be null, meaning the transformation is the identity.
|
|
* \param material_remaps: An array of maps from material slot numbers in the corresponding mesh
|
|
* to the material slot in the first mesh. It is OK for material_remaps or any of its constituent
|
|
* arrays to be empty. A -1 value means that the original index should be used with no mapping.
|
|
* \param r_intersecting_edges: Array to store indices of edges on the resulting mesh in. These
|
|
* 'new' edges are the result of the intersections.
|
|
*/
|
|
Mesh *direct_mesh_boolean(Span<const Mesh *> meshes,
|
|
Span<const float4x4 *> transforms,
|
|
const float4x4 &target_transform,
|
|
Span<Array<short>> material_remaps,
|
|
bool use_self,
|
|
bool hole_tolerant,
|
|
int boolean_mode,
|
|
Vector<int> *r_intersecting_edges);
|
|
|
|
} // namespace blender::meshintersect
|