这篇教程C++ GET_INT_FROM_POINTER函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GET_INT_FROM_POINTER函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_INT_FROM_POINTER函数的具体用法?C++ GET_INT_FROM_POINTER怎么用?C++ GET_INT_FROM_POINTER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GET_INT_FROM_POINTER函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fmod_envelope_deletepoint_cb// TODO: should we have a separate file for things like this?static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void *ind_v){ FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; int index = GET_INT_FROM_POINTER(ind_v); /* check that no data exists for the current frame... */ if (env->totvert > 1) { /* allocate a new smaller array */ fedn = MEM_callocN(sizeof(FCM_EnvelopeData) * (env->totvert - 1), "FCM_EnvelopeData"); memcpy(fedn, env->data, sizeof(FCM_EnvelopeData) * (index)); memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData) * ((env->totvert - index) - 1)); /* free old array, and set the new */ MEM_freeN(env->data); env->data = fedn; env->totvert--; } else { /* just free array, since the only vert was deleted */ if (env->data) { MEM_freeN(env->data); env->data = NULL; } env->totvert = 0; }}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:29,
示例2: Color_channel_hsv_setstatic int Color_channel_hsv_set(ColorObject *self, PyObject *value, void *type){ float hsv[3]; int i = GET_INT_FROM_POINTER(type); float f = PyFloat_AsDouble(value); if (f == -1 && PyErr_Occurred()) { PyErr_SetString(PyExc_TypeError, "color.h/s/v = value: " "assigned value not a number"); return -1; } if (BaseMath_ReadCallback(self) == -1) return -1; rgb_to_hsv_v(self->col, hsv); CLAMP(f, 0.0f, 1.0f); hsv[i] = f; hsv_to_rgb_v(hsv, self->col); if (BaseMath_WriteCallback(self) == -1) return -1; return 0;}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:26,
示例3: BPy_BMLayerCollection_CreatePyObjectstatic PyObject *bpy_bmlayeraccess_collection_get(BPy_BMLayerAccess *self, void *flag){ const int type = (int)GET_INT_FROM_POINTER(flag); BPY_BM_CHECK_OBJ(self); return BPy_BMLayerCollection_CreatePyObject(self->bm, self->htype, type);}
开发者ID:wchargin,项目名称:blender,代码行数:8,
示例4: BM_elem_cb_check_hflag_exbool BM_elem_cb_check_hflag_ex(BMElem *ele, void *user_data){ const uint hflag_pair = GET_INT_FROM_POINTER(user_data); const char hflag_p = (hflag_pair & 0xff); const char hflag_n = (hflag_pair >> 8); return ((BM_elem_flag_test(ele, hflag_p) != 0) && (BM_elem_flag_test(ele, hflag_n) == 0));}
开发者ID:mgschwan,项目名称:blensor,代码行数:9,
示例5: node_add_menustatic void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass){ Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree; int nodeclass = GET_INT_FROM_POINTER(arg_nodeclass); int event, compatibility = 0; ntree = snode->nodetree; if (!ntree) { uiItemS(layout); return; } if (ntree->type == NTREE_SHADER) { if (BKE_scene_use_new_shading_nodes(scene)) compatibility = NODE_NEW_SHADING; else compatibility = NODE_OLD_SHADING; } if (nodeclass == NODE_CLASS_GROUP) { bNodeTree *ngroup; uiLayoutSetFunc(layout, do_node_add_group, NULL); /* XXX hack: negative numbers used for empty group types */ if (node_tree_has_type(ntree->type, NODE_GROUP)) uiItemV(layout, IFACE_("New Group"), 0, -NODE_GROUP); uiItemS(layout); for (ngroup = bmain->nodetree.first, event = 0; ngroup; ngroup = ngroup->id.next, ++event) { /* only use group trees */ if (ngroup->type == ntree->type && ngroup->nodetype == NODE_GROUP) { uiItemV(layout, ngroup->id.name + 2, 0, event); } } } else { bNodeType *ntype; uiLayoutSetFunc(layout, do_node_add_static, NULL); for (ntype = ntreeGetType(ntree->type)->node_types.first; ntype; ntype = ntype->next) { if (ntype->nclass == nodeclass && ntype->name) { if (!compatibility || (ntype->compatibility & compatibility)) { uiItemV(layout, IFACE_(ntype->name), 0, ntype->type); } } } }}
开发者ID:danielmarg,项目名称:blender-main,代码行数:54,
示例6: GET_INT_FROM_POINTERstatic PyObject *Color_channel_hsv_get(ColorObject *self, void *type){ float hsv[3]; int i = GET_INT_FROM_POINTER(type); if (BaseMath_ReadCallback(self) == -1) return NULL; rgb_to_hsv(self->col[0], self->col[1], self->col[2], &(hsv[0]), &(hsv[1]), &(hsv[2])); return PyFloat_FromDouble(hsv[i]);}
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:12,
示例7: codegen_set_texid/* assign only one texid per buffer to avoid sampling the same texture twice */static void codegen_set_texid(GHash *bindhash, GPUInput *input, int *texid, void *key){ if (BLI_ghash_haskey(bindhash, key)) { /* Reuse existing texid */ input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, key)); } else { /* Allocate new texid */ input->texid = *texid; (*texid)++; input->bindtex = true; BLI_ghash_insert(bindhash, key, SET_INT_IN_POINTER(input->texid)); }}
开发者ID:mcgrathd,项目名称:blender,代码行数:15,
示例8: node_add_menustatic void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass){ Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); bNodeTree *ntree; int nodeclass= GET_INT_FROM_POINTER(arg_nodeclass); int event; ntree = snode->nodetree; if(!ntree) { uiItemS(layout); return; } if (nodeclass==NODE_CLASS_GROUP) { bNodeTree *ngroup; uiLayoutSetFunc(layout, do_node_add_group, NULL); /* XXX hack: negative numbers used for empty group types */ if (node_tree_has_type(ntree->type, NODE_GROUP)) uiItemV(layout, "New Group", 0, -NODE_GROUP); if (node_tree_has_type(ntree->type, NODE_FORLOOP)) uiItemV(layout, "New For Loop", 0, -NODE_FORLOOP); if (node_tree_has_type(ntree->type, NODE_WHILELOOP)) uiItemV(layout, "New While Loop", 0, -NODE_WHILELOOP); uiItemS(layout); for(ngroup=bmain->nodetree.first, event=0; ngroup; ngroup= ngroup->id.next, ++event) { /* only use group trees */ if (ngroup->type==ntree->type && ELEM3(ngroup->nodetype, NODE_GROUP, NODE_FORLOOP, NODE_WHILELOOP)) { uiItemV(layout, ngroup->id.name+2, 0, event); } } } else if (nodeclass==NODE_DYNAMIC) { /* disabled */ } else { bNodeType *ntype; uiLayoutSetFunc(layout, do_node_add_static, NULL); for (ntype=ntreeGetType(ntree->type)->node_types.first; ntype; ntype=ntype->next) { if(ntype->nclass==nodeclass && ntype->name) uiItemV(layout, ntype->name, 0, ntype->type); } }}
开发者ID:xinkang,项目名称:blendocv,代码行数:50,
示例9: bm_log_verts_unmakestatic void bm_log_verts_unmake(BMesh *bm, BMLog *log, GHash *verts){ GHashIterator gh_iter; GHASH_ITER (gh_iter, verts) { void *key = BLI_ghashIterator_getKey(&gh_iter); BMLogVert *lv = BLI_ghashIterator_getValue(&gh_iter); unsigned int id = GET_INT_FROM_POINTER(key); BMVert *v = bm_log_vert_from_id(log, id); /* Ensure the log has the final values of the vertex before * deleting it */ bm_log_vert_bmvert_copy(bm, lv, v); BM_vert_kill(bm, v); }
开发者ID:danielmarg,项目名称:blender-main,代码行数:15,
示例10: bpy_bmvertskin_flag_setstatic int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *flag_p){ const int flag = GET_INT_FROM_POINTER(flag_p); switch (PyC_Long_AsBool(value)) { case true: self->data->flag |= flag; return 0; case false: self->data->flag &= ~flag; return 0; default: /* error is set */ return -1; }}
开发者ID:wchargin,项目名称:blender,代码行数:16,
示例11: bpy_bmvertskin_flag_setstatic int bpy_bmvertskin_flag_set(BPy_BMVertSkin *self, PyObject *value, void *flag_p){ const int flag = GET_INT_FROM_POINTER(flag_p); switch (PyLong_AsLong(value)) { case true: self->data->flag |= flag; return 0; case false: self->data->flag &= ~flag; return 0; default: PyErr_SetString(PyExc_TypeError, "expected a boolean type 0/1"); return -1; }}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:17,
示例12: bpy_app_generic_callback/* the actual callback - not necessarily called from py */void bpy_app_generic_callback(struct Main *UNUSED(main), struct ID *id, void *arg){ PyObject *cb_list = py_cb_array[GET_INT_FROM_POINTER(arg)]; if (PyList_GET_SIZE(cb_list) > 0) { PyGILState_STATE gilstate = PyGILState_Ensure(); PyObject *args = PyTuple_New(1); /* save python creating each call */ PyObject *func; PyObject *ret; Py_ssize_t pos; /* setup arguments */ if (id) { PointerRNA id_ptr; RNA_id_pointer_create(id, &id_ptr); PyTuple_SET_ITEM(args, 0, pyrna_struct_CreatePyObject(&id_ptr)); } else { PyTuple_SET_ITEM(args, 0, Py_INCREF_RET(Py_None)); } /* Iterate the list and run the callbacks * note: don't store the list size since the scripts may remove themselves */ for (pos = 0; pos < PyList_GET_SIZE(cb_list); pos++) { func = PyList_GET_ITEM(cb_list, pos); ret = PyObject_Call(func, args, NULL); if (ret == NULL) { /* Don't set last system variables because they might cause some * dangling pointers to external render engines (when exception * happens during rendering) which will break logic of render pipeline * which expects to be the only user of render engine when rendering * is finished. */ PyErr_PrintEx(0); PyErr_Clear(); } else { Py_DECREF(ret); } } Py_DECREF(args); PyGILState_Release(gilstate); }}
开发者ID:diekev,项目名称:blender,代码行数:47,
示例13: setMPolyMaterialstatic void setMPolyMaterial(ExportMeshData *export_data, MPoly *mpoly, int which_orig_mesh){ Object *orig_object; GHash *material_hash; Material *orig_mat; if (which_orig_mesh == CARVE_MESH_LEFT) { /* No need to change materian index for faces from left operand */ return; } material_hash = export_data->material_hash; orig_object = which_object(export_data, which_orig_mesh); /* Set material, based on lookup in hash table. */ orig_mat = give_current_material(orig_object, mpoly->mat_nr + 1); if (orig_mat) { /* For faces from right operand check if there's requested material * in the left operand. And if it is, use index of that material, * otherwise fallback to first material (material with index=0). */ if (!BLI_ghash_haskey(material_hash, orig_mat)) { int a, mat_nr; mat_nr = 0; for (a = 0; a < export_data->ob_left->totcol; a++) { if (give_current_material(export_data->ob_left, a + 1) == orig_mat) { mat_nr = a; break; } } BLI_ghash_insert(material_hash, orig_mat, SET_INT_IN_POINTER(mat_nr)); mpoly->mat_nr = mat_nr; } else mpoly->mat_nr = GET_INT_FROM_POINTER(BLI_ghash_lookup(material_hash, orig_mat)); } else { mpoly->mat_nr = 0; }}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:46,
示例14: ui_node_linkstatic void ui_node_link(bContext *C, void *arg_p, void *event_p){ NodeLinkArg *arg = (NodeLinkArg *)arg_p; Main *bmain = arg->bmain; bNode *node_to = arg->node; bNodeSocket *sock_to = arg->sock; bNodeTree *ntree = arg->ntree; int event = GET_INT_FROM_POINTER(event_p); if (event == UI_NODE_LINK_DISCONNECT) node_socket_disconnect(bmain, ntree, node_to, sock_to); else if (event == UI_NODE_LINK_REMOVE) node_socket_remove(bmain, ntree, node_to, sock_to); else node_socket_add_replace(C, ntree, node_to, sock_to, arg->node_type->type, &arg->item); ED_undo_push(C, "Node input modify");}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:18,
示例15: DNA_struct_find_nr_ex/** * Returns the index of the struct info for the struct with the specified name. */int DNA_struct_find_nr_ex(const SDNA *sdna, const char *str, unsigned int *index_last){ const short *sp = NULL; if (*index_last < sdna->nr_structs) { sp = sdna->structs[*index_last]; if (strcmp(sdna->types[sp[0]], str) == 0) { return *index_last; } }#ifdef WITH_DNA_GHASH { void **index_p; int a; index_p = BLI_ghash_lookup_p(sdna->structs_map, str); if (index_p) { a = GET_INT_FROM_POINTER(*index_p); *index_last = a; } else { a = -1; } return a; }#else { int a; for (a = 0; a < sdna->nr_structs; a++) { sp = sdna->structs[a]; if (strcmp(sdna->types[sp[0]], str) == 0) { *index_last = a; return a; } } } return -1;#endif}
开发者ID:diekev,项目名称:blender,代码行数:47,
示例16: GET_INT_FROM_POINTERstatic PyObject *bpy_bmloopuv_flag_get(BPy_BMLoopUV *self, void *flag_p){ const int flag = GET_INT_FROM_POINTER(flag_p); return PyBool_FromLong(self->data->flag & flag);}
开发者ID:wchargin,项目名称:blender,代码行数:5,
示例17: BKE_scene_frame_getstatic DerivedMesh *explodeMesh(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, Scene *scene, Object *ob, DerivedMesh *to_explode){ DerivedMesh *explode, *dm = to_explode; MFace *mf = NULL, *mface; /* ParticleSettings *part=psmd->psys->part; */ /* UNUSED */ ParticleSimulationData sim = {NULL}; ParticleData *pa = NULL, *pars = psmd->psys->particles; ParticleKey state, birth; EdgeHash *vertpahash; EdgeHashIterator *ehi; float *vertco = NULL, imat[4][4]; float rot[4]; float cfra; /* float timestep; */ const int *facepa = emd->facepa; int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0; int i, v, u; unsigned int ed_v1, ed_v2, mindex = 0; MTFace *mtface = NULL, *mtf; totface = dm->getNumTessFaces(dm); totvert = dm->getNumVerts(dm); mface = dm->getTessFaceArray(dm); totpart = psmd->psys->totpart; sim.scene = scene; sim.ob = ob; sim.psys = psmd->psys; sim.psmd = psmd; /* timestep = psys_get_timestep(&sim); */ cfra = BKE_scene_frame_get(scene); /* hash table for vertice <-> particle relations */ vertpahash = BLI_edgehash_new(__func__); for (i = 0; i < totface; i++) { if (facepa[i] != totpart) { pa = pars + facepa[i]; if ((pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) || (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) || (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0)) { delface++; continue; } } /* do mindex + totvert to ensure the vertex index to be the first * with BLI_edgehashIterator_getKey */ if (facepa[i] == totpart || cfra < (pars + facepa[i])->time) mindex = totvert + totpart; else mindex = totvert + facepa[i]; mf = &mface[i]; /* set face vertices to exist in particle group */ BLI_edgehash_reinsert(vertpahash, mf->v1, mindex, NULL); BLI_edgehash_reinsert(vertpahash, mf->v2, mindex, NULL); BLI_edgehash_reinsert(vertpahash, mf->v3, mindex, NULL); if (mf->v4) BLI_edgehash_reinsert(vertpahash, mf->v4, mindex, NULL); } /* make new vertice indexes & count total vertices after duplication */ ehi = BLI_edgehashIterator_new(vertpahash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totdup)); totdup++; } BLI_edgehashIterator_free(ehi); /* the final duplicated vertices */ explode = CDDM_from_template_ex(dm, totdup, 0, totface - delface, 0, 0, CD_MASK_DERIVEDMESH | CD_MASK_FACECORNERS); mtface = CustomData_get_layer_named(&explode->faceData, CD_MTFACE, emd->uvname); /*dupvert = CDDM_get_verts(explode);*/ /* getting back to object space */ invert_m4_m4(imat, ob->obmat); psmd->psys->lattice_deform_data = psys_create_lattice_deform_data(&sim); /* duplicate & displace vertices */ ehi = BLI_edgehashIterator_new(vertpahash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { MVert source; MVert *dest; /* get particle + vertex from hash */ BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2); ed_v2 -= totvert; v = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); dm->getVert(dm, ed_v1, &source); dest = CDDM_get_vert(explode, v);//.........这里部分代码省略.........
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:101,
示例18: MEM_callocN//.........这里部分代码省略......... /* count new faces due to splitting */ for (i = 0, fs = facesplit; i < totface; i++, fs++) totfsplit += add_faces[*fs]; splitdm = CDDM_from_template(dm, totesplit, 0, totface + totfsplit, 0, 0); numlayer = CustomData_number_of_layers(&splitdm->faceData, CD_MTFACE); /* copy new faces & verts (is it really this painful with custom data??) */ for (i = 0; i < totvert; i++) { MVert source; MVert *dest; dm->getVert(dm, i, &source); dest = CDDM_get_vert(splitdm, i); DM_copy_vert_data(dm, splitdm, i, i, 1); *dest = source; } /* override original facepa (original pointer is saved in caller function) */ /* BMESH_TODO, (totfsplit * 2) over allocation is used since the quads are * later interpreted as tri's, for this to work right I think we probably * have to stop using tessface - campbell */ facepa = MEM_callocN(sizeof(int) * (totface + (totfsplit * 2)), "explode_facepa"); //memcpy(facepa, emd->facepa, totface*sizeof(int)); emd->facepa = facepa; /* create new verts */ ehi = BLI_edgehashIterator_new(edgehash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2); esplit = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); mv = CDDM_get_vert(splitdm, ed_v2); dupve = CDDM_get_vert(splitdm, esplit); DM_copy_vert_data(splitdm, splitdm, ed_v2, esplit, 1); *dupve = *mv; mv = CDDM_get_vert(splitdm, ed_v1); mid_v3_v3v3(dupve->co, dupve->co, mv->co); } BLI_edgehashIterator_free(ehi); /* create new faces */ curdupface = 0; //=totface; //curdupin=totesplit; for (i = 0, fs = facesplit; i < totface; i++, fs++) { mf = dm->getTessFaceData(dm, i, CD_MFACE); switch (*fs) { case 3: case 10: case 11: case 15: SET_VERTS(1, 2, 3, 4); break; case 5: case 6: case 7: SET_VERTS(2, 3, 4, 1); break; case 9:
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:67,
示例19: edgecut_getstatic int edgecut_get(EdgeHash *edgehash, unsigned int v1, unsigned int v2){ return GET_INT_FROM_POINTER(BLI_edgehash_lookup(edgehash, v1, v2));}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:4,
示例20: loop_syncstatic void loop_sync(bNodeTree *ntree, int sync_in_out){ bNodeSocket *sock, *sync, *nsync, *mirror; ListBase *sync_lb; if (sync_in_out==SOCK_IN) { sock = ntree->outputs.first; sync = ntree->inputs.first; sync_lb = &ntree->inputs; } else { sock = ntree->inputs.first; sync = ntree->outputs.first; sync_lb = &ntree->outputs; } /* NB: the sock->storage pointer is used here directly to store the own_index int * out the mirrored socket counterpart! */ while (sock) { /* skip static and internal sockets on the sync side (preserves socket order!) */ while (sync && ((sync->flag & SOCK_INTERNAL) || !(sync->flag & SOCK_DYNAMIC))) sync = sync->next; if (sync && !(sync->flag & SOCK_INTERNAL) && (sync->flag & SOCK_DYNAMIC)) { if (sock->storage==NULL) { /* if mirror index is 0, the sockets is newly added and a new mirror must be created. */ mirror = node_group_expose_socket(ntree, sock, sync_in_out); /* store the mirror index */ sock->storage = SET_INT_IN_POINTER(mirror->own_index); mirror->storage = SET_INT_IN_POINTER(sock->own_index); /* move mirror to the right place */ BLI_remlink(sync_lb, mirror); if (sync) BLI_insertlinkbefore(sync_lb, sync, mirror); else BLI_addtail(sync_lb, mirror); } else { /* look up the mirror socket */ for (mirror=sync; mirror; mirror=mirror->next) if (mirror->own_index == GET_INT_FROM_POINTER(sock->storage)) break; /* make sure the name is the same (only for identification by user, no deeper meaning) */ BLI_strncpy(mirror->name, sock->name, sizeof(mirror->name)); /* fix the socket order if necessary */ if (mirror != sync) { BLI_remlink(sync_lb, mirror); BLI_insertlinkbefore(sync_lb, sync, mirror); } else sync = sync->next; } } sock = sock->next; } /* remaining sockets in sync_lb are leftovers from deleted sockets, remove them */ while (sync) { nsync = sync->next; if (!(sync->flag & SOCK_INTERNAL) && (sync->flag & SOCK_DYNAMIC)) node_group_remove_socket(ntree, sync, sync_in_out); sync = nsync; }}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:69,
示例21: UNUSED//.........这里部分代码省略......... ok = FALSE; break; } } /* all verts must be available */ if (ok) { BLI_ghash_insert(polyHash, SET_INT_IN_POINTER(i), SET_INT_IN_POINTER(numPolys)); loop_mapping[numPolys] = numLoops; numPolys++; numLoops += mp->totloop; } } /* now we know the number of verts, edges and faces, * we can create the new (reduced) mesh */ result = CDDM_from_template(dm, numVerts, numEdges, 0, numLoops, numPolys); mpoly_new = CDDM_get_polys(result); mloop_new = CDDM_get_loops(result); medge_new = CDDM_get_edges(result); mvert_new = CDDM_get_verts(result); /* using ghash-iterators, map data into new mesh */ /* vertices */ for (hashIter = BLI_ghashIterator_new(vertHash); !BLI_ghashIterator_isDone(hashIter); BLI_ghashIterator_step(hashIter) ) { MVert source; MVert *dest; int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); dm->getVert(dm, oldIndex, &source); dest = &mvert_new[newIndex]; DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); *dest = source; } BLI_ghashIterator_free(hashIter); /* edges */ for (hashIter = BLI_ghashIterator_new(edgeHash); !BLI_ghashIterator_isDone(hashIter); BLI_ghashIterator_step(hashIter)) { MEdge source; MEdge *dest; int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); dm->getEdge(dm, oldIndex, &source); dest = &medge_new[newIndex]; source.v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v1))); source.v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v2))); DM_copy_edge_data(dm, result, oldIndex, newIndex, 1); *dest = source; } BLI_ghashIterator_free(hashIter); /* faces */
开发者ID:danielmarg,项目名称:blender-main,代码行数:67,
示例22: debug_mode_genericstatic int debug_mode_generic(int UNUSED(argc), const char **UNUSED(argv), void *data){ G.debug |= GET_INT_FROM_POINTER(data); return 0;}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:5,
示例23: BKE_mesh_calc_edges/** * Calculate edges from polygons * * /param mesh The mesh to add edges into * /param update When true create new edges co-exist */void BKE_mesh_calc_edges(Mesh *mesh, bool update, const bool select){ CustomData edata; EdgeHashIterator *ehi; MPoly *mp; MEdge *med, *med_orig; EdgeHash *eh = BLI_edgehash_new(); int i, totedge, totpoly = mesh->totpoly; int med_index; /* select for newly created meshes which are selected [#25595] */ const short ed_flag = (ME_EDGEDRAW | ME_EDGERENDER) | (select ? SELECT : 0); if (mesh->totedge == 0) update = false; if (update) { /* assume existing edges are valid * useful when adding more faces and generating edges from them */ med = mesh->medge; for (i = 0; i < mesh->totedge; i++, med++) BLI_edgehash_insert(eh, med->v1, med->v2, med); } /* mesh loops (bmesh only) */ for (mp = mesh->mpoly, i = 0; i < totpoly; mp++, i++) { MLoop *l = &mesh->mloop[mp->loopstart]; int j, l_prev = (l + (mp->totloop - 1))->v; for (j = 0; j < mp->totloop; j++, l++) { if (!BLI_edgehash_haskey(eh, l_prev, l->v)) { BLI_edgehash_insert(eh, l_prev, l->v, NULL); } l_prev = l->v; } } totedge = BLI_edgehash_size(eh); /* write new edges into a temporary CustomData */ CustomData_reset(&edata); CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); med = CustomData_get_layer(&edata, CD_MEDGE); for (ehi = BLI_edgehashIterator_new(eh), i = 0; BLI_edgehashIterator_isDone(ehi) == FALSE; BLI_edgehashIterator_step(ehi), ++i, ++med) { if (update && (med_orig = BLI_edgehashIterator_getValue(ehi))) { *med = *med_orig; /* copy from the original */ } else { BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); med->flag = ed_flag; } /* store the new edge index in the hash value */ BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i)); } BLI_edgehashIterator_free(ehi); if (mesh->totpoly) { /* second pass, iterate through all loops again and assign * the newly created edges to them. */ for (mp = mesh->mpoly, i = 0; i < mesh->totpoly; mp++, i++) { MLoop *l = &mesh->mloop[mp->loopstart]; MLoop *l_prev = (l + (mp->totloop - 1)); int j; for (j = 0; j < mp->totloop; j++, l++) { /* lookup hashed edge index */ med_index = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, l_prev->v, l->v)); l_prev->e = med_index; l_prev = l; } } } /* free old CustomData and assign new one */ CustomData_free(&mesh->edata, mesh->totedge); mesh->edata = edata; mesh->totedge = totedge; mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE); BLI_edgehash_free(eh, NULL);}
开发者ID:244xiao,项目名称:blender,代码行数:90,
示例24: BKE_mesh_validate_arraysint BKE_mesh_validate_arrays(Mesh *mesh, MVert *mverts, unsigned int totvert, MEdge *medges, unsigned int totedge, MFace *mfaces, unsigned int totface, MLoop *mloops, unsigned int totloop, MPoly *mpolys, unsigned int totpoly, MDeformVert *dverts, /* assume totvert length */ const bool do_verbose, const bool do_fixes){# define REMOVE_EDGE_TAG(_me) { _me->v2 = _me->v1; do_edge_free = true; } (void)0# define IS_REMOVED_EDGE(_me) (_me->v2 == _me->v1)# define REMOVE_LOOP_TAG(_ml) { _ml->e = INVALID_LOOP_EDGE_MARKER; do_polyloop_free = true; } (void)0# define REMOVE_POLY_TAG(_mp) { _mp->totloop *= -1; do_polyloop_free = true; } (void)0 MVert *mv = mverts; MEdge *me; MLoop *ml; MPoly *mp; unsigned int i, j; int *v; bool do_edge_free = false; bool do_face_free = false; bool do_polyloop_free = false; /* This regroups loops and polys! */ bool verts_fixed = false; bool vert_weights_fixed = false; bool msel_fixed = false; bool do_edge_recalc = false; EdgeHash *edge_hash = BLI_edgehash_new(); BLI_assert(!(do_fixes && mesh == NULL)); PRINT("%s: verts(%u), edges(%u), loops(%u), polygons(%u)/n", __func__, totvert, totedge, totloop, totpoly); if (totedge == 0 && totpoly != 0) { PRINT("/tLogical error, %u polygons and 0 edges/n", totpoly); do_edge_recalc = do_fixes; } for (i = 1; i < totvert; i++, mv++) { int fix_normal = TRUE; for (j = 0; j < 3; j++) { if (!finite(mv->co[j])) { PRINT("/tVertex %u: has invalid coordinate/n", i); if (do_fixes) { zero_v3(mv->co); verts_fixed = TRUE; } } if (mv->no[j] != 0) fix_normal = FALSE; } if (fix_normal) { PRINT("/tVertex %u: has zero normal, assuming Z-up normal/n", i); if (do_fixes) { mv->no[2] = SHRT_MAX; verts_fixed = TRUE; } } } for (i = 0, me = medges; i < totedge; i++, me++) { int remove = FALSE; if (me->v1 == me->v2) { PRINT("/tEdge %u: has matching verts, both %u/n", i, me->v1); remove = do_fixes; } if (me->v1 >= totvert) { PRINT("/tEdge %u: v1 index out of range, %u/n", i, me->v1); remove = do_fixes; } if (me->v2 >= totvert) { PRINT("/tEdge %u: v2 index out of range, %u/n", i, me->v2); remove = do_fixes; } if (BLI_edgehash_haskey(edge_hash, me->v1, me->v2)) { PRINT("/tEdge %u: is a duplicate of %d/n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, me->v1, me->v2))); remove = do_fixes; } if (remove == FALSE) { BLI_edgehash_insert(edge_hash, me->v1, me->v2, SET_INT_IN_POINTER(i)); } else { REMOVE_EDGE_TAG(me); } }//.........这里部分代码省略.........
开发者ID:244xiao,项目名称:blender,代码行数:101,
示例25: UNUSED//.........这里部分代码省略......... BLI_ghash_insert(edgeHash2, SET_INT_IN_POINTER(edgeMap[i]), SET_INT_IN_POINTER(j)); } } else { int numVerts = numVert_src * frac; if (bmd->randomize) { BLI_array_randomize(vertMap, sizeof(*vertMap), numVert_src, bmd->seed); } /* get the set of all vert indices that will be in the final mesh, * mapped to the new indices */ for (i = 0; i < numVerts; i++) { BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(vertMap[i]), SET_INT_IN_POINTER(i)); } } /* now we know the number of verts, edges and faces, we can create * the mesh */ result = CDDM_from_template(dm, BLI_ghash_size(vertHash), BLI_ghash_size(edgeHash), 0, numLoops_dst, numFaces_dst); /* copy the vertices across */ for (hashIter = BLI_ghashIterator_new(vertHash); BLI_ghashIterator_done(hashIter) == false; BLI_ghashIterator_step(hashIter) ) { MVert source; MVert *dest; int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); source = mvert_src[oldIndex]; dest = CDDM_get_vert(result, newIndex); DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); *dest = source; } BLI_ghashIterator_free(hashIter); /* copy the edges across, remapping indices */ for (i = 0; i < BLI_ghash_size(edgeHash); i++) { MEdge source; MEdge *dest; int oldIndex = GET_INT_FROM_POINTER(BLI_ghash_lookup(edgeHash, SET_INT_IN_POINTER(i))); source = medge_src[oldIndex]; dest = CDDM_get_edge(result, i); source.v1 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v1))); source.v2 = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(source.v2))); DM_copy_edge_data(dm, result, oldIndex, i, 1); *dest = source; } mpoly_dst = CDDM_get_polys(result); /* mloop_dst = */ ml_dst = CDDM_get_loops(result); /* copy the faces across, remapping indices */ k = 0; for (i = 0; i < numFaces_dst; i++) { MPoly *source; MPoly *dest; source = mpoly_src + faceMap[i]; dest = mpoly_dst + i; DM_copy_poly_data(dm, result, faceMap[i], i, 1); *dest = *source; dest->loopstart = k; DM_copy_loop_data(dm, result, source->loopstart, dest->loopstart, dest->totloop); ml_src = mloop_src + source->loopstart; for (j = 0; j < source->totloop; j++, k++, ml_src++, ml_dst++) { ml_dst->v = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(ml_src->v))); ml_dst->e = GET_INT_FROM_POINTER(BLI_ghash_lookup(edgeHash2, SET_INT_IN_POINTER(ml_src->e))); } } BLI_ghash_free(vertHash, NULL, NULL); BLI_ghash_free(edgeHash, NULL, NULL); BLI_ghash_free(edgeHash2, NULL, NULL); MEM_freeN(vertMap); MEM_freeN(edgeMap); MEM_freeN(faceMap); if (dm->dirty & DM_DIRTY_NORMALS) { result->dirty |= DM_DIRTY_NORMALS; } return result;}
开发者ID:244xiao,项目名称:blender,代码行数:101,
示例26: codegen_set_unique_idsstatic void codegen_set_unique_ids(ListBase *nodes){ GHash *bindhash, *definehash; GPUNode *node; GPUInput *input; GPUOutput *output; int id = 1, texid = 0; bindhash= BLI_ghash_ptr_new("codegen_set_unique_ids1 gh"); definehash= BLI_ghash_ptr_new("codegen_set_unique_ids2 gh"); for (node=nodes->first; node; node=node->next) { for (input=node->inputs.first; input; input=input->next) { /* set id for unique names of uniform variables */ input->id = id++; input->bindtex = 0; input->definetex = 0; /* set texid used for settings texture slot with multitexture */ if (codegen_input_has_texture(input) && ((input->source == GPU_SOURCE_TEX) || (input->source == GPU_SOURCE_TEX_PIXEL))) { if (input->link) { /* input is texture from buffer, assign only one texid per * buffer to avoid sampling the same texture twice */ if (!BLI_ghash_haskey(bindhash, input->link)) { input->texid = texid++; input->bindtex = 1; BLI_ghash_insert(bindhash, input->link, SET_INT_IN_POINTER(input->texid)); } else input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->link)); } else if (input->ima) { /* input is texture from image, assign only one texid per * buffer to avoid sampling the same texture twice */ if (!BLI_ghash_haskey(bindhash, input->ima)) { input->texid = texid++; input->bindtex = 1; BLI_ghash_insert(bindhash, input->ima, SET_INT_IN_POINTER(input->texid)); } else input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->ima)); } else if (input->prv) { /* input is texture from preview render, assign only one texid per * buffer to avoid sampling the same texture twice */ if (!BLI_ghash_haskey(bindhash, input->prv)) { input->texid = texid++; input->bindtex = 1; BLI_ghash_insert(bindhash, input->prv, SET_INT_IN_POINTER(input->texid)); } else input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->prv)); } else { if (!BLI_ghash_haskey(bindhash, input->tex)) { /* input is user created texture, check tex pointer */ input->texid = texid++; input->bindtex = 1; BLI_ghash_insert(bindhash, input->tex, SET_INT_IN_POINTER(input->texid)); } else input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->tex)); } /* make sure this pixel is defined exactly once */ if (input->source == GPU_SOURCE_TEX_PIXEL) { if (input->ima) { if (!BLI_ghash_haskey(definehash, input->ima)) { input->definetex = 1; BLI_ghash_insert(definehash, input->ima, SET_INT_IN_POINTER(input->texid)); } } else { if (!BLI_ghash_haskey(definehash, input->link)) { input->definetex = 1; BLI_ghash_insert(definehash, input->link, SET_INT_IN_POINTER(input->texid)); } } } } } for (output=node->outputs.first; output; output=output->next) /* set id for unique names of tmp variables storing output */ output->id = id++; } BLI_ghash_free(bindhash, NULL, NULL); BLI_ghash_free(definehash, NULL, NULL);}
开发者ID:ilent2,项目名称:Blender-Billboard-Modifier,代码行数:92,
注:本文中的GET_INT_FROM_POINTER函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GET_LENGTH函数代码示例 C++ GET_INT函数代码示例 |