Physics: Show texture properties tab when fluid modifier uses texture
Investigation into #126306 showed that the texture tab shown would actually be for the active image paint brush, but people used it to set up a texture for the fluid modifier settings anyway. Now properly register the texture user for the UI, so the texture properties tab will always be displayed when there is a fluid modifier with a "Flow" fluid type. Main issue is that fluid modifiers weren't handled by the `BKE_modifiers_foreach_tex_link()` iterator. While this could be handled as another special case in `buttons_texture_modifier_foreach()`, I updated the texture-link iterators to support texture properties that are not directly stored in the modifier, but in some nested data. Seems like this should be supported generally. It's enabled here by passing a pointer-property pair, rather than just a property name. Pull Request: https://projects.blender.org/blender/blender/pulls/126893
This commit is contained in:
committed by
Julian Eisel
parent
c9f147d301
commit
48208ab2d8
@@ -32,6 +32,8 @@ struct Main;
|
||||
struct Mesh;
|
||||
struct ModifierData;
|
||||
struct Object;
|
||||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
struct Scene;
|
||||
struct StructRNA;
|
||||
struct IDCacheKey;
|
||||
@@ -127,7 +129,11 @@ enum ModifierTypeFlag {
|
||||
ENUM_OPERATORS(ModifierTypeFlag, eModifierTypeFlag_AcceptsGreasePencil)
|
||||
|
||||
using IDWalkFunc = void (*)(void *user_data, Object *ob, ID **idpoin, int cb_flag);
|
||||
using TexWalkFunc = void (*)(void *user_data, Object *ob, ModifierData *md, const char *propname);
|
||||
using TexWalkFunc = void (*)(void *user_data,
|
||||
Object *ob,
|
||||
ModifierData *md,
|
||||
const PointerRNA *ptr,
|
||||
PropertyRNA *texture_prop);
|
||||
|
||||
enum ModifierApplyFlag {
|
||||
/** Render time. */
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "DNA_ID.h"
|
||||
#include "DNA_brush_types.h"
|
||||
#include "DNA_linestyle_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_object_force_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
@@ -211,7 +212,8 @@ static void buttons_texture_modifier_geonodes_users_add(
|
||||
static void buttons_texture_modifier_foreach(void *user_data,
|
||||
Object *ob,
|
||||
ModifierData *md,
|
||||
const char *propname)
|
||||
const PointerRNA *ptr,
|
||||
PropertyRNA *texture_prop)
|
||||
{
|
||||
ListBase *users = static_cast<ListBase *>(user_data);
|
||||
|
||||
@@ -223,13 +225,10 @@ static void buttons_texture_modifier_foreach(void *user_data,
|
||||
}
|
||||
}
|
||||
else {
|
||||
PropertyRNA *prop;
|
||||
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
prop = RNA_struct_find_property(&ptr, propname);
|
||||
const ModifierTypeInfo *modifier_type = BKE_modifier_get_info((ModifierType)md->type);
|
||||
|
||||
buttons_texture_user_property_add(
|
||||
users, &ob->id, ptr, prop, N_("Modifiers"), RNA_struct_ui_icon(ptr.type), md->name);
|
||||
users, &ob->id, *ptr, texture_prop, N_("Modifiers"), modifier_type->icon, md->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/)
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "BKE_lib_query.hh"
|
||||
#include "BKE_modifier.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
|
||||
#include "UI_interface.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
@@ -207,6 +209,18 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
}
|
||||
}
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
FluidModifierData *fmd = (FluidModifierData *)md;
|
||||
|
||||
if (fmd->type == MOD_FLUID_TYPE_FLOW && fmd->flow) {
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_FluidFlowSettings, fmd->flow);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "noise_texture");
|
||||
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
@@ -250,7 +264,7 @@ ModifierTypeInfo modifierType_Fluid = {
|
||||
/*depends_on_time*/ depends_on_time,
|
||||
/*depends_on_normals*/ nullptr,
|
||||
/*foreach_ID_link*/ foreach_ID_link,
|
||||
/*foreach_tex_link*/ nullptr,
|
||||
/*foreach_tex_link*/ foreach_tex_link,
|
||||
/*free_runtime_data*/ nullptr,
|
||||
/*panel_register*/ panel_register,
|
||||
/*blend_write*/ nullptr,
|
||||
|
||||
@@ -277,7 +277,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "RE_texture.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.hh"
|
||||
|
||||
#include "BLI_math_vector.h"
|
||||
@@ -76,7 +77,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static bool depends_on_time(Scene * /*scene*/, ModifierData *md)
|
||||
|
||||
@@ -129,7 +129,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
||||
|
||||
@@ -64,7 +64,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
||||
|
||||
@@ -113,7 +113,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "mask_texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "mask_texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "UI_interface.hh"
|
||||
#include "UI_resources.hh"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_prototypes.hh"
|
||||
|
||||
#include "DEG_depsgraph_build.hh"
|
||||
@@ -158,7 +159,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "mask_texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "mask_texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
||||
|
||||
@@ -369,7 +369,9 @@ static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void
|
||||
|
||||
static void foreach_tex_link(ModifierData *md, Object *ob, TexWalkFunc walk, void *user_data)
|
||||
{
|
||||
walk(user_data, ob, md, "mask_texture");
|
||||
PointerRNA ptr = RNA_pointer_create(&ob->id, &RNA_Modifier, md);
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, "mask_texture");
|
||||
walk(user_data, ob, md, &ptr, prop);
|
||||
}
|
||||
|
||||
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
||||
|
||||
Reference in New Issue
Block a user