forked from bartvdbraak/blender
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.
This commit is contained in:
parent
0d26333eb5
commit
b222863336
@ -199,6 +199,7 @@ class USERPREF_PT_interface(bpy.types.Panel):
|
||||
col.prop(view, "use_zoom_to_mouse")
|
||||
col.prop(view, "use_rotate_around_active")
|
||||
col.prop(view, "use_global_pivot")
|
||||
col.prop(view, "use_camera_lock_parent")
|
||||
|
||||
col.separator()
|
||||
|
||||
|
@ -92,11 +92,41 @@ 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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ********************* box view support ***************** */
|
||||
|
@ -307,7 +307,7 @@ static int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *even
|
||||
fly->dist_backup= fly->rv3d->dist;
|
||||
if (fly->rv3d->persp==RV3D_CAMOB) {
|
||||
Object *ob_back;
|
||||
if((fly->root_parent=fly->v3d->camera->parent)) {
|
||||
if((U.uiflag & USER_CAM_LOCK_NO_PARENT)==0 && (fly->root_parent=fly->v3d->camera->parent)) {
|
||||
while(fly->root_parent->parent)
|
||||
fly->root_parent= fly->root_parent->parent;
|
||||
ob_back= fly->root_parent;
|
||||
|
@ -469,7 +469,7 @@ extern UserDef U; /* from blenkernel blender.c */
|
||||
#define USER_HIDE_DOT (1 << 16)
|
||||
#define USER_SHOW_ROTVIEWICON (1 << 17)
|
||||
#define USER_SHOW_VIEWPORTNAME (1 << 18)
|
||||
// old flag for #define USER_KEYINSERTNEED (1 << 19)
|
||||
#define USER_CAM_LOCK_NO_PARENT (1 << 19)
|
||||
#define USER_ZOOM_TO_MOUSEPOS (1 << 20)
|
||||
#define USER_SHOW_FPS (1 << 21)
|
||||
#define USER_MMB_PASTE (1 << 22)
|
||||
|
@ -2040,6 +2040,10 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ORBIT_ZBUF);
|
||||
RNA_def_property_ui_text(prop, "Auto Depth", "Use the depth under the mouse to improve view pan/rotate/zoom functionality");
|
||||
|
||||
prop= RNA_def_property(srna, "use_camera_lock_parent", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_CAM_LOCK_NO_PARENT);
|
||||
RNA_def_property_ui_text(prop, "Camera Parent Lock", "When the camera is locked to the view and in fly mode, transform the parent rather then the camera");
|
||||
|
||||
/* view zoom */
|
||||
prop= RNA_def_property(srna, "use_zoom_to_mouse", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_TO_MOUSEPOS);
|
||||
|
Loading…
Reference in New Issue
Block a user