本文整理匯總了C++中BLI_insertlinkbefore函數的典型用法代碼示例。如果您正苦於以下問題:C++ BLI_insertlinkbefore函數的具體用法?C++ BLI_insertlinkbefore怎麽用?C++ BLI_insertlinkbefore使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了BLI_insertlinkbefore函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: mask_layer_move_exec
static int mask_layer_move_exec(bContext *C, wmOperator *op)
{
Mask *mask = CTX_data_edit_mask(C);
MaskLayer *mask_layer = BLI_findlink(&mask->masklayers, mask->masklay_act);
MaskLayer *mask_layer_other;
int direction = RNA_enum_get(op->ptr, "direction");
if (!mask_layer)
return OPERATOR_CANCELLED;
if (direction == -1) {
mask_layer_other = mask_layer->prev;
if (!mask_layer_other)
return OPERATOR_CANCELLED;
BLI_remlink(&mask->masklayers, mask_layer);
BLI_insertlinkbefore(&mask->masklayers, mask_layer_other, mask_layer);
mask->masklay_act--;
}
else if (direction == 1) {
mask_layer_other = mask_layer->next;
if (!mask_layer_other)
return OPERATOR_CANCELLED;
BLI_remlink(&mask->masklayers, mask_layer);
BLI_insertlinkafter(&mask->masklayers, mask_layer_other, mask_layer);
mask->masklay_act++;
}
return OPERATOR_FINISHED;
}
示例2: strip_modifier_move_exec
static int strip_modifier_move_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Sequence *seq = BKE_sequencer_active_get(scene);
char name[MAX_NAME];
int direction;
SequenceModifierData *smd;
RNA_string_get(op->ptr, "name", name);
direction = RNA_enum_get(op->ptr, "direction");
smd = BKE_sequence_modifier_find_by_name(seq, name);
if (!smd)
return OPERATOR_CANCELLED;
if (direction == SEQ_MODIFIER_MOVE_UP) {
if (smd->prev) {
BLI_remlink(&seq->modifiers, smd);
BLI_insertlinkbefore(&seq->modifiers, smd->prev, smd);
}
}
else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
if (smd->next) {
BLI_remlink(&seq->modifiers, smd);
BLI_insertlinkafter(&seq->modifiers, smd->next, smd);
}
}
BKE_sequence_invalidate_cache(scene, seq);
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
return OPERATOR_FINISHED;
}
示例3: add_marker_to_cfra_elem
/* Adds a marker to list of cfra elems */
static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only_sel)
{
CfraElem *ce, *cen;
/* should this one only be considered if it is selected? */
if ((only_sel) && ((marker->flag & SELECT) == 0))
return;
/* insertion sort - try to find a previous cfra elem */
for (ce = lb->first; ce; ce = ce->next) {
if (ce->cfra == marker->frame) {
/* do because of double keys */
if (marker->flag & SELECT)
ce->sel = marker->flag;
return;
}
else if (ce->cfra > marker->frame) {
break;
}
}
cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem");
if (ce) BLI_insertlinkbefore(lb, ce, cen);
else BLI_addtail(lb, cen);
cen->cfra = marker->frame;
cen->sel = marker->flag;
}
示例4: move_modifier
static void move_modifier(ListBase *lb, LineStyleModifier *modifier, int direction)
{
BLI_remlink(lb, modifier);
if (direction > 0)
BLI_insertlinkbefore(lb, modifier->prev, modifier);
else
BLI_insertlinkafter(lb, modifier->next, modifier);
}
示例5: multiresModifier_join
void multiresModifier_join(Object *ob)
{
Base *base = NULL;
int highest_lvl = 0;
/* First find the highest level of subdivision */
base = FIRSTBASE;
while(base) {
if(TESTBASELIB_BGMODE(v3d, base) && base->object->type==OB_MESH) {
ModifierData *md;
for(md = base->object->modifiers.first; md; md = md->next) {
if(md->type == eModifierType_Multires) {
int totlvl = ((MultiresModifierData*)md)->totlvl;
if(totlvl > highest_lvl)
highest_lvl = totlvl;
/* Ensure that all updates are processed */
multires_force_update(base->object);
}
}
}
base = base->next;
}
/* No multires meshes selected */
if(highest_lvl == 0)
return;
/* Subdivide all the displacements to the highest level */
base = FIRSTBASE;
while(base) {
if(TESTBASELIB_BGMODE(v3d, base) && base->object->type==OB_MESH) {
ModifierData *md = NULL;
MultiresModifierData *mmd = NULL;
for(md = base->object->modifiers.first; md; md = md->next) {
if(md->type == eModifierType_Multires)
mmd = (MultiresModifierData*)md;
}
/* If the object didn't have multires enabled, give it a new modifier */
if(!mmd) {
md = base->object->modifiers.first;
while(md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform)
md = md->next;
mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires);
BLI_insertlinkbefore(&base->object->modifiers, md, mmd);
modifier_unique_name(&base->object->modifiers, mmd);
}
if(mmd)
multiresModifier_subdivide(mmd, base->object, highest_lvl - mmd->totlvl, 0, 0);
}
base = base->next;
}
}
示例6: gp_ui_layer_up_cb
/* move layer up */
static void gp_ui_layer_up_cb(bContext *C, void *gpd_v, void *gpl_v)
{
bGPdata *gpd = gpd_v;
bGPDlayer *gpl = gpl_v;
BLI_remlink(&gpd->layers, gpl);
BLI_insertlinkbefore(&gpd->layers, gpl->prev, gpl);
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
}
示例7: ED_object_gpencil_modifier_move_up
int ED_object_gpencil_modifier_move_up(ReportList *UNUSED(reports),
Object *ob,
GpencilModifierData *md)
{
if (md->prev) {
BLI_remlink(&ob->greasepencil_modifiers, md);
BLI_insertlinkbefore(&ob->greasepencil_modifiers, md->prev, md);
}
return 1;
}
示例8: addedgetoscanvert
static bool addedgetoscanvert(ScanFillVertLink *sc, ScanFillEdge *eed)
{
/* find first edge to the right of eed, and insert eed before that */
ScanFillEdge *ed;
float fac, fac1, x, y;
if (sc->edge_first == NULL) {
sc->edge_first = sc->edge_last = eed;
eed->prev = eed->next = NULL;
return 1;
}
x = eed->v1->xy[0];
y = eed->v1->xy[1];
fac1 = eed->v2->xy[1] - y;
if (fac1 == 0.0f) {
fac1 = 1.0e10f * (eed->v2->xy[0] - x);
}
else {
fac1 = (x - eed->v2->xy[0]) / fac1;
}
for (ed = sc->edge_first; ed; ed = ed->next) {
if (ed->v2 == eed->v2) {
return false;
}
fac = ed->v2->xy[1] - y;
if (fac == 0.0f) {
fac = 1.0e10f * (ed->v2->xy[0] - x);
}
else {
fac = (x - ed->v2->xy[0]) / fac;
}
if (fac > fac1) {
break;
}
}
if (ed) {
BLI_insertlinkbefore((ListBase *)&(sc->edge_first), ed, eed);
}
else {
BLI_addtail((ListBase *)&(sc->edge_first), eed);
}
return true;
}
示例9: MEM_callocN
/* add a new gp-frame to the given layer */
bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
{
bGPDframe *gpf = NULL, *gf = NULL;
short state = 0;
/* error checking (neg frame only if they are not allowed in Blender!) */
if (gpl == NULL)
return NULL;
/* allocate memory for this frame */
gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe");
gpf->framenum = cframe;
/* find appropriate place to add frame */
if (gpl->frames.first) {
for (gf = gpl->frames.first; gf; gf = gf->next) {
/* check if frame matches one that is supposed to be added */
if (gf->framenum == cframe) {
state = -1;
break;
}
/* if current frame has already exceeded the frame to add, add before */
if (gf->framenum > cframe) {
BLI_insertlinkbefore(&gpl->frames, gf, gpf);
state = 1;
break;
}
}
}
/* check whether frame was added successfully */
if (state == -1) {
printf("Error: Frame (%d) existed already for this layer. Using existing frame\n", cframe);
/* free the newly created one, and use the old one instead */
MEM_freeN(gpf);
/* return existing frame instead... */
BLI_assert(gf != NULL);
gpf = gf;
}
else if (state == 0) {
/* add to end then! */
BLI_addtail(&gpl->frames, gpf);
}
/* return frame */
return gpf;
}
示例10: shape_key_move_exec
static int shape_key_move_exec(bContext *C, wmOperator *op)
{
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
int type= RNA_enum_get(op->ptr, "type");
Key *key= ob_get_key(ob);
if(key) {
KeyBlock *kb, *kb_other;
int shapenr_act= ob->shapenr-1;
int shapenr_swap= shapenr_act + type;
kb= BLI_findlink(&key->block, shapenr_act);
if((type==-1 && kb->prev==NULL) || (type==1 && kb->next==NULL)) {
return OPERATOR_CANCELLED;
}
for(kb_other= key->block.first; kb_other; kb_other= kb_other->next) {
if(kb_other->relative == shapenr_act) {
kb_other->relative += type;
}
else if(kb_other->relative == shapenr_swap) {
kb_other->relative -= type;
}
}
if(type==-1) {
/* move back */
kb_other= kb->prev;
BLI_remlink(&key->block, kb);
BLI_insertlinkbefore(&key->block, kb_other, kb);
ob->shapenr--;
}
else {
/* move next */
kb_other= kb->next;
BLI_remlink(&key->block, kb);
BLI_insertlinkafter(&key->block, kb_other, kb);
ob->shapenr++;
}
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
return OPERATOR_FINISHED;
}
示例11: voronoi_insertEvent
static void voronoi_insertEvent(VoronoiProcess *process, VoronoiEvent *event)
{
VoronoiEvent *current_event = process->queue.first;
while (current_event) {
if (current_event->site[1] < event->site[1]) {
break;
}
if (current_event->site[1] == event->site[1]) {
event->site[1] -= VORONOI_EPS;
}
current_event = current_event->next;
}
BLI_insertlinkbefore(&process->queue, current_event, event);
}
示例12: MEM_callocN
/* add a new gp-frame to the given layer */
bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
{
bGPDframe *gpf, *gf;
short state = 0;
/* error checking */
if ((gpl == NULL) || (cframe <= 0))
return NULL;
/* allocate memory for this frame */
gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe");
gpf->framenum = cframe;
/* find appropriate place to add frame */
if (gpl->frames.first) {
for (gf = gpl->frames.first; gf; gf = gf->next) {
/* check if frame matches one that is supposed to be added */
if (gf->framenum == cframe) {
state = -1;
break;
}
/* if current frame has already exceeded the frame to add, add before */
if (gf->framenum > cframe) {
BLI_insertlinkbefore(&gpl->frames, gf, gpf);
state = 1;
break;
}
}
}
/* check whether frame was added successfully */
if (state == -1) {
MEM_freeN(gpf);
printf("Error: frame (%d) existed already for this layer\n", cframe);
}
else if (state == 0) {
/* add to end then! */
BLI_addtail(&gpl->frames, gpf);
}
/* return frame */
return gpf;
}
示例13: sca_move_controller
void sca_move_controller(bController *cont_to_move, Object *ob, int move_up)
{
bController *cont, *tmp;
int val;
val = move_up ? 1 : 2;
/* make sure this controller belongs to this object */
cont= ob->controllers.first;
while (cont) {
if (cont == cont_to_move) break;
cont= cont->next;
}
if (!cont) return;
/* move up */
if (val == 1 && cont->prev) {
/* locate the controller that has the same state mask but is earlier in the list */
tmp = cont->prev;
while (tmp) {
if (tmp->state_mask & cont->state_mask)
break;
tmp = tmp->prev;
}
if (tmp) {
BLI_remlink(&ob->controllers, cont);
BLI_insertlinkbefore(&ob->controllers, tmp, cont);
}
}
/* move down */
else if (val == 2 && cont->next) {
tmp = cont->next;
while (tmp) {
if (tmp->state_mask & cont->state_mask)
break;
tmp = tmp->next;
}
BLI_remlink(&ob->controllers, cont);
BLI_insertlinkafter(&ob->controllers, tmp, cont);
}
}
示例14: wm_keymap_patch
static void wm_keymap_patch(wmKeyMap *km, wmKeyMap *diff_km)
{
wmKeyMapDiffItem *kmdi;
wmKeyMapItem *kmi_remove, *kmi_add;
for(kmdi=diff_km->diff_items.first; kmdi; kmdi=kmdi->next) {
/* find item to remove */
kmi_remove = NULL;
if(kmdi->remove_item) {
kmi_remove = wm_keymap_find_item_equals(km, kmdi->remove_item);
if(!kmi_remove)
kmi_remove = wm_keymap_find_item_equals_result(km, kmdi->remove_item);
}
/* add item */
if(kmdi->add_item) {
/* only if nothing to remove or item to remove found */
if(!kmdi->remove_item || kmi_remove) {
kmi_add = wm_keymap_item_copy(kmdi->add_item);
kmi_add->flag |= KMI_USER_MODIFIED;
if(kmi_remove) {
kmi_add->flag &= ~KMI_EXPANDED;
kmi_add->flag |= (kmi_remove->flag & KMI_EXPANDED);
kmi_add->id = kmi_remove->id;
BLI_insertlinkbefore(&km->items, kmi_remove, kmi_add);
}
else {
keymap_item_set_id(km, kmi_add);
BLI_addtail(&km->items, kmi_add);
}
}
}
/* remove item */
if(kmi_remove) {
wm_keymap_item_free(kmi_remove);
BLI_freelinkN(&km->items, kmi_remove);
}
}
}
示例15: constraint_move_up_exec
static int constraint_move_up_exec (bContext *C, wmOperator *op)
{
PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
Object *ob= ptr.id.data;
bConstraint *con= ptr.data;
if (con->prev) {
ListBase *conlist= get_active_constraints(ob);
bConstraint *prevCon= con->prev;
/* insert the nominated constraint before the one that used to be before it */
BLI_remlink(conlist, con);
BLI_insertlinkbefore(conlist, prevCon, con);
WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
return OPERATOR_CANCELLED;
}