Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/DerivedMesh.cc
| Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| else { | else { | ||||
| deformed_verts = editbmesh_vert_coords_alloc(em_input, &num_deformed_verts); | deformed_verts = editbmesh_vert_coords_alloc(em_input, &num_deformed_verts); | ||||
| } | } | ||||
| } | } | ||||
| else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) { | else if (isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) { | ||||
| if (mesh_final == nullptr) { | if (mesh_final == nullptr) { | ||||
| mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, nullptr, mesh_input); | mesh_final = BKE_mesh_from_bmesh_for_eval_nomain(em_input->bm, nullptr, mesh_input); | ||||
| BKE_mesh_ensure_default_orig_index_layers(mesh_final); | |||||
| ASSERT_IS_VALID_MESH(mesh_final); | ASSERT_IS_VALID_MESH(mesh_final); | ||||
| } | } | ||||
| BLI_assert(deformed_verts != nullptr); | BLI_assert(deformed_verts != nullptr); | ||||
| BKE_mesh_vert_coords_apply(mesh_final, deformed_verts); | BKE_mesh_vert_coords_apply(mesh_final, deformed_verts); | ||||
| } | } | ||||
| if (mti->deformVertsEM) { | if (mti->deformVertsEM) { | ||||
| BKE_modifier_deform_vertsEM( | BKE_modifier_deform_vertsEM( | ||||
| Show All 15 Lines | |||||
| BKE_mesh_vert_coords_apply(mesh_final, deformed_verts); | BKE_mesh_vert_coords_apply(mesh_final, deformed_verts); | ||||
| } | } | ||||
| else if (mesh_final == mesh_cage) { | else if (mesh_final == mesh_cage) { | ||||
| /* 'me' may be changed by this modifier, so we need to copy it. */ | /* 'me' may be changed by this modifier, so we need to copy it. */ | ||||
| mesh_final = BKE_mesh_copy_for_eval(mesh_final, false); | mesh_final = BKE_mesh_copy_for_eval(mesh_final, false); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| mesh_final = BKE_mesh_wrapper_from_editmesh_with_coords( | mesh_final = BKE_mesh_wrapper_from_editmesh_with_coords( | ||||
| em_input, nullptr, deformed_verts, mesh_input); | em_input, nullptr, deformed_verts, mesh_input); | ||||
sergey: Why there is no need to ensure origindex here? | |||||
HooglyBooglyAuthorUnsubmitted Done Inline ActionsWell, original index layers weren't added here before this patch, since this is just creating a wrapper of the BMesh. HooglyBoogly: Well, original index layers weren't added here before this patch, since this is just creating a… | |||||
| deformed_verts = nullptr; | deformed_verts = nullptr; | ||||
| } | } | ||||
| /* create an orco derivedmesh in parallel */ | /* create an orco derivedmesh in parallel */ | ||||
| CustomData_MeshMasks mask = md_datamask->mask; | CustomData_MeshMasks mask = md_datamask->mask; | ||||
| if (mask.vmask & CD_MASK_ORCO) { | if (mask.vmask & CD_MASK_ORCO) { | ||||
| if (!mesh_orco) { | if (!mesh_orco) { | ||||
| mesh_orco = create_orco_mesh(ob, mesh_input, em_input, CD_ORCO); | mesh_orco = create_orco_mesh(ob, mesh_input, em_input, CD_ORCO); | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
| else { | else { | ||||
| Mesh *me_orig = mesh_input; | Mesh *me_orig = mesh_input; | ||||
| if (me_orig->id.tag & LIB_TAG_COPIED_ON_WRITE) { | if (me_orig->id.tag & LIB_TAG_COPIED_ON_WRITE) { | ||||
| if (!BKE_mesh_runtime_ensure_edit_data(me_orig)) { | if (!BKE_mesh_runtime_ensure_edit_data(me_orig)) { | ||||
| BKE_mesh_runtime_reset_edit_data(me_orig); | BKE_mesh_runtime_reset_edit_data(me_orig); | ||||
| } | } | ||||
| me_orig->runtime.edit_data->vertexCos = (const float(*)[3])MEM_dupallocN(deformed_verts); | me_orig->runtime.edit_data->vertexCos = (const float(*)[3])MEM_dupallocN(deformed_verts); | ||||
| } | } | ||||
| mesh_cage = BKE_mesh_wrapper_from_editmesh_with_coords( | mesh_cage = BKE_mesh_wrapper_from_editmesh_with_coords( | ||||
sergeyUnsubmitted Done Inline ActionsSame as above sergey: Same as above | |||||
| em_input, | em_input, | ||||
| &final_datamask, | &final_datamask, | ||||
| deformed_verts ? (const float(*)[3])MEM_dupallocN(deformed_verts) : nullptr, | deformed_verts ? (const float(*)[3])MEM_dupallocN(deformed_verts) : nullptr, | ||||
| mesh_input); | mesh_input); | ||||
| } | } | ||||
| } | } | ||||
| isPrevDeform = (mti->type == eModifierTypeType_OnlyDeform); | isPrevDeform = (mti->type == eModifierTypeType_OnlyDeform); | ||||
| Show All 28 Lines | |||||
| if (deformed_verts) { | if (deformed_verts) { | ||||
| MEM_freeN(deformed_verts); | MEM_freeN(deformed_verts); | ||||
| } | } | ||||
| /* Add orco coordinates to final and deformed mesh if requested. */ | /* Add orco coordinates to final and deformed mesh if requested. */ | ||||
| if (final_datamask.vmask & CD_MASK_ORCO) { | if (final_datamask.vmask & CD_MASK_ORCO) { | ||||
| /* FIXME(Campbell): avoid the need to convert to mesh data just to add an orco layer. */ | /* FIXME(Campbell): avoid the need to convert to mesh data just to add an orco layer. */ | ||||
| BKE_mesh_wrapper_ensure_mdata(mesh_final); | BKE_mesh_wrapper_ensure_mdata(mesh_final); | ||||
| BKE_mesh_ensure_default_orig_index_layers(mesh_final); | |||||
sergeyUnsubmitted Done Inline ActionsWhy this is needed? As in, why the origindex was not ensured when the mesh_final was created from bmesh in the evaluation loop above? sergey: Why this is needed? As in, why the origindex was not ensured when the `mesh_final` was created… | |||||
HooglyBooglyAuthorUnsubmitted Done Inline ActionsYou're right. It will be done by the mesh wrapper when necessary anyway. HooglyBoogly: You're right. It will be done by the mesh wrapper when necessary anyway. | |||||
| add_orco_mesh(ob, em_input, mesh_final, mesh_orco, CD_ORCO); | add_orco_mesh(ob, em_input, mesh_final, mesh_orco, CD_ORCO); | ||||
| } | } | ||||
| if (mesh_orco) { | if (mesh_orco) { | ||||
| BKE_id_free(nullptr, mesh_orco); | BKE_id_free(nullptr, mesh_orco); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines | |||||
Why there is no need to ensure origindex here?