Merge branch 'blender-v4.0-release'

This commit is contained in:
Sergey Sharybin
2023-11-03 09:28:36 +01:00
3 changed files with 12 additions and 14 deletions

View File

@@ -19,8 +19,7 @@ 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 transforms: An array of transform matrices used for each mesh's positions.
* \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.
@@ -28,7 +27,7 @@ namespace blender::meshintersect {
* 'new' edges are the result of the intersections.
*/
Mesh *direct_mesh_boolean(Span<const Mesh *> meshes,
Span<const float4x4 *> transforms,
Span<float4x4> transforms,
const float4x4 &target_transform,
Span<Array<short>> material_remaps,
bool use_self,

View File

@@ -233,7 +233,7 @@ void MeshesToIMeshInfo::input_medge_for_orig_index(int orig_index,
* All allocation of memory for the IMesh comes from `arena`.
*/
static IMesh meshes_to_imesh(Span<const Mesh *> meshes,
Span<const float4x4 *> obmats,
Span<float4x4> obmats,
Span<Array<short>> material_remaps,
const float4x4 &target_transform,
IMeshArena &arena,
@@ -295,9 +295,8 @@ static IMesh meshes_to_imesh(Span<const Mesh *> meshes,
r_info->mesh_face_offset[mi] = f;
/* Get matrix that transforms a coordinate in meshes[mi]'s local space
* to the target space. */
const float4x4 objn_mat = (obmats.is_empty() || obmats[mi] == nullptr) ?
float4x4::identity() :
clean_transform(*obmats[mi]);
const float4x4 objn_mat = obmats.is_empty() ? float4x4::identity() :
clean_transform(obmats[mi]);
r_info->to_target_transform[mi] = inv_target_mat * objn_mat;
r_info->has_negative_transform[mi] = math::is_negative(objn_mat);
@@ -316,7 +315,7 @@ static IMesh meshes_to_imesh(Span<const Mesh *> meshes,
* Skip the matrix multiplication for each point when there is no transform for a mesh,
* for example when the first mesh is already in the target space. (Note the logic
* directly above, which uses an identity matrix with a null input transform). */
if (obmats.is_empty() || obmats[mi] == nullptr) {
if (obmats.is_empty() || obmats[mi] == float4x4::identity()) {
threading::parallel_for(vert_positions.index_range(), 2048, [&](IndexRange range) {
for (int i : range) {
float3 co = vert_positions[i];
@@ -797,7 +796,7 @@ static Mesh *imesh_to_mesh(IMesh *im, MeshesToIMeshInfo &mim)
#endif // WITH_GMP
Mesh *direct_mesh_boolean(Span<const Mesh *> meshes,
Span<const float4x4 *> transforms,
Span<float4x4> transforms,
const float4x4 &target_transform,
Span<Array<short>> material_remaps,
const bool use_self,

View File

@@ -415,7 +415,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
Mesh *mesh)
{
Vector<const Mesh *> meshes;
Vector<float4x4 *> obmats;
Vector<float4x4> obmats;
Vector<Array<short>> material_remaps;
@@ -428,7 +428,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
}
meshes.append(mesh);
obmats.append((float4x4 *)&ctx->object->object_to_world);
obmats.append(float4x4(ctx->object->object_to_world));
material_remaps.append({});
const BooleanModifierMaterialMode material_mode = BooleanModifierMaterialMode(
@@ -451,7 +451,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
}
BKE_mesh_wrapper_ensure_mdata(mesh_operand);
meshes.append(mesh_operand);
obmats.append((float4x4 *)&bmd->object->object_to_world);
obmats.append(float4x4(bmd->object->object_to_world));
if (material_mode == eBooleanModifierMaterialMode_Index) {
material_remaps.append(get_material_remap_index_based(ctx->object, bmd->object));
}
@@ -471,7 +471,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
}
BKE_mesh_wrapper_ensure_mdata(collection_mesh);
meshes.append(collection_mesh);
obmats.append((float4x4 *)&ob->object_to_world);
obmats.append(float4x4(ob->object_to_world));
if (material_mode == eBooleanModifierMaterialMode_Index) {
material_remaps.append(get_material_remap_index_based(ctx->object, ob));
}
@@ -489,7 +489,7 @@ static Mesh *exact_boolean_mesh(BooleanModifierData *bmd,
Mesh *result = blender::meshintersect::direct_mesh_boolean(
meshes,
obmats,
*(float4x4 *)&ctx->object->object_to_world,
float4x4(ctx->object->object_to_world),
material_remaps,
use_self,
hole_tolerant,