From 880284a41e843ebe751e005a046586ba6718681b Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Thu, 28 Jul 2022 15:32:02 +0200 Subject: Add camera rigs: use bone subtarget for DOF We no longer need the Empty workaround since rB2e70d5cb980e Also fix UI error when Track To constraint was renamed Differential Revision: https://developer.blender.org/D15471 --- add_camera_rigs/operators.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'add_camera_rigs/operators.py') diff --git a/add_camera_rigs/operators.py b/add_camera_rigs/operators.py index 18300e08..29e77e3b 100644 --- a/add_camera_rigs/operators.py +++ b/add_camera_rigs/operators.py @@ -73,30 +73,16 @@ class ADD_CAMERA_RIGS_OT_add_marker_bind(Operator, CameraRigMixin): return {'FINISHED'} -class ADD_CAMERA_RIGS_OT_add_dof_object(Operator, CameraRigMixin): - bl_idname = "add_camera_rigs.add_dof_object" - bl_label = "Add DOF Object" - bl_description = "Create Empty and add as DOF Object" +class ADD_CAMERA_RIGS_OT_set_dof_bone(Operator, CameraRigMixin): + bl_idname = "add_camera_rigs.set_dof_bone" + bl_label = "Set DOF Bone" + bl_description = "Set the Aim bone as a DOF target" def execute(self, context): rig, cam = get_rig_and_cam(context.active_object) - bone = rig.data.bones['Aim_shape_rotation-MCH'] - # Add Empty - empty_obj = bpy.data.objects.new("EmptyDOF", None) - context.scene.collection.objects.link(empty_obj) - - # Parent to Aim Child bone - empty_obj.parent = rig - empty_obj.parent_type = "BONE" - empty_obj.parent_bone = "Aim_shape_rotation-MCH" - - # Move to bone head - empty_obj.location = bone.head - - # Make this new empty the dof_object - cam.data.dof.use_dof = True - cam.data.dof.focus_object = empty_obj + cam.data.dof.focus_object = rig + cam.data.dof.focus_subtarget = 'Aim_shape_rotation-MCH' return {'FINISHED'} @@ -104,7 +90,7 @@ class ADD_CAMERA_RIGS_OT_add_dof_object(Operator, CameraRigMixin): classes = ( ADD_CAMERA_RIGS_OT_set_scene_camera, ADD_CAMERA_RIGS_OT_add_marker_bind, - ADD_CAMERA_RIGS_OT_add_dof_object, + ADD_CAMERA_RIGS_OT_set_dof_bone, ) -- cgit v1.2.3