本文整理汇总了C++中RNA_pointer_create函数的典型用法代码示例。如果您正苦于以下问题:C++ RNA_pointer_create函数的具体用法?C++ RNA_pointer_create怎么用?C++ RNA_pointer_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RNA_pointer_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:21,代码来源:node_templates.c
示例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;
}
}
}
开发者ID:ryden,项目名称:blender-mirror,代码行数:21,代码来源:bpy_operator_wrap.c
示例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);
}
开发者ID:ryden,项目名称:blender-mirror,代码行数:40,代码来源:bpy_operator_wrap.c
示例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;
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:22,代码来源:rna_ui.c
示例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);
}
开发者ID:Moguri,项目名称:blender,代码行数:24,代码来源:pose_edit.c
示例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);
}
开发者ID:castlelore,项目名称:blender-git,代码行数:24,代码来源:keyingsets.c
示例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;
}
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:37,代码来源:bpy_operator.c
示例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;
}
开发者ID:244xiao,项目名称:blender,代码行数:37,代码来源:logic_ops.c
示例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;
}
开发者ID:diekev,项目名称:blender,代码行数:37,代码来源:logic_ops.c
示例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;
}
}
}
开发者ID:Rojuinex,项目名称:Blender,代码行数:37,代码来源:wm_stereo.c
示例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;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:24,代码来源:rna_ui.c
示例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);
}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:25,代码来源:fmodifier_ui.c
示例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,
//.........这里部分代码省略.........
开发者ID:Eibriel,项目名称:kiriblender,代码行数:101,代码来源:fmodifier_ui.c
示例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:
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:67,代码来源:KX_ConvertActuators.cpp
示例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) {
//.........这里部分代码省略.........
开发者ID:244xiao,项目名称:blender,代码行数:101,代码来源:node_group.c
示例16: node_group_make_insert_selected
static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, bNode *gnode)
{
bNodeTree *ngroup = (bNodeTree *)gnode->id;
bNodeLink *link, *linkn;
bNode *node, *nextn;
bNodeSocket *sock;
ListBase anim_basepaths = {NULL, NULL};
float min[2], max[2], center[2];
int totselect;
int expose_all = FALSE;
bNode *input_node, *output_node;
/* XXX rough guess, not nice but we don't have access to UI constants here ... */
static const float offsetx = 200;
static const float offsety = 0.0f;
/* deselect all nodes in the target tree */
for (node = ngroup->nodes.first; node; node = node->next)
nodeSetSelected(node, FALSE);
totselect = node_get_selected_minmax(ntree, gnode, min, max);
add_v2_v2v2(center, min, max);
mul_v2_fl(center, 0.5f);
/* auto-add interface for "solo" nodes */
if (totselect == 1)
expose_all = TRUE;
/* move nodes over */
for (node = ntree->nodes.first; node; node = nextn) {
nextn = node->next;
if (node_group_make_use_node(node, gnode)) {
/* keep track of this node's RNA "base" path (the part of the pat identifying the node)
* if the old nodetree has animation data which potentially covers this node
*/
if (ntree->adt) {
PointerRNA ptr;
char *path;
RNA_pointer_create(&ntree->id, &RNA_Node, node, &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 outside the group */
if (node->parent && !(node->parent->flag & NODE_SELECT))
nodeDetachNode(node);
/* change node-collection membership */
BLI_remlink(&ntree->nodes, node);
BLI_addtail(&ngroup->nodes, node);
/* ensure unique node name in the ngroup */
nodeUniqueName(ngroup, node);
}
}
/* move animation data over */
if (ntree->adt) {
LinkData *ld, *ldn = NULL;
BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths);
/* paths + their wrappers need to be freed */
for (ld = anim_basepaths.first; ld; ld = ldn) {
ldn = ld->next;
MEM_freeN(ld->data);
BLI_freelinkN(&anim_basepaths, ld);
}
}
/* node groups don't use internal cached data */
ntreeFreeCache(ngroup);
/* create input node */
input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT);
input_node->locx = min[0] - center[0] - offsetx;
input_node->locy = -offsety;
/* create output node */
output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT);
output_node->locx = max[0] - center[0] + offsetx;
output_node->locy = -offsety;
/* relink external sockets */
for (link = ntree->links.first; link; link = linkn) {
int fromselect = node_group_make_use_node(link->fromnode, gnode);
int toselect = node_group_make_use_node(link->tonode, gnode);
linkn = link->next;
if ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode)) {
/* remove all links to/from the gnode.
* this can remove link information, but there's no general way to preserve it.
*/
nodeRemLink(ntree, link);
}
//.........这里部分代码省略.........
开发者ID:244xiao,项目名称:blender,代码行数:101,代码来源:node_group.c
示例17: graph_panel_drivers
/* driver settings for active F-Curve (only for 'Drivers' mode) */
static void graph_panel_drivers(const bContext *C, Panel *pa)
{
bAnimListElem *ale;
FCurve *fcu;
ChannelDriver *driver;
DriverVar *dvar;
PointerRNA driver_ptr;
uiLayout *col;
uiBlock *block;
uiBut *but;
/* Get settings from context */
if (!graph_panel_context(C, &ale, &fcu))
return;
driver = fcu->driver;
/* set event handler for panel */
block = uiLayoutGetBlock(pa->layout); // xxx?
uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
/* general actions - management */
col = uiLayoutColumn(pa->layout, FALSE);
block = uiLayoutGetBlock(col);
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22,
NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies"));
uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18,
NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver"));
uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
/* driver-level settings - type, expressions, and errors */
RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr);
col = uiLayoutColumn(pa->layout, TRUE);
block = uiLayoutGetBlock(col);
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
if (driver->type == DRIVER_TYPE_PYTHON) {
/* expression */
uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
/* errors? */
if (driver->flag & DRIVER_FLAG_INVALID)
uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR);
}
else {
/* errors? */
if (driver->flag & DRIVER_FLAG_INVALID)
uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR);
}
col = uiLayoutColumn(pa->layout, TRUE);
/* debug setting */
uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
/* value of driver */
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
uiLayout *row = uiLayoutRow(col, TRUE);
char valBuf[32];
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
uiItemL(row, valBuf, ICON_NONE);
}
/* add driver variables */
col = uiLayoutColumn(pa->layout, FALSE);
block = uiLayoutGetBlock(col);
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver"));
uiButSetFunc(but, driver_add_var_cb, driver, NULL);
/* loop over targets, drawing them */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
PointerRNA dvar_ptr;
uiLayout *box, *row;
/* sub-layout column for this variable's settings */
col = uiLayoutColumn(pa->layout, TRUE);
/* header panel */
box = uiLayoutBox(col);
/* first row context info for driver */
RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);
row = uiLayoutRow(box, FALSE);
block = uiLayoutGetBlock(row);
/* variable name */
uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
/* remove button */
uiBlockSetEmboss(block, UI_EMBOSSN);
but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
//.........这里部分代码省略.........
开发者ID:vanangamudi,项目名称:blender-main,代码行数:101,代码来源:graph_buttons.c
示例18: node_group_ungroup
/* returns 1 if its OK */
static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
{
bNodeLink *link, *linkn, *tlink;
bNode *node, *nextnode;
bNodeTree *ngroup, *wgroup;
ListBase anim_basepaths = {NULL, NULL};
ngroup = (bNodeTree *)gnode->id;
/* clear new pointers, set in copytree */
for (node = ntree->nodes.first; node; node = node->next)
node->new_node = NULL;
/* wgroup is a temporary copy of the NodeTree we're merging in
* - all of wgroup's nodes are transferred across to their new home
* - ngroup (i.e. the source NodeTree) is left unscathed
* - temp copy. don't change ID usercount
*/
wgroup = ntreeCopyTree_ex(ngroup, FALSE);
/* Add the nodes into the ntree */
for (node = wgroup->nodes.first; node; node = nextnode) {
nextnode = node->next;
/* Remove interface nodes.
* This also removes remaining links to and from interface nodes.
*/
if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
nodeFreeNode(wgroup, node);
continue;
}
/* 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 (wgroup->adt) {
PointerRNA ptr;
char *path;
RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr);
path = RNA_path_from_ID_to_struct(&ptr);
if (path)
BLI_addtail(&anim_basepaths, BLI_genericNodeN(path));
}
/* migrate node */
BLI_remlink(&wgroup->nodes, node);
BLI_addtail(&ntree->nodes, node);
/* ensure unique node name in the node tree */
nodeUniqueName(ntree, node);
if (!node->parent) {
node->locx += gnode->locx;
node->locy += gnode->locy;
}
node->flag |= NODE_SELECT;
}
/* Add internal links to the ntree */
for (link = wgroup->links.first; link; link = linkn) {
linkn = link->next;
BLI_remlink(&wgroup->links, link);
BLI_addtail(&ntree->links, link);
}
/* and copy across the animation,
* note that the animation data's action can be NULL here */
if (wgroup->adt) {
LinkData *ld, *ldn = NULL;
bAction *waction;
/* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */
waction = wgroup->adt->action = BKE_action_copy(wgroup->adt->action);
/* now perform the moving */
BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths);
/* paths + their wrappers need to be freed */
for (ld = anim_basepaths.first; ld; ld = ldn) {
ldn = ld->next;
MEM_freeN(ld->data);
BLI_freelinkN(&anim_basepaths, ld);
}
/* free temp action too */
if (waction) {
BKE_libblock_free(&G.main->action, waction);
}
}
/* free the group tree (takes care of user count) */
BKE_libblock_free(&G.main->nodetree, wgroup);
/* restore external links to and from the gnode */
/* note: the nodes have been copied to intermediate wgroup first (so need to use new_node),
//.........这里部分代码省略.........
开发者ID:244xiao,项目名称:blender,代码行数:101,代码来源:node_group.c
示例19: graph_panel_key_properties
static void graph_panel_key_properties(const bContext *C, Panel *pa)
{
bAnimListElem *ale;
FCurve *fcu;
BezTriple *bezt, *prevbezt;
uiLayout *layout = pa->layout;
uiLayout *col;
uiBlock *block;
if (!graph_panel_context(C, &ale, &fcu))
return;
block = uiLayoutGetBlock(layout);
uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
/* only show this info if there are keyframes to edit */
if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) {
PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr;
PropertyRNA *fcu_prop = NULL;
uiBut *but;
int unit = B_UNIT_NONE;
/* RNA pointer to keyframe, to allow editing */
RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr);
/* get property that F-Curve affects, for some unit-conversion magic */
RNA_id_pointer_create(ale->id, &id_ptr);
if (RNA_path_resolve(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop) && fcu_prop) {
/* determine the unit for this property */
unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop));
}
/* interpolation */
col = uiLayoutColumn(layout, FALSE);
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
/* numerical coordinate editing
* - we use the button-versions of the calls so that we can attach special update handlers
* and unit conversion magic that cannot be achieved using a purely RNA-approach
*/
// XXX:
col = uiLayoutColumn(layout, TRUE);
/* keyframe itself */
{
uiItemL(col, IFACE_("Key:"), ICON_NONE);
but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
uiButSetUnitType(but, unit);
}
/* previous handle - only if previous was Bezier interpolation */
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
uiButSetUnitType(but, unit);
}
/* next handle - only if current is Bezier interpolation */
if (bezt->ipo == BEZT_IPO_BEZ) {
uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
uiButSetUnitType(but, unit);
}
}
else {
if ((fcu->bezt == NULL) && (fcu->modifiers.first)) {
/* modifiers only - so no keyframes to be active */
uiItemL(layout, IFACE_("F-Curve only has F-Modifiers"), ICON_NONE);
uiItemL(layout, IFACE_("See Modifiers panel below"), ICON_INFO);
}
else if (fcu->fpt) {
/* samples only */
uiItemL(layout, IFACE_("F-Curve doesn't have any keyframes as it only contains sampled points"),
ICON_NONE);
}
else
uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE);
}
//.........这里部分代码省略.........
开发者ID:vanangamudi,项目名称:blender-main,代码行数:101,代码来源:graph_buttons.c
示例20: RNA_struct_find_property
static char *rna_ColorRampElement_path(PointerRNA *ptr)
{
PointerRNA ramp_ptr;
PropertyRNA *prop;
char *path = NULL;
int index;
/* helper macro for use here to try and get the path
* - this calls the standard code for getting a path to a texture...
*/
#define COLRAMP_GETPATH \
{ \
prop = RNA_struct_find_property(&ramp_ptr, "elements"); \
if (prop) { \
index = RNA_property_collection_lookup_index(&ramp_ptr, prop, ptr); \
if (index != -1) { \
char *texture_path = rna_ColorRamp_path(&ramp_ptr); \
path = BLI_sprintfN("%s.elements[%d]", texture_path, index); \
MEM_freeN(texture_path); \
} \
} \
} (void)0
/* determine the path from the ID-block to the ramp */
/* FIXME: this is a very slow way to do it, but it will have to suffice... */
if (ptr->id.data) {
ID *id = ptr->id.data;
switch (GS(id->name)) {
case ID_MA: /* 2 cases for material - diffuse and spec */
{
Material *ma = (Material *)id;
/* try diffuse first */
if (ma->ramp_col) {
RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_col, &ramp_ptr);
COLRAMP_GETPATH;
}
/* try specular if not diffuse */
if (!path && ma->ramp_spec) {
RNA_pointer_create(id, &RNA_ColorRamp, ma->ramp_
|
请发表评论