diff options
Diffstat (limited to 'source/blender/editors')
11 files changed, 37 insertions, 26 deletions
diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index 0d1e3c08d84..76d0bab8a52 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -22,7 +22,9 @@ #include "BKE_customdata.h" #include "BKE_deform.h" #include "BKE_editmesh.h" +#include "BKE_editmesh_cache.h" #include "BKE_layer.h" +#include "BKE_mesh.h" #include "BKE_report.h" #include "WM_api.h" @@ -1065,8 +1067,8 @@ bool EDBM_unified_findnearest_from_raycast(ViewContext *vc, { Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(vc->depsgraph, static_cast<ID *>(obedit->data)); - if (me_eval->runtime.edit_data) { - coords = me_eval->runtime.edit_data->vertexCos; + if (me_eval->runtime->edit_data) { + coords = me_eval->runtime->edit_data->vertexCos; } } diff --git a/source/blender/editors/mesh/editmesh_undo.cc b/source/blender/editors/mesh/editmesh_undo.cc index d810e782a1b..5c837e61a79 100644 --- a/source/blender/editors/mesh/editmesh_undo.cc +++ b/source/blender/editors/mesh/editmesh_undo.cc @@ -597,6 +597,11 @@ static void *undomesh_from_editmesh(UndoMesh *um, BMEditMesh *em, Key *key, Undo * on it. Necessary to use the attribute API. */ strcpy(um->me.id.name, "MEundomesh_from_editmesh"); + /* Runtime data is necessary for some asserts in other code, and the overhead of creating it for + * undo meshes should be low. */ + BLI_assert(um->me.runtime == nullptr); + um->me.runtime = new blender::bke::MeshRuntime(); + CustomData_MeshMasks cd_mask_extra{}; cd_mask_extra.vmask = CD_MASK_SHAPE_KEYINDEX; BMeshToMeshParams params{}; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 761a6702c6f..e6d0aca7902 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3533,7 +3533,7 @@ static void PE_mirror_x(Depsgraph *depsgraph, Scene *scene, Object *ob, int tagg } const bool use_dm_final_indices = (psys->part->use_modifier_stack && - !psmd_eval->mesh_final->runtime.deformed_only); + !BKE_mesh_is_deformed_only(psmd_eval->mesh_final)); /* NOTE: this is not nice to use tessfaces but hard to avoid since pa->num uses tessfaces */ BKE_mesh_tessface_ensure(me); @@ -4353,7 +4353,7 @@ static void brush_add_count_iter(void *__restrict iter_data_v, 0, 0, 0)) { - if (psys->part->use_modifier_stack && !psmd_eval->mesh_final->runtime.deformed_only) { + if (psys->part->use_modifier_stack && !BKE_mesh_is_deformed_only(psmd_eval->mesh_final)) { add_pars[iter].num = add_pars[iter].num_dmcache; add_pars[iter].num_dmcache = DMCACHE_ISCHILD; } @@ -4430,7 +4430,7 @@ static int brush_add(const bContext *C, PEData *data, short number) timestep = psys_get_timestep(&sim); - if (psys->part->use_modifier_stack || psmd_eval->mesh_final->runtime.deformed_only) { + if (psys->part->use_modifier_stack || BKE_mesh_is_deformed_only(psmd_eval->mesh_final)) { mesh = psmd_eval->mesh_final; } else { diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 08db03db0e9..71ed32caede 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -732,7 +732,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, invert_m4_m4(to_imat, to_mat); const bool use_dm_final_indices = (target_psys->part->use_modifier_stack && - !target_psmd->mesh_final->runtime.deformed_only); + !BKE_mesh_is_deformed_only(target_psmd->mesh_final)); if (use_dm_final_indices || !target_psmd->mesh_original) { mesh = target_psmd->mesh_final; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 8ffa78cd457..41d5090b38c 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -4074,7 +4074,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p ps->totloop_eval = ps->me_eval->totloop; ps->mlooptri_eval = BKE_mesh_runtime_looptri_ensure(ps->me_eval); - ps->totlooptri_eval = ps->me_eval->runtime.looptris.len; + ps->totlooptri_eval = BKE_mesh_runtime_looptri_len(ps->me_eval); ps->poly_to_loop_uv = MEM_mallocN(ps->totpoly_eval * sizeof(MLoopUV *), "proj_paint_mtfaces"); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index cb981a3bfb1..ce4a5151a20 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -286,7 +286,7 @@ static void imapaint_pick_uv( const ePaintCanvasSource mode = scene->toolsettings->imapaint.mode; const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval); - const int tottri = me_eval->runtime.looptris.len; + const int tottri = BKE_mesh_runtime_looptri_len(me_eval); const MVert *mvert = BKE_mesh_verts(me_eval); const MLoop *mloop = BKE_mesh_loops(me_eval); diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index cac0dbb0067..e8b005b2b67 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -40,6 +40,7 @@ #include "BKE_key.h" #include "BKE_layer.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_particle.h" @@ -94,8 +95,8 @@ static bool stats_mesheval(const Mesh *me_eval, bool is_selected, SceneStats *st int totvert, totedge, totface, totloop; - const SubdivCCG *subdiv_ccg = me_eval->runtime.subdiv_ccg; - const SubsurfRuntimeData *subsurf_runtime_data = me_eval->runtime.subsurf_runtime_data; + const SubdivCCG *subdiv_ccg = me_eval->runtime->subdiv_ccg; + const SubsurfRuntimeData *subsurf_runtime_data = me_eval->runtime->subsurf_runtime_data; if (subdiv_ccg != nullptr) { BKE_subdiv_ccg_topology_counters(subdiv_ccg, &totvert, &totedge, &totface, &totloop); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 36ced74a8b7..6370d56ae8c 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -17,6 +17,7 @@ #include "BKE_editmesh.h" #include "BKE_global.h" #include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" #include "BKE_object.h" #include "DEG_depsgraph.h" @@ -94,8 +95,8 @@ void ED_draw_object_facemap(Depsgraph *depsgraph, const MPoly *mp; int i; - if (me->runtime.looptris.array) { - const MLoopTri *mlt = me->runtime.looptris.array; + if (BKE_mesh_runtime_looptri_ensure(me)) { + const MLoopTri *mlt = BKE_mesh_runtime_looptri_ensure(me); for (mp = polys, i = 0; i < mpoly_len; i++, mp++) { if (facemap_data[i] == facemap) { for (int j = 2; j < mp->totloop; j++) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc index c61eac3c777..793ada4f577 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.cc @@ -19,8 +19,10 @@ #include "BKE_context.h" #include "BKE_editmesh.h" +#include "BKE_editmesh_cache.h" #include "BKE_global.h" #include "BKE_layer.h" +#include "BKE_mesh.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_query.h" @@ -234,8 +236,8 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int Object *ob = gz_ele->bases[gz_ele->base_index]->object; Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, static_cast<ID *>(ob->data)); - if (me_eval->runtime.edit_data) { - coords = me_eval->runtime.edit_data->vertexCos; + if (me_eval->runtime->edit_data) { + coords = me_eval->runtime->edit_data->vertexCos; } } EDBM_preselect_elem_update_from_single(gz_ele->psel, bm, best.ele, coords); diff --git a/source/blender/editors/space_view3d/view3d_iterators.cc b/source/blender/editors/space_view3d/view3d_iterators.cc index 204e4673aa4..932563863fe 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.cc +++ b/source/blender/editors/space_view3d/view3d_iterators.cc @@ -576,7 +576,7 @@ void mesh_foreachScreenFace( BM_mesh_elem_table_ensure(vc->em->bm, BM_FACE); - if (me->runtime.subsurf_face_dot_tags != nullptr) { + if (me->runtime->subsurf_face_dot_tags != nullptr) { BKE_mesh_foreach_mapped_subdiv_face_center( me, mesh_foreachScreenFace__mapFunc, &data, MESH_FOREACH_NOP); } diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 90a13722b63..f2711db5011 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -105,7 +105,7 @@ struct SnapData_EditMesh { /* Looptris. */ BVHTreeFromEditMesh treedata_editmesh; - struct Mesh_Runtime *mesh_runtime; + blender::bke::MeshRuntime *mesh_runtime; float min[3], max[3]; void clear() @@ -189,14 +189,14 @@ static const Mesh *mesh_for_snap(Object *ob_eval, eSnapEditType edit_mode_type, const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval); if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) { - if (editmesh_eval_final->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH) { + if (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { return nullptr; } me_eval = editmesh_eval_final; use_hide = true; } else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) { - if (editmesh_eval_cage->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH) { + if (editmesh_eval_cage->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { return nullptr; } me_eval = editmesh_eval_cage; @@ -253,21 +253,21 @@ static SnapData_Mesh *snap_object_data_mesh_get(SnapObjectContext *sctx, sod = sod_p->get(); bool is_dirty = false; if (sod->treedata_mesh.tree && sod->treedata_mesh.cached && - !bvhcache_has_tree(me_eval->runtime.bvh_cache, sod->treedata_mesh.tree)) { + !bvhcache_has_tree(me_eval->runtime->bvh_cache, sod->treedata_mesh.tree)) { /* The tree is owned by the Mesh and may have been freed since we last used. */ is_dirty = true; } else if (sod->bvhtree[0] && sod->cached[0] && - !bvhcache_has_tree(me_eval->runtime.bvh_cache, sod->bvhtree[0])) { + !bvhcache_has_tree(me_eval->runtime->bvh_cache, sod->bvhtree[0])) { /* The tree is owned by the Mesh and may have been freed since we last used. */ is_dirty = true; } else if (sod->bvhtree[1] && sod->cached[1] && - !bvhcache_has_tree(me_eval->runtime.bvh_cache, sod->bvhtree[1])) { + !bvhcache_has_tree(me_eval->runtime->bvh_cache, sod->bvhtree[1])) { /* The tree is owned by the Mesh and may have been freed since we last used. */ is_dirty = true; } - else if (sod->treedata_mesh.looptri != me_eval->runtime.looptris.array) { + else if (sod->treedata_mesh.looptri != me_eval->looptris().data()) { is_dirty = true; } else if (sod->treedata_mesh.vert != verts.data()) { @@ -330,19 +330,19 @@ static SnapData_Mesh *snap_object_data_mesh_get(SnapObjectContext *sctx, /* Searches for the #Mesh_Runtime associated with the object that is most likely to be updated due * to changes in the `edit_mesh`. */ -static Mesh_Runtime *snap_object_data_editmesh_runtime_get(Object *ob_eval) +static blender::bke::MeshRuntime *snap_object_data_editmesh_runtime_get(Object *ob_eval) { Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob_eval); if (editmesh_eval_final) { - return &editmesh_eval_final->runtime; + return editmesh_eval_final->runtime; } Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval); if (editmesh_eval_cage) { - return &editmesh_eval_cage->runtime; + return editmesh_eval_cage->runtime; } - return &((Mesh *)ob_eval->data)->runtime; + return ((Mesh *)ob_eval->data)->runtime; } static SnapData_EditMesh *snap_object_data_editmesh_get(SnapObjectContext *sctx, |