Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-08-13 16:39:01 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-08-13 17:04:06 +0300
commit5c61be777f10f65fce0184d43804c2d01cb284ad (patch)
treed69200bc4367b55dea18b9ee4a0b0b774c265933 /source/blender/modifiers
parentaac5458fa5800cc6c0a7243c1baa13d8190fa4b0 (diff)
Subsurf: Introduce quality option
For users it defines how accurate vertex positions are in terms of limit surface (as in, how close the vertices locations to the condition when they are calculated for an infinitely subdivided mesh). This affects things like: - Irregular vertices (joint of 3 or more edges) - Crease Keep quality value low for performance. NOTE: Going higher does not necessarily mean real improvement in quality, ideal case might be reached well before maximum quality of 10. Quality of 3 is a good starting point. Internally quality is translated directly to adaptive subdivision level. Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D3599
Diffstat (limited to 'source/blender/modifiers')
-rw-r--r--source/blender/modifiers/CMakeLists.txt4
-rw-r--r--source/blender/modifiers/intern/MOD_subsurf.c40
2 files changed, 20 insertions, 24 deletions
diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt
index 045a5d31fcb..522e15be856 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -144,8 +144,8 @@ if(WITH_INTERNATIONAL)
add_definitions(-DWITH_INTERNATIONAL)
endif()
-if(WITH_OPENSUBDIV)
- add_definitions(-DWITH_OPENSUBDIV)
+if(WITH_OPENSUBDIV_MODIFIER)
+ add_definitions(-DWITH_OPENSUBDIV_MODIFIER)
endif()
# So we can have special tricks in modifier system.
diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c
index 58cdea0df10..4cf830f9787 100644
--- a/source/blender/modifiers/intern/MOD_subsurf.c
+++ b/source/blender/modifiers/intern/MOD_subsurf.c
@@ -39,10 +39,6 @@
#include "DNA_scene_types.h"
#include "DNA_mesh_types.h"
-#ifdef WITH_OPENSUBDIV
-# include "DNA_userdef_types.h"
-#endif
-
#include "BLI_utildefines.h"
#include "BKE_cdderivedmesh.h"
@@ -57,8 +53,6 @@
#include "intern/CCGSubSurf.h"
-// #define USE_OPENSUBDIV
-
static void initData(ModifierData *md)
{
SubsurfModifierData *smd = (SubsurfModifierData *) md;
@@ -66,6 +60,7 @@ static void initData(ModifierData *md)
smd->levels = 1;
smd->renderLevels = 2;
smd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS;
+ smd->quality = 3;
}
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
@@ -151,26 +146,25 @@ static DerivedMesh *applyModifierEM(
return result;
}
-#ifdef USE_OPENSUBDIV
+#ifdef WITH_OPENSUBDIV_MODIFIER
static int subdiv_levels_for_modifier_get(const SubsurfModifierData *smd,
const ModifierEvalContext *ctx)
{
- Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
- const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER);
- const int requested_levels = (use_render_params) ? smd->renderLevels
- : smd->levels;
- return get_render_subsurf_level(&scene->r,
- requested_levels,
- use_render_params);
+ Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
+ const bool use_render_params = (ctx->flag & MOD_APPLY_RENDER);
+ const int requested_levels = (use_render_params) ? smd->renderLevels
+ : smd->levels;
+ return get_render_subsurf_level(&scene->r,
+ requested_levels,
+ use_render_params);
}
static void subdiv_settings_init(SubdivSettings *settings,
- const SubsurfModifierData *smd,
- const ModifierEvalContext *ctx)
+ const SubsurfModifierData *smd)
{
settings->is_simple = (smd->subdivType == SUBSURF_TYPE_SIMPLE);
settings->is_adaptive = !settings->is_simple;
- settings->level = subdiv_levels_for_modifier_get(smd, ctx);
+ settings->level = smd->quality;
switch (smd->uv_smooth) {
case SUBSURF_UV_SMOOTH_NONE:
settings->fvar_linear_interpolation =
@@ -200,9 +194,11 @@ static void subdiv_settings_init(SubdivSettings *settings,
}
static void subdiv_mesh_settings_init(SubdivToMeshSettings *settings,
- const SubdivSettings *subdiv_settings)
+ const SubsurfModifierData *smd,
+ const ModifierEvalContext *ctx)
{
- settings->resolution = (1 << subdiv_settings->level) + 1;
+ const int level = subdiv_levels_for_modifier_get(smd, ctx);
+ settings->resolution = (1 << level) + 1;
}
static Mesh *applyModifier_subdiv(ModifierData *md,
@@ -212,7 +208,7 @@ static Mesh *applyModifier_subdiv(ModifierData *md,
Mesh *result = mesh;
SubsurfModifierData *smd = (SubsurfModifierData *) md;
SubdivSettings subdiv_settings;
- subdiv_settings_init(&subdiv_settings, smd, ctx);
+ subdiv_settings_init(&subdiv_settings, smd);
if (subdiv_settings.level == 0) {
/* NOTE: Shouldn't really happen, is supposed to be catched by
* isDisabled() callback.
@@ -226,7 +222,7 @@ static Mesh *applyModifier_subdiv(ModifierData *md,
return result;
}
SubdivToMeshSettings mesh_settings;
- subdiv_mesh_settings_init(&mesh_settings, &subdiv_settings);
+ subdiv_mesh_settings_init(&mesh_settings, smd, ctx);
result = BKE_subdiv_to_mesh(subdiv, &mesh_settings, mesh);
/* TODO(sergey): Cache subdiv somehow. */
// BKE_subdiv_stats_print(&subdiv->stats);
@@ -259,7 +255,7 @@ ModifierTypeInfo modifierType_Subsurf = {
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
-#ifdef USE_OPENSUBDIV
+#ifdef WITH_OPENSUBDIV_MODIFIER
/* applyModifier */ applyModifier_subdiv,
#else
/* applyModifier */ NULL,