diff options
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_texture.c')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_texture.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 87cf0e8c9e3..72de7e5c81c 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -46,6 +46,7 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" #include "DNA_object_force.h" +#include "DNA_particle_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -58,6 +59,7 @@ #include "BKE_modifier.h" #include "BKE_node.h" #include "BKE_paint.h" +#include "BKE_particle.h" #include "BKE_scene.h" #ifdef WITH_FREESTYLE # include "BKE_freestyle.h" @@ -96,6 +98,12 @@ bool ED_texture_context_check_lamp(const bContext *C) return (ob && (ob->type == OB_LAMP)); } +bool ED_texture_context_check_particles(const bContext *C) +{ + Object *ob = CTX_data_active_object(C); + return (ob && ob->particlesystem.first); +} + bool ED_texture_context_check_linestyle(const bContext *C) { #ifdef WITH_FREESTYLE @@ -170,6 +178,7 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) bool valid_world = ED_texture_context_check_world(C); bool valid_material = ED_texture_context_check_material(C); bool valid_lamp = ED_texture_context_check_lamp(C); + bool valid_particles = ED_texture_context_check_particles(C); bool valid_linestyle = ED_texture_context_check_linestyle(C); bool valid_others = ED_texture_context_check_others(C); @@ -183,6 +192,9 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) else if ((sbuts->mainb == BCONTEXT_DATA) && valid_lamp) { sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LAMP; } + else if ((sbuts->mainb == BCONTEXT_PARTICLE) && valid_particles) { + sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_PARTICLES; + } else if ((sbuts->mainb == BCONTEXT_RENDER_LAYER) && valid_linestyle) { sbuts->texture_context = sbuts->texture_context_prev = SB_TEXC_LINESTYLE; } @@ -194,6 +206,7 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) (((sbuts->texture_context_prev == SB_TEXC_WORLD) && valid_world) || ((sbuts->texture_context_prev == SB_TEXC_MATERIAL) && valid_material) || ((sbuts->texture_context_prev == SB_TEXC_LAMP) && valid_lamp) || + ((sbuts->texture_context_prev == SB_TEXC_PARTICLES) && valid_particles) || ((sbuts->texture_context_prev == SB_TEXC_LINESTYLE) && valid_linestyle) || ((sbuts->texture_context_prev == SB_TEXC_OTHER) && valid_others))) { @@ -203,6 +216,7 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) else if (((sbuts->texture_context == SB_TEXC_WORLD) && !valid_world) || ((sbuts->texture_context == SB_TEXC_MATERIAL) && !valid_material) || ((sbuts->texture_context == SB_TEXC_LAMP) && !valid_lamp) || + ((sbuts->texture_context == SB_TEXC_PARTICLES) && !valid_particles) || ((sbuts->texture_context == SB_TEXC_LINESTYLE) && !valid_linestyle) || ((sbuts->texture_context == SB_TEXC_OTHER) && !valid_others)) { @@ -214,6 +228,9 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) else if (valid_lamp) { sbuts->texture_context = SB_TEXC_LAMP; } + else if (valid_particles) { + sbuts->texture_context = SB_TEXC_PARTICLES; + } else if (valid_linestyle) { sbuts->texture_context = SB_TEXC_LINESTYLE; } @@ -358,9 +375,31 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, N_("Line Style")); if (ob) { + ParticleSystem *psys = psys_get_current(ob); + MTex *mtex; + int a; + /* modifiers */ modifiers_foreachTexLink(ob, buttons_texture_modifier_foreach, users); + /* particle systems */ + if (psys && !limited_mode) { + for (a = 0; a < MAX_MTEX; a++) { + mtex = psys->part->mtex[a]; + + if (mtex) { + PointerRNA ptr; + PropertyRNA *prop; + + RNA_pointer_create(&psys->part->id, &RNA_ParticleSettingsTextureSlot, mtex, &ptr); + prop = RNA_struct_find_property(&ptr, "texture"); + + buttons_texture_user_property_add(users, &psys->part->id, ptr, prop, N_("Particles"), + RNA_struct_ui_icon(&RNA_ParticleSettings), psys->name); + } + } + } + /* field */ if (ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) { PointerRNA ptr; @@ -490,6 +529,17 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) ct->texture = tex; + if (user->ptr.type == &RNA_ParticleSettingsTextureSlot) { + /* stupid exception for particle systems which still uses influence + * from the old texture system, set the active texture slots as well */ + ParticleSettings *part = user->ptr.id.data; + int a; + + for (a = 0; a < MAX_MTEX; a++) + if (user->ptr.data == part->mtex[a]) + part->texact = a; + } + if (sbuts && tex) sbuts->preview = 1; } |