2.5
****** small commit, ported cameratoview3d, please check i have the correct naming and notifier
This commit is contained in:
@@ -116,6 +116,7 @@ void VIEW3D_OT_lasso_select(struct wmOperatorType *ot);
|
||||
|
||||
/* view3d_view.c */
|
||||
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);
|
||||
void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot);
|
||||
|
||||
void view3d_operator_needs_opengl(const struct bContext *C);
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ void view3d_operatortypes(void)
|
||||
WM_operatortype_append(VIEW3D_OT_render_border);
|
||||
WM_operatortype_append(VIEW3D_OT_cursor3d);
|
||||
WM_operatortype_append(VIEW3D_OT_lasso_select);
|
||||
WM_operatortype_append(VIEW3D_OT_setcameratoview);
|
||||
|
||||
transform_operatortypes();
|
||||
}
|
||||
@@ -130,6 +131,8 @@ void view3d_keymap(wmWindowManager *wm)
|
||||
|
||||
WM_keymap_add_item(keymap, "VIEW3D_OT_clipping", BKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "VIEW3D_OT_set_camera_to_view", PAD0, KM_PRESS, KM_ALT|KM_CTRL, 0);
|
||||
|
||||
/* TODO - this is just while we have no way to load a text datablock */
|
||||
RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");
|
||||
|
||||
@@ -380,6 +380,46 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot)
|
||||
|
||||
ot->poll= ED_operator_view3d_active;
|
||||
}
|
||||
static int view3d_setcameratoview_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
View3D *v3d= sa->spacedata.first;
|
||||
Object *ob;
|
||||
float dvec[3];
|
||||
|
||||
ob= v3d->camera;
|
||||
dvec[0]= v3d->dist*v3d->viewinv[2][0];
|
||||
dvec[1]= v3d->dist*v3d->viewinv[2][1];
|
||||
dvec[2]= v3d->dist*v3d->viewinv[2][2];
|
||||
VECCOPY(ob->loc, dvec);
|
||||
VecSubf(ob->loc, ob->loc, v3d->ofs);
|
||||
v3d->viewquat[0]= -v3d->viewquat[0];
|
||||
/* */
|
||||
/*if (ob->transflag & OB_QUAT) {
|
||||
QUATCOPY(ob->quat, v3d->viewquat);
|
||||
} else {*/
|
||||
QuatToEul(v3d->viewquat, ob->rot);
|
||||
/*}*/
|
||||
v3d->viewquat[0]= -v3d->viewquat[0];
|
||||
|
||||
ob->recalc= OB_RECALC_OB;
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, CTX_data_scene(C));
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
|
||||
}
|
||||
void VIEW3D_OT_setcameratoview(wmOperatorType *ot)
|
||||
{
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Align Camera To View";
|
||||
ot->idname= "VIEW3D_OT_set_camera_to_view";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= view3d_setcameratoview_exec;
|
||||
ot->poll= ED_operator_view3d_active;
|
||||
}
|
||||
|
||||
/* ********************************** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user