Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_boolean.c
| Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | if (mesh_other) { | ||||
| /* when one of objects is empty (has got no faces) we could speed up | /* 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) | * calculation a bit returning one of objects' derived meshes (or empty one) | ||||
| * Returning mesh is depended on modifiers operation (sergey) */ | * Returning mesh is depended on modifiers operation (sergey) */ | ||||
| result = get_quick_mesh(object, mesh, other, mesh_other, bmd->operation); | result = get_quick_mesh(object, mesh, other, mesh_other, bmd->operation); | ||||
| if (result == NULL) { | if (result == NULL) { | ||||
| const bool is_flip = (is_negative_m4(object->obmat) != is_negative_m4(other->obmat)); | const bool is_flip = (is_negative_m4(object->obmat) != is_negative_m4(other->obmat)); | ||||
| const bool has_facemap = CustomData_has_layer(&mesh->pdata, CD_FACEMAP); | |||||
| const bool has_facemap_other = CustomData_has_layer(&mesh_other->pdata, CD_FACEMAP); | |||||
| BMesh *bm; | BMesh *bm; | ||||
| const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_other); | const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh, mesh_other); | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| TIMEIT_START(boolean_bmesh); | TIMEIT_START(boolean_bmesh); | ||||
| #endif | #endif | ||||
| bm = BM_mesh_create(&allocsize, | bm = BM_mesh_create(&allocsize, | ||||
| &((struct BMeshCreateParams){ | &((struct BMeshCreateParams){ | ||||
| .use_toolflags = false, | .use_toolflags = false, | ||||
| })); | })); | ||||
| BM_mesh_bm_from_me(bm, | BM_mesh_bm_from_me(bm, | ||||
| mesh_other, | mesh_other, | ||||
| &((struct BMeshFromMeshParams){ | &((struct BMeshFromMeshParams){ | ||||
| .calc_face_normal = true, | .calc_face_normal = true, | ||||
| .add_facemap_layer = (has_facemap && !has_facemap_other), | |||||
| })); | })); | ||||
| if (UNLIKELY(is_flip)) { | if (UNLIKELY(is_flip)) { | ||||
| const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS); | const int cd_loop_mdisp_offset = CustomData_get_offset(&bm->ldata, CD_MDISPS); | ||||
| BMIter iter; | BMIter iter; | ||||
| BMFace *efa; | BMFace *efa; | ||||
| BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { | BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { | ||||
| BM_face_normal_flip_ex(bm, efa, cd_loop_mdisp_offset, true); | BM_face_normal_flip_ex(bm, efa, cd_loop_mdisp_offset, true); | ||||
| } | } | ||||
| } | } | ||||
| BM_mesh_bm_from_me(bm, | BM_mesh_bm_from_me(bm, | ||||
| mesh, | mesh, | ||||
| &((struct BMeshFromMeshParams){ | &((struct BMeshFromMeshParams){ | ||||
| .calc_face_normal = true, | .calc_face_normal = true, | ||||
| .add_facemap_layer = (has_facemap_other && !has_facemap), | |||||
| })); | })); | ||||
| /* main bmesh intersection setup */ | /* main bmesh intersection setup */ | ||||
| { | { | ||||
| /* create tessface & intersect */ | /* create tessface & intersect */ | ||||
| const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop); | const int looptris_tot = poly_to_tri_count(bm->totface, bm->totloop); | ||||
| int tottri; | int tottri; | ||||
| BMLoop *(*looptris)[3]; | BMLoop *(*looptris)[3]; | ||||
| ▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines | |||||