MVert is NULL in 2.90 when it shouldn't be and isn't NULL in 2.83

Any idea why this works in 2.83, but not in 2.90?

  Mesh *mesh = editbmesh_get_eval_cage_from_orig(
      vc->depsgraph, vc->scene, vc->obedit, &CD_MASK_BAREMESH);

  const MVert *mvert = mesh->mvert;

In 2.83, this allows Select Through to work:

But in 2.90, even though mesh isn’t NULL, it thinks mvert is.

Exception thrown: read access violation.
**mvert** was nullptr.

Been looking around for anything that’s different between 2.83 and 2.90 to make this happen. Nothing yet, please help.

Evaluated meshes can now wrap other kinds of data (currently edit-mesh, in the future subsurf could be made to work too).

To ensure the mesh data is created, call BKE_mesh_wrapper_ensure_mdata, although this creates a full copy of the mesh and may add a noticeable slowdown in the case of heavy meshes and should be avoided by using the edit-mesh directly.

For more background see:


I have a problem I just realized when trying to test the difference between using BKE_mesh_wrapper_ensure_mdata , and what I thought was ‘using editmesh directly’ like you suggest. I am pretty sure that I don’t really know what you meant, and was hoping it was just something simple like this:

I can do Mesh *me = vc->obact->data; which will solve the original issue of mvert being NULL in 2.90, but when the mesh is changed at all, none of the face positions or new faces are updated. It thinks everything is exactly as it was entering edit mode. For example, if you subdivide all the faces, and then drag over the entire mesh, only the faces that existed last time you entered edit mode will be selected (in their new location and smaller size). Only way to update this information is to exit and re-enter edit mode.

Or, to use the performance heavy

  Mesh *me = editbmesh_get_eval_cage_from_orig(
      vc->depsgraph, vc->scene, vc->obedit, &CD_MASK_BAREMESH);

I was thinking I could at least save a little performance by doing

Mesh *me = vc->obact->data;

But that has the same issue of not updating mesh info on each new selection.

Is there a way to update mesh info without exit re-enter edit mode?

Is there some equivalent to MVert that I can get/use from BMEditMesh to avoid BKE_mesh_wrapper_ensure_mdata(me);?

Thanks, I am already thinking the whole thing here:
will need to be re-written to use BMEditMesh information, or something else, but that would mean me being able to understand it a lot better than I do.

Converting/copying mesh data just for selection is inefficient, this should use the BMEditMesh data directly.

Alright I figured it would need to be re-written.

Any help you can offer is appreciated. I’m looking around blind for the most part, trying to figure out where information is, some examples of how it’s used.

For an example of looping over faces, see: BKE_mesh_foreach_mapped_face_center.

1 Like