Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_boolean_convert.cc
| Context not available. | |||||
| Span<Array<short>> material_remaps, | Span<Array<short>> material_remaps, | ||||
| const float4x4 &target_transform, | const float4x4 &target_transform, | ||||
| IMeshArena &arena, | IMeshArena &arena, | ||||
| MeshesToIMeshInfo *r_info) | MeshesToIMeshInfo *r_info, | ||||
| Array<bool> &r_flips) | |||||
| { | { | ||||
| int nmeshes = meshes.size(); | int nmeshes = meshes.size(); | ||||
| BLI_assert(nmeshes > 0); | BLI_assert(nmeshes > 0); | ||||
| Context not available. | |||||
| * target matrix. Exact Boolean works better if these matrices are 'cleaned' | * target matrix. Exact Boolean works better if these matrices are 'cleaned' | ||||
| * -- see the comment for the `clean_obmat` function, above. */ | * -- see the comment for the `clean_obmat` function, above. */ | ||||
| const float4x4 inv_target_mat = clean_obmat(target_transform).inverted(); | const float4x4 inv_target_mat = clean_obmat(target_transform).inverted(); | ||||
| const bool target_sign = is_negative_m4(target_transform.ptr()); | |||||
| /* For each input `Mesh`, make `Vert`s and `Face`s for the corresponding | /* For each input `Mesh`, make `Vert`s and `Face`s for the corresponding | ||||
| * `MVert`s and `MPoly`s, and keep track of the original indices (using the | * `MVert`s and `MPoly`s, and keep track of the original indices (using the | ||||
| Context not available. | |||||
| clean_obmat(*obmats[mi]); | clean_obmat(*obmats[mi]); | ||||
| r_info->to_target_transform[mi] = inv_target_mat * objn_mat; | r_info->to_target_transform[mi] = inv_target_mat * objn_mat; | ||||
| /* Normals need to be flipped if the sign of a transform differs from the target's sign */ | |||||
| r_flips[mi] = target_sign != is_negative_m4(objn_mat.ptr()); | |||||
| /* Skip the matrix multiplication for each point when there is no transform for a mesh, | /* 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 | * 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). */ | * above, which uses an identity matrix with a null input transform). */ | ||||
| Context not available. | |||||
| } | } | ||||
| MeshesToIMeshInfo mim; | MeshesToIMeshInfo mim; | ||||
| IMeshArena arena; | IMeshArena arena; | ||||
| IMesh m_in = meshes_to_imesh(meshes, obmats, material_remaps, target_transform, arena, &mim); | Array<bool> flips(meshes.size()); | ||||
| IMesh m_in = meshes_to_imesh(meshes, obmats, material_remaps, target_transform, arena, &mim, flips); | |||||
| std::function<int(int)> shape_fn = [&mim](int f) { | std::function<int(int)> shape_fn = [&mim](int f) { | ||||
| for (int mi = 0; mi < mim.mesh_poly_offset.size() - 1; ++mi) { | for (int mi = 0; mi < mim.mesh_poly_offset.size() - 1; ++mi) { | ||||
| if (f < mim.mesh_poly_offset[mi + 1]) { | if (f < mim.mesh_poly_offset[mi + 1]) { | ||||
| Context not available. | |||||
| } | } | ||||
| return static_cast<int>(mim.mesh_poly_offset.size()) - 1; | return static_cast<int>(mim.mesh_poly_offset.size()) - 1; | ||||
| }; | }; | ||||
| if (dbg_level > 0) { | |||||
| std::cout << "flips="; | |||||
| for (bool b : flips) { | |||||
| std::cout << b << ' '; | |||||
| } | |||||
| std::cout << '\n'; | |||||
| } | |||||
| IMesh m_out = boolean_mesh(m_in, | IMesh m_out = boolean_mesh(m_in, | ||||
| static_cast<BoolOpType>(boolean_mode), | static_cast<BoolOpType>(boolean_mode), | ||||
| meshes.size(), | meshes.size(), | ||||
| Context not available. | |||||
| use_self, | use_self, | ||||
| hole_tolerant, | hole_tolerant, | ||||
| nullptr, | nullptr, | ||||
| &arena); | &arena, | ||||
| flips); | |||||
| if (dbg_level > 0) { | if (dbg_level > 0) { | ||||
| std::cout << m_out; | std::cout << m_out; | ||||
| write_obj_mesh(m_out, "m_out"); | write_obj_mesh(m_out, "m_out"); | ||||
| Context not available. | |||||