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