您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CTX_wm_view3d函数代码示例

51自学网 2021-06-01 20:07:08
  C++
这篇教程C++ CTX_wm_view3d函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CTX_wm_view3d函数的典型用法代码示例。如果您正苦于以下问题:C++ CTX_wm_view3d函数的具体用法?C++ CTX_wm_view3d怎么用?C++ CTX_wm_view3d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CTX_wm_view3d函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: edbm_inset_exit

static void edbm_inset_exit(bContext *C, wmOperator *op){    InsetData *opdata;    ScrArea *sa = CTX_wm_area(C);    opdata = op->customdata;    if (opdata->is_modal) {        View3D *v3d = CTX_wm_view3d(C);        ARegion *ar = CTX_wm_region(C);        EDBM_redo_state_free(&opdata->mesh_backup, NULL, false);        ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);        v3d->twtype = opdata->twtype;        G.moving = 0;    }    if (sa) {        ED_area_headerprint(sa, NULL);    }    MEM_freeN(op->customdata);}
开发者ID:flair2005,项目名称:mechanical-blender,代码行数:21,


示例2: ED_view3d_snap_ray

static bool ED_view3d_snap_ray(bContext *C, float r_co[3],                               const float ray_start[3], const float ray_normal[3]){	float dist_px = MVAL_MAX_PX_DIST;  /* snap dist */	float r_no_dummy[3];	float ray_dist = TRANSFORM_DIST_MAX_RAY;	bool ret;	Scene *scene = CTX_data_scene(C);	View3D *v3d = CTX_wm_view3d(C);	ARegion *ar = CTX_wm_region(C);	struct Object *obedit = CTX_data_edit_object(C);	/* try snap edge, then face if it fails */	ret = snapObjectsRayEx(scene, NULL, v3d, ar, obedit, SCE_SNAP_MODE_FACE,	                       NULL, NULL,	                       ray_start, ray_normal, &ray_dist,	                       NULL, &dist_px, r_co, r_no_dummy, SNAP_ALL);	return ret;}
开发者ID:Eibriel,项目名称:kiriblender,代码行数:21,


示例3: depthdropper_init

static int depthdropper_init(bContext *C, wmOperator *op){	DepthDropper *ddr;	int index_dummy;	SpaceType *st;	ARegionType *art;	st = BKE_spacetype_from_id(SPACE_VIEW3D);	art = BKE_regiontype_from_id(st, RGN_TYPE_WINDOW);	op->customdata = ddr = MEM_callocN(sizeof(DepthDropper), "DepthDropper");	UI_context_active_but_prop_get(C, &ddr->ptr, &ddr->prop, &index_dummy);	/* fallback to the active camera's dof */	if (ddr->prop == NULL) {		RegionView3D *rv3d = CTX_wm_region_view3d(C);		if (rv3d && rv3d->persp == RV3D_CAMOB) {			View3D *v3d = CTX_wm_view3d(C);			if (v3d->camera && v3d->camera->data && (((ID *)v3d->camera->data)->lib == NULL)) {				RNA_id_pointer_create(v3d->camera->data, &ddr->ptr);				ddr->prop = RNA_struct_find_property(&ddr->ptr, "dof_distance");			}		}	}	if ((ddr->ptr.data == NULL) ||	    (ddr->prop == NULL) ||	    (RNA_property_editable(&ddr->ptr, ddr->prop) == false) ||	    (RNA_property_type(ddr->prop) != PROP_FLOAT))	{		return false;	}	ddr->art = art;	ddr->draw_handle_pixel = ED_region_draw_cb_activate(art, depthdropper_draw_cb, ddr, REGION_DRAW_POST_PIXEL);	return true;}
开发者ID:DrangPo,项目名称:blender,代码行数:40,


示例4: edbm_inset_init

static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal){	InsetData *opdata;	Scene *scene = CTX_data_scene(C);	Object *obedit = CTX_data_edit_object(C);	BMEditMesh *em = BKE_editmesh_from_object(obedit);	if (em->bm->totvertsel == 0) {		return false;	}	op->customdata = opdata = MEM_mallocN(sizeof(InsetData), "inset_operator_data");	opdata->old_thickness = 0.01;	opdata->old_depth = 0.0;	opdata->modify_depth = false;	opdata->shift = false;	opdata->shift_amount = 0.0f;	opdata->is_modal = is_modal;	opdata->em = em;	initNumInput(&opdata->num_input);	opdata->num_input.idx_max = 1; /* Two elements. */	opdata->num_input.unit_sys = scene->unit.system;	opdata->num_input.unit_type[0] = B_UNIT_LENGTH;	opdata->num_input.unit_type[1] = B_UNIT_LENGTH;	if (is_modal) {		View3D *v3d = CTX_wm_view3d(C);		ARegion *ar = CTX_wm_region(C);		opdata->mesh_backup = EDBM_redo_state_store(em);		opdata->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);		G.moving = G_TRANSFORM_EDIT;		opdata->twtype = v3d->twtype;		v3d->twtype = 0;	}	return true;}
开发者ID:bitfusionio,项目名称:blender,代码行数:40,


示例5: view3d_camera_to_view_selected_exec

/* unlike VIEW3D_OT_view_selected this is for framing a render and not * meant to take into account vertex/bone selection for eg. */static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op){	Scene *scene = CTX_data_scene(C);	View3D *v3d = CTX_wm_view3d(C);  /* can be NULL */	Object *camera_ob = v3d ? v3d->camera : scene->camera;	float r_co[3]; /* the new location to apply */	float r_scale; /* only for ortho cameras */	if (camera_ob == NULL) {		BKE_report(op->reports, RPT_ERROR, "No active camera");		return OPERATOR_CANCELLED;	}	/* this function does all the important stuff */	if (BKE_camera_view_frame_fit_to_scene(scene, v3d, camera_ob, r_co, &r_scale)) {		ObjectTfmProtectedChannels obtfm;		float obmat_new[4][4];		if ((camera_ob->type == OB_CAMERA) && (((Camera *)camera_ob->data)->type == CAM_ORTHO)) {			((Camera *)camera_ob->data)->ortho_scale = r_scale;		}		copy_m4_m4(obmat_new, camera_ob->obmat);		copy_v3_v3(obmat_new[3], r_co);		/* only touch location */		BKE_object_tfm_protected_backup(camera_ob, &obtfm);		BKE_object_apply_mat4(camera_ob, obmat_new, true, true);		BKE_object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D);		/* notifiers */		DAG_id_tag_update(&camera_ob->id, OB_RECALC_OB);		WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, camera_ob);		return OPERATOR_FINISHED;	}	else {		return OPERATOR_CANCELLED;	}}
开发者ID:greg100795,项目名称:blender-git,代码行数:42,


示例6: rna_Object_visible_get

static bool rna_Object_visible_get(    Object *ob, bContext *C, ReportList *reports, ViewLayer *view_layer, View3D *v3d){  if (view_layer == NULL) {    view_layer = CTX_data_view_layer(C);  }  if (v3d == NULL) {    v3d = CTX_wm_view3d(C);  }  Base *base = BKE_view_layer_base_find(view_layer, ob);  if (!base) {    BKE_reportf(reports,                RPT_ERROR,                "Object '%s' not in View Layer '%s'!",                ob->id.name + 2,                view_layer->name);    return false;  }  return BASE_VISIBLE(v3d, base);}
开发者ID:dfelinto,项目名称:blender,代码行数:22,


示例7: snap_curs_to_grid_exec

static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op)){	Scene *scene = CTX_data_scene(C);	RegionView3D *rv3d = CTX_wm_region_data(C);	View3D *v3d = CTX_wm_view3d(C);	float gridf, *curs;	if (v3d->flag3 & V3D_LOCK_CURSOR) { // bfa - lock cursor		return OPERATOR_CANCELLED;	}	gridf = rv3d->gridview;	curs = ED_view3d_cursor3d_get(scene, v3d);	curs[0] = gridf * floorf(0.5f + curs[0] / gridf);	curs[1] = gridf * floorf(0.5f + curs[1] / gridf);	curs[2] = gridf * floorf(0.5f + curs[2] / gridf);		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);  /* hrm */	return OPERATOR_FINISHED;}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:22,


示例8: create_orientation_exec

static int create_orientation_exec(bContext *C, wmOperator *op){	char name[MAX_NAME];	const bool use = RNA_boolean_get(op->ptr, "use");	const bool overwrite = RNA_boolean_get(op->ptr, "overwrite");	const bool use_view = RNA_boolean_get(op->ptr, "use_view");	View3D *v3d = CTX_wm_view3d(C);	RNA_string_get(op->ptr, "name", name);	if (use && !v3d) {		BKE_report(op->reports, RPT_ERROR, "Create Orientation's 'use' parameter only valid in a 3DView context");		return OPERATOR_CANCELLED;	}	BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite);	WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);	WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));		return OPERATOR_FINISHED;}
开发者ID:LucaRood,项目名称:Blender,代码行数:22,


示例9: gp_strokepoint_convertcoords

/* convert the coordinates from the given stroke point into 3d-coordinates  *	- assumes that the active space is the 3D-View */static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect){	Scene *scene = CTX_data_scene(C);	View3D *v3d = CTX_wm_view3d(C);	ARegion *ar = CTX_wm_region(C);		if (gps->flag & GP_STROKE_3DSPACE) {		/* directly use 3d-coordinates */		copy_v3_v3(p3d, &pt->x);	}	else {		const float *fp = give_cursor(scene, v3d);		float mvalf[2];				/* get screen coordinate */		if (gps->flag & GP_STROKE_2DSPACE) {			int mvali[2];			View2D *v2d = &ar->v2d;			UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali + 1);			VECCOPY2D(mvalf, mvali);		}		else {			if (subrect) {				mvalf[0] = (((float)pt->x / 100.0f) * BLI_rctf_size_x(subrect)) + subrect->xmin;				mvalf[1] = (((float)pt->y / 100.0f) * BLI_rctf_size_y(subrect)) + subrect->ymin;			}			else {				mvalf[0] = (float)pt->x / 100.0f * ar->winx;				mvalf[1] = (float)pt->y / 100.0f * ar->winy;			}		}				/* convert screen coordinate to 3d coordinates 		 *	- method taken from editview.c - mouse_cursor() 		 */		ED_view3d_win_to_3d(ar, fp, mvalf, p3d);	}}
开发者ID:diosney,项目名称:blender,代码行数:41,


示例10: handle_view3d_lock

/* XXX quickly ported across */static void handle_view3d_lock(bContext *C){	Main *bmain = CTX_data_main(C);	Scene *scene = CTX_data_scene(C);	ScrArea *sa = CTX_wm_area(C);	View3D *v3d = CTX_wm_view3d(C);		if (v3d != NULL && sa != NULL) {		if (v3d->localvd == NULL && v3d->scenelock && sa->spacetype == SPACE_VIEW3D) {			/* copy to scene */			scene->lay = v3d->lay;			scene->layact = v3d->layact;			scene->camera = v3d->camera;			/* not through notifier, listener don't have context			 * and non-open screens or spaces need to be updated too */			BKE_screen_view3d_main_sync(&bmain->screen, scene);						/* notifiers for scene update */			WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene);		}	}}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:24,


示例11: edbm_bevel_init

static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal){	Object *obedit = CTX_data_edit_object(C);	Scene *scene = CTX_data_scene(C);	BMEditMesh *em = BKE_editmesh_from_object(obedit);	BevelData *opdata;	if (em->bm->totvertsel == 0) {		return false;	}	op->customdata = opdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");	opdata->em = em;	opdata->is_modal = is_modal;	opdata->shift_factor = -1.0f;	initNumInput(&opdata->num_input);	opdata->num_input.idx_max = 0;	opdata->num_input.val_flag[0] |= NUM_NO_NEGATIVE;	opdata->num_input.unit_sys = scene->unit.system;	opdata->num_input.unit_type[0] = B_UNIT_NONE;  /* Not sure this is a factor or a unit? */	/* avoid the cost of allocating a bm copy */	if (is_modal) {		View3D *v3d = CTX_wm_view3d(C);		ARegion *ar = CTX_wm_region(C);		opdata->mesh_backup = EDBM_redo_state_store(em);		opdata->draw_handle_pixel = ED_region_draw_cb_activate(ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);		G.moving = G_TRANSFORM_EDIT;		opdata->twtype = v3d->twtype;		v3d->twtype = 0;	}	return true;}
开发者ID:jonntd,项目名称:blender,代码行数:37,


示例12: view3d_ruler_modal

static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event){	bool do_draw = false;	int exit_code = OPERATOR_RUNNING_MODAL;	RulerInfo *ruler_info = op->customdata;	ScrArea *sa = ruler_info->sa;	ARegion *ar = ruler_info->ar;	RegionView3D *rv3d = ar->regiondata;	/* its possible to change  spaces while running the operator [#34894] */	if (UNLIKELY(ar != CTX_wm_region(C))) {		exit_code = OPERATOR_FINISHED;		goto exit;	}	switch (event->type) {		case LEFTMOUSE:			if (event->val == KM_RELEASE) {				if (ruler_info->state == RULER_STATE_DRAG) {					/* rubber-band angle removal */					RulerItem *ruler_item = ruler_item_active_get(ruler_info);					if (ruler_item && (ruler_item->co_index == 1) && (ruler_item->flag & RULERITEM_USE_ANGLE)) {						if (!BLI_rcti_isect_pt_v(&ar->winrct, &event->x)) {							ruler_item->flag &= ~RULERITEM_USE_ANGLE;							do_draw = true;						}					}					if (ruler_info->snap_flag & RULER_SNAP_OK) {						ruler_info->snap_flag &= ~RULER_SNAP_OK;						do_draw = true;					}					ruler_info->state = RULER_STATE_NORMAL;				}			}			else {				if (ruler_info->state == RULER_STATE_NORMAL) {					if (event->ctrl ||					    /* weak - but user friendly */					    BLI_listbase_is_empty(&ruler_info->items))					{						View3D *v3d = CTX_wm_view3d(C);						const bool use_depth = (v3d->drawtype >= OB_SOLID);						/* Create new line */						RulerItem *ruler_item_prev = ruler_item_active_get(ruler_info);						RulerItem *ruler_item;						/* check if we want to drag an existing point or add a new one */						ruler_info->state = RULER_STATE_DRAG;						ruler_item = ruler_item_add(ruler_info);						ruler_item_active_set(ruler_info, ruler_item);						if (use_depth) {							/* snap the first point added, not essential but handy */							ruler_item->co_index = 0;							view3d_ruler_item_mousemove(C, ruler_info, event->mval, false, true);							copy_v3_v3(ruler_info->drag_start_co, ruler_item->co[ruler_item->co_index]);						}						else {							/* initial depth either previous ruler, view offset */							if (ruler_item_prev) {								copy_v3_v3(ruler_info->drag_start_co, ruler_item_prev->co[ruler_item_prev->co_index]);							}							else {								negate_v3_v3(ruler_info->drag_start_co, rv3d->ofs);							}							copy_v3_v3(ruler_item->co[0], ruler_info->drag_start_co);							view3d_ruler_item_project(ruler_info, ruler_item->co[0], event->mval);						}						copy_v3_v3(ruler_item->co[2], ruler_item->co[0]);						ruler_item->co_index = 2;						do_draw = true;					}					else {						float mval_fl[2] = {UNPACK2(event->mval)};						RulerItem *ruler_item_pick;						int co_index;						/* select and drag */						if (view3d_ruler_pick(ruler_info, mval_fl, &ruler_item_pick, &co_index)) {							if (co_index == -1) {								if ((ruler_item_pick->flag & RULERITEM_USE_ANGLE) == 0) {									/* Add Center Point */									ruler_item_active_set(ruler_info, ruler_item_pick);									ruler_item_pick->flag |= RULERITEM_USE_ANGLE;									ruler_item_pick->co_index = 1;									ruler_info->state = RULER_STATE_DRAG;									/* find the factor */									{										float co_ss[2][2];										float fac;										ED_view3d_project_float_global(ar, ruler_item_pick->co[0], co_ss[0], V3D_PROJ_TEST_NOP);										ED_view3d_project_float_global(ar, ruler_item_pick->co[2], co_ss[1], V3D_PROJ_TEST_NOP);//.........这里部分代码省略.........
开发者ID:SuriyaaKudoIsc,项目名称:blender-git,代码行数:101,


示例13: snap_curs_to_sel_ex

static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]){	Object *obedit = CTX_data_edit_object(C);	Scene *scene = CTX_data_scene(C);	View3D *v3d = CTX_wm_view3d(C);	TransVertStore tvs = {NULL};	TransVert *tv;	float bmat[3][3], vec[3], min[3], max[3], centroid[3];	int count, a;	count = 0;	INIT_MINMAX(min, max);	zero_v3(centroid);	if (obedit) {		if (ED_transverts_check_obedit(obedit))			ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES);		if (tvs.transverts_tot == 0) {			return false;		}		copy_m3_m4(bmat, obedit->obmat);				tv = tvs.transverts;		for (a = 0; a < tvs.transverts_tot; a++, tv++) {			copy_v3_v3(vec, tv->loc);			mul_m3_v3(bmat, vec);			add_v3_v3(vec, obedit->obmat[3]);			add_v3_v3(centroid, vec);			minmax_v3v3_v3(min, max, vec);		}				if (v3d->around == V3D_AROUND_CENTER_MEAN) {			mul_v3_fl(centroid, 1.0f / (float)tvs.transverts_tot);			copy_v3_v3(cursor, centroid);		}		else {			mid_v3_v3v3(cursor, min, max);		}		ED_transverts_free(&tvs);	}	else {		Object *obact = CTX_data_active_object(C);				if (obact && (obact->mode & OB_MODE_POSE)) {			bArmature *arm = obact->data;			bPoseChannel *pchan;			for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) {				if (arm->layer & pchan->bone->layer) {					if (pchan->bone->flag & BONE_SELECTED) {						copy_v3_v3(vec, pchan->pose_head);						mul_m4_v3(obact->obmat, vec);						add_v3_v3(centroid, vec);						minmax_v3v3_v3(min, max, vec);						count++;					}				}			}		}		else {			CTX_DATA_BEGIN (C, Object *, ob, selected_objects)			{				copy_v3_v3(vec, ob->obmat[3]);				/* special case for camera -- snap to bundles */				if (ob->type == OB_CAMERA) {					/* snap to bundles should happen only when bundles are visible */					if (v3d->flag2 & V3D_SHOW_RECONSTRUCTION) {						bundle_midpoint(scene, ob, vec);					}				}				add_v3_v3(centroid, vec);				minmax_v3v3_v3(min, max, vec);				count++;			}			CTX_DATA_END;		}		if (count == 0) {			return false;		}		if (v3d->around == V3D_AROUND_CENTER_MEAN) {			mul_v3_fl(centroid, 1.0f / (float)count);			copy_v3_v3(cursor, centroid);		}		else {			mid_v3_v3v3(cursor, min, max);		}	}
开发者ID:diekev,项目名称:blender,代码行数:94,


示例14: snap_selected_to_location

static int snap_selected_to_location(bContext *C, const float snap_target_global[3], const bool use_offset){	Scene *scene = CTX_data_scene(C);	Object *obedit = CTX_data_edit_object(C);	Object *obact = CTX_data_active_object(C);	View3D *v3d = CTX_wm_view3d(C);	TransVertStore tvs = {NULL};	TransVert *tv;	float imat[3][3], bmat[3][3];	float center_global[3];	float offset_global[3];	int a;	if (use_offset) {		if ((v3d && v3d->around == V3D_AROUND_ACTIVE) &&		    snap_calc_active_center(C, true, center_global))		{			/* pass */		}		else {			snap_curs_to_sel_ex(C, center_global);		}		sub_v3_v3v3(offset_global, snap_target_global, center_global);	}	if (obedit) {		float snap_target_local[3];				if (ED_transverts_check_obedit(obedit))			ED_transverts_create_from_obedit(&tvs, obedit, 0);		if (tvs.transverts_tot == 0)			return OPERATOR_CANCELLED;		copy_m3_m4(bmat, obedit->obmat);		invert_m3_m3(imat, bmat);				/* get the cursor in object space */		sub_v3_v3v3(snap_target_local, snap_target_global, obedit->obmat[3]);		mul_m3_v3(imat, snap_target_local);		if (use_offset) {			float offset_local[3];			mul_v3_m3v3(offset_local, imat, offset_global);			tv = tvs.transverts;			for (a = 0; a < tvs.transverts_tot; a++, tv++) {				add_v3_v3(tv->loc, offset_local);			}		}		else {			tv = tvs.transverts;			for (a = 0; a < tvs.transverts_tot; a++, tv++) {				copy_v3_v3(tv->loc, snap_target_local);			}		}				ED_transverts_update_obedit(&tvs, obedit);		ED_transverts_free(&tvs);	}	else if (obact && (obact->mode & OB_MODE_POSE)) {		struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);		bPoseChannel *pchan;		bArmature *arm = obact->data;		float snap_target_local[3];		invert_m4_m4(obact->imat, obact->obmat);		mul_v3_m4v3(snap_target_local, obact->imat, snap_target_global);		for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) {			if ((pchan->bone->flag & BONE_SELECTED) &&			    (PBONE_VISIBLE(arm, pchan->bone)) &&			    /* if the bone has a parent and is connected to the parent,			     * don't do anything - will break chain unless we do auto-ik.			     */			    (pchan->bone->flag & BONE_CONNECTED) == 0)			{				pchan->bone->flag |= BONE_TRANSFORM;			}			else {				pchan->bone->flag &= ~BONE_TRANSFORM;			}		}		for (pchan = obact->pose->chanbase.first; pchan; pchan = pchan->next) {			if ((pchan->bone->flag & BONE_TRANSFORM) &&			    /* check that our parents not transformed (if we have one) */			    ((pchan->bone->parent &&			      BKE_armature_bone_flag_test_recursive(pchan->bone->parent, BONE_TRANSFORM)) == 0))			{				/* Get position in pchan (pose) space. */				float cursor_pose[3];				if (use_offset) {					mul_v3_m4v3(cursor_pose, obact->obmat, pchan->pose_mat[3]);					add_v3_v3(cursor_pose, offset_global);					mul_m4_v3(obact->imat, cursor_pose);					BKE_armature_loc_pose_to_bone(pchan, cursor_pose, cursor_pose);//.........这里部分代码省略.........
开发者ID:diekev,项目名称:blender,代码行数:101,


示例15: gp_layer_to_curve

/* convert a given grease-pencil layer to a 3d-curve representation (using current view if appropriate) */static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bGPDlayer *gpl, const int mode,                              const bool norm_weights, const float rad_fac, const bool link_strokes, tGpTimingData *gtd){	struct Main *bmain = CTX_data_main(C);	View3D *v3d = CTX_wm_view3d(C);  /* may be NULL */	Scene *scene = CTX_data_scene(C);	bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0);	bGPDstroke *gps, *prev_gps = NULL;	Object *ob;	Curve *cu;	Nurb *nu = NULL;	Base *base_orig = BASACT, *base_new = NULL;	float minmax_weights[2] = {1.0f, 0.0f};		/* camera framing */	rctf subrect, *subrect_ptr = NULL;		/* error checking */	if (ELEM(NULL, gpd, gpl, gpf))		return;		/* only convert if there are any strokes on this layer's frame to convert */	if (BLI_listbase_is_empty(&gpf->strokes))		return;		/* initialize camera framing */	if (gp_camera_view_subrect(C, &subrect)) {		subrect_ptr = &subrect;	}		/* init the curve object (remove rotation and get curve data from it)	 *	- must clear transforms set on object, as those skew our results	 */	ob = BKE_object_add_only_object(bmain, OB_CURVE, gpl->info);	cu = ob->data = BKE_curve_add(bmain, gpl->info, OB_CURVE);	base_new = BKE_scene_base_add(scene, ob);		cu->flag |= CU_3D;		gtd->inittime = ((bGPDstroke *)gpf->strokes.first)->inittime;		/* add points to curve */	for (gps = gpf->strokes.first; gps; gps = gps->next) {		const bool add_start_point = (link_strokes && !(prev_gps));		const bool add_end_point = (link_strokes && !(gps->next));				/* Detect new strokes created because of GP_STROKE_BUFFER_MAX reached, and stitch them to previous one. */		bool stitch = false;		if (prev_gps) {			bGPDspoint *pt1 = &prev_gps->points[prev_gps->totpoints - 1];			bGPDspoint *pt2 = &gps->points[0];						if ((pt1->x == pt2->x) && (pt1->y == pt2->y)) {				stitch = true;			}		}				/* Decide whether we connect this stroke to previous one */		if (!(stitch || link_strokes)) {			nu = NULL;		}				switch (mode) {			case GP_STROKECONVERT_PATH:				gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch,				                  add_start_point, add_end_point, gtd);				break;			case GP_STROKECONVERT_CURVE:			case GP_STROKECONVERT_POLY:  /* convert after */				gp_stroke_to_bezier(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch,				                    add_start_point, add_end_point, gtd);				break;			default:				BLI_assert(!"invalid mode");				break;		}		prev_gps = gps;	}		/* If link_strokes, be sure first and last points have a zero weight/size! */	if (link_strokes) {		gp_stroke_finalize_curve_endpoints(cu);	}		/* Update curve's weights, if needed */	if (norm_weights && ((minmax_weights[0] > 0.0f) || (minmax_weights[1] < 1.0f))) {		gp_stroke_norm_curve_weights(cu, minmax_weights);	}		/* Create the path animation, if needed */	gp_stroke_path_animation(C, reports, cu, gtd);		if (mode == GP_STROKECONVERT_POLY) {		for (nu = cu->nurb.first; nu; nu = nu->next) {			BKE_nurb_type_convert(nu, CU_POLY, false);		}	}		/* set the layer and select *///.........这里部分代码省略.........
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:101,


示例16: armature_click_extrude_exec

/* the ctrl-click method */static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)){	View3D *v3d;	bArmature *arm;	EditBone *ebone, *newbone, *flipbone;	float mat[3][3], imat[3][3];	const float *curs;	int a, to_root = 0;	Object *obedit;	Scene *scene;	scene = CTX_data_scene(C);	v3d = CTX_wm_view3d(C);	obedit = CTX_data_edit_object(C);	arm = obedit->data;		/* find the active or selected bone */	for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {		if (EBONE_VISIBLE(arm, ebone)) {			if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone)				break;		}	}		if (ebone == NULL) {		for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {			if (EBONE_VISIBLE(arm, ebone)) {				if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone)					break;			}		}		if (ebone == NULL) 			return OPERATOR_CANCELLED;				to_root = 1;	}		ED_armature_deselect_all(obedit);		/* we re-use code for mirror editing... */	flipbone = NULL;	if (arm->flag & ARM_MIRROR_EDIT)		flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);	for (a = 0; a < 2; a++) {		if (a == 1) {			if (flipbone == NULL)				break;			else {				SWAP(EditBone *, flipbone, ebone);			}		}				newbone = ED_armature_edit_bone_add(arm, ebone->name);		arm->act_edbone = newbone;				if (to_root) {			copy_v3_v3(newbone->head, ebone->head);			newbone->rad_head = ebone->rad_tail;			newbone->parent = ebone->parent;		}		else {			copy_v3_v3(newbone->head, ebone->tail);			newbone->rad_head = ebone->rad_tail;			newbone->parent = ebone;			newbone->flag |= BONE_CONNECTED;		}				curs = ED_view3d_cursor3d_get(scene, v3d);		copy_v3_v3(newbone->tail, curs);		sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);				if (a == 1)			newbone->tail[0] = -newbone->tail[0];				copy_m3_m4(mat, obedit->obmat);		invert_m3_m3(imat, mat);		mul_m3_v3(imat, newbone->tail);				newbone->length = len_v3v3(newbone->head, newbone->tail);		newbone->rad_tail = newbone->length * 0.05f;		newbone->dist = newbone->length * 0.25f;			}		ED_armature_sync_selection(arm->edbo);	WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);		return OPERATOR_FINISHED;}
开发者ID:DarkDefender,项目名称:blender-npr-tess2,代码行数:92,


示例17: render_view3d_flag_changed

static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C){	RegionView3D *rv3d = CTX_wm_region_view3d(C);	View3D *v3d = CTX_wm_view3d(C);	ARegion *ar = CTX_wm_region(C);	Scene *scene = CTX_data_scene(C);	Render *re;	rctf viewplane;	rcti disprect;	float clipsta, clipend;	bool orth;	int job_update_flag = 0;	char name[32];		/* ensure render engine exists */	re = engine->re;	if (!re) {		sprintf(name, "View3dPreview %p", (void *)ar);		re = engine->re = RE_GetRender(name);		if (!re)			re = engine->re = RE_NewRender(name);		engine->update_flag |= RE_ENGINE_UPDATE_DATABASE;	}	/* check update_flag */	if (engine->update_flag & RE_ENGINE_UPDATE_MA)		job_update_flag |= PR_UPDATE_MATERIAL;		if (engine->update_flag & RE_ENGINE_UPDATE_OTHER)		job_update_flag |= PR_UPDATE_MATERIAL;		if (engine->update_flag & RE_ENGINE_UPDATE_DATABASE) {		job_update_flag |= PR_UPDATE_DATABASE;		/* load editmesh */		if (scene->obedit)			ED_object_editmode_load(scene->obedit);	}		engine->update_flag = 0;		/* check if viewport changed */	if (engine->last_winx != ar->winx || engine->last_winy != ar->winy) {		engine->last_winx = ar->winx;		engine->last_winy = ar->winy;		job_update_flag |= PR_UPDATE_RENDERSIZE;	}	if (compare_m4m4(engine->last_viewmat, rv3d->viewmat, 0.00001f) == 0) {		copy_m4_m4(engine->last_viewmat, rv3d->viewmat);		job_update_flag |= PR_UPDATE_VIEW;	}		render_view3d_get_rects(ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth);		if (BLI_rctf_compare(&viewplane, &engine->last_viewplane, 0.00001f) == 0) {		engine->last_viewplane = viewplane;		job_update_flag |= PR_UPDATE_VIEW;	}		render_view3d_disprect(scene, ar, v3d, rv3d, &disprect);	if (BLI_rcti_compare(&disprect, &engine->last_disprect) == 0) {		engine->last_disprect = disprect;		job_update_flag |= PR_UPDATE_RENDERSIZE;	}	/* any changes? go ahead and rerender */	if (job_update_flag) {		engine->job_update_flag |= job_update_flag;		return true;	}	return false;}
开发者ID:diosney,项目名称:blender,代码行数:76,


示例18: armature_fill_bones_exec

/* bone adding between selected joints */static int armature_fill_bones_exec(bContext *C, wmOperator *op){	Object *obedit = CTX_data_edit_object(C);	bArmature *arm = (obedit) ? obedit->data : NULL;	Scene *scene = CTX_data_scene(C);	View3D *v3d = CTX_wm_view3d(C);	ListBase points = {NULL, NULL};	int count;	/* sanity checks */	if (ELEM(NULL, obedit, arm))		return OPERATOR_CANCELLED;	/* loop over all bones, and only consider if visible */	CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)	{		if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL))			fill_add_joint(ebone, 0, &points);		if (ebone->flag & BONE_TIPSEL) 			fill_add_joint(ebone, 1, &points);	}	CTX_DATA_END;		/* the number of joints determines how we fill:	 *  1) between joint and cursor (joint=head, cursor=tail)	 *  2) between the two joints (order is dependent on active-bone/hierachy)	 *  3+) error (a smarter method involving finding chains needs to be worked out	 */	count = BLI_countlist(&points);		if (count == 0) {		BKE_report(op->reports, RPT_ERROR, "No joints selected");		return OPERATOR_CANCELLED;	}	else if (count == 1) {		EditBonePoint *ebp;		float curs[3];				/* Get Points - selected joint */		ebp = (EditBonePoint *)points.first;				/* Get points - cursor (tail) */		invert_m4_m4(obedit->imat, obedit->obmat);		mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));				/* Create a bone */		/* newbone = */ add_points_bone(obedit, ebp->vec, curs);	}	else if (count == 2) {		EditBonePoint *ebp, *ebp2;		float head[3], tail[3];		short headtail = 0;				/* check that the points don't belong to the same bone */		ebp = (EditBonePoint *)points.first;		ebp2 = ebp->next;				if ((ebp->head_owner == ebp2->tail_owner) && (ebp->head_owner != NULL)) {			BKE_report(op->reports, RPT_ERROR, "Same bone selected...");			BLI_freelistN(&points);			return OPERATOR_CANCELLED;		}		if ((ebp->tail_owner == ebp2->head_owner) && (ebp->tail_owner != NULL)) {			BKE_report(op->reports, RPT_ERROR, "Same bone selected...");			BLI_freelistN(&points);			return OPERATOR_CANCELLED;		}				/* find which one should be the 'head' */		if ((ebp->head_owner && ebp2->head_owner) || (ebp->tail_owner && ebp2->tail_owner)) {			/* rule: whichever one is closer to 3d-cursor */			float curs[3];			float vecA[3], vecB[3];			float distA, distB;						/* get cursor location */			invert_m4_m4(obedit->imat, obedit->obmat);			mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));						/* get distances */			sub_v3_v3v3(vecA, ebp->vec, curs);			sub_v3_v3v3(vecB, ebp2->vec, curs);			distA = len_v3(vecA);			distB = len_v3(vecB);						/* compare distances - closer one therefore acts as direction for bone to go */			headtail = (distA < distB) ? 2 : 1;		}		else if (ebp->head_owner) {			headtail = 1;		}		else if (ebp2->head_owner) {			headtail = 2;		}				/* assign head/tail combinations */		if (headtail == 2) {			copy_v3_v3(head, ebp->vec);			copy_v3_v3(tail, ebp2->vec);//.........这里部分代码省略.........
开发者ID:244xiao,项目名称:blender,代码行数:101,


示例19: armature_calc_roll_exec

static int armature_calc_roll_exec(bContext *C, wmOperator *op) {	Object *ob = CTX_data_edit_object(C);	const short type = RNA_enum_get(op->ptr, "type");	const short axis_only = RNA_boolean_get(op->ptr, "axis_only");	const short axis_flip = RNA_boolean_get(op->ptr, "axis_flip");	float imat[3][3];	bArmature *arm = ob->data;	EditBone *ebone;	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 = give_cursor(scene, v3d);						copy_v3_v3(cursor_local, cursor);		mul_m3_v3(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);				ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, 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;			}						copy_v3_v3(vec, rv3d->viewinv[2]);			mul_m3_v3(imat, vec);		}		else if (type == CALC_ROLL_ACTIVE) {			float mat[3][3], nor[3];			ebone = (EditBone *)arm->act_edbone;			if (ebone == NULL) {				BKE_report(op->reports, RPT_ERROR, "No active bone set");				return OPERATOR_CANCELLED;			}						sub_v3_v3v3(nor, ebone->tail, ebone->head);			vec_roll_to_mat3(nor, ebone->roll, mat);			copy_v3_v3(vec, mat[2]);		}		else { /* Axis */			assert(type >= 0 && type <= 5);			if (type < 3) vec[type] = 1.0f;			else vec[type - 2] = -1.0f;			mul_m3_v3(imat, vec);		}				if (axis_flip) negate_v3(vec);				for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {			if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {				/* roll func is a callback which assumes that all is well */				ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only);			}		}	}		if (arm->flag & ARM_MIRROR_EDIT) {		for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {			if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {				EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone);				if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {					ebone->roll = -ebone_mirr->roll;				}			}		}	}		/* note, notifier might evolve */	WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);		return OPERATOR_FINISHED;}
开发者ID:244xiao,项目名称:blender,代码行数:92,


示例20: screen_render_invoke

/* using context, starts job */static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *event){	/* new render clears all callbacks */	Main *mainp;	Scene *scene = CTX_data_scene(C);	SceneRenderLayer *srl = NULL;	View3D *v3d = CTX_wm_view3d(C);	Render *re;	wmJob *wm_job;	RenderJob *rj;	Image *ima;	int jobflag;	const short is_animation = RNA_boolean_get(op->ptr, "animation");	const short is_write_still = RNA_boolean_get(op->ptr, "write_still");	struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;	const char *name;	Object *active_object = CTX_data_active_object(C);		/* only one render job at a time */	if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER))		return OPERATOR_CANCELLED;	if (!RE_is_rendering_allowed(scene, camera_override, op->reports)) {		return OPERATOR_CANCELLED;	}	if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) {		BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected");		return OPERATOR_CANCELLED;	}		/* stop all running jobs, except screen one. currently previews frustrate Render */	WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C));	/* get main */	if (G.debug_value == 101) {		/* thread-safety experiment, copy main from the undo buffer */		mainp = BKE_undo_get_main(&scene);	}	else		mainp = CTX_data_main(C);	/* cancel animation playback */	if (ED_screen_animation_playing(CTX_wm_manager(C)))		ED_screen_animation_play(C, 0, 0);		/* handle UI stuff */	WM_cursor_wait(1);	/* flush multires changes (for sculpt) */	multires_force_render_update(active_object);	/* flush changes from dynamic topology sculpt */	sculptsession_bm_to_me_for_render(active_object);	/* cleanup sequencer caches before starting user triggered render.	 * otherwise, invalidated cache entries can make their way into	 * the output rendering. We can't put that into RE_BlenderFrame,	 * since sequence rendering can call that recursively... (peter) */	BKE_sequencer_cache_cleanup();	/* get editmode results */	ED_object_editmode_load(CTX_data_edit_object(C));	// store spare	// get view3d layer, local layer, make this nice api call to render	// store spare	/* ensure at least 1 area shows result */	render_view_open(C, event->x, event->y);	jobflag = WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS;		/* custom scene and single layer re-render */	screen_render_scene_layer_set(op, mainp, &scene, &srl);	if (RNA_struct_property_is_set(op->ptr, "layer"))		jobflag |= WM_JOB_SUSPEND;	/* job custom data */	rj = MEM_callocN(sizeof(RenderJob), "render job");	rj->main = mainp;	rj->scene = scene;	rj->win = CTX_wm_window(C);	rj->srl = srl;	rj->camera_override = camera_override;	rj->lay = scene->lay;	rj->anim = is_animation;	rj->write_still = is_write_still && !is_animation;	rj->iuser.scene = scene;	rj->iuser.ok = 1;	rj->reports = op->reports;	if (v3d) {		rj->lay = v3d->lay;		if (v3d->localvd)			rj->lay |= v3d->localvd->lay;	}//.........这里部分代码省略.........
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:101,


示例21: view3d_layers_poll

static int view3d_layers_poll(bContext *C){	return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd == NULL);}
开发者ID:vanangamudi,项目名称:blender-main,代码行数:4,


示例22: screen_render_invoke

/* using context, starts job */static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event){	/* new render clears all callbacks */	Main *mainp;	Scene *scene= CTX_data_scene(C);	SceneRenderLayer *srl=NULL;	bScreen *screen= CTX_wm_screen(C);	View3D *v3d= CTX_wm_view3d(C);	Render *re;	wmJob *steve;	RenderJob *rj;	Image *ima;	int jobflag;	const short is_animation= RNA_boolean_get(op->ptr, "animation");	const short is_write_still= RNA_boolean_get(op->ptr, "write_still");	struct Object *camera_override= v3d ? V3D_CAMERA_LOCAL(v3d) : NULL;		/* only one render job at a time */	if(WM_jobs_test(CTX_wm_manager(C), scene))		return OPERATOR_CANCELLED;	if(!RE_is_rendering_allowed(scene, camera_override, op->reports)) {		return OPERATOR_CANCELLED;	}	if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) {		BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected.");		return OPERATOR_CANCELLED;	}			/* stop all running jobs, currently previews frustrate Render */	WM_jobs_stop_all(CTX_wm_manager(C));	/* get main */	if(G.rt == 101) {		/* thread-safety experiment, copy main from the undo buffer */		mainp= BKE_undo_get_main(&scene);	}	else		mainp= CTX_data_main(C);	/* cancel animation playback */	if (screen->animtimer)		ED_screen_animation_play(C, 0, 0);		/* handle UI stuff */	WM_cursor_wait(1);	/* flush multires changes (for sculpt) */	multires_force_render_update(CTX_data_active_object(C));	/* cleanup sequencer caches before starting user triggered render.	   otherwise, invalidated cache entries can make their way into	   the output rendering. We can't put that into RE_BlenderFrame,	   since sequence rendering can call that recursively... (peter) */	seq_stripelem_cache_cleanup();	/* get editmode results */	ED_object_exit_editmode(C, 0);	/* 0 = does not exit editmode */	// store spare	// get view3d layer, local layer, make this nice api call to render	// store spare	/* ensure at least 1 area shows result */	render_view_open(C, event->x, event->y);	jobflag= WM_JOB_EXCL_RENDER|WM_JOB_PRIORITY|WM_JOB_PROGRESS;		/* single layer re-render */	if(RNA_property_is_set(op->ptr, "layer")) {		SceneRenderLayer *rl;		Scene *scn;		char scene_name[MAX_ID_NAME-2], rl_name[RE_MAXNAME];		RNA_string_get(op->ptr, "layer", rl_name);		RNA_string_get(op->ptr, "scene", scene_name);		scn = (Scene *)BLI_findstring(&mainp->scene, scene_name, offsetof(ID, name) + 2);		rl = (SceneRenderLayer *)BLI_findstring(&scene->r.layers, rl_name, offsetof(SceneRenderLayer, name));				if (scn && rl) {			/* camera switch wont have updated */			scn->r.cfra= scene->r.cfra;			scene_camera_switch_update(scn);			scene = scn;			srl = rl;		}		jobflag |= WM_JOB_SUSPEND;	}	/* job custom data */	rj= MEM_callocN(sizeof(RenderJob), "render job");	rj->main= mainp;	rj->scene= scene;	rj->win= CTX_wm_window(C);	rj->srl = srl;	rj->camera_override = camera_override;//.........这里部分代码省略.........
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:101,


示例23: draw_gpencil_panel

/* Draw the contents for a grease-pencil panel*/static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, PointerRNA *ctx_ptr){	PointerRNA gpd_ptr;	bGPDlayer *gpl;	uiLayout *col, *row;	SpaceClip *sc = CTX_wm_space_clip(C);	short v3d_stroke_opts = STROKE_OPTS_NORMAL;	const short is_v3d = CTX_wm_view3d(C) != NULL;		/* make new PointerRNA for Grease Pencil block */	RNA_id_pointer_create((ID *)gpd, &gpd_ptr);		/* draw gpd settings first ------------------------------------- */	col = uiLayoutColumn(layout, FALSE);	/* current Grease Pencil block */	/* TODO: show some info about who owns this? */	uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink");		/* add new layer button - can be used even when no data, since it can add a new block too */	uiItemO(col, IFACE_("New Layer"), ICON_NONE, "GPENCIL_OT_layer_add");	row = uiLayoutRow(col, TRUE);	uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete");	uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert");		/* sanity checks... */	if (gpd == NULL)		return;		/* draw each layer --------------------------------------------- */	for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {		col = uiLayoutColumn(layout, TRUE);		gp_drawui_layer(col, gpd, gpl, is_v3d);	}		/* draw gpd drawing settings first ------------------------------------- */	col = uiLayoutColumn(layout, TRUE);	/* label */	uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE);			/* check whether advanced 3D-View drawing space options can be used */	if (is_v3d) {		if (gpd->flag & (GP_DATA_DEPTH_STROKE | GP_DATA_DEPTH_VIEW))			v3d_stroke_opts = STROKE_OPTS_V3D_ON;		else			v3d_stroke_opts = STROKE_OPTS_V3D_OFF;	}			/* drawing space options */	row = uiLayoutRow(col, TRUE);	uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE);	uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE);	if (sc == NULL) {		row = uiLayoutRow(col, TRUE);		uiLayoutSetActive(row, v3d_stroke_opts);		uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE);		uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE);		row = uiLayoutRow(col, FALSE);		uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON);		uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE);	}}
开发者ID:244xiao,项目名称:blender,代码行数:65,


示例24: StartKetsjiShell

extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *cam_frame, int always_use_expand_framing){	/* context values */	struct wmWindowManager *wm= CTX_wm_manager(C);	struct wmWindow *win= CTX_wm_window(C);	struct Scene *startscene= CTX_data_scene(C);	struct Main* maggie1= CTX_data_main(C);	RAS_Rect area_rect;	area_rect.SetLeft(cam_frame->xmin);	area_rect.SetBottom(cam_frame->ymin);	area_rect.SetRight(cam_frame->xmax);	area_rect.SetTop(cam_frame->ymax);	int exitrequested = KX_EXIT_REQUEST_NO_REQUEST;	Main* blenderdata = maggie1;	char* startscenename = startscene->id.name+2;	char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE];	STR_String exitstring = "";	BlendFileData *bfd= NULL;	BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));	BLI_strncpy(oldsce, G.main->name, sizeof(oldsce));#ifdef WITH_PYTHON	resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path	setGamePythonPath(G.main->name);	// Acquire Python's GIL (global interpreter lock)	// so we can safely run Python code and API calls	PyGILState_STATE gilstate = PyGILState_Ensure();		PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */#endif		bgl::InitExtensions(true);	// VBO code for derived mesh is not compatible with BGE (couldn't find why), so disable	int disableVBO = (U.gameflags & USER_DISABLE_VBO);	U.gameflags |= USER_DISABLE_VBO;	// Globals to be carried on over blender files	GlobalSettings gs;	gs.matmode= startscene->gm.matmode;	gs.glslflag= startscene->gm.flag;	do	{		View3D *v3d= CTX_wm_view3d(C);		RegionView3D *rv3d= CTX_wm_region_view3d(C);		// get some preferences		SYS_SystemHandle syshandle = SYS_GetSystem();		bool properties	= (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);		bool usefixed = (SYS_GetCommandLineInt(syshandle, "fixedtime", 0) != 0);		bool profile = (SYS_GetCommandLineInt(syshandle, "show_profile", 0) != 0);		bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);		bool animation_record = (SYS_GetCommandLineInt(syshandle, "animation_record", 0) != 0);		bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0) && GPU_display_list_support();#ifdef WITH_PYTHON		bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 0) != 0);#endif		// bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0);		bool mouse_state = (startscene->gm.flag & GAME_SHOW_MOUSE) != 0;		bool restrictAnimFPS = (startscene->gm.flag & GAME_RESTRICT_ANIM_UPDATES) != 0;		short drawtype = v3d->drawtype;				/* we do not support material mode in game engine, force change to texture mode */		if (drawtype == OB_MATERIAL) drawtype = OB_TEXTURE;		if (animation_record) usefixed= false; /* override since you don't want to run full-speed for sim recording */		// create the canvas and rasterizer		RAS_ICanvas* canvas = new KX_BlenderCanvas(wm, win, area_rect, ar);				// default mouse state set on render panel		if (mouse_state)			canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);		else			canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);		// Setup vsync		int previous_vsync = 0;		canvas->GetSwapInterval(previous_vsync);		if (startscene->gm.vsync == VSYNC_ADAPTIVE)			canvas->SetSwapInterval(-1);		else			canvas->SetSwapInterval((startscene->gm.vsync == VSYNC_ON) ? 1 : 0);		RAS_IRasterizer* rasterizer = NULL;		//Don't use displaylists with VBOs		//If auto starts using VBOs, make sure to check for that here		if (displaylists && startscene->gm.raster_storage != RAS_STORE_VBO)			rasterizer = new RAS_ListRasterizer(canvas, true, startscene->gm.raster_storage);		else			rasterizer = new RAS_OpenGLRasterizer(canvas, startscene->gm.raster_storage);		RAS_IRasterizer::MipmapOption mipmapval = rasterizer->GetMipmapping();//.........这里部分代码省略.........
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:101,


示例25: initWalkInfo

static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op){	wmWindow *win = CTX_wm_window(C);	walk->rv3d = CTX_wm_region_view3d(C);	walk->v3d = CTX_wm_view3d(C);	walk->ar = CTX_wm_region(C);	walk->scene = CTX_data_scene(C);#ifdef NDOF_WALK_DEBUG	puts("/n-- walk begin --");#endif	/* sanity check: for rare but possible case (if lib-linking the camera fails) */	if ((walk->rv3d->persp == RV3D_CAMOB) && (walk->v3d->camera == NULL)) {		walk->rv3d->persp = RV3D_PERSP;	}	if (walk->rv3d->persp == RV3D_CAMOB && walk->v3d->camera->id.lib) {		BKE_report(op->reports, RPT_ERROR, "Cannot navigate a camera from an external library");		return false;	}	if (ED_view3d_offset_lock_check(walk->v3d, walk->rv3d)) {		BKE_report(op->reports, RPT_ERROR, "Cannot navigate when the view offset is locked");		return false;	}	if (walk->rv3d->persp == RV3D_CAMOB && walk->v3d->camera->constraints.first) {		BKE_report(op->reports, RPT_ERROR, "Cannot navigate an object with constraints");		return false;	}	walk->state = WALK_RUNNING;	if (fabsf(U.walk_navigation.walk_speed - userdef_speed) > 0.1f) {		base_speed = U.walk_navigation.walk_speed;		userdef_speed = U.walk_navigation.walk_speed;	}	walk->speed = 0.0f;	walk->is_fast = false;	walk->is_slow = false;	walk->grid = (walk->scene->unit.system == USER_UNIT_NONE) ? 1.f : 1.f / walk->scene->unit.scale_length;	/* user preference settings */	walk->teleport.duration = U.walk_navigation.teleport_time;	walk->mouse_speed = U.walk_navigation.mouse_speed;	if ((U.walk_navigation.flag & USER_WALK_GRAVITY))		walk_navigation_mode_set(C, op, walk, WALK_MODE_GRAVITY);	else		walk_navigation_mode_set(C, op, walk, WALK_MODE_FREE);	walk->view_height = U.walk_navigation.view_height;	walk->jump_height = U.walk_navigation.jump_height;	walk->speed = U.walk_navigation.walk_speed;	walk->speed_factor = U.walk_navigation.walk_speed_factor;	walk->gravity_state = WALK_GRAVITY_STATE_OFF;	if ((walk->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY)) {		walk->gravity = fabsf(walk->scene->physics_settings.gravity[2]);	}	else {		walk->gravity = 9.80668f; /* m/s2 */	}	walk->is_reversed = ((U.walk_navigation.flag & USER_WALK_MOUSE_REVERSE) != 0);#ifdef USE_TABLET_SUPPORT	walk->is_cursor_first = true;	walk->is_cursor_absolute = false;#endif	walk->active_directions = 0;#ifdef NDOF_WALK_DRAW_TOOMUCH	walk->redraw = 1;#endif	zero_v3(walk->dvec_prev);	walk->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);	walk->ndof = NULL;	walk->time_lastdraw = PIL_check_seconds_timer();	walk->draw_handle_pixel = ED_region_draw_cb_activate(walk->ar->type, drawWalkPixel, walk, REGION_DRAW_POST_PIXEL);	walk->rv3d->rflag |= RV3D_NAVIGATING;	walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(	        walk->scene, walk->v3d, walk->rv3d,	        (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);	/* center the mouse */	walk->center_mval[0] = walk->ar->winx * 0.5f;//.........这里部分代码省略.........
开发者ID:Bforartists,项目名称:Bforartists,代码行数:101,



注:本文中的CTX_wm_view3d函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CTX_wm_window_set函数代码示例
C++ CTX_wm_space_node函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。