From c34c6d3e25f2f4d96d124cb5ec43c4392e7de4dc Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 12 Oct 2022 20:55:26 -0500 Subject: Mesh: Move runtime data out of DNA This commit replaces the `Mesh_Runtime` struct embedded in `Mesh` with `blender::bke::MeshRuntime`. This has quite a few benefits: - It's possible to use C++ types like `std::mutex`, `Array`, `BitVector`, etc. more easily - Meshes saved in files are slightly smaller - Copying and writing meshes is a bit more obvious without clearing of runtime data, etc. The first is by far the most important. It will allows us to avoid a bunch of manual memory management boilerplate that is error-prone and annoying. It should also simplify future CoW improvements for runtime data. This patch doesn't change anything besides changing `mesh.runtime.data` to `mesh.runtime->data`. The cleanups above will happen separately. Differential Revision: https://developer.blender.org/D16180 --- source/blender/blenkernel/intern/paint.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern/paint.cc') diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index fbb7642c067..d45ce776b64 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -1743,7 +1743,7 @@ static void sculpt_update_object( ss->hide_poly = (bool *)CustomData_get_layer_named(&me->pdata, CD_PROP_BOOL, ".hide_poly"); - ss->subdiv_ccg = me_eval->runtime.subdiv_ccg; + ss->subdiv_ccg = me_eval->runtime->subdiv_ccg; PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(depsgraph, ob); BLI_assert(pbvh == ss->pbvh); @@ -2258,7 +2258,7 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) { Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); Mesh *mesh_eval = static_cast(object_eval->data); - SubdivCCG *subdiv_ccg = mesh_eval->runtime.subdiv_ccg; + SubdivCCG *subdiv_ccg = mesh_eval->runtime->subdiv_ccg; if (subdiv_ccg != nullptr) { BKE_sculpt_bvh_update_from_ccg(pbvh, subdiv_ccg); } @@ -2277,8 +2277,8 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) else { Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); Mesh *mesh_eval = static_cast(object_eval->data); - if (mesh_eval->runtime.subdiv_ccg != nullptr) { - pbvh = build_pbvh_from_ccg(ob, mesh_eval->runtime.subdiv_ccg, respect_hide); + if (mesh_eval->runtime->subdiv_ccg != nullptr) { + pbvh = build_pbvh_from_ccg(ob, mesh_eval->runtime->subdiv_ccg, respect_hide); } else if (ob->type == OB_MESH) { Mesh *me_eval_deform = object_eval->runtime.mesh_deform_eval; -- cgit v1.2.3