Add check in BKE_pbvh_apply_vertCos that number of deforming cos matches number of pbvh vertices.
This shall help catching issues in future.
This commit is contained in:
parent
06357b23a2
commit
934b9e80d0
Notes:
blender-bot
2024-03-22 15:57:27 +01:00
Referenced by issue #72028, Crash switching to vertex paint (from editmode, mesh with modifier, after adding/removing geometry in editmode) Referenced by issue #65200, Crash by hiting "tab" after sculpting with dyntopo.
|
@ -240,7 +240,7 @@ void BKE_pbvh_node_layer_disp_free(PBVHNode *node);
|
|||
|
||||
/* vertex deformer */
|
||||
float (*BKE_pbvh_get_vertCos(struct PBVH *pbvh))[3];
|
||||
void BKE_pbvh_apply_vertCos(struct PBVH *pbvh, float (*vertCos)[3]);
|
||||
void BKE_pbvh_apply_vertCos(struct PBVH *pbvh, float (*vertCos)[3], const int totvert);
|
||||
bool BKE_pbvh_isDeformed(struct PBVH *pbvh);
|
||||
|
||||
/* Vertex Iterator */
|
||||
|
|
|
@ -325,7 +325,7 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
|||
totvert = deformdm->getNumVerts(deformdm);
|
||||
vertCos = MEM_malloc_arrayN(totvert, sizeof(float[3]), "cdDM_getPBVH vertCos");
|
||||
deformdm->getVertCos(deformdm, vertCos);
|
||||
BKE_pbvh_apply_vertCos(cddm->pbvh, vertCos);
|
||||
BKE_pbvh_apply_vertCos(cddm->pbvh, vertCos, totvert);
|
||||
MEM_freeN(vertCos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -946,7 +946,7 @@ void BKE_sculpt_update_mesh_elements(
|
|||
ss->orig_cos = (ss->kb) ? BKE_keyblock_convert_to_vertcos(ob, ss->kb) : BKE_mesh_vertexCos_get(me, NULL);
|
||||
|
||||
BKE_crazyspace_build_sculpt(depsgraph, scene, ob, &ss->deform_imats, &ss->deform_cos);
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos);
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos, me->totvert);
|
||||
|
||||
for (a = 0; a < me->totvert; ++a) {
|
||||
invert_m3(ss->deform_imats[a]);
|
||||
|
@ -970,7 +970,7 @@ void BKE_sculpt_update_mesh_elements(
|
|||
if (vertCos) {
|
||||
if (!pbvh_deformed) {
|
||||
/* apply shape keys coordinates to PBVH */
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, vertCos);
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, me->totvert);
|
||||
}
|
||||
if (ss->deform_cos == NULL) {
|
||||
ss->deform_cos = vertCos;
|
||||
|
|
|
@ -2189,8 +2189,13 @@ float (*BKE_pbvh_get_vertCos(PBVH *pbvh))[3]
|
|||
return vertCos;
|
||||
}
|
||||
|
||||
void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3])
|
||||
void BKE_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3], const int totvert)
|
||||
{
|
||||
if (totvert != pbvh->totvert) {
|
||||
BLI_assert(!"PBVH: Given deforming vcos number does not natch PBVH vertex number!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pbvh->deformed) {
|
||||
if (pbvh->verts) {
|
||||
/* if pbvh is not already deformed, verts/faces points to the */
|
||||
|
|
|
@ -2352,7 +2352,7 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
|
|||
totvert = deformdm->getNumVerts(deformdm);
|
||||
vertCos = MEM_malloc_arrayN(totvert, sizeof(float[3]), "ccgDM_getPBVH vertCos");
|
||||
deformdm->getVertCos(deformdm, vertCos);
|
||||
BKE_pbvh_apply_vertCos(ccgdm->pbvh, vertCos);
|
||||
BKE_pbvh_apply_vertCos(ccgdm->pbvh, vertCos, totvert);
|
||||
MEM_freeN(vertCos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN
|
|||
|
||||
/* pbvh uses it's own mvert array, so coords should be */
|
||||
/* propagated to pbvh here */
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, vertCos);
|
||||
BKE_pbvh_apply_vertCos(ss->pbvh, vertCos, unode->totvert);
|
||||
|
||||
MEM_freeN(vertCos);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue