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:
authorHans Goudey <h.goudey@me.com>2020-09-02 22:13:26 +0300
committerHans Goudey <h.goudey@me.com>2020-09-02 22:13:26 +0300
commitba4a2a4c8b827201b18e97d9dd025ef93a4db754 (patch)
treea71d6b72aaf0616ebda671bf4b011880b49bb280 /source/blender/modifiers/intern/MOD_ocean.c
parentff7d74235023d0c927c0ad3f4d72d1c5dd41b240 (diff)
UI: Use instanced panel custom data instead of list index
For modifier shortcuts we added a "custom_data" field to panels. This commit uses the same system for accessing the list data that corresponds to each panel. This way the context is only used once and the modifier for each panel can be accessed more easily later. This ends up being mostly a cleanup commit with a few small changes in interface_panel.c. The large changes in the UI functions are due to the fact that the panel custom data is now passed around as a single pointer instead of being created again for every panel. The list_index variable in Panel.runtime is removed as it's now unnecessary. Differential Revision: https://developer.blender.org/D8559
Diffstat (limited to 'source/blender/modifiers/intern/MOD_ocean.c')
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c123
1 files changed, 57 insertions, 66 deletions
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index 7b31886a220..ccd105f8f69 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -546,169 +546,160 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
return result;
}
// #define WITH_OCEANSIM
-static void panel_draw(const bContext *C, Panel *panel)
+static void panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
#ifdef WITH_OCEANSIM
uiLayout *col, *sub;
- PointerRNA ptr;
PointerRNA ob_ptr;
- modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
- uiItemR(col, &ptr, "geometry_mode", 0, NULL, ICON_NONE);
- if (RNA_enum_get(&ptr, "geometry_mode") == MOD_OCEAN_GEOM_GENERATE) {
+ uiItemR(col, ptr, "geometry_mode", 0, NULL, ICON_NONE);
+ if (RNA_enum_get(ptr, "geometry_mode") == MOD_OCEAN_GEOM_GENERATE) {
sub = uiLayoutColumn(col, true);
- uiItemR(sub, &ptr, "repeat_x", 0, IFACE_("Repeat X"), ICON_NONE);
- uiItemR(sub, &ptr, "repeat_y", 0, IFACE_("Y"), ICON_NONE);
+ uiItemR(sub, ptr, "repeat_x", 0, IFACE_("Repeat X"), ICON_NONE);
+ uiItemR(sub, ptr, "repeat_y", 0, IFACE_("Y"), ICON_NONE);
}
sub = uiLayoutColumn(col, true);
- uiItemR(sub, &ptr, "viewport_resolution", 0, IFACE_("Resolution Viewport"), ICON_NONE);
- uiItemR(sub, &ptr, "resolution", 0, IFACE_("Render"), ICON_NONE);
+ uiItemR(sub, ptr, "viewport_resolution", 0, IFACE_("Resolution Viewport"), ICON_NONE);
+ uiItemR(sub, ptr, "resolution", 0, IFACE_("Render"), ICON_NONE);
- uiItemR(col, &ptr, "time", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "time", 0, NULL, ICON_NONE);
- uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE);
- uiItemR(col, &ptr, "size", 0, NULL, ICON_NONE);
- uiItemR(col, &ptr, "spatial_size", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "depth", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "spatial_size", 0, NULL, ICON_NONE);
- uiItemR(col, &ptr, "random_seed", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "random_seed", 0, NULL, ICON_NONE);
- uiItemR(col, &ptr, "use_normals", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "use_normals", 0, NULL, ICON_NONE);
- modifier_panel_end(layout, &ptr);
+ modifier_panel_end(layout, ptr);
#else /* WITH_OCEANSIM */
uiItemL(layout, IFACE_("Built without Ocean modifier"), ICON_NONE);
- UNUSED_VARS(C);
#endif /* WITH_OCEANSIM */
}
#ifdef WITH_OCEANSIM
-static void waves_panel_draw(const bContext *C, Panel *panel)
+static void waves_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col, *sub;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
- uiItemR(col, &ptr, "wave_scale", 0, IFACE_("Scale"), ICON_NONE);
- uiItemR(col, &ptr, "wave_scale_min", 0, NULL, ICON_NONE);
- uiItemR(col, &ptr, "choppiness", 0, NULL, ICON_NONE);
- uiItemR(col, &ptr, "wind_velocity", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "wave_scale", 0, IFACE_("Scale"), ICON_NONE);
+ uiItemR(col, ptr, "wave_scale_min", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "choppiness", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "wind_velocity", 0, NULL, ICON_NONE);
uiItemS(layout);
col = uiLayoutColumn(layout, false);
- uiItemR(col, &ptr, "wave_alignment", UI_ITEM_R_SLIDER, 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);
- uiItemR(sub, &ptr, "damping", 0, NULL, ICON_NONE);
+ uiLayoutSetActive(sub, RNA_float_get(ptr, "wave_alignment") > 0.0f);
+ uiItemR(sub, ptr, "wave_direction", 0, IFACE_("Direction"), ICON_NONE);
+ uiItemR(sub, ptr, "damping", 0, NULL, ICON_NONE);
}
-static void foam_panel_draw_header(const bContext *C, Panel *panel)
+static void foam_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
- uiItemR(layout, &ptr, "use_foam", 0, IFACE_("Foam"), ICON_NONE);
+ uiItemR(layout, ptr, "use_foam", 0, IFACE_("Foam"), ICON_NONE);
}
-static void foam_panel_draw(const bContext *C, Panel *panel)
+static void foam_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
- bool use_foam = RNA_boolean_get(&ptr, "use_foam");
+ bool use_foam = RNA_boolean_get(ptr, "use_foam");
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, use_foam);
- uiItemR(col, &ptr, "foam_layer_name", 0, IFACE_("Data Layer"), ICON_NONE);
- uiItemR(col, &ptr, "foam_coverage", 0, IFACE_("Coverage"), ICON_NONE);
+ uiItemR(col, ptr, "foam_layer_name", 0, IFACE_("Data Layer"), ICON_NONE);
+ uiItemR(col, ptr, "foam_coverage", 0, IFACE_("Coverage"), ICON_NONE);
}
-static void spray_panel_draw_header(const bContext *C, Panel *panel)
+static void spray_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *row;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
- bool use_foam = RNA_boolean_get(&ptr, "use_foam");
+ bool use_foam = RNA_boolean_get(ptr, "use_foam");
row = uiLayoutRow(layout, false);
uiLayoutSetActive(row, use_foam);
- uiItemR(row, &ptr, "use_spray", 0, IFACE_("Spray"), ICON_NONE);
+ uiItemR(row, ptr, "use_spray", 0, IFACE_("Spray"), ICON_NONE);
}
-static void spray_panel_draw(const bContext *C, Panel *panel)
+static void spray_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
- bool use_foam = RNA_boolean_get(&ptr, "use_foam");
- bool use_spray = RNA_boolean_get(&ptr, "use_spray");
+ bool use_foam = RNA_boolean_get(ptr, "use_foam");
+ bool use_spray = RNA_boolean_get(ptr, "use_spray");
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, use_foam && use_spray);
- uiItemR(col, &ptr, "spray_layer_name", 0, IFACE_("Data Layer"), ICON_NONE);
- uiItemR(col, &ptr, "invert_spray", 0, IFACE_("Invert"), ICON_NONE);
+ uiItemR(col, ptr, "spray_layer_name", 0, IFACE_("Data Layer"), ICON_NONE);
+ uiItemR(col, ptr, "invert_spray", 0, IFACE_("Invert"), ICON_NONE);
}
-static void spectrum_panel_draw(const bContext *C, Panel *panel)
+static void spectrum_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
- int spectrum = RNA_enum_get(&ptr, "spectrum");
+ int spectrum = RNA_enum_get(ptr, "spectrum");
uiLayoutSetPropSep(layout, true);
col = uiLayoutColumn(layout, false);
- uiItemR(col, &ptr, "spectrum", 0, NULL, ICON_NONE);
+ 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", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
- uiItemR(col, &ptr, "fetch_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);
}
}
-static void bake_panel_draw(const bContext *C, Panel *panel)
+static void bake_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
uiLayout *col;
uiLayout *layout = panel->layout;
- PointerRNA ptr;
- modifier_panel_get_property_pointers(C, panel, NULL, &ptr);
+ PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
uiLayoutSetPropSep(layout, true);
- bool is_cached = RNA_boolean_get(&ptr, "is_cached");
- bool use_foam = RNA_boolean_get(&ptr, "use_foam");
+ bool is_cached = RNA_boolean_get(ptr, "is_cached");
+ bool use_foam = RNA_boolean_get(ptr, "use_foam");
if (is_cached) {
PointerRNA op_ptr;
@@ -726,16 +717,16 @@ static void bake_panel_draw(const bContext *C, Panel *panel)
uiItemO(layout, NULL, ICON_NONE, "OBJECT_OT_ocean_bake");
}
- uiItemR(layout, &ptr, "filepath", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "filepath", 0, NULL, ICON_NONE);
col = uiLayoutColumn(layout, true);
uiLayoutSetEnabled(col, !is_cached);
- uiItemR(col, &ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE);
- uiItemR(col, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
+ uiItemR(col, ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE);
+ uiItemR(col, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
col = uiLayoutColumn(layout, false);
uiLayoutSetActive(col, use_foam);
- uiItemR(col, &ptr, "bake_foam_fade", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "bake_foam_fade", 0, NULL, ICON_NONE);
}
#endif /* WITH_OCEANSIM */