Fix part of T60735: invalid CD_ORIGINDEX data in some modifier stack evaluations.
BKE_mesh_new_nomain automatically added a CD_ORIGINDEX layer initialized to 0, which was never filled in correctly. In 2.7 the equivalent function used to modify the source derivedmesh and add valid original indices to it, but this is no longer possible in the new design and was quite unpredictable anyway. Now instead rely on mesh_calc_modifiers and the depsgraph to determine when CD_ORIGINDEX should be added.
This commit is contained in:
@@ -584,18 +584,6 @@ static void mesh_ensure_cdlayers_primary(Mesh *mesh, bool do_tessface)
|
|||||||
if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE))
|
if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_MFACE))
|
||||||
CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, NULL, mesh->totface);
|
CustomData_add_layer(&mesh->fdata, CD_MFACE, CD_CALLOC, NULL, mesh->totface);
|
||||||
}
|
}
|
||||||
static void mesh_ensure_cdlayers_origindex(Mesh *mesh, bool do_tessface)
|
|
||||||
{
|
|
||||||
if (!CustomData_get_layer(&mesh->vdata, CD_ORIGINDEX))
|
|
||||||
CustomData_add_layer(&mesh->vdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totvert);
|
|
||||||
if (!CustomData_get_layer(&mesh->edata, CD_ORIGINDEX))
|
|
||||||
CustomData_add_layer(&mesh->edata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totedge);
|
|
||||||
if (!CustomData_get_layer(&mesh->pdata, CD_ORIGINDEX))
|
|
||||||
CustomData_add_layer(&mesh->pdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totpoly);
|
|
||||||
|
|
||||||
if (do_tessface && !CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX))
|
|
||||||
CustomData_add_layer(&mesh->fdata, CD_ORIGINDEX, CD_CALLOC, NULL, mesh->totface);
|
|
||||||
}
|
|
||||||
|
|
||||||
Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
|
Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
|
||||||
{
|
{
|
||||||
@@ -619,7 +607,6 @@ Mesh *BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int lo
|
|||||||
mesh->totpoly = polys_len;
|
mesh->totpoly = polys_len;
|
||||||
|
|
||||||
mesh_ensure_cdlayers_primary(mesh, true);
|
mesh_ensure_cdlayers_primary(mesh, true);
|
||||||
mesh_ensure_cdlayers_origindex(mesh, true);
|
|
||||||
BKE_mesh_update_customdata_pointers(mesh, false);
|
BKE_mesh_update_customdata_pointers(mesh, false);
|
||||||
|
|
||||||
return mesh;
|
return mesh;
|
||||||
@@ -662,7 +649,6 @@ static Mesh *mesh_new_nomain_from_template_ex(
|
|||||||
/* The destination mesh should at least have valid primary CD layers,
|
/* The destination mesh should at least have valid primary CD layers,
|
||||||
* even in cases where the source mesh does not. */
|
* even in cases where the source mesh does not. */
|
||||||
mesh_ensure_cdlayers_primary(me_dst, do_tessface);
|
mesh_ensure_cdlayers_primary(me_dst, do_tessface);
|
||||||
mesh_ensure_cdlayers_origindex(me_dst, false);
|
|
||||||
BKE_mesh_update_customdata_pointers(me_dst, false);
|
BKE_mesh_update_customdata_pointers(me_dst, false);
|
||||||
|
|
||||||
return me_dst;
|
return me_dst;
|
||||||
|
@@ -931,6 +931,11 @@ void DepsgraphRelationBuilder::build_object_parent(Object *object)
|
|||||||
* so we onl;y hook up to transform channel here. */
|
* so we onl;y hook up to transform channel here. */
|
||||||
add_relation(parent_geometry_key, ob_key, "Parent");
|
add_relation(parent_geometry_key, ob_key, "Parent");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Dupliverts uses original vertex index. */
|
||||||
|
if (parent->transflag & OB_DUPLIVERTS) {
|
||||||
|
add_customdata_mask(parent, DEGCustomDataMeshMasks::MaskVert(CD_MASK_ORIGINDEX));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DepsgraphRelationBuilder::build_object_pointcache(Object *object)
|
void DepsgraphRelationBuilder::build_object_pointcache(Object *object)
|
||||||
|
@@ -176,7 +176,6 @@ typedef struct GenerateOceanGeometryData {
|
|||||||
MVert *mverts;
|
MVert *mverts;
|
||||||
MPoly *mpolys;
|
MPoly *mpolys;
|
||||||
MLoop *mloops;
|
MLoop *mloops;
|
||||||
int *origindex;
|
|
||||||
MLoopUV *mloopuvs;
|
MLoopUV *mloopuvs;
|
||||||
|
|
||||||
int res_x, res_y;
|
int res_x, res_y;
|
||||||
@@ -230,9 +229,6 @@ static void generate_ocean_geometry_polygons(
|
|||||||
mp->totloop = 4;
|
mp->totloop = 4;
|
||||||
|
|
||||||
mp->flag |= ME_SMOOTH;
|
mp->flag |= ME_SMOOTH;
|
||||||
|
|
||||||
/* generated geometry does not map to original faces */
|
|
||||||
gogd->origindex[fi] = ORIGINDEX_NONE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,8 +295,6 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd)
|
|||||||
gogd.mpolys = result->mpoly;
|
gogd.mpolys = result->mpoly;
|
||||||
gogd.mloops = result->mloop;
|
gogd.mloops = result->mloop;
|
||||||
|
|
||||||
gogd.origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX);
|
|
||||||
|
|
||||||
ParallelRangeSettings settings;
|
ParallelRangeSettings settings;
|
||||||
BLI_parallel_range_settings_defaults(&settings);
|
BLI_parallel_range_settings_defaults(&settings);
|
||||||
settings.use_threading = use_threading;
|
settings.use_threading = use_threading;
|
||||||
|
Reference in New Issue
Block a user