diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-08-14 12:45:26 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-08-14 13:02:21 +0300 |
commit | 02dbe3b0c78045abb49a32c562933b621f3aa0b1 (patch) | |
tree | 3acb9fe0912e00190504ad62e03a7f217b4f1874 /source/blender | |
parent | e25fdb6a795db3d3f6af864496af723599abdd34 (diff) |
Multires: Synchronize settings with Subsurf modifier
Currently no functional changes, just exposes all settings which we need
for OpenSubdiv, similar to what Subsurf modifier is doing already.
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D3602
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 12 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 20 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake_api.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 10 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 60 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_multires.c | 2 |
6 files changed, 64 insertions, 42 deletions
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 0774d65182f..bb261ec9590 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -884,7 +884,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object /* subdivide the mesh to highest level without displacements */ cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - origdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0, false); + origdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, 0, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE, 0, false); cddm->release(cddm); /* calc disps */ @@ -925,7 +925,7 @@ static void multires_subdivide( /* create subsurf DM from original mesh at high level */ cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask, false); + highdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, simple, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE, has_mask, false); ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh at low level */ @@ -1246,7 +1246,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene) else cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask, false); + highdm = subsurf_dm_create_local(scene, ob, cddm, totlvl, mmd->simple, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE, has_mask, false); ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh and displacements */ @@ -1308,7 +1308,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene) else cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - subdm = subsurf_dm_create_local(scene, ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, has_mask, false); + subdm = subsurf_dm_create_local(scene, ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE, has_mask, false); cddm->release(cddm); multiresModifier_disp_run(dm, me, NULL, CALC_DISPLACEMENTS, subdm->getGridData(subdm), mmd->totlvl); @@ -1390,7 +1390,7 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, result = subsurf_dm_create_local(scene, ob, dm, lvl, mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, - mmd->flags & eMultiresModifierFlag_PlainUv, + mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE, flags & MULTIRES_ALLOC_PAINT_MASK, render); @@ -2214,7 +2214,7 @@ static void multires_apply_smat(struct Depsgraph *depsgraph, Scene *scene, Objec MEM_freeN(vertCos); /* scaled ccgDM for tangent space of object with applied scale */ - dm = subsurf_dm_create_local(scene, ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0, false); + dm = subsurf_dm_create_local(scene, ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->uv_smooth == SUBSURF_UV_SMOOTH_NONE, 0, false); cddm->release(cddm); gridSize = dm->getGridSize(dm); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index fbc98a594a2..fb579aff479 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1840,12 +1840,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } { + /* Versioning code for Subsurf modifier. */ if (!DNA_struct_elem_find(fd->filesdna, "SubsurfModifier", "short", "uv_smooth")) { for (Object *object = bmain->object.first; object != NULL; object = object->id.next) { for (ModifierData *md = object->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Subsurf) { SubsurfModifierData *smd = (SubsurfModifierData *)md; - if (smd->flags & eSubsurfModifierFlag_SubsurfUv) { + if (smd->flags & eSubsurfModifierFlag_SubsurfUv_DEPRECATED) { smd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS; } else { @@ -1866,5 +1867,22 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } } + /* Versioning code for Multires modifier. */ + if (!DNA_struct_elem_find(fd->filesdna, "MultiresModifier", "short", "quality")) { + for (Object *object = bmain->object.first; object != NULL; object = object->id.next) { + for (ModifierData *md = object->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Multires) { + MultiresModifierData *mmd = (MultiresModifierData *)md; + mmd->quality = 3; + if (mmd->flags & eMultiresModifierFlag_PlainUv_DEPRECATED) { + mmd->uv_smooth = SUBSURF_UV_SMOOTH_NONE; + } + else { + mmd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS; + } + } + } + } + } } } diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index e8fabdabf17..d0d82a8ccc7 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -792,7 +792,7 @@ static int bake( mmd_low = (MultiresModifierData *) modifiers_findByType(ob_low, eModifierType_Multires); if (mmd_low) { mmd_flags_low = mmd_low->flags; - mmd_low->flags |= eMultiresModifierFlag_PlainUv; + mmd_low->uv_smooth = SUBSURF_UV_SMOOTH_NONE; } } diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 404e8d2d137..642e7d14869 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -140,7 +140,7 @@ typedef enum { eSubsurfModifierFlag_DebugIncr = (1 << 1), eSubsurfModifierFlag_ControlEdges = (1 << 2), /* DEPRECATED, ONLY USED FOR DO-VERSIONS */ - eSubsurfModifierFlag_SubsurfUv = (1 << 3), + eSubsurfModifierFlag_SubsurfUv_DEPRECATED = (1 << 3), } SubsurfModifierFlag; typedef enum { @@ -155,7 +155,7 @@ typedef enum { SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE = 3, SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES = 4, SUBSURF_UV_SMOOTH_ALL = 5, -} eSubsurfModifierUVSmooth; +} eSubsurfUVSmooth; typedef struct SubsurfModifierData { ModifierData modifier; @@ -844,11 +844,15 @@ typedef struct MultiresModifierData { char lvl, sculptlvl, renderlvl, totlvl; char simple, flags, pad[2]; + short quality; + short uv_smooth; + short pad2[2]; } MultiresModifierData; typedef enum { eMultiresModifierFlag_ControlEdges = (1 << 0), - eMultiresModifierFlag_PlainUv = (1 << 1), + /* DEPRECATED, only used for versioning. */ + eMultiresModifierFlag_PlainUv_DEPRECATED = (1 << 1), } MultiresModifierFlag; typedef struct FluidsimModifierData { diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 50907503aca..2b0f22eb8fc 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -1176,6 +1176,7 @@ static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr, co #else +/* NOTE: *MUST* return subdivision_type property. */ static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[]) { static const EnumPropertyItem prop_subdivision_type_items[] = { @@ -1184,17 +1185,6 @@ static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const c {0, NULL, 0, NULL, NULL} }; - PropertyRNA *prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, type); - RNA_def_property_enum_items(prop, prop_subdivision_type_items); - RNA_def_property_ui_text(prop, "Subdivision Type", "Select type of subdivision algorithm"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - return prop; -} - -static void rna_def_modifier_subsurf(BlenderRNA *brna) -{ static const EnumPropertyItem prop_uv_smooth_items[] = { {SUBSURF_UV_SMOOTH_NONE, "NONE", 0, "Sharp", "UVs are not smoothed, boundaries are kept sharp"}, @@ -1215,6 +1205,34 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + PropertyRNA *prop; + + prop = RNA_def_property(srna, "uv_smooth", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "uv_smooth"); + RNA_def_property_enum_items(prop, prop_uv_smooth_items); + RNA_def_property_ui_text(prop, "UV Smooth", "Controls how smoothing is applied to UVs"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + +#ifdef WITH_OPENSUBDIV_MODIFIER + prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "quality"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_range(prop, 1, 6, 1, -1); + RNA_def_property_ui_text(prop, "Quality", "Accuracy of vertex positions, lower value is faster but less precise"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +#endif + + prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, type); + RNA_def_property_enum_items(prop, prop_subdivision_type_items); + RNA_def_property_ui_text(prop, "Subdivision Type", "Select type of subdivision algorithm"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + return prop; +} + +static void rna_def_modifier_subsurf(BlenderRNA *brna) +{ StructRNA *srna; PropertyRNA *prop; @@ -1243,21 +1261,6 @@ static void rna_def_modifier_subsurf(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_ControlEdges); RNA_def_property_ui_text(prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "uv_smooth", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "uv_smooth"); - RNA_def_property_enum_items(prop, prop_uv_smooth_items); - RNA_def_property_ui_text(prop, "UV Smooth", "Controls how smoothing is applied to UVs"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); - -#ifdef WITH_OPENSUBDIV_MODIFIER - prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_sdna(prop, NULL, "quality"); - RNA_def_property_range(prop, 1, 10); - RNA_def_property_ui_range(prop, 1, 6, 1, -1); - RNA_def_property_ui_text(prop, "Quality", "Accuracy of vertex positions, lower value is faster but less precise"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); -#endif } static void rna_def_modifier_generic_map_info(StructRNA *srna) @@ -1403,11 +1406,6 @@ static void rna_def_modifier_multires(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", eMultiresModifierFlag_ControlEdges); RNA_def_property_ui_text(prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - - prop = RNA_def_property(srna, "use_subsurf_uv", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", eMultiresModifierFlag_PlainUv); - RNA_def_property_ui_text(prop, "Subdivide UVs", "Use subsurf to subdivide UVs"); - RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_lattice(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index aa9bc0dbc20..36bfa4fcd56 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -58,6 +58,8 @@ static void initData(ModifierData *md) mmd->sculptlvl = 0; mmd->renderlvl = 0; mmd->totlvl = 0; + mmd->uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS; + mmd->quality = 3; } static DerivedMesh *applyModifier( |