Fix #105455: GPU subdivision with textures corrupts display after undo
This is an issue revealed by the recent optimization in 4d3bfb3f41
to have
CPU and GPU subdivision topology both cached.
BKE_subsurf_modifier_subdiv_descriptor_ensure is what (re)creates the
topology refiner when needed. Invalidating the topology refiner on changes
must be done before it, otherwise we end up with an incomplete Subdiv that
either does not draw or draws incorrectly.
Pull Request: https://projects.blender.org/blender/blender/pulls/105844
This commit is contained in:
parent
f46fb8051d
commit
20a8bc1204
|
@ -838,8 +838,12 @@ static DRWSubdivCache *mesh_batch_cache_ensure_subdiv_cache(MeshBatchCache *mbc)
|
|||
|
||||
static void draw_subdiv_invalidate_evaluator_for_orco(Subdiv *subdiv, Mesh *mesh)
|
||||
{
|
||||
if (!(subdiv && subdiv->evaluator)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool has_orco = CustomData_has_layer(&mesh->vdata, CD_ORCO);
|
||||
if (has_orco && subdiv->evaluator && !subdiv->evaluator->hasVertexData(subdiv->evaluator)) {
|
||||
if (has_orco && !subdiv->evaluator->hasVertexData(subdiv->evaluator)) {
|
||||
/* If we suddenly have/need original coordinates, recreate the evaluator if the extra
|
||||
* source was not created yet. The refiner also has to be recreated as refinement for source
|
||||
* and vertex data is done only once. */
|
||||
|
@ -2113,13 +2117,13 @@ static bool draw_subdiv_create_requested_buffers(Object *ob,
|
|||
bm = mesh->edit_mesh->bm;
|
||||
}
|
||||
|
||||
draw_subdiv_invalidate_evaluator_for_orco(runtime_data->subdiv_gpu, mesh_eval);
|
||||
|
||||
Subdiv *subdiv = BKE_subsurf_modifier_subdiv_descriptor_ensure(runtime_data, mesh_eval, true);
|
||||
if (!subdiv) {
|
||||
return false;
|
||||
}
|
||||
|
||||
draw_subdiv_invalidate_evaluator_for_orco(subdiv, mesh_eval);
|
||||
|
||||
if (!BKE_subdiv_eval_begin_from_mesh(
|
||||
subdiv, mesh_eval, nullptr, SUBDIV_EVALUATOR_TYPE_GPU, evaluator_cache)) {
|
||||
/* This could happen in two situations:
|
||||
|
|
Loading…
Reference in New Issue