This diff allows using an Armature’s bone as a DOF target for a camera. This is useful when using an armature as a camera rig, to avoid creating and targetting an Empty object.
Details
Details
Diff Detail
Diff Detail
- Repository
- rB Blender
Event Timeline
Comment Actions
I wanted to investigate a bit more whether I could implement Cycles support, but I really couldn’t. I’ll assign it to the developers who wrote the code surrounding the modifications now.
Comment Actions
Accepting functionality, there are some missing relationship updates though.
- ED_armature_bone_rename should be updated.
- source/blender/depsgraph/intern/builder/deg_builder_relations.cc needs to know about this relationship too.
| source/blender/makesdna/DNA_camera_types.h | ||
|---|---|---|
| 74 | Anything against the name focus_subtarget? matching constraints, allowing for non-bone sub-targets in the future. | |
Comment Actions
For Cycles it would be something like this (untested):
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 40a1a2c2edc..4beef2ffa9d 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -140,11 +140,20 @@ static float blender_camera_focal_distance(BL::RenderEngine &b_engine, if (!b_dof_object) return b_camera.dof().focus_distance(); + Transform dofmat = get_transform(b_dof_object.matrix_world()); + + string focus_bone = b_camera.dof().focus_bone(); + if (b_dof_object.pose() && !focus_bone.empty()) { + BL::PoseBone b_bone = b_dof_object.pose().bones[focus_bone]; + if (b_bone) { + dofmat = dofmat * get_transform(b_bone.matrix()); + } + } + /* for dof object, return distance along camera Z direction */ BL::Array<float, 16> b_ob_matrix; b_engine.camera_model_matrix(b_ob, bcam->use_spherical_stereo, b_ob_matrix); Transform obmat = transform_clear_scale(get_transform(b_ob_matrix)); - Transform dofmat = get_transform(b_dof_object.matrix_world()); float3 view_dir = normalize(transform_get_column(&obmat, 2)); float3 dof_dir = transform_get_column(&obmat, 3) - transform_get_column(&dofmat, 3); return fabsf(dot(view_dir, dof_dir));
Comment Actions
- Rename focus_bone to focus_subtarget
- Use Brecht’s code for Cycles
- Expose the property in Cycles’ UI
- Side note: the focus_object property does not display the same name in Cycles’ (Focus Object) and Eevee’s UIs (Focus on Object). I named the subtarget property accordingly (Focus Bone, Focus on Bone), but perhaps they should be unified.
- Update source/blender/editors/armature/armature_naming.c and source/blender/depsgraph/intern/builder/deg_builder_relations.cc
- I don’t properly understand the depsgraph’s logic so I may have got it wrong:
- the code in deg_builder_relations.cc doesn’t appear to have any effect
- in armature_naming.c I call DEG_id_tag_update() on the camera data, which isn’t done elsewhere in this file.
Comment Actions
Update to latest master: there were very few conflicts, and the patch still works as expected.
| release/scripts/startup/bl_ui/properties_data_camera.py | ||
|---|---|---|
| 221 | *picky* enum strings normally^ use single quotes 'ARMATURE'. | |