static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, PointerRNA *fcu_ptr) { FCurve *fcu = fcu_ptr->data; if (fcu->grp) { if (BLI_findindex(&act->groups, fcu->grp) == -1) { BKE_reportf(reports, RPT_ERROR, "F-Curve's action group '%s' not found in action '%s'", fcu->grp->name, act->id.name + 2); return; } action_groups_remove_channel(act, fcu); free_fcurve(fcu); RNA_POINTER_INVALIDATE(fcu_ptr); } else { if (BLI_findindex(&act->curves, fcu) == -1) { BKE_reportf(reports, RPT_ERROR, "F-Curve not found in action '%s'", act->id.name + 2); return; } BLI_remlink(&act->curves, fcu); free_fcurve(fcu); RNA_POINTER_INVALIDATE(fcu_ptr); } }
/* Get the index of the Keying Set provided, for the given Scene */ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks) { int index; /* if no KeyingSet provided, have none */ if (ks == NULL) return 0; /* check if the KeyingSet exists in scene list */ if (scene) { /* get index and if valid, return * - (absolute) Scene KeyingSets are from (>= 1) */ index = BLI_findindex(&scene->keyingsets, ks); if (index != -1) return (index + 1); } /* still here, so try builtins list too * - builtins are from (<= -1) * - none/invalid is (= 0) */ index = BLI_findindex(&builtin_keyingsets, ks); if (index != -1) return -(index + 1); else return 0; }
static char *rna_MetaElement_path(PointerRNA *ptr) { MetaBall *mb = ptr->id.data; MetaElem *ml = ptr->data; int index = -1; if (mb->editelems) index = BLI_findindex(mb->editelems, ml); if (index == -1) index = BLI_findindex(&mb->elems, ml); if (index == -1) return NULL; return BLI_sprintfN("elements[%d]", index); }
int BKE_linestyle_color_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m) { if (BLI_findindex(&linestyle->color_modifiers, m) == -1) return -1; switch (m->type) { case LS_MODIFIER_ALONG_STROKE: MEM_freeN(((LineStyleColorModifier_AlongStroke *)m)->color_ramp); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: MEM_freeN(((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: MEM_freeN(((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp); break; case LS_MODIFIER_MATERIAL: MEM_freeN(((LineStyleColorModifier_Material *)m)->color_ramp); break; case LS_MODIFIER_TANGENT: MEM_freeN(((LineStyleColorModifier_Tangent *)m)->color_ramp); break; case LS_MODIFIER_NOISE: MEM_freeN(((LineStyleColorModifier_Noise *)m)->color_ramp); break; case LS_MODIFIER_CREASE_ANGLE: MEM_freeN(((LineStyleColorModifier_CreaseAngle *)m)->color_ramp); break; case LS_MODIFIER_CURVATURE_3D: MEM_freeN(((LineStyleColorModifier_Curvature_3D *)m)->color_ramp); break; } BLI_freelinkN(&linestyle->color_modifiers, m); return 0; }
int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m) { if (BLI_findindex(&linestyle->thickness_modifiers, m) == -1) return -1; switch (m->type) { case LS_MODIFIER_ALONG_STROKE: curvemapping_free(((LineStyleThicknessModifier_AlongStroke *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: curvemapping_free(((LineStyleThicknessModifier_DistanceFromCamera *)m)->curve); break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: curvemapping_free(((LineStyleThicknessModifier_DistanceFromObject *)m)->curve); break; case LS_MODIFIER_MATERIAL: curvemapping_free(((LineStyleThicknessModifier_Material *)m)->curve); break; case LS_MODIFIER_CALLIGRAPHY: break; case LS_MODIFIER_TANGENT: curvemapping_free(((LineStyleThicknessModifier_Tangent *)m)->curve); break; case LS_MODIFIER_NOISE: break; case LS_MODIFIER_CREASE_ANGLE: break; case LS_MODIFIER_CURVATURE_3D: break; } BLI_freelinkN(&linestyle->thickness_modifiers, m); return 0; }
static void set_vertex_channel(float *channel, float time, struct Scene *scene, struct FluidObject *fobj, int i) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); float *verts; int *tris=NULL, numVerts=0, numTris=0; int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd); int framesize = (3*fobj->numVerts) + 1; int j; if (channel == NULL) return; initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex); /* don't allow mesh to change number of verts in anim sequence */ if (numVerts != fobj->numVerts) { MEM_freeN(channel); channel = NULL; return; } /* fill frame of channel with vertex locations */ for (j=0; j < (3*numVerts); j++) { channel[i*framesize + j] = verts[j]; } channel[i*framesize + framesize-1] = time; MEM_freeN(verts); MEM_freeN(tris); }
bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, const char *name, ImageFormatData *im_format) { NodeImageMultiFile *nimf = node->storage; bNodeSocket *sock = nodeAddSocket(ntree, node, SOCK_IN, "", SOCK_RGBA); /* create format data for the input socket */ NodeImageMultiFileSocket *sockdata = MEM_callocN(sizeof(NodeImageMultiFileSocket), "socket image format"); sock->storage = sockdata; BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path)); ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_'); BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer)); ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_'); if (im_format) { sockdata->format= *im_format; if (BKE_imtype_is_movie(sockdata->format.imtype)) { sockdata->format.imtype= R_IMF_IMTYPE_OPENEXR; } } else BKE_imformat_defaults(&sockdata->format); /* use node data format by default */ sockdata->use_node_format = TRUE; nimf->active_input = BLI_findindex(&node->inputs, sock); return sock; }
/* Remove the given bone-group (expects 'virtual' index (+1 one, used by active_group etc.)) * index might be invalid ( < 1), in which case it will be find from grp. */ void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index) { bPoseChannel *pchan; int idx = index; if (idx < 1) { idx = BLI_findindex(&pose->agroups, grp) + 1; } BLI_assert(idx > 0); /* adjust group references (the trouble of using indices!): * - firstly, make sure nothing references it * - also, make sure that those after this item get corrected */ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->agrp_index == idx) pchan->agrp_index = 0; else if (pchan->agrp_index > idx) pchan->agrp_index--; } /* now, remove it from the pose */ BLI_freelinkN(&pose->agroups, grp); if (pose->active_group >= idx) { const bool has_groups = !BLI_listbase_is_empty(&pose->agroups); pose->active_group--; if (pose->active_group == 0 && has_groups) { pose->active_group = 1; } else if (pose->active_group < 0 || !has_groups) { pose->active_group = 0; } } }
static int rna_GPencil_active_layer_index_get(PointerRNA *ptr) { bGPdata *gpd = (bGPdata *)ptr->id.data; bGPDlayer *gpl = gpencil_layer_getactive(gpd); return BLI_findindex(&gpd->layers, gpl); }
static int tree_element_active_sequence(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { Sequence *seq = (Sequence *) te->directdata; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (set) { /* only check on setting */ if (BLI_findindex(ed->seqbasep, seq) != -1) { if (set == 2) { BKE_sequencer_active_set(scene, NULL); } ED_sequencer_deselect_all(scene); if (set == 2 && seq->flag & SELECT) { seq->flag &= ~SELECT; } else { seq->flag |= SELECT; BKE_sequencer_active_set(scene, seq); } } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); } else { if (ed->act_seq == seq && seq->flag & SELECT) { return 1; } } return(0); }
static uiBlock *ui_block_func_PIE(bContext *UNUSED(C), uiPopupBlockHandle *handle, void *arg_pie) { uiBlock *block; uiPieMenu *pie = arg_pie; int minwidth, width, height; minwidth = 50; block = pie->block_radial; /* in some cases we create the block before the region, * so we set it delayed here if necessary */ if (BLI_findindex(&handle->region->uiblocks, block) == -1) UI_block_region_set(block, handle->region); UI_block_layout_resolve(block, &width, &height); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NUMSELECT); block->minbounds = minwidth; block->bounds = 1; block->mx = 0; block->my = 0; block->bounds_type = UI_BLOCK_BOUNDS_PIE_CENTER; block->pie_data.pie_center_spawned[0] = pie->mx; block->pie_data.pie_center_spawned[1] = pie->my; return pie->block_radial; }
int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *m) { if (BLI_findindex(&linestyle->geometry_modifiers, m) == -1) return -1; BLI_freelinkN(&linestyle->geometry_modifiers, m); return 0; }
void buttons_texture_context_compute(const bContext *C, SpaceProperties *sbuts) { /* gather available texture users in context. runs on every draw of * properties editor, before the buttons are created. */ ButsContextTexture *ct = sbuts->texuser; ID *pinid = sbuts->pinid; if (!ct) { ct = MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); sbuts->texuser = ct; } else { BLI_freelistN(&ct->users); } buttons_texture_users_from_context(&ct->users, C, sbuts); if (pinid && GS(pinid->name) == ID_TE) { ct->user = NULL; ct->texture = (Tex *)pinid; } else { /* set one user as active based on active index */ if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1)) { ct->index = 0; } ct->user = BLI_findlink(&ct->users, ct->index); ct->texture = NULL; if (ct->user) { if (ct->user->ptr.data) { PointerRNA texptr; Tex *tex; /* get texture datablock pointer if it's a property */ texptr = RNA_property_pointer_get(&ct->user->ptr, ct->user->prop); tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL; ct->texture = tex; } else if (ct->user->node && !(ct->user->node->flag & NODE_ACTIVE_TEXTURE)) { ButsTextureUser *user; /* detect change of active texture node in same node tree, in that * case we also automatically switch to the other node */ for (user = ct->users.first; user; user = user->next) { if (user->ntree == ct->user->ntree && user->node != ct->user->node) { if (user->node->flag & NODE_ACTIVE_TEXTURE) { ct->user = user; ct->index = BLI_findindex(&ct->users, user); break; } } } } } } }
static void rna_RenderSlot_clear(ID *id, RenderSlot *slot, ImageUser *iuser) { Image *image = (Image *)id; int index = BLI_findindex(&image->renderslots, slot); BKE_image_clear_renderslot(image, iuser, index); WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, image); }
/* After previewing poses */ static void poselib_preview_cleanup (bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata; Scene *scene= pld->scene; Object *ob= pld->ob; bPose *pose= pld->pose; bArmature *arm= pld->arm; bAction *act= pld->act; TimeMarker *marker= pld->marker; /* redraw the header so that it doesn't show any of our stuff anymore */ ED_area_headerprint(pld->sa, NULL); /* this signal does one recalc on pose, then unlocks, so ESC or edit will work */ pose->flag |= POSE_DO_UNLOCK; /* clear pose if cancelled */ if (pld->state == PL_PREVIEW_CANCEL) { poselib_backup_restore(pld); /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ if ((arm->flag & ARM_DELAYDEFORM)==0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else where_is_pose(scene, ob); } else if (pld->state == PL_PREVIEW_CONFIRM) { /* tag poses as appropriate */ poselib_keytag_pose(C, scene, pld); /* change active pose setting */ act->active_marker= BLI_findindex(&act->markers, marker) + 1; action_set_activemarker(act, marker, NULL); /* Update event for pose and deformation children */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* updates */ if (IS_AUTOKEY_MODE(scene, NORMAL)) { //remake_action_ipos(ob->action); } else where_is_pose(scene, ob); } /* free memory used for backups and searching */ poselib_backup_free_data(pld); BLI_freelistN(&pld->searchp); /* free temp data for operator */ MEM_freeN(pld); op->customdata= NULL; }
/** * Checks that \a vlink is linked into listbase, removing it from there if so. */ bool BLI_remlink_safe(ListBase *listbase, void *vlink) { if (BLI_findindex(listbase, vlink) != -1) { BLI_remlink(listbase, vlink); return true; } else { return false; } }
int BKE_sequence_modifier_remove(Sequence *seq, SequenceModifierData *smd) { if (BLI_findindex(&seq->modifiers, smd) == -1) return FALSE; BLI_remlink(&seq->modifiers, smd); BKE_sequence_modifier_free(smd); return TRUE; }
void text_drawcache_tag_update(SpaceText *st, int full) { /* this happens if text editor ops are caled from python */ if (st == NULL) return; if (st->drawcache) { DrawCache *drawcache = (DrawCache *)st->drawcache; Text *txt = st->text; if (drawcache->update_flag) { /* happens when tagging update from space listener */ /* should do nothing to prevent locally tagged cache be fully recalculated */ return; } if (!full) { int sellno = BLI_findindex(&txt->lines, txt->sell); int curlno = BLI_findindex(&txt->lines, txt->curl); if (curlno < sellno) { drawcache->valid_head = curlno; drawcache->valid_tail = drawcache->nlines - sellno - 1; } else { drawcache->valid_head = sellno; drawcache->valid_tail = drawcache->nlines - curlno - 1; } /* quick cache recalculation is also used in delete operator, * which could merge lines which are adjacent to current selection lines * expand recalculate area to this lines */ if (drawcache->valid_head > 0) drawcache->valid_head--; if (drawcache->valid_tail > 0) drawcache->valid_tail--; } else { drawcache->valid_head = 0; drawcache->valid_tail = 0; } drawcache->update_flag = 1; } }
bool BKE_sequence_modifier_remove(Sequence *seq, SequenceModifierData *smd) { if (BLI_findindex(&seq->modifiers, smd) == -1) return false; BLI_remlink(&seq->modifiers, smd); BKE_sequence_modifier_free(smd); return true; }
int BLI_remlink_safe(ListBase *listbase, void *vlink) { if (BLI_findindex(listbase, vlink) != -1) { BLI_remlink(listbase, vlink); return 1; } else { return 0; } }
static void rna_MaskLayer_active_spline_set(PointerRNA *ptr, PointerRNA value) { MaskLayer *masklay = (MaskLayer *)ptr->data; MaskSpline *spline = (MaskSpline *)value.data; int index = BLI_findindex(&masklay->splines, spline); if (index >= 0) masklay->act_spline = spline; else masklay->act_spline = NULL; }
static void ED_object_shape_key_add(bContext *C, Object *ob, const bool from_mix) { KeyBlock *kb; if ((kb = BKE_object_shapekey_insert(ob, NULL, from_mix))) { Key *key = BKE_key_from_object(ob); /* for absolute shape keys, new keys may not be added last */ ob->shapenr = BLI_findindex(&key->block, kb) + 1; WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } }
int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current) { Key *key = rna_ShapeKey_find_key(id); if (key) { int a = BLI_findindex(&key->block, value.data); if (a != -1) return a; } return current; }
static void rna_NlaStrip_remove(NlaTrack *track, bContext *C, ReportList *reports, NlaStrip *strip) { if(BLI_findindex(&track->strips, strip) == -1) { BKE_reportf(reports, RPT_ERROR, "NLA's Strip '%s' not found in track '%s'", strip->name, track->name); return; } else { free_nlastrip(&track->strips, strip); WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_REMOVED, NULL); } }
void WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi) { if(BLI_findindex(&keymap->items, kmi) != -1) { if(kmi->ptr) { WM_operator_properties_free(kmi->ptr); MEM_freeN(kmi->ptr); } BLI_freelinkN(&keymap->items, kmi); WM_keyconfig_update_tag(keymap, kmi); } }
/** * \note, ideally we can get the area from the context, * there are a few places however where this isn't practical. */ ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc, SpaceLink *sl) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { if (BLI_findindex(&sa->spacedata, sl) != -1) { break; } } return sa; }
static void rna_render_slots_active_set(PointerRNA *ptr, PointerRNA value, struct ReportList *UNUSED(reports)) { Image *image = (Image *)ptr->id.data; if (value.id.data == image) { RenderSlot *slot = (RenderSlot *)value.data; int index = BLI_findindex(&image->renderslots, slot); if (index != -1) image->render_slot = index; } }
static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve *fcu) { if (fcu->grp) { if (BLI_findindex(&act->groups, fcu->grp) == -1) { BKE_reportf(reports, RPT_ERROR, "F-Curve's ActionGroup '%s' not found in action '%s'", fcu->grp->name, act->id.name+2); return; } action_groups_remove_channel(act, fcu); free_fcurve(fcu); } else { if (BLI_findindex(&act->curves, fcu) == -1) { BKE_reportf(reports, RPT_ERROR, "F-Curve not found in action '%s'", act->id.name+2); return; } BLI_remlink(&act->curves, fcu); free_fcurve(fcu); } }
static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr) { Sequence *seq = (Sequence *)te->directdata; if (event == 1) { Scene *scene = (Scene *)scene_ptr; Editing *ed = BKE_sequencer_editing_get(scene, false); if (BLI_findindex(ed->seqbasep, seq) != -1) { ED_sequencer_select_sequence_single(scene, seq, true); } } (void)tselem; }
static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, PointerRNA *masklay_ptr) { MaskLayer *masklay = masklay_ptr->data; if (BLI_findindex(&mask->masklayers, masklay) == -1) { BKE_reportf(reports, RPT_ERROR, "Mask layer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2); return; } BKE_mask_layer_remove(mask, masklay); RNA_POINTER_INVALIDATE(masklay_ptr); WM_main_add_notifier(NC_MASK | NA_EDITED, mask); }