Fix BMesh mesh conversion

This commit is contained in:
Hans Goudey 2022-12-07 13:41:12 -06:00
parent 3fee39220f
commit e608dca494
3 changed files with 12 additions and 6 deletions

View File

@ -2380,7 +2380,7 @@ static bool attribute_stored_in_bmesh_flag(const StringRef name)
".select_vert",
".select_edge",
".select_poly",
"material_index"
"material_index",
".corner_vert",
".corner_edge");
}

View File

@ -734,7 +734,7 @@ const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh)
bool BKE_mesh_attribute_required(const char *name)
{
return StringRef(name) == "position";
return ELEM(StringRef(name), "position", ".corner_vert", ".corner_edge");
}
void BKE_mesh_ensure_skin_customdata(Mesh *me)

View File

@ -854,6 +854,8 @@ static void assert_bmesh_has_no_mesh_only_attributes(const BMesh &bm)
{
(void)bm; /* Unused in the release builds. */
BLI_assert(CustomData_get_layer_named(&bm.vdata, CD_PROP_FLOAT3, "position") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.ldata, CD_PROP_FLOAT3, ".corner_vert") == nullptr);
BLI_assert(CustomData_get_layer_named(&bm.ldata, CD_PROP_FLOAT3, ".corner_edge") == nullptr);
/* The "hide" attributes are stored as flags on #BMesh. */
BLI_assert(CustomData_get_layer_named(&bm.vdata, CD_PROP_BOOL, ".hide_vert") == nullptr);
@ -1223,10 +1225,14 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *
&me->vdata, CD_PROP_FLOAT3, CD_CONSTRUCT, nullptr, bm->totvert, "position");
}
CustomData_add_layer(&me->edata, CD_MEDGE, CD_SET_DEFAULT, nullptr, bm->totedge);
CustomData_add_layer_named(
&me->ldata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, bm->totloop, ".corner_vert");
CustomData_add_layer_named(
&me->ldata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, bm->totloop, ".corner_edge");
if (!CustomData_get_layer_named(&me->ldata, CD_PROP_INT32, ".corner_vert")) {
CustomData_add_layer_named(
&me->ldata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, bm->totloop, ".corner_vert");
}
if (!CustomData_get_layer_named(&me->ldata, CD_PROP_INT32, ".corner_edge")) {
CustomData_add_layer_named(
&me->ldata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, bm->totloop, ".corner_edge");
}
CustomData_add_layer(&me->pdata, CD_MPOLY, CD_SET_DEFAULT, nullptr, bm->totface);
/* Don't process shape-keys, we only feed them through the modifier stack as needed,