本文整理匯總了C++中GET_INT_FROM_POINTER函數的典型用法代碼示例。如果您正苦於以下問題:C++ GET_INT_FROM_POINTER函數的具體用法?C++ GET_INT_FROM_POINTER怎麽用?C++ GET_INT_FROM_POINTER使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GET_INT_FROM_POINTER函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
}
示例2: Color_channel_hsv_set
static 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;
}
示例3: BPy_BMLayerCollection_CreatePyObject
static 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);
}
示例4: BM_elem_cb_check_hflag_ex
bool 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));
}
示例5: node_add_menu
static 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);
}
}
}
}
}
示例6: GET_INT_FROM_POINTER
static 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]);
}
示例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));
}
}
示例8: node_add_menu
static 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);
}
}
}
示例9: bm_log_verts_unmake
static 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);
}
示例10: bpy_bmvertskin_flag_set
static 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;
}
}
示例11: bpy_bmvertskin_flag_set
static 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;
}
}
示例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);
}
}
示例13: setMPolyMaterial
static 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;
}
}
示例14: ui_node_link
static 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");
}
示例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
}