这篇教程C++ BLI_addhead函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BLI_addhead函数的典型用法代码示例。如果您正苦于以下问题:C++ BLI_addhead函数的具体用法?C++ BLI_addhead怎么用?C++ BLI_addhead使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BLI_addhead函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: MEM_callocNstatic void *ml_addview_cb(void *base, const char *str){ RenderResult *rr = base; RenderView *rv; rv = MEM_callocN(sizeof(RenderView), "new render view"); BLI_strncpy(rv->name, str, EXR_VIEW_MAXNAME); /* For stereo drawing we need to ensure: * STEREO_LEFT_NAME == STEREO_LEFT_ID and * STEREO_RIGHT_NAME == STEREO_RIGHT_ID */ if (STREQ(str, STEREO_LEFT_NAME)) { BLI_addhead(&rr->views, rv); } else if (STREQ(str, STEREO_RIGHT_NAME)) { RenderView *left_rv = BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name)); if (left_rv == NULL) { BLI_addhead(&rr->views, rv); } else { BLI_insertlinkafter(&rr->views, left_rv, rv); } } else { BLI_addtail(&rr->views, rv); } return rv;}
开发者ID:sntulix,项目名称:blender-api-javascript,代码行数:31,
示例2: BLI_remlinkstatic unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf *ibuf, int tx, int ty){ ImThreadTile *ttile, lookuptile; ImGlobalTile *gtile, *replacetile; int toffs= ibuf->xtiles*ty + tx; /* test if it is already in our thread local cache */ if((ttile=cache->tiles.first)) { /* check last used tile before going to hash */ if(ttile->ibuf == ibuf && ttile->tx == tx && ttile->ty == ty) return ibuf->tiles[toffs]; /* find tile in hash */ lookuptile.ibuf = ibuf; lookuptile.tx = tx; lookuptile.ty = ty; if((ttile=BLI_ghash_lookup(cache->tilehash, &lookuptile))) { BLI_remlink(&cache->tiles, ttile); BLI_addhead(&cache->tiles, ttile); return ibuf->tiles[toffs]; } } /* not found, have to do slow lookup in global cache */ if(cache->unused.first == NULL) { ttile= cache->tiles.last; replacetile= ttile->global; BLI_remlink(&cache->tiles, ttile); BLI_ghash_remove(cache->tilehash, ttile, NULL, NULL); } else { ttile= cache->unused.first; replacetile= NULL; BLI_remlink(&cache->unused, ttile); } BLI_addhead(&cache->tiles, ttile); BLI_ghash_insert(cache->tilehash, ttile, ttile); gtile= imb_global_cache_get_tile(ibuf, tx, ty, replacetile); ttile->ibuf= gtile->ibuf; ttile->tx= gtile->tx; ttile->ty= gtile->ty; ttile->global= gtile; return ibuf->tiles[toffs];}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:50,
示例3: ed_marker_duplicate_apply/* duplicate selected TimeMarkers */static void ed_marker_duplicate_apply(bContext *C, wmOperator *op){ ListBase *markers= context_get_markers(C); TimeMarker *marker, *newmarker; if (markers == NULL) return; /* go through the list of markers, duplicate selected markers and add duplicated copies * to the begining of the list (unselect original markers) */ for (marker= markers->first; marker; marker= marker->next) { if (marker->flag & SELECT) { /* unselect selected marker */ marker->flag &= ~SELECT; /* create and set up new marker */ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); newmarker->flag= SELECT; newmarker->frame= marker->frame; BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name)); /* new marker is added to the begining of list */ BLI_addhead(markers, newmarker); } }}
开发者ID:jinjoh,项目名称:NOOR,代码行数:28,
示例4: group_linkobs2scene_cbstatic void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem){ Group *group = (Group *)tselem->id; GroupObject *gob; Base *base; for (gob = group->gobject.first; gob; gob = gob->next) { base = BKE_scene_base_find(scene, gob->ob); if (base) { base->object->flag |= SELECT; base->flag |= SELECT; } else { /* link to scene */ base = MEM_callocN(sizeof(Base), "add_base"); BLI_addhead(&scene->base, base); base->lay = gob->ob->lay; gob->ob->flag |= SELECT; base->flag = gob->ob->flag; base->object = gob->ob; id_lib_extern((ID *)gob->ob); /* in case these are from a linked group */ } }}
开发者ID:244xiao,项目名称:blender,代码行数:25,
示例5: ed_marker_duplicate_apply/* duplicate selected TimeMarkers */static void ed_marker_duplicate_apply(bContext *C){ ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *newmarker; if (markers == NULL) return; /* go through the list of markers, duplicate selected markers and add duplicated copies * to the beginning of the list (unselect original markers) */ for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { /* unselect selected marker */ marker->flag &= ~SELECT; /* create and set up new marker */ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); newmarker->flag = SELECT; newmarker->frame = marker->frame; BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name)); #ifdef DURIAN_CAMERA_SWITCH newmarker->camera = marker->camera;#endif /* new marker is added to the beginning of list */ // FIXME: bad ordering! BLI_addhead(markers, newmarker); } }}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:33,
示例6: wm_history_file_update/** * Run after saving a file to refresh the #BLENDER_HISTORY_FILE list. */static void wm_history_file_update(void){ RecentFile *recent; /* no write history for recovered startup files */ if (G.main->name[0] == 0) return; recent = G.recent_files.first; /* refresh recent-files.txt of recent opened files, when current file was changed */ if (!(recent) || (BLI_path_cmp(recent->filepath, G.main->name) != 0)) { recent = wm_file_history_find(G.main->name); if (recent) { BLI_remlink(&G.recent_files, recent); } else { RecentFile *recent_next; for (recent = BLI_findlink(&G.recent_files, U.recent_files - 1); recent; recent = recent_next) { recent_next = recent->next; wm_history_file_free(recent); } recent = wm_history_file_new(G.main->name); } /* add current file to the beginning of list */ BLI_addhead(&(G.recent_files), recent); /* write current file to recent-files.txt */ wm_history_file_write(); /* also update most recent files on System */ GHOST_addToSystemRecentFiles(G.main->name); }}
开发者ID:ChunHungLiu,项目名称:blender,代码行数:38,
示例7: wm_keymap_addon_addstatic void wm_keymap_addon_add(wmKeyMap *keymap, wmKeyMap *addonmap){ wmKeyMapItem *kmi, *kmin; for(kmi=addonmap->items.first; kmi; kmi=kmi->next) { kmin = wm_keymap_item_copy(kmi); keymap_item_set_id(keymap, kmin); BLI_addhead(&keymap->items, kmin); }}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:10,
示例8: MEM_callocNBase *BKE_scene_base_add(Scene *sce, Object *ob){ Base *b = MEM_callocN(sizeof(*b), "BKE_scene_base_add"); BLI_addhead(&sce->base, b); b->object = ob; b->flag = ob->flag; b->lay = ob->lay; return b;}
开发者ID:scorpion81,项目名称:blender-voro,代码行数:11,
示例9: BKE_blender_user_menu_findbUserMenu *BKE_blender_user_menu_ensure(ListBase *lb, char space_type, const char *context){ bUserMenu *um = BKE_blender_user_menu_find(lb, space_type, context); if (um == NULL) { um = MEM_callocN(sizeof(bUserMenu), __func__); um->space_type = space_type; STRNCPY(um->context, context); BLI_addhead(lb, um); } return um;}
开发者ID:dfelinto,项目名称:blender,代码行数:11,
示例10: BLF_dir_addvoid BLF_dir_add(const char *path){ DirBLF *dir; dir = blf_dir_find(path); if (dir) /* already in the list ? just return. */ return; dir = (DirBLF *)MEM_callocN(sizeof(DirBLF), "BLF_dir_add"); dir->path = BLI_strdup(path); BLI_addhead(&global_font_dir, dir);}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:12,
示例11: BKE_reportstatic wmKeyMapItem *rna_KeyMap_item_new(wmKeyMap *km, ReportList *reports, const char *idname, int type, int value, bool any, bool shift, bool ctrl, bool alt, bool oskey, int keymodifier, bool head){ /* wmWindowManager *wm = CTX_wm_manager(C); */ wmKeyMapItem *kmi = NULL; char idname_bl[OP_MAX_TYPENAME]; int modifier = 0; /* only on non-modal maps */ if (km->flag & KEYMAP_MODAL) { BKE_report(reports, RPT_ERROR, "Not a non-modal keymap"); return NULL; } WM_operator_bl_idname(idname_bl, idname); if (shift) modifier |= KM_SHIFT; if (ctrl) modifier |= KM_CTRL; if (alt) modifier |= KM_ALT; if (oskey) modifier |= KM_OSKEY; if (any) modifier = KM_ANY; /* create keymap item */ kmi = WM_keymap_add_item(km, idname_bl, type, value, modifier, keymodifier); /* [#32437] allow scripts to define hotkeys that get added to start of keymap * so that they stand a chance against catch-all defines later on */ if (head) { BLI_remlink(&km->items, kmi); BLI_addhead(&km->items, kmi); } return kmi;}
开发者ID:dfelinto,项目名称:blender,代码行数:51,
示例12: task_scheduler_pushstatic void task_scheduler_push(TaskScheduler *scheduler, Task *task, TaskPriority priority){ task_pool_num_increase(task->pool); /* add task to queue */ BLI_mutex_lock(&scheduler->queue_mutex); if (priority == TASK_PRIORITY_HIGH) BLI_addhead(&scheduler->queue, task); else BLI_addtail(&scheduler->queue, task); BLI_condition_notify_one(&scheduler->queue_cond); BLI_mutex_unlock(&scheduler->queue_mutex);}
开发者ID:LucaRood,项目名称:Blender,代码行数:15,
示例13: console_history_cycle_exec/* the python exec operator uses this */static int console_history_cycle_exec(bContext *C, wmOperator *op){ SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevents crashes when no command line */ const bool reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */ int prev_len = ci->len; /* keep a copy of the line above so when history is cycled * this is the only function that needs to know about the double-up */ if (ci->prev) { ConsoleLine *ci_prev = (ConsoleLine *)ci->prev; if (STREQ(ci->line, ci_prev->line)) console_history_free(sc, ci_prev); } if (reverse) { /* last item in history */ ci = sc->history.last; BLI_remlink(&sc->history, ci); BLI_addhead(&sc->history, ci); } else { ci = sc->history.first; BLI_remlink(&sc->history, ci); BLI_addtail(&sc->history, ci); } { /* add a duplicate of the new arg and remove all other instances */ ConsoleLine *cl; while ((cl = console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); console_history_add(sc, (ConsoleLine *)sc->history.last); } ci = sc->history.last; console_select_offset(sc, ci->len - prev_len); /* could be wrapped so update scroll rect */ console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); console_scroll_bottom(ar); return OPERATOR_FINISHED;}
开发者ID:mistajuliax,项目名称:OctaneBlender,代码行数:49,
示例14: memset/* Create a new glyph cache for the current size and dpi. */GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font){ GlyphCacheBLF *gc; gc = (GlyphCacheBLF *)MEM_callocN(sizeof(GlyphCacheBLF), "blf_glyph_cache_new"); gc->next = NULL; gc->prev = NULL; gc->size = font->size; gc->dpi = font->dpi; memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); gc->textures = (GLuint *)MEM_mallocN(sizeof(GLuint) * 256, __func__); gc->ntex = 256; gc->cur_tex = BLF_CURTEX_UNSET; gc->x_offs = 0; gc->y_offs = 0; gc->pad = 3; gc->num_glyphs = (int)font->face->num_glyphs; gc->rem_glyphs = (int)font->face->num_glyphs; gc->ascender = ((float)font->face->size->metrics.ascender) / 64.0f; gc->descender = ((float)font->face->size->metrics.descender) / 64.0f; if (FT_IS_SCALABLE(font->face)) { gc->max_glyph_width = (int)((float)(font->face->bbox.xMax - font->face->bbox.xMin) * (((float)font->face->size->metrics.x_ppem) / ((float)font->face->units_per_EM))); gc->max_glyph_height = (int)((float)(font->face->bbox.yMax - font->face->bbox.yMin) * (((float)font->face->size->metrics.y_ppem) / ((float)font->face->units_per_EM))); } else { gc->max_glyph_width = (int)(((float)font->face->size->metrics.max_advance) / 64.0f); gc->max_glyph_height = (int)(((float)font->face->size->metrics.height) / 64.0f); } gc->p2_width = 0; gc->p2_height = 0; BLI_addhead(&font->cache, gc); return gc;}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:46,
示例15: BLI_mempool_alloc/** * /brief Add a new Walker State * * Allocate a new empty state and put it on the worklist. * A pointer to the new state is returned so that the caller * can fill in the state data. The new state will be inserted * at the front for depth-first walks, and at the end for * breadth-first walks. */void *BMW_state_add(BMWalker *walker){ BMwGenericWalker *newstate; newstate = BLI_mempool_alloc(walker->worklist); newstate->depth = walker->depth; switch (walker->order) { case BMW_DEPTH_FIRST: BLI_addhead(&walker->states, newstate); break; case BMW_BREADTH_FIRST: BLI_addtail(&walker->states, newstate); break; default: BLI_assert(0); break; } return newstate;}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:27,
示例16: writeBlogstatic void writeBlog(void){ struct RecentFile *recent, *next_recent; char name[FILE_MAXDIR+FILE_MAXFILE]; FILE *fp; int i; BLI_make_file_string("/", name, BLI_gethome(), ".Blog"); recent = G.recent_files.first; /* refresh .Blog of recent opened files, when current file was changed */ if(!(recent) || (strcmp(recent->filename, G.sce)!=0)) { fp= fopen(name, "w"); if (fp) { /* add current file to the beginning of list */ recent = (RecentFile*)MEM_mallocN(sizeof(RecentFile),"RecentFile"); recent->filename = (char*)MEM_mallocN(sizeof(char)*(strlen(G.sce)+1), "name of file"); recent->filename[0] = '/0'; strcpy(recent->filename, G.sce); BLI_addhead(&(G.recent_files), recent); /* write current file to .Blog */ fprintf(fp, "%s/n", recent->filename); recent = recent->next; i=1; /* write rest of recent opened files to .Blog */ while((i<U.recent_files) && (recent)){ /* this prevents to have duplicities in list */ if (strcmp(recent->filename, G.sce)!=0) { fprintf(fp, "%s/n", recent->filename); recent = recent->next; } else { next_recent = recent->next; MEM_freeN(recent->filename); BLI_freelinkN(&(G.recent_files), recent); recent = next_recent; } i++; } fclose(fp); } }}
开发者ID:jinjoh,项目名称:NOOR,代码行数:43,
示例17: copy_objectstatic Object *AddNewBlenderMesh(Scene *scene, Base *base){ // This little function adds a new mesh object to the blender object list // It uses ob to duplicate data as this seems to be easier than creating // a new one. This new oject contains no faces nor vertices. Mesh *old_me; Base *basen; Object *ob_new; // now create a new blender object. // duplicating all the settings from the previous object // to the new one. ob_new= copy_object(base->object); // Ok we don't want to use the actual data from the // last object, the above function incremented the // number of users, so decrement it here. old_me= ob_new->data; old_me->id.us--; // Now create a new base to add into the linked list of // vase objects. basen= MEM_mallocN(sizeof(Base), "duplibase"); *basen= *base; BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ basen->object= ob_new; basen->flag &= ~SELECT; // Initialize the mesh data associated with this object. ob_new->data= add_mesh("Mesh"); // Finally assign the object type. ob_new->type= OB_MESH; return ob_new;}
开发者ID:BHCLL,项目名称:blendocv,代码行数:37,
示例18: copy_particle_dupliob_execstatic int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)){ PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; ParticleSettings *part; ParticleDupliWeight *dw; if (!psys) return OPERATOR_CANCELLED; part = psys->part; for (dw=part->dupliweights.first; dw; dw=dw->next) { if (dw->flag & PART_DUPLIW_CURRENT) { dw->flag &= ~PART_DUPLIW_CURRENT; dw = MEM_dupallocN(dw); dw->flag |= PART_DUPLIW_CURRENT; BLI_addhead(&part->dupliweights, dw); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); break; } } return OPERATOR_FINISHED;}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:24,
示例19: blf_glyph_searchGlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c){ FT_GlyphSlot slot; GlyphBLF *g; FT_Error err; FT_Bitmap bitmap, tempbitmap; const bool is_sharp = (U.text_render & USER_TEXT_DISABLE_AA) != 0; int flags = FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; FT_BBox bbox; unsigned int key; g = blf_glyph_search(font->glyph_cache, c); if (g) return g; /* glyphs are dynamically created as needed by font rendering. this means that * to make font rendering thread safe we have to do locking here. note that this * must be a lock for the whole library and not just per font, because the font * renderer uses a shared buffer internally */ BLI_spin_lock(font->ft_lib_mutex); /* search again after locking */ g = blf_glyph_search(font->glyph_cache, c); if (g) { BLI_spin_unlock(font->ft_lib_mutex); return g; } if (font->flags & BLF_HINTING) flags &= ~FT_LOAD_NO_HINTING; if (is_sharp) err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO); else err = FT_Load_Glyph(font->face, (FT_UInt)index, flags); if (err) { BLI_spin_unlock(font->ft_lib_mutex); return NULL; } /* get the glyph. */ slot = font->face->glyph; if (is_sharp) { err = FT_Render_Glyph(slot, FT_RENDER_MODE_MONO); /* Convert result from 1 bit per pixel to 8 bit per pixel */ /* Accum errors for later, fine if not interested beyond "ok vs any error" */ FT_Bitmap_New(&tempbitmap); err += FT_Bitmap_Convert(font->ft_lib, &slot->bitmap, &tempbitmap, 1); /* Does Blender use Pitch 1 always? It works so far */ err += FT_Bitmap_Copy(font->ft_lib, &tempbitmap, &slot->bitmap); err += FT_Bitmap_Done(font->ft_lib, &tempbitmap); } else { err = FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL); } if (err || slot->format != FT_GLYPH_FORMAT_BITMAP) { BLI_spin_unlock(font->ft_lib_mutex); return NULL; } g = (GlyphBLF *)MEM_callocN(sizeof(GlyphBLF), "blf_glyph_add"); g->c = c; g->idx = (FT_UInt)index; g->xoff = -1; g->yoff = -1; bitmap = slot->bitmap; g->width = (int)bitmap.width; g->height = (int)bitmap.rows; if (g->width && g->height) { if (is_sharp) { /* Font buffer uses only 0 or 1 values, Blender expects full 0..255 range */ int i; for (i = 0; i < (g->width * g->height); i++) { bitmap.buffer[i] = bitmap.buffer[i] ? 255 : 0; } } g->bitmap = (unsigned char *)MEM_mallocN((size_t)(g->width * g->height), "glyph bitmap"); memcpy((void *)g->bitmap, (void *)bitmap.buffer, (size_t)(g->width * g->height)); } g->advance = ((float)slot->advance.x) / 64.0f; g->advance_i = (int)g->advance; g->pos_x = (float)slot->bitmap_left; g->pos_y = (float)slot->bitmap_top; g->pitch = slot->bitmap.pitch; FT_Outline_Get_CBox(&(slot->outline), &bbox); g->box.xmin = ((float)bbox.xMin) / 64.0f; g->box.xmax = ((float)bbox.xMax) / 64.0f; g->box.ymin = ((float)bbox.yMin) / 64.0f; g->box.ymax = ((float)bbox.yMax) / 64.0f; key = blf_hash(g->c); BLI_addhead(&(font->glyph_cache->bucket[key]), g);//.........这里部分代码省略.........
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:101,
示例20: bli_builddirstatic void bli_builddir(const char *dirname, const char *relname){ struct dirent *fname; struct dirlink *dlink; int rellen, newnum = 0; char buf[256]; DIR *dir; BLI_strncpy(buf, relname, sizeof(buf)); rellen=strlen(relname); if (rellen) { buf[rellen]='/'; rellen++; }#ifndef WIN32 if (chdir(dirname) == -1) { perror(dirname); return; }#else UTF16_ENCODE(dirname); if (!SetCurrentDirectoryW(dirname_16)) { perror(dirname); free(dirname_16); return; } UTF16_UN_ENCODE(dirname);#endif if ((dir = (DIR *)opendir("."))) { while ((fname = (struct dirent*) readdir(dir)) != NULL) { dlink = (struct dirlink *)malloc(sizeof(struct dirlink)); if (dlink) { BLI_strncpy(buf + rellen, fname->d_name, sizeof(buf) - rellen); dlink->name = BLI_strdup(buf); BLI_addhead(dirbase, dlink); newnum++; } } if (newnum) { if (files) { void *tmp = realloc(files, (totnum+newnum) * sizeof(struct direntry)); if (tmp) { files = (struct direntry *)tmp; } else { /* realloc fail */ free(files); files = NULL; } } if (files==NULL) files=(struct direntry *)malloc(newnum * sizeof(struct direntry)); if (files) { dlink = (struct dirlink *) dirbase->first; while (dlink) { memset(&files[actnum], 0, sizeof(struct direntry)); files[actnum].relname = dlink->name; files[actnum].path = BLI_strdupcat(dirname, dlink->name);// use 64 bit file size, only needed for WIN32 and WIN64. // Excluding other than current MSVC compiler until able to test#ifdef WIN32 {wchar_t * name_16 = alloc_utf16_from_8(dlink->name, 0);#if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500) _wstat64(name_16, &files[actnum].s);#elif defined(__MINGW32__) _stati64(dlink->name, &files[actnum].s);#endif free(name_16);};#else stat(dlink->name, &files[actnum].s);#endif files[actnum].type=files[actnum].s.st_mode; files[actnum].flags = 0; totnum++; actnum++; dlink = dlink->next; } } else { printf("Couldn't get memory for dir/n"); exit(1); } BLI_freelist(dirbase); if (files) qsort(files, actnum, sizeof(struct direntry), (int (*)(const void *, const void*))bli_compare); } else { printf("%s empty directory/n", dirname); } closedir(dir); } else { printf("%s non-existant directory/n", dirname);//.........这里部分代码省略.........
开发者ID:nttputus,项目名称:blensor,代码行数:101,
示例21: bli_builddir/** * Scans the directory named *dirname and appends entries for its contents to files. */static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname){ struct ListBase dirbase = {NULL, NULL}; int newnum = 0; DIR *dir; if ((dir = opendir(dirname)) != NULL) { const struct dirent *fname; while ((fname = readdir(dir)) != NULL) { struct dirlink * const dlink = (struct dirlink *)malloc(sizeof(struct dirlink)); if (dlink != NULL) { dlink->name = BLI_strdup(fname->d_name); BLI_addhead(&dirbase, dlink); newnum++; } } if (newnum) { if (dir_ctx->files) { void * const tmp = realloc(dir_ctx->files, (dir_ctx->nrfiles + newnum) * sizeof(struct direntry)); if (tmp) { dir_ctx->files = (struct direntry *)tmp; } else { /* realloc fail */ free(dir_ctx->files); dir_ctx->files = NULL; } } if (dir_ctx->files == NULL) dir_ctx->files = (struct direntry *)malloc(newnum * sizeof(struct direntry)); if (dir_ctx->files) { struct dirlink * dlink = (struct dirlink *) dirbase.first; struct direntry *file = &dir_ctx->files[dir_ctx->nrfiles]; while (dlink) { char fullname[PATH_MAX]; memset(file, 0, sizeof(struct direntry)); file->relname = dlink->name; file->path = BLI_strdupcat(dirname, dlink->name); BLI_join_dirfile(fullname, sizeof(fullname), dirname, dlink->name);// use 64 bit file size, only needed for WIN32 and WIN64. // Excluding other than current MSVC compiler until able to test#ifdef WIN32 { wchar_t *name_16 = alloc_utf16_from_8(fullname, 0);#if defined(_MSC_VER) && (_MSC_VER >= 1500) _wstat64(name_16, &file->s);#elif defined(__MINGW32__) _stati64(fullname, &file->s);#endif free(name_16); }#else stat(fullname, &file->s);#endif file->type = file->s.st_mode; file->flags = 0; dir_ctx->nrfiles++; file++; dlink = dlink->next; } } else { printf("Couldn't get memory for dir/n"); exit(1); } BLI_freelist(&dirbase); if (dir_ctx->files) { qsort(dir_ctx->files, dir_ctx->nrfiles, sizeof(struct direntry), (int (*)(const void *, const void *))bli_compare); } } else { printf("%s empty directory/n", dirname); } closedir(dir); } else { printf("%s non-existant directory/n", dirname); }}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:89,
示例22: BKE_displist_fill//.........这里部分代码省略......... sf_ctx.poly_nr++; /* make editverts and edges */ f1 = dl->verts; a = dl->nr; sf_vert = sf_vert_new = NULL; while (a--) { sf_vert_last = sf_vert; sf_vert = BLI_scanfill_vert_add(&sf_ctx, f1); totvert++; if (sf_vert_last == NULL) sf_vert_new = sf_vert; else { BLI_scanfill_edge_add(&sf_ctx, sf_vert_last, sf_vert); } f1 += 3; } if (sf_vert != NULL && sf_vert_new != NULL) { BLI_scanfill_edge_add(&sf_ctx, sf_vert, sf_vert_new); } } else if (colnr < dl->col) { /* got poly with next material at current char */ cont = 1; nextcol = 1; } } dl_flag_accum |= dl->flag; } dl = dl->next; } /* XXX (obedit && obedit->actcol) ? (obedit->actcol - 1) : 0)) { */ if (totvert && (tot = BLI_scanfill_calc_ex(&sf_ctx, scanfill_flag, normal_proj))) { if (tot) { dlnew = MEM_callocN(sizeof(DispList), "filldisplist"); dlnew->type = DL_INDEX3; dlnew->flag = (dl_flag_accum & (DL_BACK_CURVE | DL_FRONT_CURVE)); dlnew->col = colnr; dlnew->nr = totvert; dlnew->parts = tot; dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex"); dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts"); /* vert data */ f1 = dlnew->verts; totvert = 0; for (sf_vert = sf_ctx.fillvertbase.first; sf_vert; sf_vert = sf_vert->next) { copy_v3_v3(f1, sf_vert->co); f1 += 3; /* index number */ sf_vert->tmp.i = totvert; totvert++; } /* index data */ index = dlnew->index; for (sf_tri = sf_ctx.fillfacebase.first; sf_tri; sf_tri = sf_tri->next) { index[0] = sf_tri->v1->tmp.i; index[1] = sf_tri->v2->tmp.i; index[2] = sf_tri->v3->tmp.i; if (flipnormal) SWAP(int, index[0], index[2]); index += 3; } } BLI_addhead(to, dlnew); } BLI_scanfill_end_arena(&sf_ctx, sf_arena); if (nextcol) { /* stay at current char but fill polys with next material */ colnr++; } else { /* switch to next char and start filling from first material */ charidx++; colnr = 0; } } BLI_memarena_free(sf_arena); /* do not free polys, needed for wireframe display */}
开发者ID:mgschwan,项目名称:blensor,代码行数:101,
示例23: BLI_mutex_lockstatic ImGlobalTile *imb_global_cache_get_tile(ImBuf *ibuf, int tx, int ty, ImGlobalTile *replacetile){ ImGlobalTile *gtile, lookuptile; BLI_mutex_lock(&GLOBAL_CACHE.mutex); if(replacetile) replacetile->refcount--; /* find tile in global cache */ lookuptile.ibuf = ibuf; lookuptile.tx = tx; lookuptile.ty = ty; gtile= BLI_ghash_lookup(GLOBAL_CACHE.tilehash, &lookuptile); if(gtile) { /* found tile. however it may be in the process of being loaded by another thread, in that case we do stupid busy loop waiting for the other thread to load the tile */ gtile->refcount++; BLI_mutex_unlock(&GLOBAL_CACHE.mutex); while(gtile->loading) ; } else { /* not found, let's load it from disk */ /* first check if we hit the memory limit */ if(GLOBAL_CACHE.maxmem && GLOBAL_CACHE.totmem > GLOBAL_CACHE.maxmem) { /* find an existing tile to unload */ for(gtile=GLOBAL_CACHE.tiles.last; gtile; gtile=gtile->prev) if(gtile->refcount == 0 && gtile->loading == 0) break; } if(gtile) { /* found a tile to unload */ imb_global_cache_tile_unload(gtile); BLI_ghash_remove(GLOBAL_CACHE.tilehash, gtile, NULL, NULL); BLI_remlink(&GLOBAL_CACHE.tiles, gtile); } else { /* allocate a new tile or reuse unused */ if(GLOBAL_CACHE.unused.first) { gtile= GLOBAL_CACHE.unused.first; BLI_remlink(&GLOBAL_CACHE.unused, gtile); } else gtile= BLI_memarena_alloc(GLOBAL_CACHE.memarena, sizeof(ImGlobalTile)); } /* setup new tile */ gtile->ibuf= ibuf; gtile->tx= tx; gtile->ty= ty; gtile->refcount= 1; gtile->loading= 1; BLI_ghash_insert(GLOBAL_CACHE.tilehash, gtile, gtile); BLI_addhead(&GLOBAL_CACHE.tiles, gtile); /* mark as being loaded and unlock to allow other threads to load too */ GLOBAL_CACHE.totmem += sizeof(unsigned int)*ibuf->tilex*ibuf->tiley; BLI_mutex_unlock(&GLOBAL_CACHE.mutex); /* load from disk */ imb_global_cache_tile_load(gtile); /* mark as done loading */ gtile->loading= 0; } return gtile;}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:77,
注:本文中的BLI_addhead函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BLI_addtail函数代码示例 C++ BLE_UUID_BLE_ASSIGN函数代码示例 |