當前位置: 首頁>>代碼示例>>C++>>正文


C++ ED_object_context函數代碼示例

本文整理匯總了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;
}
開發者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


注:本文中的ED_object_context函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。