本文整理汇总了C++中BLI_ghash_lookup函数的典型用法代码示例。如果您正苦于以下问题:C++ BLI_ghash_lookup函数的具体用法?C++ BLI_ghash_lookup怎么用?C++ BLI_ghash_lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BLI_ghash_lookup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strand_shade_get
static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert)
{
StrandCacheEntry *entry;
StrandPoint p;
int *refcount;
GHashPair pair = strand_shade_hash_pair(sseg->obi, svert);
entry= BLI_ghash_lookup(cache->resulthash, &pair);
refcount= BLI_ghash_lookup(cache->refcounthash, &pair);
if (!entry) {
/* not shaded yet, shade and insert into hash */
p.t= (sseg->v[1] == svert)? 0.0f: 1.0f;
strand_eval_point(sseg, &p);
strand_shade_point(re, ssamp, sseg, svert, &p);
entry= MEM_callocN(sizeof(StrandCacheEntry), "StrandCacheEntry");
entry->pair = pair;
entry->shr = ssamp->shr[0];
BLI_ghash_insert(cache->resulthash, entry, entry);
}
else
/* already shaded, just copy previous result from hash */
ssamp->shr[0]= entry->shr;
/* lower reference count and remove if not needed anymore by any samples */
(*refcount)--;
if (*refcount == 0) {
BLI_ghash_remove(cache->resulthash, &pair, (GHashKeyFreeFP)MEM_freeN, NULL);
BLI_ghash_remove(cache->refcounthash, &pair, NULL, NULL);
}
}
示例2: if
BME_TransData *BME_assign_transdata(BME_TransData_Head *td, BME_Mesh *bm, BME_Vert *v,
float *co, float *org, float *vec, float *loc,
float factor, float weight, float maxfactor, float *max) {
BME_TransData *vtd;
int is_new = 0;
if (v == NULL) return NULL;
if ((vtd = BLI_ghash_lookup(td->gh, v)) == NULL && bm != NULL) {
vtd = BLI_memarena_alloc(td->ma, sizeof(*vtd));
BLI_ghash_insert(td->gh, v, vtd);
td->len++;
is_new = 1;
}
vtd->bm = bm;
vtd->v = v;
if (co != NULL) VECCOPY(vtd->co,co);
if (org == NULL && is_new) { VECCOPY(vtd->org,v->co); } /* default */
else if (org != NULL) VECCOPY(vtd->org,org);
if (vec != NULL) {
VECCOPY(vtd->vec,vec);
normalize_v3(vtd->vec);
}
vtd->loc = loc;
vtd->factor = factor;
vtd->weight = weight;
vtd->maxfactor = maxfactor;
vtd->max = max;
return vtd;
}
示例3: ghash_insert_link
static bool ghash_insert_link(
GHash *gh, void *key, void *val, bool use_test,
MemArena *mem_arena)
{
struct LinkBase *ls_base;
LinkNode *ls;
ls_base = BLI_ghash_lookup(gh, key);
if (ls_base) {
if (use_test && (BLI_linklist_index(ls_base->list, key) != -1)) {
return false;
}
}
else {
ls_base = BLI_memarena_alloc(mem_arena, sizeof(*ls_base));
ls_base->list = NULL;
ls_base->list_len = 0;
BLI_ghash_insert(gh, key, ls_base);
}
ls = BLI_memarena_alloc(mem_arena, sizeof(*ls));
ls->next = ls_base->list;
ls->link = val;
ls_base->list = ls;
ls_base->list_len += 1;
return true;
}
示例4: BLI_ghash_str_new
bool *BKE_objdef_validmap_get(Object *ob, const int defbase_tot)
{
bDeformGroup *dg;
ModifierData *md;
bool *vgroup_validmap;
GHash *gh;
int i, step1 = 1;
//int defbase_tot = BLI_countlist(&ob->defbase);
if (ob->defbase.first == NULL) {
return NULL;
}
gh = BLI_ghash_str_new("BKE_objdef_validmap_get gh");
/* add all names to a hash table */
for (dg = ob->defbase.first; dg; dg = dg->next) {
BLI_ghash_insert(gh, dg->name, NULL);
}
BLI_assert(BLI_ghash_size(gh) == defbase_tot);
/* now loop through the armature modifiers and identify deform bones */
for (md = ob->modifiers.first; md; md = !md->next && step1 ? (step1 = 0), modifiers_getVirtualModifierList(ob) : md->next) {
if (!(md->mode & (eModifierMode_Realtime | eModifierMode_Virtual)))
continue;
if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *) md;
if (amd->object && amd->object->pose) {
bPose *pose = amd->object->pose;
bPoseChannel *chan;
for (chan = pose->chanbase.first; chan; chan = chan->next) {
if (chan->bone->flag & BONE_NO_DEFORM)
continue;
if (BLI_ghash_remove(gh, chan->name, NULL, NULL)) {
BLI_ghash_insert(gh, chan->name, SET_INT_IN_POINTER(1));
}
}
}
}
}
vgroup_validmap = MEM_mallocN(sizeof(*vgroup_validmap) * defbase_tot, "wpaint valid map");
/* add all names to a hash table */
for (dg = ob->defbase.first, i = 0; dg; dg = dg->next, i++) {
vgroup_validmap[i] = (BLI_ghash_lookup(gh, dg->name) != NULL);
}
BLI_assert(i == BLI_ghash_size(gh));
BLI_ghash_free(gh, NULL, NULL);
return vgroup_validmap;
}
示例5: view_layer_bases_hash_create
Base *BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
{
if (!view_layer->object_bases_hash) {
view_layer_bases_hash_create(view_layer);
}
return BLI_ghash_lookup(view_layer->object_bases_hash, ob);
}
示例6: BLI_ghash_str_new
GPUFunction *GPU_lookup_function(const char *name)
{
if (!FUNCTION_HASH) {
FUNCTION_HASH = BLI_ghash_str_new("GPU_lookup_function gh");
gpu_parse_functions_string(FUNCTION_HASH, glsl_material_library);
}
return (GPUFunction*)BLI_ghash_lookup(FUNCTION_HASH, (void *)name);
}
示例7: BLI_ghash_lookup
static bArgument *lookUp(struct bArgs *ba, const char *arg, int pass, int case_str)
{
bAKey key;
key.case_str = case_str;
key.pass = pass;
key.arg = arg;
return BLI_ghash_lookup(ba->items, &key);
}
示例8: debug_data_insert
static void debug_data_insert(SimDebugData *debug_data, SimDebugElement *elem)
{
SimDebugElement *old_elem = BLI_ghash_lookup(debug_data->gh, elem);
if (old_elem) {
*old_elem = *elem;
MEM_freeN(elem);
}
else
BLI_ghash_insert(debug_data->gh, elem, elem);
}
示例9: BLI_ghash_lookup
/**
* Return a pointer to the pose channel of the given name
* from this pose.
*/
bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
{
if (ELEM(NULL, pose, name) || (name[0] == '\0'))
return NULL;
if (pose->chanhash)
return BLI_ghash_lookup(pose->chanhash, (const void *)name);
return BLI_findstring(&((const bPose *)pose)->chanbase, name, offsetof(bPoseChannel, name));
}
示例10: BLI_ghash_lookup
static ListBase *edge_isect_ls_ensure(GHash *isect_hash, ScanFillEdge *eed)
{
ListBase *e_ls;
e_ls = BLI_ghash_lookup(isect_hash, eed);
if (e_ls == NULL) {
e_ls = MEM_callocN(sizeof(ListBase), __func__);
BLI_ghash_insert(isect_hash, eed, e_ls);
}
return e_ls;
}
示例11: BLI_ghash_str_new
GPUFunction *GPU_lookup_function(const char *name)
{
if (!FUNCTION_HASH) {
FUNCTION_HASH = BLI_ghash_str_new("GPU_lookup_function gh");
gpu_parse_functions_string(FUNCTION_HASH, glsl_material_library);
/*FUNCTION_PROTOTYPES = gpu_generate_function_prototyps(FUNCTION_HASH);
FUNCTION_LIB = GPU_shader_create_lib(datatoc_gpu_shader_material_glsl);*/
}
return (GPUFunction*)BLI_ghash_lookup(FUNCTION_HASH, (void *)name);
}
示例12: BLI_assert
static TseGroup *BKE_outliner_treehash_lookup_group(GHash *th, short type, short nr, struct ID *id)
{
TreeStoreElem tse_template;
tse_template.type = type;
tse_template.nr = type ? nr : 0; // we're picky! :)
tse_template.id = id;
BLI_assert(th);
return BLI_ghash_lookup(th, &tse_template);
}
示例13: BLI_ghash_lookup
Icon *BKE_icon_get(int icon_id)
{
Icon *icon = NULL;
icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
if (!icon) {
printf("%s: Internal error, no icon for icon ID: %d\n", __func__, icon_id);
return NULL;
}
return icon;
}
示例14: BKE_pose_channels_is_valid
bool BKE_pose_channels_is_valid(const bPose *pose)
{
if (pose->chanhash) {
bPoseChannel *pchan;
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
if (BLI_ghash_lookup(pose->chanhash, pchan->name) != pchan) {
return false;
}
}
}
return true;
}
示例15:
static 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];
}