X-Plane / XPlane2Blender

Scenery & Aircraft export addon for Blender and X-Plane
GNU General Public License v3.0
190 stars 67 forks source link

Fix: dataref keyframes not imported correctly #716

Closed galvedro closed 1 year ago

galvedro commented 1 year ago

The importer is not being able to bring in dataref value animations. It does create keyframes for them, but the value of the first keyframe is replicated to all the others, effectively loosing all the dataref animations.

The root cause has to do with the mechanisms documented here: No updates after setting values

What happens in the addon is that the values are correctly read, but the following call:

bpy.ops.object.add_xplane_dataref_keyframe(
    {"object": blender_struct}, index=dataref_index
)

triggers an internal view_layer.update(). This update happens before the control reaches the add_xplane_dataref_keyframe function, it is internal to Blender's machinery. The effect of the call is to reset the object to what was set in the previous keyframe. Therefore, the state of the first keyframe propagates to all that follow.

The proposed fix is to call view_layer.update() before writing the new keyframe information to blender_struct. This seems to work.

bsupnik commented 1 year ago

Hi,

I think this PR is obsoleted by 6c8f8dec7dadad4a2d943717f488fe84d098a7e0, which uses frame_set() to force an update.