本文整理汇总了C++中RNA_boolean_get函数的典型用法代码示例。如果您正苦于以下问题:C++ RNA_boolean_get函数的具体用法?C++ RNA_boolean_get怎么用?C++ RNA_boolean_get使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RNA_boolean_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: armature_calc_roll_exec
static int armature_calc_roll_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
eCalcRollTypes type = RNA_enum_get(op->ptr, "type");
const bool axis_only = RNA_boolean_get(op->ptr, "axis_only");
/* axis_flip when matching the active bone never makes sense */
bool axis_flip = ((type >= CALC_ROLL_ACTIVE) ? RNA_boolean_get(op->ptr, "axis_flip") :
(type >= CALC_ROLL_TAN_NEG_X) ? true : false);
float imat[3][3];
bArmature *arm = ob->data;
EditBone *ebone;
if ((type >= CALC_ROLL_NEG_X) && (type <= CALC_ROLL_TAN_NEG_Z)) {
type -= (CALC_ROLL_ACTIVE - CALC_ROLL_NEG_X);
axis_flip = true;
}
copy_m3_m4(imat, ob->obmat);
invert_m3(imat);
if (type == CALC_ROLL_CURSOR) { /* Cursor */
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
float cursor_local[3];
const float *cursor = ED_view3d_cursor3d_get(scene, v3d);
invert_m4_m4(ob->imat, ob->obmat);
copy_v3_v3(cursor_local, cursor);
mul_m4_v3(ob->imat, cursor_local);
/* cursor */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
float cursor_rel[3];
sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
if (axis_flip) negate_v3(cursor_rel);
if (normalize_v3(cursor_rel) != 0.0f) {
ebone->roll = ED_armature_ebone_roll_to_vector(ebone, cursor_rel, axis_only);
}
}
}
}
else if (ELEM(type, CALC_ROLL_TAN_POS_X, CALC_ROLL_TAN_POS_Z)) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (ebone->parent) {
bool is_edit = (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone));
bool is_edit_parent = (EBONE_VISIBLE(arm, ebone->parent) && EBONE_EDITABLE(ebone->parent));
if (is_edit || is_edit_parent) {
EditBone *ebone_other = ebone->parent;
float dir_a[3];
float dir_b[3];
float vec[3];
bool is_vec_zero;
sub_v3_v3v3(dir_a, ebone->tail, ebone->head);
normalize_v3(dir_a);
/* find the first bone in the chane with a different direction */
do {
sub_v3_v3v3(dir_b, ebone_other->head, ebone_other->tail);
normalize_v3(dir_b);
if (type == CALC_ROLL_TAN_POS_Z) {
cross_v3_v3v3(vec, dir_a, dir_b);
}
else {
add_v3_v3v3(vec, dir_a, dir_b);
}
} while ((is_vec_zero = (normalize_v3(vec) < 0.00001f)) &&
(ebone_other = ebone_other->parent));
if (!is_vec_zero) {
if (axis_flip) negate_v3(vec);
if (is_edit) {
ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only);
}
/* parentless bones use cross product with child */
if (is_edit_parent) {
if (ebone->parent->parent == NULL) {
ebone->parent->roll = ED_armature_ebone_roll_to_vector(ebone->parent, vec, axis_only);
}
}
}
}
}
}
}
else {
float vec[3] = {0.0f, 0.0f, 0.0f};
if (type == CALC_ROLL_VIEW) { /* View */
RegionView3D *rv3d = CTX_wm_region_view3d(C);
if (rv3d == NULL) {
BKE_report(op->reports, RPT_ERROR, "No region view3d available");
return OPERATOR_CANCELLED;
//.........这里部分代码省略.........
示例2: add_keyingset_button_exec
static int add_keyingset_button_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
KeyingSet *ks = NULL;
PropertyRNA *prop = NULL;
PointerRNA ptr = {{NULL}};
char *path = NULL;
short success = 0;
int index = 0, pflag = 0;
const bool all = RNA_boolean_get(op->ptr, "all");
/* verify the Keying Set to use:
* - use the active one for now (more control over this can be added later)
* - add a new one if it doesn't exist
*/
if (scene->active_keyingset == 0) {
short flag = 0, keyingflag = 0;
/* validate flags
* - absolute KeyingSets should be created by default
*/
flag |= KEYINGSET_ABSOLUTE;
keyingflag |= ANIM_get_keyframing_flags(scene, 0);
if (IS_AUTOKEY_FLAG(scene, XYZ2RGB))
keyingflag |= INSERTKEY_XYZ2RGB;
/* call the API func, and set the active keyingset index */
ks = BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag);
scene->active_keyingset = BLI_countlist(&scene->keyingsets);
}
else if (scene->active_keyingset < 0) {
BKE_report(op->reports, RPT_ERROR, "Cannot add property to built in keying set");
return OPERATOR_CANCELLED;
}
else {
ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1);
}
/* try to add to keyingset using property retrieved from UI */
uiContextActiveProperty(C, &ptr, &prop, &index);
/* check if property is able to be added */
if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) {
path = RNA_path_from_ID_to_property(&ptr, prop);
if (path) {
/* set flags */
if (all) {
pflag |= KSP_FLAG_WHOLE_ARRAY;
/* we need to set the index for this to 0, even though it may break in some cases, this is
* necessary if we want the entire array for most cases to get included without the user
* having to worry about where they clicked
*/
index = 0;
}
/* add path to this setting */
BKE_keyingset_add_path(ks, ptr.id.data, NULL, path, index, pflag, KSP_GROUP_KSNAME);
ks->active_path = BLI_countlist(&ks->paths);
success = 1;
/* free the temp path created */
MEM_freeN(path);
}
}
if (success) {
/* send updates */
WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL);
/* show notification/report header, so that users notice that something changed */
BKE_reportf(op->reports, RPT_INFO, "Property added to Keying Set: '%s'", ks->name);
}
return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
示例3: uiCollada_exportSettings
static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
{
uiLayout *box, *row, *col, *split;
/* Export Options: */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA);
row = uiLayoutRow(box, false);
split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT);
col = uiLayoutColumn(split, false);
uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE);
col = uiLayoutColumn(split, false);
uiItemR(col, imfptr, "export_mesh_type_selection", 0, "", ICON_NONE);
uiLayoutSetEnabled(col, RNA_boolean_get(imfptr, "apply_modifiers"));
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "include_children", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "include_shapekeys", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
/* Texture options */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "active_uv_only", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "include_uv_textures", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "include_material_textures", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE);
/* Armature options */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "deform_bones_only", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "open_sim", 0, NULL, ICON_NONE);
/* Collada options: */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Collada Options:"), ICON_MODIFIER);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "use_object_instantiation", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "use_blender_profile", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT);
uiItemL(split, IFACE_("Transformation Type"), ICON_NONE);
uiItemR(split, imfptr, "export_transformation_type_selection", 0, "", ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE);
}
示例4: view3d_layers_exec
static int view3d_layers_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
ScrArea *sa= CTX_wm_area(C);
View3D *v3d= sa->spacedata.first;
int nr= RNA_int_get(op->ptr, "nr");
int toggle= RNA_boolean_get(op->ptr, "toggle");
if(nr < 0)
return OPERATOR_CANCELLED;
if(nr == 0) {
/* all layers */
if(!v3d->layact)
v3d->layact= 1;
if (toggle && v3d->lay == ((1<<20)-1)) {
/* return to active layer only */
v3d->lay = v3d->layact;
view3d_layers_editmode_ensure(scene, v3d);
}
else {
v3d->lay |= (1<<20)-1;
}
}
else {
int bit;
nr--;
if(RNA_boolean_get(op->ptr, "extend")) {
if(toggle && v3d->lay & (1<<nr) && (v3d->lay & ~(1<<nr)))
v3d->lay &= ~(1<<nr);
else
v3d->lay |= (1<<nr);
} else {
v3d->lay = (1<<nr);
}
view3d_layers_editmode_ensure(scene, v3d);
/* set active layer, ensure to always have one */
if(v3d->lay & (1<<nr))
v3d->layact= 1<<nr;
else if((v3d->lay & v3d->layact)==0) {
for(bit=0; bit<32; bit++) {
if(v3d->lay & (1<<bit)) {
v3d->layact= 1<<bit;
break;
}
}
}
}
if(v3d->scenelock) handle_view3d_lock(C);
DAG_on_visible_update(CTX_data_main(C), FALSE);
ED_area_tag_redraw(sa);
return OPERATOR_FINISHED;
}
示例5: sequencer_select_invoke
static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
View2D *v2d = UI_view2d_fromcontext(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
const bool extend = RNA_boolean_get(op->ptr, "extend");
const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle");
const bool linked_time = RNA_boolean_get(op->ptr, "linked_time");
bool left_right = RNA_boolean_get(op->ptr, "left_right");
Sequence *seq, *neighbor, *act_orig;
int hand, sel_side;
TimeMarker *marker;
if (ed == NULL)
return OPERATOR_CANCELLED;
marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now
seq = find_nearest_seq(scene, v2d, &hand, event->mval);
// XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip
if (seq && linked_time && left_right)
left_right = false;
if (marker) {
int oldflag;
/* select timeline marker */
if (extend) {
oldflag = marker->flag;
if (oldflag & SELECT)
marker->flag &= ~SELECT;
else
marker->flag |= SELECT;
}
else {
/* deselect_markers(0, 0); */ /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */
marker->flag |= SELECT;
}
}
else if (left_right) {
/* use different logic for this */
float x;
ED_sequencer_deselect_all(scene);
x = UI_view2d_region_to_view_x(v2d, event->mval[0]);
SEQP_BEGIN (ed, seq)
{
if (x < CFRA) {
if (seq->enddisp < CFRA) {
seq->flag |= SELECT;
recurs_sel_seq(seq);
}
}
else {
if (seq->startdisp > CFRA) {
seq->flag |= SELECT;
recurs_sel_seq(seq);
}
}
}
SEQ_END
{
SpaceSeq *sseq = CTX_wm_space_seq(C);
if (sseq && sseq->flag & SEQ_MARKER_TRANS) {
TimeMarker *tmarker;
for (tmarker = scene->markers.first; tmarker; tmarker = tmarker->next) {
if (((x < CFRA) && tmarker->frame < CFRA) ||
((x >= CFRA) && tmarker->frame >= CFRA))
{
tmarker->flag |= SELECT;
}
else {
tmarker->flag &= ~SELECT;
}
}
}
}
}
else {
示例6: ED_fileselect_set_params
short ED_fileselect_set_params(SpaceFile *sfile)
{
char name[FILE_MAX], dir[FILE_MAX], file[FILE_MAX];
FileSelectParams *params;
wmOperator *op = sfile->op;
/* create new parameters if necessary */
if (!sfile->params) {
sfile->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams");
/* set path to most recently opened .blend */
BLI_strncpy(sfile->params->dir, G.sce, sizeof(sfile->params->dir));
BLI_split_dirfile(G.sce, dir, file);
BLI_strncpy(sfile->params->file, file, sizeof(sfile->params->file));
BLI_make_file_string(G.sce, sfile->params->dir, dir, ""); /* XXX needed ? - also solve G.sce */
}
params = sfile->params;
/* set the parameters from the operator, if it exists */
if (op) {
BLI_strncpy(params->title, op->type->name, sizeof(params->title));
if(RNA_struct_find_property(op->ptr, "filename"))
params->type = RNA_int_get(op->ptr, "filemode");
else
params->type = FILE_SPECIAL;
if (RNA_property_is_set(op->ptr, "path")) {
RNA_string_get(op->ptr, "path", name);
if (params->type == FILE_LOADLIB) {
BLI_strncpy(params->dir, name, sizeof(params->dir));
BLI_cleanup_dir(G.sce, params->dir);
} else {
/* if operator has path set, use it, otherwise keep the last */
BLI_convertstringcode(name, G.sce);
BLI_split_dirfile(name, dir, file);
BLI_strncpy(params->file, file, sizeof(params->file));
BLI_make_file_string(G.sce, params->dir, dir, ""); /* XXX needed ? - also solve G.sce */
}
}
params->filter = 0;
if(RNA_struct_find_property(op->ptr, "filter_blender"))
params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_image"))
params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_movie"))
params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_text"))
params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_python"))
params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_font"))
params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_sound"))
params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_text"))
params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0;
if(RNA_struct_find_property(op->ptr, "filter_folder"))
params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0;
if (params->filter != 0)
params->flag |= FILE_FILTER;
params->flag |= FILE_HIDE_DOT;
if (params->type == FILE_LOADLIB) {
params->flag |= RNA_boolean_get(op->ptr, "link") ? FILE_LINK : 0;
params->flag |= RNA_boolean_get(op->ptr, "autoselect") ? FILE_AUTOSELECT : 0;
params->flag |= RNA_boolean_get(op->ptr, "active_layer") ? FILE_ACTIVELAY : 0;
}
if(params->filter & (IMAGEFILE|MOVIEFILE))
params->display= FILE_IMGDISPLAY;
else
params->display= FILE_SHORTDISPLAY;
} else {
/* default values, if no operator */
params->type = FILE_UNIX;
params->flag |= FILE_HIDE_DOT;
params->display = FILE_SHORTDISPLAY;
params->filter = 0;
params->sort = FILE_SORT_ALPHA;
}
return 1;
}
示例7: wm_alembic_export_exec
static int wm_alembic_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
const struct AlembicExportParams params = {
.frame_start = RNA_int_get(op->ptr, "start"),
.frame_end = RNA_int_get(op->ptr, "end"),
.frame_step_xform = 1.0 / (double)RNA_int_get(op->ptr, "xsamples"),
.frame_step_shape = 1.0 / (double)RNA_int_get(op->ptr, "gsamples"),
.shutter_open = RNA_float_get(op->ptr, "sh_open"),
.shutter_close = RNA_float_get(op->ptr, "sh_close"),
.selected_only = RNA_boolean_get(op->ptr, "selected"),
.uvs = RNA_boolean_get(op->ptr, "uvs"),
.normals = RNA_boolean_get(op->ptr, "normals"),
.vcolors = RNA_boolean_get(op->ptr, "vcolors"),
.apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"),
.flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"),
.visible_layers_only = RNA_boolean_get(op->ptr, "visible_layers_only"),
.renderable_only = RNA_boolean_get(op->ptr, "renderable_only"),
.face_sets = RNA_boolean_get(op->ptr, "face_sets"),
.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
.compression_type = RNA_enum_get(op->ptr, "compression_type"),
.packuv = RNA_boolean_get(op->ptr, "packuv"),
.triangulate = RNA_boolean_get(op->ptr, "triangulate"),
.quad_method = RNA_enum_get(op->ptr, "quad_method"),
.ngon_method = RNA_enum_get(op->ptr, "ngon_method"),
.global_scale = RNA_float_get(op->ptr, "global_scale"),
};
ABC_export(CTX_data_scene(C), C, filename, ¶ms);
return OPERATOR_FINISHED;
}
static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
{
uiLayout *box;
uiLayout *row;
#ifdef WITH_ALEMBIC_HDF5
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Archive Options:"), ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE);
#endif
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "global_scale", 0, NULL, ICON_NONE);
/* Scene Options */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Scene Options:"), ICON_SCENE_DATA);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "start", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "end", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "xsamples", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "gsamples", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "sh_open", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "sh_close", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "selected", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "renderable_only", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "visible_layers_only", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "flatten", 0, NULL, ICON_NONE);
//.........这里部分代码省略.........
示例8: wm_alembic_export_exec
static int wm_alembic_export_exec(bContext *C, wmOperator *op)
{
if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
BKE_report(op->reports, RPT_ERROR, "No filename given");
return OPERATOR_CANCELLED;
}
char filename[FILE_MAX];
RNA_string_get(op->ptr, "filepath", filename);
struct AlembicExportParams params = {
.frame_start = RNA_int_get(op->ptr, "start"),
.frame_end = RNA_int_get(op->ptr, "end"),
.frame_samples_xform = RNA_int_get(op->ptr, "xsamples"),
.frame_samples_shape = RNA_int_get(op->ptr, "gsamples"),
.shutter_open = RNA_float_get(op->ptr, "sh_open"),
.shutter_close = RNA_float_get(op->ptr, "sh_close"),
.selected_only = RNA_boolean_get(op->ptr, "selected"),
.uvs = RNA_boolean_get(op->ptr, "uvs"),
.normals = RNA_boolean_get(op->ptr, "normals"),
.vcolors = RNA_boolean_get(op->ptr, "vcolors"),
.apply_subdiv = RNA_boolean_get(op->ptr, "apply_subdiv"),
.flatten_hierarchy = RNA_boolean_get(op->ptr, "flatten"),
.visible_layers_only = RNA_boolean_get(op->ptr, "visible_layers_only"),
.renderable_only = RNA_boolean_get(op->ptr, "renderable_only"),
.face_sets = RNA_boolean_get(op->ptr, "face_sets"),
.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
.export_hair = RNA_boolean_get(op->ptr, "export_hair"),
.export_particles = RNA_boolean_get(op->ptr, "export_particles"),
.compression_type = RNA_enum_get(op->ptr, "compression_type"),
.packuv = RNA_boolean_get(op->ptr, "packuv"),
.triangulate = RNA_boolean_get(op->ptr, "triangulate"),
.quad_method = RNA_enum_get(op->ptr, "quad_method"),
.ngon_method = RNA_enum_get(op->ptr, "ngon_method"),
.global_scale = RNA_float_get(op->ptr, "global_scale"),
};
/* Take some defaults from the scene, if not specified explicitly. */
Scene *scene = CTX_data_scene(C);
if (params.frame_start == INT_MIN) {
params.frame_start = SFRA;
}
if (params.frame_end == INT_MIN) {
params.frame_end = EFRA;
}
const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
bool ok = ABC_export(scene, C, filename, ¶ms, as_background_job);
return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
{
uiLayout *box;
uiLayout *row;
uiLayout *col;
#ifdef WITH_ALEMBIC_HDF5
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Archive Options:"), ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE);
#endif
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "global_scale", 0, NULL, ICON_NONE);
/* Scene Options */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Scene Options:"), ICON_SCENE_DATA);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "start", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "end", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "xsamples", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "gsamples", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "sh_open", 0, NULL, ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "sh_close", 0, NULL, ICON_NONE);
//.........这里部分代码省略.........
示例9: edbm_bevel_calc
static bool edbm_bevel_calc(wmOperator *op)
{
BevelData *opdata = op->customdata;
BMEditMesh *em;
BMOperator bmop;
bool changed = false;
const float offset = get_bevel_offset(op);
const int offset_type = RNA_enum_get(op->ptr, "offset_type");
const int segments = RNA_int_get(op->ptr, "segments");
const float profile = RNA_float_get(op->ptr, "profile");
const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only");
const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap");
int material = RNA_int_get(op->ptr, "material");
const bool loop_slide = RNA_boolean_get(op->ptr, "loop_slide");
const bool mark_seam = RNA_boolean_get(op->ptr, "mark_seam");
const bool mark_sharp = RNA_boolean_get(op->ptr, "mark_sharp");
const bool harden_normals = RNA_boolean_get(op->ptr, "harden_normals");
const int face_strength_mode = RNA_enum_get(op->ptr, "face_strength_mode");
const int miter_outer = RNA_enum_get(op->ptr, "miter_outer");
const int miter_inner = RNA_enum_get(op->ptr, "miter_inner");
const float spread = RNA_float_get(op->ptr, "spread");
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
em = opdata->ob_store[ob_index].em;
/* revert to original mesh */
if (opdata->is_modal) {
EDBM_redo_state_restore(opdata->ob_store[ob_index].mesh_backup, em, false);
}
if (em->ob) {
material = CLAMPIS(material, -1, em->ob->totcol - 1);
}
Mesh *me = em->ob->data;
if (harden_normals && !(me->flag & ME_AUTOSMOOTH)) {
/* harden_normals only has a visible effect if autosmooth is on, so turn it on */
me->flag |= ME_AUTOSMOOTH;
}
EDBM_op_init(em,
&bmop,
op,
"bevel geom=%hev offset=%f segments=%i vertex_only=%b offset_type=%i profile=%f "
"clamp_overlap=%b material=%i loop_slide=%b mark_seam=%b mark_sharp=%b "
"harden_normals=%b face_strength_mode=%i "
"miter_outer=%i miter_inner=%i spread=%f smoothresh=%f",
BM_ELEM_SELECT,
offset,
segments,
vertex_only,
offset_type,
profile,
clamp_overlap,
material,
loop_slide,
mark_seam,
mark_sharp,
harden_normals,
face_strength_mode,
miter_outer,
miter_inner,
spread,
me->smoothresh);
BMO_op_exec(em->bm, &bmop);
if (offset != 0.0f) {
/* not essential, but we may have some loose geometry that
* won't get bevel'd and better not leave it selected */
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
BMO_slot_buffer_hflag_enable(
em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
}
/* no need to de-select existing geometry */
if (!EDBM_op_finish(em, &bmop, op, true)) {
continue;
}
EDBM_mesh_normals_update(em);
EDBM_update_generic(em, true, true);
changed = true;
}
return changed;
}
示例10: edbm_bevel_modal
static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
BevelData *opdata = op->customdata;
const bool has_numinput = hasNumInput(&opdata->num_input[opdata->value_mode]);
bool handled = false;
short etype = event->type;
short eval = event->val;
/* When activated from toolbar, need to convert leftmouse release to confirm */
if (etype == LEFTMOUSE && eval == KM_RELEASE && RNA_boolean_get(op->ptr, "release_confirm")) {
etype = EVT_MODAL_MAP;
eval = BEV_MODAL_CONFIRM;
}
/* Modal numinput active, try to handle numeric inputs first... */
if (etype != EVT_MODAL_MAP && eval == KM_PRESS && has_numinput &&
handleNumInput(C, &opdata->num_input[opdata->value_mode], event)) {
edbm_bevel_numinput_set_value(op);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
return OPERATOR_RUNNING_MODAL;
}
else if (etype == MOUSEMOVE) {
if (!has_numinput) {
edbm_bevel_mouse_set_value(op, event);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
handled = true;
}
}
else if (etype == MOUSEPAN) {
float delta = 0.02f * (event->y - event->prevy);
if (opdata->segments >= 1 && opdata->segments + delta < 1) {
opdata->segments = 1;
}
else {
opdata->segments += delta;
}
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
handled = true;
}
else if (etype == EVT_MODAL_MAP) {
switch (eval) {
case BEV_MODAL_CANCEL:
edbm_bevel_cancel(C, op);
ED_workspace_status_text(C, NULL);
return OPERATOR_CANCELLED;
case BEV_MODAL_CONFIRM:
edbm_bevel_calc(op);
edbm_bevel_exit(C, op);
ED_workspace_status_text(C, NULL);
return OPERATOR_FINISHED;
case BEV_MODAL_SEGMENTS_UP:
opdata->segments = opdata->segments + 1;
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
handled = true;
break;
case BEV_MODAL_SEGMENTS_DOWN:
opdata->segments = max_ff(opdata->segments - 1, 1);
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
handled = true;
break;
case BEV_MODAL_OFFSET_MODE_CHANGE: {
int type = RNA_enum_get(op->ptr, "offset_type");
type++;
if (type > BEVEL_AMT_PERCENT) {
type = BEVEL_AMT_OFFSET;
}
if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE_PERCENT;
}
else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT) {
opdata->value_mode = OFFSET_VALUE;
}
RNA_enum_set(op->ptr, "offset_type", type);
if (opdata->initial_length[opdata->value_mode] == -1.0f) {
edbm_bevel_calc_initial_length(op, event, true);
}
}
/* Update offset accordingly to new offset_type. */
if (!has_numinput &&
(opdata->value_mode == OFFSET_VALUE || opdata->value_mode == OFFSET_VALUE_PERCENT)) {
edbm_bevel_mouse_set_value(op, event);
}
edbm_bevel_calc(op);
edbm_bevel_update_header(C, op);
handled = true;
break;
case BEV_MODAL_CLAMP_OVERLAP_TOGGLE: {
bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap");
//.........这里部分代码省略.........
示例11: edbm_bevel_update_header
static void edbm_bevel_update_header(bContext *C, wmOperator *op)
{
char header[UI_MAX_DRAW_STR];
char buf[UI_MAX_DRAW_STR];
char *p = buf;
int available_len = sizeof(buf);
Scene *sce = CTX_data_scene(C);
char offset_str[NUM_STR_REP_LEN];
const char *mode_str, *omiter_str, *imiter_str;
PropertyRNA *prop;
#define WM_MODALKEY(_id) \
WM_modalkeymap_operator_items_to_string_buf( \
op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p)
if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%.1f%%", RNA_float_get(op->ptr, "offset_pct"));
}
else {
bUnit_AsString2(offset_str,
NUM_STR_REP_LEN,
(double)RNA_float_get(op->ptr, "offset"),
3,
B_UNIT_LENGTH,
&sce->unit,
true);
}
prop = RNA_struct_find_property(op->ptr, "offset_type");
RNA_property_enum_name_gettexted(
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &mode_str);
prop = RNA_struct_find_property(op->ptr, "miter_outer");
RNA_property_enum_name_gettexted(
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &omiter_str);
prop = RNA_struct_find_property(op->ptr, "miter_inner");
RNA_property_enum_name_gettexted(
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &imiter_str);
BLI_snprintf(header,
sizeof(header),
IFACE_("%s: confirm, "
"%s: cancel, "
"%s: mode (%s), "
"%s: width (%s), "
"%s: segments (%d), "
"%s: profile (%.3f), "
"%s: clamp overlap (%s), "
"%s: vertex only (%s), "
"%s: outer miter (%s), "
"%s: inner miter (%s), "
"%s: harden normals (%s), "
"%s: mark seam (%s), "
"%s: mark sharp (%s)"),
WM_MODALKEY(BEV_MODAL_CONFIRM),
WM_MODALKEY(BEV_MODAL_CANCEL),
WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE),
mode_str,
WM_MODALKEY(BEV_MODAL_VALUE_OFFSET),
offset_str,
WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS),
RNA_int_get(op->ptr, "segments"),
WM_MODALKEY(BEV_MODAL_VALUE_PROFILE),
RNA_float_get(op->ptr, "profile"),
WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE),
WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
WM_MODALKEY(BEV_MODAL_VERTEX_ONLY_TOGGLE),
WM_bool_as_string(RNA_boolean_get(op->ptr, "vertex_only")),
WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE),
omiter_str,
WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE),
imiter_str,
WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE),
WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")),
WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE),
WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")),
WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE),
WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp")));
#undef WM_MODALKEY
ED_workspace_status_text(C, header);
}
示例12: borderselect_exec
/* borderselect operator */
static int borderselect_exec(bContext *C, wmOperator *op)
{
SpaceInfo *sinfo = CTX_wm_space_info(C);
ARegion *ar = CTX_wm_region(C);
ReportList *reports = CTX_wm_reports(C);
int report_mask = info_report_mask(sinfo);
int extend = RNA_boolean_get(op->ptr, "extend");
Report *report_min, *report_max, *report;
//View2D *v2d = UI_view2d_fromcontext(C);
rcti rect;
//rctf rectf, rq;
short selecting = (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT);
//int mval[2];
WM_operator_properties_border_to_rcti(op, &rect);
#if 0
mval[0] = rect.xmin;
mval[1] = rect.ymin;
UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmin, &rectf.ymin);
mval[0] = rect.xmax;
mval[1] = rect.ymax;
UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax);
#endif
if (!extend) {
for (report = reports->list.first; report; report = report->next) {
if ((report->type & report_mask) == 0)
continue;
report->flag &= ~SELECT;
}
}
report_min = info_text_pick(sinfo, ar, reports, rect.ymax);
report_max = info_text_pick(sinfo, ar, reports, rect.ymin);
/* get the first report if none found */
if (report_min == NULL) {
// printf("find_min\n");
for (report = reports->list.first; report; report = report->next) {
if (report->type & report_mask) {
report_min = report;
break;
}
}
}
if (report_max == NULL) {
// printf("find_max\n");
for (report = reports->list.last; report; report = report->prev) {
if (report->type & report_mask) {
report_max = report;
break;
}
}
}
if (report_min == NULL || report_max == NULL)
return OPERATOR_CANCELLED;
for (report = report_min; (report != report_max->next); report = report->next) {
if ((report->type & report_mask) == 0)
continue;
if (selecting)
report->flag |= SELECT;
else
report->flag &= ~SELECT;
}
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
}
示例13: node_select_same_type_step_exec
static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
ARegion *ar = CTX_wm_region(C);
bNode **node_array;
bNode *active = nodeGetActive(snode->edittree);
int totnodes;
int revert = RNA_boolean_get(op->ptr, "prev");
int same_type = 1;
ntreeGetDependencyList(snode->edittree, &node_array, &totnodes);
if (totnodes > 1) {
int a;
for (a = 0; a < totnodes; a++) {
if (node_array[a] == active)
break;
}
if (same_type) {
bNode *node = NULL;
while (node == NULL) {
if (revert) a--;
else a++;
if (a < 0 || a >= totnodes)
break;
node = node_array[a];
if (node->type == active->type)
break;
else node = NULL;
}
if (node)
active = node;
}
else {
if (revert) {
if (a == 0)
active = node_array[totnodes - 1];
else
active = node_array[a - 1];
}
else {
if (a == totnodes - 1)
active = node_array[0];
else
active = node_array[a + 1];
}
}
node_select_single(C, active);
/* is note outside view? */
if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax ||
active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax)
{
space_node_view_flag(C, snode, CTX_wm_region(C), NODE_SELECT);
}
}
if (node_array)
MEM_freeN(node_array);
return OPERATOR_FINISHED;
}
示例14: find_shader
//.........这里部分代码省略.........
* because the shader needs different mesh attributes */
bool attribute_recalc = false;
foreach(uint shader, mesh->used_shaders)
if(scene->shaders[shader]->need_update_attributes)
attribute_recalc = true;
if(!attribute_recalc)
return mesh;
}
}
/* ensure we only sync instanced meshes once */
if(mesh_synced.find(mesh) != mesh_synced.end())
return mesh;
mesh_synced.insert(mesh);
/* create derived mesh */
PointerRNA cmesh = RNA_pointer_get(&b_ob_data.ptr, "cycles");
vector<Mesh::Triangle> oldtriangle = mesh->triangles;
/* compares curve_keys rather than strands in order to handle quick hair
* adjustments in dynamic BVH - other methods could probably do this better*/
vector<float4> oldcurve_keys = mesh->curve_keys;
mesh->clear();
mesh->used_shaders = used_shaders;
mesh->name = ustring(b_ob_data.name().c_str());
if(requested_geometry_flags != Mesh::GEOMETRY_NONE) {
/* mesh objects does have special handle in the dependency graph,
* they're ensured to have properly updated.
*
* updating meshes here will end up having derived mesh referencing
* freed data from the blender side.
*/
if(preview && b_ob.type() != BL::Object::type_MESH)
b_ob.update_from_editmode();
bool need_undeformed = mesh->need_attribute(scene, ATTR_STD_GENERATED);
BL::Mesh b_mesh = object_to_mesh(b_data, b_ob, b_scene, true, !preview, need_undeformed);
if(b_mesh) {
if(render_layer.use_surfaces && !hide_tris) {
if(cmesh.data && experimental && RNA_boolean_get(&cmesh, "use_subdivision"))
create_subd_mesh(scene, mesh, b_mesh, &cmesh, used_shaders);
else
create_mesh(scene, mesh, b_mesh, used_shaders);
create_mesh_volume_attributes(scene, b_ob, mesh, b_scene.frame_current());
}
if(render_layer.use_hair)
sync_curves(mesh, b_mesh, b_ob, false);
if(can_free_caches) {
b_ob.cache_release();
}
/* free derived mesh */
b_data.meshes.remove(b_mesh);
}
}
mesh->geometry_flags = requested_geometry_flags;
/* displacement method */
if(cmesh.data) {
const int method = get_enum(cmesh, "displacement_method");
if(method == 0 || !experimental)
mesh->displacement_method = Mesh::DISPLACE_BUMP;
else if(method == 1)
mesh->displacement_method = Mesh::DISPLACE_TRUE;
else
mesh->displacement_method = Mesh::DISPLACE_BOTH;
}
/* tag update */
bool rebuild = false;
if(oldtriangle.size() != mesh->triangles.size())
rebuild = true;
else if(oldtriangle.size()) {
if(memcmp(&oldtriangle[0], &mesh->triangles[0], sizeof(Mesh::Triangle)*oldtriangle.size()) != 0)
rebuild = true;
}
if(oldcurve_keys.size() != mesh->curve_keys.size())
rebuild = true;
else if(oldcurve_keys.size()) {
if(memcmp(&oldcurve_keys[0], &mesh->curve_keys[0], sizeof(float4)*oldcurve_keys.size()) != 0)
rebuild = true;
}
mesh->tag_update(scene, rebuild);
return mesh;
}
示例15: file_browse_exec
static int file_browse_exec(bContext *C, wmOperator *op)
{
FileBrowseOp *fbo = op->customdata;
ID *id;
char *str, path[FILE_MAX];
const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath";
if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL)
return OPERATOR_CANCELLED;
str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0);
/* add slash for directories, important for some properties */
if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) {
const bool is_relative = RNA_boolean_get(op->ptr, "relative_path");
id = fbo->ptr.id.data;
BLI_strncpy(path, str, FILE_MAX);
BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name);
if (BLI_is_dir(path)) {
/* do this first so '//' isnt converted to '//\' on windows */
BLI_add_slash(path);
if (is_relative) {
BLI_strncpy(path, str, FILE_MAX);
BLI_path_rel(path, G.main->name);
str = MEM_reallocN(str, strlen(path) + 2);
BLI_strncpy(str, path, FILE_MAX);
}
else {
str = MEM_reallocN(str, strlen(str) + 2);
}
}
else {
char * const lslash = (char *)BLI_last_slash(str);
if (lslash) lslash[1] = '\0';
}
}
RNA_property_string_set(&fbo->ptr, fbo->prop, str);
RNA_property_update(C, &fbo->ptr, fbo->prop);
MEM_freeN(str);
if (fbo->is_undo) {
const char *undostr = RNA_property_identifier(fbo->prop);
ED_undo_push(C, undostr);
}
/* special, annoying exception, filesel on redo panel [#26618] */
{
wmOperator *redo_op = WM_operator_last_redo(C);
if (redo_op) {
if (fbo->ptr.data == redo_op->ptr->data) {
ED_undo_operator_repeat(C, redo_op);
}
}
}
MEM_freeN(op->customdata);
return OPERATOR_FINISHED;
}