本文整理汇总了C++中ED_object_context函数的典型用法代码示例。如果您正苦于以下问题:C++ ED_object_context函数的具体用法?C++ ED_object_context怎么用?C++ ED_object_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ED_object_context函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: disconnect_hair_exec
static int disconnect_hair_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_context(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys= NULL;
int all = RNA_boolean_get(op->ptr, "all");
if (!ob)
return OPERATOR_CANCELLED;
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
disconnect_hair(scene, ob, psys);
}
}
else {
psys = ptr.data;
disconnect_hair(scene, ob, psys);
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
return OPERATOR_FINISHED;
}
开发者ID:244xiao,项目名称:blender,代码行数:26,代码来源:particle_object.c
示例2: surface_slot_add_exec
static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
{
DynamicPaintModifierData *pmd = NULL;
Object *cObject = ED_object_context(C);
DynamicPaintCanvasSettings *canvas;
DynamicPaintSurface *surface;
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
if (!pmd || !pmd->canvas)
return OPERATOR_CANCELLED;
canvas = pmd->canvas;
surface = dynamicPaint_createNewSurface(canvas, CTX_data_scene(C));
if (!surface)
return OPERATOR_CANCELLED;
/* set preview for this surface only and set active */
canvas->active_sur = 0;
for (surface = surface->prev; surface; surface = surface->prev) {
surface->flags &= ~MOD_DPAINT_PREVIEW;
canvas->active_sur++;
}
return OPERATOR_FINISHED;
}
开发者ID:mgschwan,项目名称:blensor,代码行数:27,代码来源:dynamicpaint_ops.c
示例3: dynamicPaint_initBake
/*
* Bake Dynamic Paint image sequence surface
*/
static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op)
{
DynamicPaintModifierData *pmd = NULL;
DynamicPaintCanvasSettings *canvas;
Object *ob = ED_object_context(C);
int status = 0;
double timer = PIL_check_seconds_timer();
DynamicPaintSurface *surface;
/*
* Get modifier data
*/
pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
if (!pmd) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found");
return 0;
}
/* Make sure we're dealing with a canvas */
canvas = pmd->canvas;
if (!canvas) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas");
return 0;
}
surface = get_activeSurface(canvas);
/* Set state to baking and init surface */
canvas->error[0] = '\0';
canvas->flags |= MOD_DPAINT_BAKING;
G.is_break = FALSE; /* reset blender_test_break*/
/* Bake Dynamic Paint */
status = dynamicPaint_bakeImageSequence(C, surface, ob);
/* Clear bake */
canvas->flags &= ~MOD_DPAINT_BAKING;
WM_cursor_restore(CTX_wm_window(C));
dynamicPaint_freeSurfaceData(surface);
/* Bake was successful:
* Report for ended bake and how long it took */
if (status) {
/* Format time string */
char time_str[30];
double time = PIL_check_seconds_timer() - timer;
BLI_timestr(time, time_str);
/* Show bake info */
BKE_reportf(op->reports, RPT_INFO, "Bake complete! (%s)", time_str);
}
else {
if (strlen(canvas->error)) { /* If an error occurred */
BKE_reportf(op->reports, RPT_ERROR, "Bake failed: %s", canvas->error);
}
else { /* User canceled the bake */
BKE_report(op->reports, RPT_WARNING, "Baking canceled!");
}
}
return status;
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:63,代码来源:dynamicpaint_ops.c
示例4: connect_hair_exec
static int connect_hair_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_context(C);
PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem);
ParticleSystem *psys= NULL;
const bool all = RNA_boolean_get(op->ptr, "all");
bool any_connected = false;
if (!ob)
return OPERATOR_CANCELLED;
if (all) {
for (psys=ob->particlesystem.first; psys; psys=psys->next) {
any_connected |= connect_hair(scene, ob, psys);
}
}
else {
psys = ptr.data;
any_connected |= connect_hair(scene, ob, psys);
}
if (!any_connected) {
BKE_report(op->reports, RPT_ERROR, "Can't disconnect hair if particle system modifier is disabled");
return OPERATOR_CANCELLED;
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
return OPERATOR_FINISHED;
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:32,代码来源:particle_object.c
示例5: surface_slot_remove_exec
static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
DynamicPaintModifierData *pmd = NULL;
Object *obj_ctx = ED_object_context(C);
DynamicPaintCanvasSettings *canvas;
DynamicPaintSurface *surface;
int id = 0;
/* Make sure we're dealing with a canvas */
pmd = (DynamicPaintModifierData *)modifiers_findByType(obj_ctx, eModifierType_DynamicPaint);
if (!pmd || !pmd->canvas) return OPERATOR_CANCELLED;
canvas = pmd->canvas;
surface = canvas->surfaces.first;
/* find active surface and remove it */
for (; surface; surface = surface->next) {
if (id == canvas->active_sur) {
canvas->active_sur -= 1;
dynamicPaint_freeSurface(surface);
break;
}
id++;
}
dynamicPaint_resetPreview(canvas);
DAG_id_tag_update(&obj_ctx->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx);
return OPERATOR_FINISHED;
}
开发者ID:mgschwan,项目名称:blensor,代码行数:31,代码来源:dynamicpaint_ops.c
示例6: ED_object_context
/* can be called with C == NULL */
static EnumPropertyItem *group_object_active_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
{
Object *ob;
EnumPropertyItem *item = NULL, item_tmp = {0};
int totitem = 0;
if (C == NULL) {
return DummyRNA_NULL_items;
}
ob = ED_object_context(C);
/* check that the action exists */
if (ob) {
Group *group = NULL;
int i = 0;
while ((group = BKE_group_object_find(group, ob))) {
item_tmp.identifier = item_tmp.name = group->id.name + 2;
/* item_tmp.icon = ICON_ARMATURE_DATA; */
item_tmp.value = i;
RNA_enum_item_add(&item, &totitem, &item_tmp);
i++;
}
}
RNA_enum_item_end(&item, &totitem);
*free = 1;
return item;
}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:32,代码来源:object_group.c
示例7: particle_system_remove_exec
static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
int mode_orig;
if (!scene || !ob)
return OPERATOR_CANCELLED;
mode_orig = ob->mode;
object_remove_particle_system(scene, ob);
/* possible this isn't the active object
* object_remove_particle_system() clears the mode on the last psys
*/
if (mode_orig & OB_MODE_PARTICLE_EDIT) {
if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
if (scene->basact && scene->basact->object == ob) {
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
}
}
}
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:28,代码来源:particle_object.c
示例8: shape_key_move_exec
static int shape_key_move_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
Key *key = BKE_key_from_object(ob);
const int type = RNA_enum_get(op->ptr, "type");
const int totkey = key->totkey;
const int act_index = ob->shapenr - 1;
int new_index;
switch (type) {
case KB_MOVE_TOP:
/* Replace the ref key only if we're at the top already (only for relative keys) */
new_index = (ELEM(act_index, 0, 1) || key->type == KEY_NORMAL) ? 0 : 1;
break;
case KB_MOVE_BOTTOM:
new_index = totkey - 1;
break;
case KB_MOVE_UP:
case KB_MOVE_DOWN:
default:
new_index = (totkey + act_index + type) % totkey;
break;
}
if (!BKE_keyblock_move(ob, act_index, new_index)) {
return OPERATOR_CANCELLED;
}
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
return OPERATOR_FINISHED;
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:34,代码来源:object_shapekey.c
示例9: type_toggle_exec
static int type_toggle_exec(bContext *C, wmOperator *op)
{
Object *cObject = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(cObject, eModifierType_DynamicPaint);
int type = RNA_enum_get(op->ptr, "type");
if (!pmd) return OPERATOR_CANCELLED;
/* if type is already enabled, toggle it off */
if (type == MOD_DYNAMICPAINT_TYPE_CANVAS && pmd->canvas) {
dynamicPaint_freeCanvas(pmd);
}
else if (type == MOD_DYNAMICPAINT_TYPE_BRUSH && pmd->brush) {
dynamicPaint_freeBrush(pmd);
}
/* else create a new type */
else {
if (!dynamicPaint_createType(pmd, type, scene))
return OPERATOR_CANCELLED;
}
/* update dependency */
DAG_id_tag_update(&cObject->id, OB_RECALC_DATA);
DAG_relations_tag_update(CTX_data_main(C));
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, cObject);
return OPERATOR_FINISHED;
}
开发者ID:mgschwan,项目名称:blensor,代码行数:30,代码来源:dynamicpaint_ops.c
示例10: shape_key_move_poll
static int shape_key_move_poll(bContext *C)
{
/* Same as shape_key_mode_exists_poll above, but ensure we have at least two shapes! */
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
Key *key = BKE_key_from_object(ob);
return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT && key && key->totkey > 1);
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:9,代码来源:object_shapekey.c
示例11: shape_key_add_exec
static int shape_key_add_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
const bool from_mix = RNA_boolean_get(op->ptr, "from_mix");
ED_object_shape_key_add(C, scene, ob, from_mix);
return OPERATOR_FINISHED;
}
开发者ID:caomw,项目名称:blender-ui,代码行数:10,代码来源:object_shapekey.c
示例12: shape_key_mode_exists_poll
static int shape_key_mode_exists_poll(bContext *C)
{
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
/* same as shape_key_mode_poll */
return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT) &&
/* check a keyblock exists */
(BKE_keyblock_from_object(ob) != NULL);
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:10,代码来源:object_shapekey.c
示例13: object_lod_remove_exec
static int object_lod_remove_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
int index = RNA_int_get(op->ptr, "index");
if (!BKE_object_lod_remove(ob, index))
return OPERATOR_CANCELLED;
WM_event_add_notifier(C, NC_OBJECT | ND_LOD, CTX_wm_view3d(C));
return OPERATOR_FINISHED;
}
开发者ID:BlueLabelStudio,项目名称:blender,代码行数:11,代码来源:object_lod.c
示例14: shape_key_add_exec
static int shape_key_add_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
const bool from_mix = RNA_boolean_get(op->ptr, "from_mix");
ED_object_shape_key_add(C, ob, from_mix);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
DAG_relations_tag_update(CTX_data_main(C));
return OPERATOR_FINISHED;
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:12,代码来源:object_shapekey.c
示例15: object_lod_add_exec
static int object_lod_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_object_context(C);
#ifdef WITH_GAMEENGINE
BKE_object_lod_add(ob);
#else
(void)ob;
#endif
return OPERATOR_FINISHED;
}
开发者ID:linkedinyou,项目名称:blender-git,代码行数:12,代码来源:object_lod.c
示例16: dynamicpaint_bake_exec
/*
* Bake Dynamic Paint image sequence surface
*/
static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
{
DynamicPaintModifierData *pmd = NULL;
DynamicPaintCanvasSettings *canvas;
Object *ob = ED_object_context(C);
Scene *scene = CTX_data_scene(C);
DynamicPaintSurface *surface;
/*
* Get modifier data
*/
pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint);
if (!pmd) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found");
return OPERATOR_CANCELLED;
}
/* Make sure we're dealing with a canvas */
canvas = pmd->canvas;
if (!canvas) {
BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas");
return OPERATOR_CANCELLED;
}
surface = get_activeSurface(canvas);
/* Set state to baking and init surface */
canvas->error[0] = '\0';
canvas->flags |= MOD_DPAINT_BAKING;
DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob");
job->bmain = CTX_data_main(C);
job->scene = scene;
job->ob = ob;
job->canvas = canvas;
job->surface = surface;
wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene,
"Dynamic Paint Bake", WM_JOB_PROGRESS,
WM_JOB_TYPE_DPAINT_BAKE);
WM_jobs_customdata_set(wm_job, job, dpaint_bake_free);
WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER);
WM_jobs_callbacks(wm_job, dpaint_bake_startjob, NULL, NULL, dpaint_bake_endjob);
WM_set_locked_interface(CTX_wm_manager(C), true);
/* Bake Dynamic Paint */
WM_jobs_start(CTX_wm_manager(C), wm_job);
return OPERATOR_FINISHED;
}
开发者ID:mgschwan,项目名称:blensor,代码行数:55,代码来源:dynamicpaint_ops.c
示例17: shape_key_mirror_exec
static int shape_key_mirror_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
int totmirr = 0, totfail = 0;
bool use_topology = RNA_boolean_get(op->ptr, "use_topology");
if (!object_shape_key_mirror(C, ob, &totmirr, &totfail, use_topology))
return OPERATOR_CANCELLED;
ED_mesh_report_mirror(op, totmirr, totfail);
return OPERATOR_FINISHED;
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:13,代码来源:object_shapekey.c
示例18: objects_add_active_exec
static int objects_add_active_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_context(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
int single_group_index = RNA_enum_get(op->ptr, "group");
Group *single_group = group_object_active_find_index(ob, single_group_index);
Group *group;
bool is_cycle = false;
bool updated = false;
if (ob == NULL)
return OPERATOR_CANCELLED;
/* now add all selected objects to the group(s) */
for (group = bmain->group.first; group; group = group->id.next) {
if (single_group && group != single_group)
continue;
if (!BKE_group_object_exists(group, ob))
continue;
/* for recursive check */
BKE_main_id_tag_listbase(&bmain->group, true);
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
if (group_link_early_exit_check(group, base->object))
continue;
if (base->object->dup_group != group && !check_group_contains_object_recursive(group, base->object)) {
BKE_group_object_add(group, base->object, scene, base);
updated = true;
}
else {
is_cycle = true;
}
}
CTX_DATA_END;
}
if (is_cycle)
BKE_report(op->reports, RPT_WARNING, "Skipped some groups because of cycle detected");
if (!updated)
return OPERATOR_CANCELLED;
DAG_relations_tag_update(bmain);
WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL);
return OPERATOR_FINISHED;
}
开发者ID:Walid-Shouman,项目名称:Blender,代码行数:51,代码来源:object_group.c
示例19: particle_system_add_exec
static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
Scene *scene = CTX_data_scene(C);
if (!scene || !ob)
return OPERATOR_CANCELLED;
object_add_particle_system(scene, ob, NULL);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob);
WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob);
return OPERATOR_FINISHED;
}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:15,代码来源:particle_object.c
示例20: CTX_wm_area
/* matches logic with ED_operator_posemode_context() */
Object *ED_pose_object_from_context(bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
Object *ob;
/* since this call may also be used from the buttons window, we need to check for where to get the object */
if (sa && sa->spacetype == SPACE_BUTS) {
ob = ED_object_context(C);
}
else {
ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
}
return ob;
}
开发者ID:Moguri,项目名称:blender,代码行数:16,代码来源:pose_edit.c
注:本文中的ED_object_context函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论