Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-10-05 17:15:58 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-10-05 17:15:58 +0400
commit1bf56930ac18c7ae6c37079fb25446108e1e7309 (patch)
tree9a5aaa872b2107952499c6a25154286131726097
parent629ddacd48d1cb4256f25620730ab870bbd7eb60 (diff)
bugfix [#24122] Shift-C doesn't work in "Camera View"
also fixed some glitches with smoothview.
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c30
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c32
2 files changed, 26 insertions, 36 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 06d93f01e02..4cac0e297d1 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1274,7 +1274,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX);
}
-static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
+static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */
{
ARegion *ar= CTX_wm_region(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -1289,12 +1289,11 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
int ok= 1, onedone=0;
if(center) {
- min[0]= min[1]= min[2]= 0.0f;
- max[0]= max[1]= max[2]= 0.0f;
-
/* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */
curs= give_cursor(scene, v3d);
- curs[0]= curs[1]= curs[2]= 0.0;
+ zero_v3(min);
+ zero_v3(max);
+ zero_v3(curs);
}
else {
INIT_MINMAX(min, max);
@@ -1318,9 +1317,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
return OPERATOR_FINISHED;
}
- afm[0]= (max[0]-min[0]);
- afm[1]= (max[1]-min[1]);
- afm[2]= (max[2]-min[2]);
+ sub_v3_v3v3(afm, max, min);
size= 0.7f*MAX3(afm[0], afm[1], afm[2]);
if(size==0.0) ok= 0;
@@ -1342,7 +1339,7 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
if (rv3d->persp==RV3D_CAMOB) {
rv3d->persp= RV3D_PERSP;
- smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL);
+ smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL);
}
else {
smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
@@ -1358,17 +1355,6 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
return OPERATOR_FINISHED;
}
-static int viewhome_poll(bContext *C)
-{
- if(ED_operator_view3d_active(C)) {
- RegionView3D *rv3d= CTX_wm_region_view3d(C); //XXX, when accessed from a header menu this doesnt work!
- if(rv3d && rv3d->persp!=RV3D_CAMOB) {
- return 1;
- }
- }
-
- return 0;
-}
void VIEW3D_OT_view_all(wmOperatorType *ot)
{
@@ -1378,8 +1364,8 @@ void VIEW3D_OT_view_all(wmOperatorType *ot)
ot->idname= "VIEW3D_OT_view_all";
/* api callbacks */
- ot->exec= viewhome_exec;
- ot->poll= viewhome_poll;
+ ot->exec= view3d_all_exec;
+ ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= 0;
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index d66144b2c30..860f9f461c4 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -205,7 +205,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
if(quat) copy_qt_qt(sms.new_quat, quat);
if(dist) sms.new_dist= *dist;
if(lens) sms.new_lens= *lens;
-
+
if (camera) {
view3d_settings_from_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens);
sms.to_camera= 1; /* restore view3d values in end */
@@ -214,15 +214,15 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
if (C && U.smooth_viewtx) {
int changed = 0; /* zero means no difference */
- if (sms.new_dist != rv3d->dist)
+ if (oldcamera != camera)
changed = 1;
- if (sms.new_lens != v3d->lens)
+ else if (sms.new_dist != rv3d->dist)
changed = 1;
-
- if (!equals_v3v3(sms.new_ofs, rv3d->ofs))
+ else if (sms.new_lens != v3d->lens)
changed = 1;
-
- if (!equals_v4v4(sms.new_quat, rv3d->viewquat))
+ else if (!equals_v3v3(sms.new_ofs, rv3d->ofs))
+ changed = 1;
+ else if (!equals_v4v4(sms.new_quat, rv3d->viewquat))
changed = 1;
/* The new view is different from the old one
@@ -449,17 +449,21 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
Scene *scene= CTX_data_scene(C);
-
- if(BASACT) {
+ Object *ob = CTX_data_active_object(C);
+
+ if(ob) {
+ Object *camera_old= (rv3d->persp == RV3D_CAMOB && scene->camera) ? scene->camera : NULL;
rv3d->persp= RV3D_CAMOB;
- v3d->camera= OBACT;
+ v3d->camera= ob;
if(v3d->scenelock)
- scene->camera= OBACT;
- smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
+ scene->camera= ob;
+
+ if(camera_old != ob) /* unlikely but looks like a glitch when set to the same */
+ smooth_view(C, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
+
+ WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C));
}
- WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C));
-
return OPERATOR_FINISHED;
}