UI: Use sliders and [0, 1] ranges in ocean modifier
The ocean modifier has two properties that use a [0, 10] hard min and hard max. The values act as factors though, so it makes more sense to use sliders and a 0 to 1 range. This commit also bumps the file subversion to avoid repeatedly applying the change to the properties' range. Differential Revision: https://developer.blender.org/D8186
This commit is contained in:
parent
2a39b34a09
commit
53d41e1a6f
|
@ -40,7 +40,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 5
|
||||
#define BLENDER_FILE_SUBVERSION 6
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
|
|
@ -831,7 +831,7 @@ void BKE_ocean_init(struct Ocean *o,
|
|||
o->_A = A;
|
||||
o->_w = w;
|
||||
o->_damp_reflections = 1.0f - damp;
|
||||
o->_wind_alignment = alignment;
|
||||
o->_wind_alignment = alignment * 10.0f;
|
||||
o->_depth = depth;
|
||||
o->_Lx = Lx;
|
||||
o->_Lz = Lz;
|
||||
|
@ -845,7 +845,7 @@ void BKE_ocean_init(struct Ocean *o,
|
|||
|
||||
/* Common JONSWAP parameters. */
|
||||
o->_fetch_jonswap = fetch_jonswap;
|
||||
o->_sharpen_peak_jonswap = sharpen_peak_jonswap;
|
||||
o->_sharpen_peak_jonswap = sharpen_peak_jonswap * 10.0f;
|
||||
|
||||
o->_do_disp_y = do_height_field;
|
||||
o->_do_normals = do_normals;
|
||||
|
|
|
@ -257,18 +257,7 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 290, 6)) {
|
||||
/* Transition to saving expansion for all of a modifier's sub-panels. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "ModifierData", "short", "ui_expand_flag")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
|
@ -338,19 +327,43 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Refactor bevel profile type to use an enum. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "short", "profile_type")) {
|
||||
/* Refactor bevel profile type to use an enum. */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "short", "profile_type")) {
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_Bevel) {
|
||||
BevelModifierData *bmd = (BevelModifierData *)md;
|
||||
bool use_custom_profile = bmd->flags & MOD_BEVEL_CUSTOM_PROFILE_DEPRECATED;
|
||||
bmd->profile_type = use_custom_profile ? MOD_BEVEL_PROFILE_CUSTOM :
|
||||
MOD_BEVEL_PROFILE_SUPERELLIPSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Change ocean modifier values from [0, 10] to [0, 1] ranges. */
|
||||
for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
|
||||
LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
|
||||
if (md->type == eModifierType_Bevel) {
|
||||
BevelModifierData *bmd = (BevelModifierData *)md;
|
||||
bool use_custom_profile = bmd->flags & MOD_BEVEL_CUSTOM_PROFILE_DEPRECATED;
|
||||
bmd->profile_type = use_custom_profile ? MOD_BEVEL_PROFILE_CUSTOM :
|
||||
MOD_BEVEL_PROFILE_SUPERELLIPSE;
|
||||
if (md->type == eModifierType_Ocean) {
|
||||
OceanModifierData *omd = (OceanModifierData *)md;
|
||||
omd->wave_alignment *= 0.1f;
|
||||
omd->sharpen_peak_jonswap *= 0.1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - "versioning_userdef.c", #BLO_version_defaults_userpref_blend
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5644,7 +5644,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "wave_alignment", PROP_FLOAT, PROP_UNSIGNED);
|
||||
RNA_def_property_float_sdna(prop, NULL, "wave_alignment");
|
||||
RNA_def_property_range(prop, 0.0, 10.0);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_ui_text(prop, "Wave Alignment", "How much the waves are aligned to each other");
|
||||
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
|
||||
|
||||
|
@ -5721,7 +5721,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "sharpen_peak_jonswap", PROP_FLOAT, PROP_UNSIGNED);
|
||||
RNA_def_property_float_sdna(prop, NULL, "sharpen_peak_jonswap");
|
||||
RNA_def_property_range(prop, 0.0, 10.0);
|
||||
RNA_def_property_range(prop, 0.0, 1.0);
|
||||
RNA_def_property_ui_text(prop, "Sharpen peak", "Peak sharpening for 'JONSWAP' and 'TMA' models");
|
||||
RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
|
||||
|
||||
|
|
|
@ -598,7 +598,7 @@ static void waves_panel_draw(const bContext *C, Panel *panel)
|
|||
uiItemS(layout);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "wave_alignment", 0, IFACE_("Alignment"), ICON_NONE);
|
||||
uiItemR(col, &ptr, "wave_alignment", UI_ITEM_R_SLIDER, IFACE_("Alignment"), ICON_NONE);
|
||||
sub = uiLayoutColumn(col, false);
|
||||
uiLayoutSetActive(sub, RNA_float_get(&ptr, "wave_alignment") > 0.0f);
|
||||
uiItemR(sub, &ptr, "wave_direction", 0, IFACE_("Direction"), ICON_NONE);
|
||||
|
@ -682,7 +682,7 @@ static void spectrum_panel_draw(const bContext *C, Panel *panel)
|
|||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, &ptr, "spectrum", 0, NULL, ICON_NONE);
|
||||
if (ELEM(spectrum, MOD_OCEAN_SPECTRUM_TEXEL_MARSEN_ARSLOE, MOD_OCEAN_SPECTRUM_JONSWAP)) {
|
||||
uiItemR(col, &ptr, "sharpen_peak_jonswap", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "sharpen_peak_jonswap", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(col, &ptr, "fetch_jonswap", 0, NULL, ICON_NONE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue