From 6070f92ab94be7bd1d6729f178d71c71c4245fbb Mon Sep 17 00:00:00 2001 From: Piotr Ostrowski Date: Wed, 30 Sep 2020 15:56:37 +0200 Subject: Subdivision Surfaces: add boundary smooth option to modifiers This adds the option to either smooth the entire boundary, or to keep corners sharp, for the Subdivision Surface and Multiresolution modifiers. This mainly helps with compatibility with other software. The default behavior remains to smooth the entire boundary. Differential Revision: https://developer.blender.org/D8485 --- source/blender/blenkernel/intern/multires_subdiv.c | 3 ++- source/blender/blenkernel/intern/subdiv.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires_subdiv.c b/source/blender/blenkernel/intern/multires_subdiv.c index fc092d3ccce..73ef623fbfd 100644 --- a/source/blender/blenkernel/intern/multires_subdiv.c +++ b/source/blender/blenkernel/intern/multires_subdiv.c @@ -40,7 +40,8 @@ void BKE_multires_subdiv_settings_init(SubdivSettings *settings, const MultiresM settings->is_adaptive = true; settings->level = settings->is_simple ? 1 : mmd->quality; settings->use_creases = (mmd->flags & eMultiresModifierFlag_UseCrease); - settings->vtx_boundary_interpolation = SUBDIV_VTX_BOUNDARY_EDGE_ONLY; + settings->vtx_boundary_interpolation = BKE_subdiv_vtx_boundary_interpolation_from_subsurf( + mmd->boundary_smooth); settings->fvar_linear_interpolation = BKE_subdiv_fvar_interpolation_from_uv_smooth( mmd->uv_smooth); } diff --git a/source/blender/blenkernel/intern/subdiv.c b/source/blender/blenkernel/intern/subdiv.c index fe1dd3835fd..f1cde39f657 100644 --- a/source/blender/blenkernel/intern/subdiv.c +++ b/source/blender/blenkernel/intern/subdiv.c @@ -72,6 +72,19 @@ eSubdivFVarLinearInterpolation BKE_subdiv_fvar_interpolation_from_uv_smooth(int return SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL; } +eSubdivVtxBoundaryInterpolation BKE_subdiv_vtx_boundary_interpolation_from_subsurf( + int boundary_smooth) +{ + switch (boundary_smooth) { + case SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS: + return SUBDIV_VTX_BOUNDARY_EDGE_AND_CORNER; + case SUBSURF_BOUNDARY_SMOOTH_ALL: + return SUBDIV_VTX_BOUNDARY_EDGE_ONLY; + } + BLI_assert(!"Unknown boundary smooth flag"); + return SUBDIV_VTX_BOUNDARY_EDGE_ONLY; +} + /* ================================ SETTINGS ================================ */ static bool check_mesh_has_non_quad(const Mesh *mesh) -- cgit v1.2.3