Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh_render_data.cc
| Show First 20 Lines • Show All 488 Lines • ▼ Show 20 Lines | if (mr->edit_data) { | ||||
| } | } | ||||
| mr->bm_vert_coords = mr->edit_data->vertexCos; | mr->bm_vert_coords = mr->edit_data->vertexCos; | ||||
| mr->bm_vert_normals = mr->edit_data->vertexNos; | mr->bm_vert_normals = mr->edit_data->vertexNos; | ||||
| mr->bm_poly_normals = mr->edit_data->polyNos; | mr->bm_poly_normals = mr->edit_data->polyNos; | ||||
| mr->bm_poly_centers = mr->edit_data->polyCos; | mr->bm_poly_centers = mr->edit_data->polyCos; | ||||
| } | } | ||||
| /* A subdivision wrapper may be created in edit mode when X-ray is turned on to ensure that the | |||||
| * topology seen by the user matches the one used for the selection routines. This wrapper | |||||
| * seemingly takes precedence over the MDATA one, however the mesh we use for rendering is not | |||||
| * the subdivided one, but the one where the MDATA wrapper would have been added. So consider | |||||
| * the subdivision wrapper as well for the `has_mdata` case. */ | |||||
| bool has_mdata = is_mode_active && ELEM(mr->me->runtime.wrapper_type, | |||||
| ME_WRAPPER_TYPE_MDATA, | |||||
| ME_WRAPPER_TYPE_SUBD); | |||||
| bool use_mapped = is_mode_active && | |||||
| (has_mdata && !do_uvedit && mr->me && !mr->me->runtime.is_original); | |||||
| int bm_ensure_types = BM_VERT | BM_EDGE | BM_LOOP | BM_FACE; | int bm_ensure_types = BM_VERT | BM_EDGE | BM_LOOP | BM_FACE; | ||||
| BM_mesh_elem_index_ensure(mr->bm, bm_ensure_types); | BM_mesh_elem_index_ensure(mr->bm, bm_ensure_types); | ||||
| BM_mesh_elem_table_ensure(mr->bm, bm_ensure_types & ~BM_LOOP); | BM_mesh_elem_table_ensure(mr->bm, bm_ensure_types & ~BM_LOOP); | ||||
| mr->efa_act_uv = EDBM_uv_active_face_get(mr->edit_bmesh, false, false); | mr->efa_act_uv = EDBM_uv_active_face_get(mr->edit_bmesh, false, false); | ||||
| mr->efa_act = BM_mesh_active_face_get(mr->bm, false, true); | mr->efa_act = BM_mesh_active_face_get(mr->bm, false, true); | ||||
| mr->eed_act = BM_mesh_active_edge_get(mr->bm); | mr->eed_act = BM_mesh_active_edge_get(mr->bm); | ||||
| mr->eve_act = BM_mesh_active_vert_get(mr->bm); | mr->eve_act = BM_mesh_active_vert_get(mr->bm); | ||||
| mr->vert_crease_ofs = CustomData_get_offset(&mr->bm->vdata, CD_CREASE); | mr->vert_crease_ofs = CustomData_get_offset(&mr->bm->vdata, CD_CREASE); | ||||
| mr->edge_crease_ofs = CustomData_get_offset(&mr->bm->edata, CD_CREASE); | mr->edge_crease_ofs = CustomData_get_offset(&mr->bm->edata, CD_CREASE); | ||||
| mr->bweight_ofs = CustomData_get_offset(&mr->bm->edata, CD_BWEIGHT); | mr->bweight_ofs = CustomData_get_offset(&mr->bm->edata, CD_BWEIGHT); | ||||
| #ifdef WITH_FREESTYLE | #ifdef WITH_FREESTYLE | ||||
| mr->freestyle_edge_ofs = CustomData_get_offset(&mr->bm->edata, CD_FREESTYLE_EDGE); | mr->freestyle_edge_ofs = CustomData_get_offset(&mr->bm->edata, CD_FREESTYLE_EDGE); | ||||
| mr->freestyle_face_ofs = CustomData_get_offset(&mr->bm->pdata, CD_FREESTYLE_FACE); | mr->freestyle_face_ofs = CustomData_get_offset(&mr->bm->pdata, CD_FREESTYLE_FACE); | ||||
| #endif | #endif | ||||
| /* Use bmesh directly when the object is in edit mode unchanged by any modifiers. | |||||
| * For non-final UVs, always use original bmesh since the UV editor does not support | |||||
| * using the cage mesh with deformed coordinates. */ | |||||
| const bool use_bmesh = (is_mode_active && mr->me->runtime.is_original_bmesh && | |||||
| mr->me->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH) || | |||||
| (do_uvedit && !do_final); | |||||
| /* Use mapping to original mesh when the object is in edit mode and the final mesh is | |||||
| * different from the cage mesh. This implies the final mesh topology is different | |||||
| * from the original mesh so that mapping is needed. */ | |||||
| bool use_mapped = !use_bmesh && is_mode_active && do_final && | |||||
| editmesh_eval_final != editmesh_eval_cage; | |||||
| if (use_mapped) { | if (use_mapped) { | ||||
| mr->v_origindex = static_cast<const int *>( | mr->v_origindex = static_cast<const int *>( | ||||
| CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX)); | CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX)); | ||||
| mr->e_origindex = static_cast<const int *>( | mr->e_origindex = static_cast<const int *>( | ||||
| CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX)); | CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX)); | ||||
| mr->p_origindex = static_cast<const int *>( | mr->p_origindex = static_cast<const int *>( | ||||
| CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX)); | CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX)); | ||||
| use_mapped = (mr->v_origindex || mr->e_origindex || mr->p_origindex); | use_mapped = (mr->v_origindex || mr->e_origindex || mr->p_origindex); | ||||
| } | } | ||||
| mr->extract_type = use_mapped ? MR_EXTRACT_MAPPED : MR_EXTRACT_BMESH; | mr->extract_type = use_bmesh ? MR_EXTRACT_BMESH : | ||||
| use_mapped ? MR_EXTRACT_MAPPED : | |||||
| /* Seems like the mesh_eval_final do not have the right origin indices. | MR_EXTRACT_MESH; | ||||
| * Force not mapped in this case. */ | |||||
| if (has_mdata && do_final && editmesh_eval_final != editmesh_eval_cage) { | |||||
| // mr->edit_bmesh = NULL; | |||||
| mr->extract_type = MR_EXTRACT_MESH; | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| mr->me = me; | mr->me = me; | ||||
| mr->edit_bmesh = nullptr; | mr->edit_bmesh = nullptr; | ||||
| bool use_mapped = is_paint_mode && mr->me && !mr->me->runtime.is_original; | bool use_mapped = is_paint_mode && mr->me; | ||||
| if (use_mapped) { | if (use_mapped) { | ||||
| mr->v_origindex = static_cast<const int *>( | mr->v_origindex = static_cast<const int *>( | ||||
| CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX)); | CustomData_get_layer(&mr->me->vdata, CD_ORIGINDEX)); | ||||
| mr->e_origindex = static_cast<const int *>( | mr->e_origindex = static_cast<const int *>( | ||||
| CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX)); | CustomData_get_layer(&mr->me->edata, CD_ORIGINDEX)); | ||||
| mr->p_origindex = static_cast<const int *>( | mr->p_origindex = static_cast<const int *>( | ||||
| CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX)); | CustomData_get_layer(&mr->me->pdata, CD_ORIGINDEX)); | ||||
| ▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines | |||||