diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-05-23 06:53:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-05-23 06:53:30 +0400 |
commit | b222863336a86e772bcf5d7e1007a72f6667d53b (patch) | |
tree | 040c83983b5a5dcc7a0b9feca6005e9f8a979eaf /source/blender/editors/space_view3d/view3d_edit.c | |
parent | 0d26333eb502d9a25e0b82aa5b5276b4767a08f0 (diff) |
fix [#27459] Flymode moves parent
for durian we had camera rigs which needed to have the parent transformed rather then the camera, for this reason I made fly mode fly the parent rather then the camera its self.
Make this a preference and use this for view camera/view locking too.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index f039a3a7571..9b451095c64 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -92,9 +92,39 @@ void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) void ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) { if(v3d->camera && (v3d->flag2 & V3D_LOCK_CAMERA) && (rv3d->persp==RV3D_CAMOB)) { - ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); - WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera); + Object *root_parent; + + if((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (root_parent= v3d->camera->parent)) { + Object *ob_update; + float view_mat[4][4]; + float diff_mat[4][4]; + float parent_mat[4][4]; + + while(root_parent->parent) { + root_parent= root_parent->parent; + } + + ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); + + invert_m4_m4(v3d->camera->imat, v3d->camera->obmat); + mul_m4_m4m4(diff_mat, v3d->camera->imat, view_mat); + + mul_m4_m4m4(parent_mat, root_parent->obmat, diff_mat); + object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); + + ob_update= v3d->camera; + while(ob_update) { + DAG_id_tag_update(&ob_update->id, OB_RECALC_OB); + WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, ob_update); + ob_update= ob_update->parent; + } + } + else { + ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); + root_parent= v3d->camera; + DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); + WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, v3d->camera); + } } } |