本文整理汇总了C++中RNA_pointer_create函数的典型用法代码示例。如果您正苦于以下问题:C++ RNA_pointer_create函数的具体用法?C++ RNA_pointer_create怎么用?C++ RNA_pointer_create使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RNA_pointer_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ui_node_draw_node
static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, int depth)
{
bNodeSocket *input;
uiLayout *col, *split;
PointerRNA nodeptr;
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
if (node->typeinfo->draw_buttons) {
if (node->type != NODE_GROUP) {
split = uiLayoutSplit(layout, 0.35f, false);
col = uiLayoutColumn(split, false);
col = uiLayoutColumn(split, false);
node->typeinfo->draw_buttons(col, C, &nodeptr);
}
}
for (input = node->inputs.first; input; input = input->next)
ui_node_draw_input(layout, C, ntree, node, input, depth + 1);
}
示例2: operator_wrapper
void operator_wrapper(wmOperatorType *ot, void *userdata)
{
/* take care not to overwrite anything set in
* WM_operatortype_append_ptr before opfunc() is called */
StructRNA *srna = ot->srna;
*ot = *((wmOperatorType *)userdata);
ot->srna = srna; /* restore */
operator_properties_init(ot);
{ /* XXX - not nice, set the first enum as searchable, should have a way for python to set */
PointerRNA ptr;
PropertyRNA *prop;
RNA_pointer_create(NULL, ot->srna, NULL, &ptr);
prop = RNA_struct_find_property(&ptr, "type");
if (prop) {
ot->prop = prop;
}
}
}
示例3: PyErr_Format
PyObject *PYOP_wrap_macro_define(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
PyObject *macro;
PointerRNA ptr_otmacro;
StructRNA *srna;
char *opname;
const char *macroname;
if (!PyArg_ParseTuple(args, "Os:_bpy.ops.macro_define", ¯o, &opname))
return NULL;
if (WM_operatortype_find(opname, TRUE) == NULL) {
PyErr_Format(PyExc_ValueError,
"Macro Define: '%s' is not a valid operator id",
opname);
return NULL;
}
/* identifiers */
srna = srna_from_self(macro, "Macro Define:");
macroname = RNA_struct_identifier(srna);
ot = WM_operatortype_find(macroname, TRUE);
if (!ot) {
PyErr_Format(PyExc_ValueError,
"Macro Define: '%s' is not a valid macro or hasn't been registered yet",
macroname);
return NULL;
}
otmacro = WM_operatortype_macro_define(ot, opname);
RNA_pointer_create(NULL, &RNA_OperatorMacro, otmacro, &ptr_otmacro);
return pyrna_struct_CreatePyObject(&ptr_otmacro);
}
示例4: panel_poll
static int panel_poll(const bContext *C, PanelType *pt)
{
PointerRNA ptr;
ParameterList list;
FunctionRNA *func;
void *ret;
int visible;
RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */
func= RNA_struct_find_function(&ptr, "poll");
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "context", &C);
pt->ext.call((bContext *)C, &ptr, func, &list);
RNA_parameter_get_lookup(&list, "visible", &ret);
visible= *(int*)ret;
RNA_parameter_list_free(&list);
return visible;
}
示例5: pose_calculate_paths_invoke
/* show popup to determine settings */
static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
/* set default settings from existing/stored settings */
{
bAnimVizSettings *avs = &ob->pose->avs;
PointerRNA avs_ptr;
RNA_int_set(op->ptr, "start_frame", avs->path_sf);
RNA_int_set(op->ptr, "end_frame", avs->path_ef);
RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location"));
}
/* show popup dialog to allow editing of range... */
// FIXME: hardcoded dimensions here are just arbitrary
return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y);
}
示例6: ANIM_relative_keyingset_add_source
/* Add new data source for relative Keying Sets */
void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *srna, void *data)
{
tRKS_DSource *ds;
/* sanity checks
* - we must have somewhere to output the data
* - we must have both srna+data (and with id too optionally), or id by itself only
*/
if (dsources == NULL)
return;
if (ELEM(NULL, srna, data) && (id == NULL))
return;
/* allocate new elem, and add to the list */
ds = MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource");
BLI_addtail(dsources, ds);
/* depending on what data we have, create using ID or full pointer call */
if (srna && data)
RNA_pointer_create(id, srna, data, &ds->ptr);
else
RNA_id_pointer_create(id, &ds->ptr);
}
示例7: _PyUnicode_AsString
static PyObject *pyop_getinstance(PyObject *UNUSED(self), PyObject *value)
{
wmOperatorType *ot;
wmOperator *op;
PointerRNA ptr;
const char *opname = _PyUnicode_AsString(value);
BPy_StructRNA *pyrna = NULL;
if (opname == NULL) {
PyErr_SetString(PyExc_TypeError, "_bpy.ops.get_instance() expects a string argument");
return NULL;
}
ot = WM_operatortype_find(opname, true);
if (ot == NULL) {
PyErr_Format(PyExc_KeyError, "_bpy.ops.get_instance(\"%s\") not found", opname);
return NULL;
}
#ifdef PYRNA_FREE_SUPPORT
op = MEM_callocN(sizeof(wmOperator), __func__);
#else
op = PyMem_MALLOC(sizeof(wmOperator));
memset(op, 0, sizeof(wmOperator));
#endif
BLI_strncpy(op->idname, op->idname, sizeof(op->idname)); /* in case its needed */
op->type = ot;
RNA_pointer_create(NULL, &RNA_Operator, op, &ptr);
pyrna = (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ptr);
#ifdef PYRNA_FREE_SUPPORT
pyrna->freeptr = true;
#endif
op->ptr = &pyrna->ptr;
return (PyObject *)pyrna;
}
示例8: actuator_add_exec
static int actuator_add_exec(bContext *C, wmOperator *op)
{
Object *ob;
bActuator *act;
PointerRNA act_ptr;
PropertyRNA *prop;
const char *act_name;
char name[MAX_NAME];
int type = RNA_enum_get(op->ptr, "type");
ob = edit_object_property_get(C, op);
if (!ob)
return OPERATOR_CANCELLED;
act = new_actuator(type);
BLI_addtail(&(ob->actuators), act);
/* set the actuator name based on rna type enum */
RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &act_ptr);
prop = RNA_struct_find_property(&act_ptr, "type");
RNA_string_get(op->ptr, "name", name);
if (*name) {
BLI_strncpy(act->name, name, sizeof(act->name));
}
else {
RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name);
BLI_strncpy(act->name, act_name, sizeof(act->name));
}
make_unique_prop_names(C, act->name);
ob->scaflag |= OB_SHOWACT;
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
}
示例9: sensor_add_exec
static int sensor_add_exec(bContext *C, wmOperator *op)
{
Object *ob;
bSensor *sens;
PointerRNA sens_ptr;
PropertyRNA *prop;
const char *sens_name;
char name[MAX_NAME];
int type = RNA_enum_get(op->ptr, "type");
ob = edit_object_property_get(C, op);
if (!ob)
return OPERATOR_CANCELLED;
sens = new_sensor(type);
BLI_addtail(&(ob->sensors), sens);
/* set the sensor name based on rna type enum */
RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &sens_ptr);
prop = RNA_struct_find_property(&sens_ptr, "type");
RNA_string_get(op->ptr, "name", name);
if (*name) {
BLI_strncpy(sens->name, name, sizeof(sens->name));
}
else {
RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name);
BLI_strncpy(sens->name, sens_name, sizeof(sens->name));
}
BLI_uniquename(&ob->sensors, sens, DATA_("Sensor"), '.', offsetof(bSensor, name), sizeof(sens->name));
ob->scaflag |= OB_SHOWSENS;
WM_event_add_notifier(C, NC_LOGIC, NULL);
return OPERATOR_FINISHED;
}
示例10: wm_stereo3d_set_draw
void wm_stereo3d_set_draw(bContext *UNUSED(C), wmOperator *op)
{
Stereo3dData *s3dd = op->customdata;
PointerRNA stereo3d_format_ptr;
uiLayout *layout = op->layout;
uiLayout *col;
RNA_pointer_create(NULL, &RNA_Stereo3dDisplay, &s3dd->stereo3d_format, &stereo3d_format_ptr);
col = uiLayoutColumn(layout, false);
uiItemR(col, &stereo3d_format_ptr, "display_mode", 0, NULL, ICON_NONE);
switch (s3dd->stereo3d_format.display_mode) {
case S3D_DISPLAY_ANAGLYPH:
{
uiItemR(col, &stereo3d_format_ptr, "anaglyph_type", 0, NULL, ICON_NONE);
break;
}
case S3D_DISPLAY_INTERLACE:
{
uiItemR(col, &stereo3d_format_ptr, "interlace_type", 0, NULL, ICON_NONE);
uiItemR(col, &stereo3d_format_ptr, "use_interlace_swap", 0, NULL, ICON_NONE);
break;
}
case S3D_DISPLAY_SIDEBYSIDE:
{
uiItemR(col, &stereo3d_format_ptr, "use_sidebyside_crosseyed", 0, NULL, ICON_NONE);
/* fall-through */
}
case S3D_DISPLAY_PAGEFLIP:
case S3D_DISPLAY_TOPBOTTOM:
default:
{
break;
}
}
}
示例11: menu_poll
static bool menu_poll(const bContext *C, MenuType *pt)
{
extern FunctionRNA rna_Menu_poll_func;
PointerRNA ptr;
ParameterList list;
FunctionRNA *func;
void *ret;
bool visible;
RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */
func = &rna_Menu_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */
RNA_parameter_list_create(&list, &ptr, func);
RNA_parameter_set_lookup(&list, "context", &C);
pt->ext.call((bContext *)C, &ptr, func, &list);
RNA_parameter_get_lookup(&list, "visible", &ret);
visible = *(bool *)ret;
RNA_parameter_list_free(&list);
return visible;
}
示例12: draw_modifier__noise
/* draw settings for noise modifier */
static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short UNUSED(width))
{
uiLayout *split, *col;
PointerRNA ptr;
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr);
/* blending mode */
uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE);
/* split into 2 columns */
split = uiLayoutSplit(layout, 0.5f, FALSE);
/* col 1 */
col = uiLayoutColumn(split, FALSE);
uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE);
/* col 2 */
col = uiLayoutColumn(split, FALSE);
uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE);
uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE);
}
示例13: draw_modifier__generator
/* draw settings for generator modifier */
static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width)
{
FMod_Generator *data = (FMod_Generator *)fcm->data;
uiLayout /* *col, */ /* UNUSED */ *row;
uiBlock *block;
uiBut *but;
PointerRNA ptr;
short bwidth = width - 1.5 * UI_UNIT_X; /* max button width */
/* init the RNA-pointer */
RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr);
/* basic settings (backdrop + mode selector + some padding) */
/* col = uiLayoutColumn(layout, TRUE); */ /* UNUSED */
block = uiLayoutGetBlock(layout);
uiBlockBeginAlign(block);
but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL);
uiBlockEndAlign(block);
/* now add settings for individual modes */
switch (data->mode) {
case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */
{
float *cp = NULL;
char xval[32];
unsigned int i;
int maxXWidth;
/* draw polynomial order selector */
row = uiLayoutRow(layout, FALSE);
block = uiLayoutGetBlock(row);
but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0.5f * UI_UNIT_X, 0, bwidth, UI_UNIT_Y,
&data->poly_order, 1, 100, 0, 0,
TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)"));
uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL);
/* calculate maximum width of label for "x^n" labels */
if (data->arraysize > 2) {
BLI_snprintf(xval, sizeof(xval), "x^%u", data->arraysize);
maxXWidth = UI_GetStringWidth(xval) + 0.5 * UI_UNIT_X; /* XXX: UI_GetStringWidth is not accurate */
}
else {
/* basic size (just "x") */
maxXWidth = UI_GetStringWidth("x") + 0.5 * UI_UNIT_X;
}
/* draw controls for each coefficient and a + sign at end of row */
row = uiLayoutRow(layout, TRUE);
block = uiLayoutGetBlock(row);
cp = data->coefficients;
for (i = 0; (i < data->arraysize) && (cp); i++, cp++) {
/* To align with first line... */
if (i)
uiDefBut(block, LABEL, 1, " ", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
else
uiDefBut(block, LABEL, 1, "y =", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
/* coefficient */
uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, bwidth / 2, UI_UNIT_Y, cp, -UI_FLT_MAX, UI_FLT_MAX,
10, 3, TIP_("Coefficient for polynomial"));
/* 'x' param (and '+' if necessary) */
if (i == 0)
BLI_strncpy(xval, "", sizeof(xval));
else if (i == 1)
BLI_strncpy(xval, "x", sizeof(xval));
else
BLI_snprintf(xval, sizeof(xval), "x^%u", i);
uiDefBut(block, LABEL, 1, xval, 0, 0, maxXWidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Power of x"));
if ( (i != (data->arraysize - 1)) || ((i == 0) && data->arraysize == 2) ) {
uiDefBut(block, LABEL, 1, "+", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
/* next coefficient on a new row */
row = uiLayoutRow(layout, TRUE);
block = uiLayoutGetBlock(row);
}
else {
/* For alignment in UI! */
uiDefBut(block, LABEL, 1, " ", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, "");
}
}
break;
}
case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial expression */
{
float *cp = NULL;
unsigned int i;
/* draw polynomial order selector */
row = uiLayoutRow(layout, FALSE);
block = uiLayoutGetBlock(row);
but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width - 1.5 * UI_UNIT_X, UI_UNIT_Y,
//.........这里部分代码省略.........
示例14: BL_ConvertActuators
//.........这里部分代码省略.........
= new KX_ParentActuator(gameobj,
mode,
addToCompound,
ghost,
tmpgob);
baseact = tmpparact;
break;
}
case ACT_ARMATURE:
{
bArmatureActuator* armAct = (bArmatureActuator*) bact->data;
KX_GameObject *tmpgob = converter->FindGameObject(armAct->target);
KX_GameObject *subgob = converter->FindGameObject(armAct->subtarget);
BL_ArmatureActuator* tmparmact = new BL_ArmatureActuator(
gameobj,
armAct->type,
armAct->posechannel,
armAct->constraint,
tmpgob,
subgob,
armAct->weight,
armAct->influence);
baseact = tmparmact;
break;
}
case ACT_STEERING:
{
bSteeringActuator *stAct = (bSteeringActuator *) bact->data;
KX_GameObject *navmeshob = NULL;
if (stAct->navmesh)
{
PointerRNA settings_ptr;
RNA_pointer_create((ID *)stAct->navmesh, &RNA_GameObjectSettings, stAct->navmesh, &settings_ptr);
if (RNA_enum_get(&settings_ptr, "physics_type") == OB_BODY_TYPE_NAVMESH)
navmeshob = converter->FindGameObject(stAct->navmesh);
}
KX_GameObject *targetob = converter->FindGameObject(stAct->target);
int mode = KX_SteeringActuator::KX_STEERING_NODEF;
switch (stAct->type) {
case ACT_STEERING_SEEK:
mode = KX_SteeringActuator::KX_STEERING_SEEK;
break;
case ACT_STEERING_FLEE:
mode = KX_SteeringActuator::KX_STEERING_FLEE;
break;
case ACT_STEERING_PATHFOLLOWING:
mode = KX_SteeringActuator::KX_STEERING_PATHFOLLOWING;
break;
}
bool selfTerminated = (stAct->flag & ACT_STEERING_SELFTERMINATED) !=0;
bool enableVisualization = (stAct->flag & ACT_STEERING_ENABLEVISUALIZATION) !=0;
short facingMode = (stAct->flag & ACT_STEERING_AUTOMATICFACING) ? stAct->facingaxis : 0;
bool normalup = (stAct->flag & ACT_STEERING_NORMALUP) !=0;
bool lockzvel = (stAct->flag & ACT_STEERING_LOCKZVEL) !=0;
KX_SteeringActuator *tmpstact
= new KX_SteeringActuator(gameobj, mode, targetob, navmeshob,stAct->dist,
stAct->velocity, stAct->acceleration, stAct->turnspeed,
selfTerminated, stAct->updateTime,
scene->GetObstacleSimulation(), facingMode, normalup, enableVisualization, lockzvel);
baseact = tmpstact;
break;
}
case ACT_MOUSE:
示例15: node_group_separate_selected
/* returns 1 if its OK */
static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, float offx, float offy, int make_copy)
{
bNodeLink *link, *link_next;
bNode *node, *node_next, *newnode;
ListBase anim_basepaths = {NULL, NULL};
/* deselect all nodes in the target tree */
for (node = ntree->nodes.first; node; node = node->next)
nodeSetSelected(node, FALSE);
/* clear new pointers, set in nodeCopyNode */
for (node = ngroup->nodes.first; node; node = node->next)
node->new_node = NULL;
/* add selected nodes into the ntree */
for (node = ngroup->nodes.first; node; node = node_next) {
node_next = node->next;
if (!(node->flag & NODE_SELECT))
continue;
/* ignore interface nodes */
if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
nodeSetSelected(node, FALSE);
continue;
}
if (make_copy) {
/* make a copy */
newnode = nodeCopyNode(ngroup, node);
}
else {
/* use the existing node */
newnode = node;
}
/* keep track of this node's RNA "base" path (the part of the path identifying the node)
* if the old nodetree has animation data which potentially covers this node
*/
if (ngroup->adt) {
PointerRNA ptr;
char *path;
RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
if (path)
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
}
/* ensure valid parent pointers, detach if parent stays inside the group */
if (newnode->parent && !(newnode->parent->flag & NODE_SELECT))
nodeDetachNode(newnode);
/* migrate node */
BLI_remlink(&ngroup->nodes, newnode);
BLI_addtail(&ntree->nodes, newnode);
/* ensure unique node name in the node tree */
nodeUniqueName(ntree, newnode);
if (!newnode->parent) {
newnode->locx += offx;
newnode->locy += offy;
}
}
/* add internal links to the ntree */
for (link = ngroup->links.first; link; link = link_next) {
int fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT));
int toselect = (link->tonode && (link->tonode->flag & NODE_SELECT));
link_next = link->next;
if (make_copy) {
/* make a copy of internal links */
if (fromselect && toselect)
nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock, link->tonode->new_node, link->tosock->new_sock);
}
else {
/* move valid links over, delete broken links */
if (fromselect && toselect) {
BLI_remlink(&ngroup->links, link);
BLI_addtail(&ntree->links, link);
}
else if (fromselect || toselect) {
nodeRemLink(ngroup, link);
}
}
}
/* and copy across the animation,
* note that the animation data's action can be NULL here */
if (ngroup->adt) {
LinkData *ld, *ldn = NULL;
/* now perform the moving */
BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths);
/* paths + their wrappers need to be freed */
for (ld = anim_basepaths.first; ld; ld = ldn) {
//.........这里部分代码省略.........