Fix T67888: Incorrect Wireframe After Applying SubSurf/MultiRes

Show control edges stores the control edges in the mesh which is
picked up by the draw manager. When applyng a subsurf (or multires) we
don't want that data present in the base mesh. Any rebuilding of the mesh
would overwrite the data anyway.

This patch introduces a new flag for applying modifiers
that can be checked to ignore storing display specific data in
the base mesh.

Reviewed By: Brecht van Lommel

Differential Revision: https://developer.blender.org/D7163
This commit is contained in:
Jeroen Bakker 2020-03-26 14:36:39 +01:00 committed by Jeroen Bakker
parent 2e8fb95e7c
commit 7ed3ebbc6e
Notes: blender-bot 2023-07-10 10:12:37 +02:00
Referenced by issue #67888, Wireframe not updating after applying subsurf
6 changed files with 22 additions and 7 deletions

View File

@ -125,6 +125,11 @@ typedef enum ModifierApplyFlag {
/** Ignore scene simplification flag and use subdivisions
* level set in multires modifier. */
MOD_APPLY_IGNORE_SIMPLIFY = 1 << 3,
/** The effect of this modifier will be applied to the base mesh
* The modifier itself will be removed from the modifier stack.
* This flag can be checked to ignore rendering display data to the mesh.
* See `OBJECT_OT_modifier_apply` operator. */
MOD_APPLY_TO_BASE_MESH = 1 << 4,
} ModifierApplyFlag;
typedef struct ModifierUpdateDepsgraphContext {

View File

@ -197,7 +197,8 @@ void BKE_multires_subdiv_mesh_settings_init(struct SubdivToMeshSettings *mesh_se
const struct Object *object,
const struct MultiresModifierData *mmd,
const bool use_render_params,
const bool ignore_simplify);
const bool ignore_simplify,
const bool ignore_control_edges);
/* General helpers. */

View File

@ -1304,7 +1304,7 @@ Mesh *BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph,
const ModifierTypeInfo *mti = modifierType_getInfo(md_eval->type);
Mesh *result;
KeyBlock *kb;
ModifierEvalContext mectx = {depsgraph, ob_eval, 0};
ModifierEvalContext mectx = {depsgraph, ob_eval, MOD_APPLY_TO_BASE_MESH};
if (!(md_eval->mode & eModifierMode_Realtime)) {
return NULL;

View File

@ -50,9 +50,11 @@ void BKE_multires_subdiv_mesh_settings_init(SubdivToMeshSettings *mesh_settings,
const Object *object,
const MultiresModifierData *mmd,
const bool use_render_params,
const bool ignore_simplify)
const bool ignore_simplify,
const bool ignore_control_edges)
{
const int level = multires_get_level(scene, object, mmd, use_render_params, ignore_simplify);
mesh_settings->resolution = (1 << level) + 1;
mesh_settings->use_optimal_display = (mmd->flags & eMultiresModifierFlag_ControlEdges);
mesh_settings->use_optimal_display = (mmd->flags & eMultiresModifierFlag_ControlEdges) &&
!ignore_control_edges;
}

View File

@ -119,11 +119,17 @@ static Mesh *multires_as_mesh(MultiresModifierData *mmd,
Mesh *result = mesh;
const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER);
const bool ignore_simplify = (ctx->flag & MOD_APPLY_IGNORE_SIMPLIFY);
const bool ignore_control_edges = (ctx->flag & MOD_APPLY_TO_BASE_MESH);
const Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
Object *object = ctx->object;
SubdivToMeshSettings mesh_settings;
BKE_multires_subdiv_mesh_settings_init(
&mesh_settings, scene, object, mmd, use_render_params, ignore_simplify);
BKE_multires_subdiv_mesh_settings_init(&mesh_settings,
scene,
object,
mmd,
use_render_params,
ignore_simplify,
ignore_control_edges);
if (mesh_settings.resolution < 3) {
return result;
}

View File

@ -148,7 +148,8 @@ static void subdiv_mesh_settings_init(SubdivToMeshSettings *settings,
{
const int level = subdiv_levels_for_modifier_get(smd, ctx);
settings->resolution = (1 << level) + 1;
settings->use_optimal_display = (smd->flags & eSubsurfModifierFlag_ControlEdges);
settings->use_optimal_display = (smd->flags & eSubsurfModifierFlag_ControlEdges) &&
!(ctx->flag & MOD_APPLY_TO_BASE_MESH);
}
static Mesh *subdiv_as_mesh(SubsurfModifierData *smd,