Merge pull request #54039 from nekomatata/fix-soft-body-memory-corruption-bullet-3.x

This commit is contained in:
Rémi Verschelde 2021-11-08 23:59:05 +01:00 committed by GitHub
commit 3be409aa5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,19 +117,17 @@ void SoftBodyBullet::update_visual_server(SoftBodyVisualServerHandler *p_visual_
}
void SoftBodyBullet::set_soft_mesh(const Ref<Mesh> &p_mesh) {
if (p_mesh.is_null()) {
soft_mesh.unref();
} else {
soft_mesh = p_mesh;
}
destroy_soft_body();
soft_mesh = p_mesh;
if (soft_mesh.is_null()) {
destroy_soft_body();
return;
}
Array arrays = soft_mesh->surface_get_arrays(0);
ERR_FAIL_COND(!(soft_mesh->surface_get_format(0) & VS::ARRAY_FORMAT_INDEX));
Array arrays = soft_mesh->surface_get_arrays(0);
set_trimesh_body_shape(arrays[VS::ARRAY_INDEX], arrays[VS::ARRAY_VERTEX]);
}