static int buttons_context_path_particle(ButsContextPath *path) { Object *ob; ParticleSystem *psys; PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have (pinned) particle settings, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { return 1; } /* if we have an object, get the active particle system */ if (buttons_context_path_object(path)) { ob = path->ptr[path->len - 1].data; if (ob && ob->type == OB_MESH) { psys = psys_get_current(ob); RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]); path->len++; return 1; } } /* no path to a particle system possible */ return 0; }
static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *UNUSED(free)) { Scene *scene = CTX_data_scene(C); Object *ob = (scene->basact) ? scene->basact->object : NULL; #if 0 PTCacheEdit *edit = PE_get_current(scene, ob); ParticleSystem *psys = edit ? edit->psys : NULL; #else /* use this rather than PE_get_current() - because the editing cache is * dependent on the cache being updated which can happen after this UI * draws causing a glitch [#28883] */ ParticleSystem *psys = psys_get_current(ob); #endif if (psys) { if (psys->flag & PSYS_GLOBAL_HAIR) { return particle_edit_disconnected_hair_brush_items; } else { return particle_edit_hair_brush_items; } } return particle_edit_cache_brush_items; }
static void buttons_texture_users_from_context(ListBase *users, const bContext *C, SpaceButs *sbuts) { Scene *scene = NULL; Object *ob = NULL; Material *ma = NULL; Lamp *la = NULL; World *wrld = NULL; Brush *brush = NULL; ID *pinid = sbuts->pinid; bool limited_mode = (sbuts->flag & SB_TEX_USER_LIMITED) != 0; /* get data from context */ if (pinid) { if (GS(pinid->name) == ID_SCE) scene = (Scene *)pinid; else if (GS(pinid->name) == ID_OB) ob = (Object *)pinid; else if (GS(pinid->name) == ID_LA) la = (Lamp *)pinid; else if (GS(pinid->name) == ID_WO) wrld = (World *)pinid; else if (GS(pinid->name) == ID_MA) ma = (Material *)pinid; else if (GS(pinid->name) == ID_BR) brush = (Brush *)pinid; } if (!scene) scene = CTX_data_scene(C); if (!(pinid || pinid == &scene->id)) { ob = (scene->basact) ? scene->basact->object : NULL; wrld = scene->world; brush = BKE_paint_brush(BKE_paint_get_active_from_context(C)); } if (ob && ob->type == OB_LAMP && !la) la = ob->data; if (ob && !ma) ma = give_current_material(ob, ob->actcol); /* fill users */ users->first = users->last = NULL; if (ma && !limited_mode) buttons_texture_users_find_nodetree(users, &ma->id, ma->nodetree, "Material"); if (la && !limited_mode) buttons_texture_users_find_nodetree(users, &la->id, la->nodetree, "Lamp"); if (wrld && !limited_mode) buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, "World"); 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, "Particles", RNA_struct_ui_icon(&RNA_ParticleSettings), psys->name); } } } /* field */ if (ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) { PointerRNA ptr; PropertyRNA *prop; RNA_pointer_create(&ob->id, &RNA_FieldSettings, ob->pd, &ptr); prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &ob->id, ptr, prop, "Fields", ICON_FORCE_TEXTURE, "Texture Field"); } } /* brush */ if (brush) { PointerRNA ptr; PropertyRNA *prop; /* texture */ RNA_pointer_create(&brush->id, &RNA_BrushTextureSlot, &brush->mtex, &ptr); prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &brush->id, ptr, prop, "Brush", ICON_BRUSH_DATA, "Brush"); /* mask texture */ RNA_pointer_create(&brush->id, &RNA_BrushTextureSlot, &brush->mask_mtex, &ptr); prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &brush->id, ptr, prop, "Brush", ICON_BRUSH_DATA, "Brush Mask"); } }
static void buttons_texture_users_from_context(ListBase *users, const bContext *C, SpaceProperties *sbuts) { Scene *scene = NULL; Object *ob = NULL; FreestyleLineStyle *linestyle = NULL; Brush *brush = NULL; ID *pinid = sbuts->pinid; bool limited_mode = (sbuts->flag & SB_TEX_USER_LIMITED) != 0; /* get data from context */ if (pinid) { if (GS(pinid->name) == ID_SCE) { scene = (Scene *)pinid; } else if (GS(pinid->name) == ID_OB) { ob = (Object *)pinid; } else if (GS(pinid->name) == ID_BR) { brush = (Brush *)pinid; } else if (GS(pinid->name) == ID_LS) { linestyle = (FreestyleLineStyle *)pinid; } } if (!scene) { scene = CTX_data_scene(C); } const ID_Type id_type = pinid != NULL ? GS(pinid->name) : -1; if (!pinid || id_type == ID_SCE) { wmWindow *win = CTX_wm_window(C); ViewLayer *view_layer = (win->scene == scene) ? WM_window_get_active_view_layer(win) : BKE_view_layer_default_view(scene); brush = BKE_paint_brush(BKE_paint_get_active_from_context(C)); linestyle = BKE_linestyle_active_from_view_layer(view_layer); ob = OBACT(view_layer); } /* fill users */ BLI_listbase_clear(users); if (linestyle && !limited_mode) { 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); /* grease pencil modifiers */ BKE_gpencil_modifiers_foreachTexLink(ob, buttons_texture_modifier_gpencil_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; PropertyRNA *prop; RNA_pointer_create(&ob->id, &RNA_FieldSettings, ob->pd, &ptr); prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add( users, &ob->id, ptr, prop, N_("Fields"), ICON_FORCE_TEXTURE, IFACE_("Texture Field")); } } /* brush */ if (brush) { PointerRNA ptr; PropertyRNA *prop; /* texture */ RNA_pointer_create(&brush->id, &RNA_BrushTextureSlot, &brush->mtex, &ptr); prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add( users, &brush->id, ptr, prop, N_("Brush"), ICON_BRUSH_DATA, IFACE_("Brush")); /* mask texture */ RNA_pointer_create(&brush->id, &RNA_BrushTextureSlot, &brush->mask_mtex, &ptr); prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add( users, &brush->id, ptr, prop, N_("Brush"), ICON_BRUSH_DATA, IFACE_("Brush Mask")); } }