Cleanup: Avoid mesh positions copy applying sculpt to shape key

`BKE_pbvh_vert_coords_alloc` is unnecessary after 1af62cb3bf
since PBVH vertex positions are stored in a contiguous array.
This commit is contained in:
Hans Goudey
2023-09-04 21:21:46 -04:00
parent 6de294a191
commit afdbb734cf
3 changed files with 6 additions and 27 deletions

View File

@@ -462,7 +462,6 @@ void BKE_pbvh_face_sets_color_set(PBVH *pbvh, int seed, int color_default);
/* Vertex Deformer. */
float (*BKE_pbvh_vert_coords_alloc(PBVH *pbvh))[3];
void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], int totvert);
bool BKE_pbvh_is_deformed(PBVH *pbvh);

View File

@@ -2968,19 +2968,6 @@ void BKE_pbvh_grids_update(PBVH *pbvh,
}
}
float (*BKE_pbvh_vert_coords_alloc(PBVH *pbvh))[3]
{
float(*vertCos)[3] = nullptr;
if (!pbvh->vert_positions.is_empty()) {
vertCos = static_cast<float(*)[3]>(
MEM_malloc_arrayN(pbvh->totvert, sizeof(float[3]), __func__));
memcpy(vertCos, pbvh->vert_positions.data(), sizeof(float[3]) * pbvh->totvert);
}
return vertCos;
}
void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float (*vertCos)[3], const int totvert)
{
if (totvert != pbvh->totvert) {

View File

@@ -3872,25 +3872,17 @@ void SCULPT_combine_transform_proxies(Sculpt *sd, Object *ob)
static void sculpt_update_keyblock(Object *ob)
{
SculptSession *ss = ob->sculpt;
float(*vertCos)[3];
/* Key-block update happens after handling deformation caused by modifiers,
* so ss->orig_cos would be updated with new stroke. */
if (ss->orig_cos) {
vertCos = ss->orig_cos;
SCULPT_vertcos_to_key(ob, ss->shapekey_active, ss->orig_cos);
}
else {
vertCos = BKE_pbvh_vert_coords_alloc(ss->pbvh);
}
if (!vertCos) {
return;
}
SCULPT_vertcos_to_key(ob, ss->shapekey_active, vertCos);
if (vertCos != ss->orig_cos) {
MEM_freeN(vertCos);
const float(*positions)[3] = BKE_pbvh_get_vert_positions(ss->pbvh);
if (positions != nullptr) {
SCULPT_vertcos_to_key(ob, ss->shapekey_active, positions);
}
}
}
@@ -5641,6 +5633,7 @@ static void sculpt_stroke_update_step(bContext *C,
PaintStroke *stroke,
PointerRNA *itemptr)
{
SCOPED_TIMER_AVERAGED(__func__);
UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
Object *ob = CTX_data_active_object(C);