Blender Git Loki
Git Commits -> Revision 686ab4c
Revision 686ab4c by Sybren A. Stüvel (master) July 20, 2020, 09:51 (GMT) |
T77086 Animation: Passing Dependency Graph to Drivers Custom driver functions need access to the dependency graph that is triggering the evaluation of the driver. This patch passes the dependency graph pointer through all the animation-related calls. Instead of passing the evaluation time to functions, the code now passes an `AnimationEvalContext` pointer: ``` typedef struct AnimationEvalContext { struct Depsgraph *const depsgraph; const float eval_time; } AnimationEvalContext; ``` These structs are read-only, meaning that the code cannot change the evaluation time. Note that the `depsgraph` pointer itself is const, but it points to a non-const depsgraph. FCurves and Drivers can be evaluated at a different time than the current scene time, for example when evaluating NLA strips. This means that, even though the current time is stored in the dependency graph, we need an explicit evaluation time. There are two functions that allow creation of `AnimationEvalContext` objects: - `BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float eval_time)`, which creates a new context object from scratch, and - `BKE_animsys_eval_context_construct_at(AnimationEvalContext *anim_eval_context, float eval_time)`, which can be used to create a `AnimationEvalContext` with the same depsgraph, but at a different time. This makes it possible to later add fields without changing any of the code that just want to change the eval time. This also provides a fix for T75553, although it does require a change to the custom driver function. The driver should call `custom_function(depsgraph)`, and the function should use that depsgraph instead of information from `bpy.context`. Reviewed By: brecht, sergey Differential Revision: https://developer.blender.org/D8047 |
Commit Details:
Full Hash: 686ab4c9401a90b22fb17e46c992eb513fe4f693
Parent Commit: 6fbfa52
Lines Changed: +503, -183
36 Modified Paths:
/source/blender/blenkernel/BKE_action.h (+2, -1) (Diff)
/source/blender/blenkernel/BKE_animsys.h (+26, -8) (Diff)
/source/blender/blenkernel/BKE_fcurve.h (+5, -2) (Diff)
/source/blender/blenkernel/BKE_fcurve_driver.h (+2, -1) (Diff)
/source/blender/blenkernel/intern/action.c (+8, -4) (Diff)
/source/blender/blenkernel/intern/anim_sys.c (+113, -50) (Diff)
/source/blender/blenkernel/intern/constraint.c (+6, -3) (Diff)
/source/blender/blenkernel/intern/fcurve.c (+8, -5) (Diff)
/source/blender/blenkernel/intern/fcurve_driver.c (+8, -6) (Diff)
/source/blender/blenkernel/intern/object.c (+13, -4) (Diff)
/source/blender/blenkernel/intern/particle_system.c (+3, -1) (Diff)
/source/blender/blenkernel/intern/seqprefetch.c (+6, -1) (Diff)
/source/blender/blenkernel/intern/sequencer.c (+3, -1) (Diff)
/source/blender/blenkernel/nla_private.h (+8, -2) (Diff)
/source/blender/editors/animation/anim_channels_defines.c (+27, -9) (Diff)
/source/blender/editors/animation/anim_filter.c (+1, -0) (Diff)
/source/blender/editors/animation/keyframing.c (+62, -30) (Diff)
/source/blender/editors/animation/keyingsets.c (+4, -1) (Diff)
/source/blender/editors/armature/pose_lib.c (+10, -3) (Diff)
/source/blender/editors/armature/pose_transform.c (+5, -2) (Diff)
/source/blender/editors/gpencil/gpencil_convert.c (+54, -11) (Diff)
/source/blender/editors/include/ED_anim_api.h (+2, -0) (Diff)
/source/blender/editors/include/ED_keyframing.h (+4, -3) (Diff)
/source/blender/editors/interface/interface.c (+5, -1) (Diff)
/source/blender/editors/interface/interface_anim.c (+6, -2) (Diff)
/source/blender/editors/interface/interface_handlers.c (+5, -1) (Diff)
/source/blender/editors/interface/interface_intern.h (+2, -1) (Diff)
/source/blender/editors/object/object_modifier.c (+5, -1) (Diff)
/source/blender/editors/space_action/action_edit.c (+5, -3) (Diff)
/source/blender/editors/space_graph/graph_edit.c (+4, -2) (Diff)
/source/blender/editors/transform/transform_convert_armature.c (+14, -7) (Diff)
/source/blender/editors/transform/transform_convert_object.c (+14, -7) (Diff)
/source/blender/python/BPY_extern.h (+2, -1) (Diff)
/source/blender/python/intern/bpy_driver.c (+40, -4) (Diff)
/source/blender/python/intern/bpy_rna_anim.c (+18, -4) (Diff)
/source/blender/render/intern/source/pipeline.c (+3, -1) (Diff)
/source/blender/blenkernel/BKE_animsys.h (+26, -8) (Diff)
/source/blender/blenkernel/BKE_fcurve.h (+5, -2) (Diff)
/source/blender/blenkernel/BKE_fcurve_driver.h (+2, -1) (Diff)
/source/blender/blenkernel/intern/action.c (+8, -4) (Diff)
/source/blender/blenkernel/intern/anim_sys.c (+113, -50) (Diff)
/source/blender/blenkernel/intern/constraint.c (+6, -3) (Diff)
/source/blender/blenkernel/intern/fcurve.c (+8, -5) (Diff)
/source/blender/blenkernel/intern/fcurve_driver.c (+8, -6) (Diff)
/source/blender/blenkernel/intern/object.c (+13, -4) (Diff)
/source/blender/blenkernel/intern/particle_system.c (+3, -1) (Diff)
/source/blender/blenkernel/intern/seqprefetch.c (+6, -1) (Diff)
/source/blender/blenkernel/intern/sequencer.c (+3, -1) (Diff)
/source/blender/blenkernel/nla_private.h (+8, -2) (Diff)
/source/blender/editors/animation/anim_channels_defines.c (+27, -9) (Diff)
/source/blender/editors/animation/anim_filter.c (+1, -0) (Diff)
/source/blender/editors/animation/keyframing.c (+62, -30) (Diff)
/source/blender/editors/animation/keyingsets.c (+4, -1) (Diff)
/source/blender/editors/armature/pose_lib.c (+10, -3) (Diff)
/source/blender/editors/armature/pose_transform.c (+5, -2) (Diff)
/source/blender/editors/gpencil/gpencil_convert.c (+54, -11) (Diff)
/source/blender/editors/include/ED_anim_api.h (+2, -0) (Diff)
/source/blender/editors/include/ED_keyframing.h (+4, -3) (Diff)
/source/blender/editors/interface/interface.c (+5, -1) (Diff)
/source/blender/editors/interface/interface_anim.c (+6, -2) (Diff)
/source/blender/editors/interface/interface_handlers.c (+5, -1) (Diff)
/source/blender/editors/interface/interface_intern.h (+2, -1) (Diff)
/source/blender/editors/object/object_modifier.c (+5, -1) (Diff)
/source/blender/editors/space_action/action_edit.c (+5, -3) (Diff)
/source/blender/editors/space_graph/graph_edit.c (+4, -2) (Diff)
/source/blender/editors/transform/transform_convert_armature.c (+14, -7) (Diff)
/source/blender/editors/transform/transform_convert_object.c (+14, -7) (Diff)
/source/blender/python/BPY_extern.h (+2, -1) (Diff)
/source/blender/python/intern/bpy_driver.c (+40, -4) (Diff)
/source/blender/python/intern/bpy_rna_anim.c (+18, -4) (Diff)
/source/blender/render/intern/source/pipeline.c (+3, -1) (Diff)