One of the largest current time sucks in the exporter is the stupidly inefficient use of bpy.context.scene.frame_set(frame=self.frame) inside XPlaneKeyframe's constructor. In order to get the location/rotation at each Blender Keyframe we currently do:
for every animated object,
go through each frame of it's action that has a keyframe,
call frame_set
get the location and rotation
and (removed by PR #465) set the frame back (which is useless)
With the BD-5J, this is currently taking 7 to 10 seconds on my computer repeatedly setting the current frame to frames 1-10!
It would be far better to call frame_set only 1-10 times instead thousands, using this simple algorithm:
- Before collectionAnimations is called on each bone, find every frame referenced by every Action block in the scene
- Make a Dict[BlenderObjectInTree,List[Tuple[FrameIndex, LocRotAnimationData]]]
- Visit each frame once, and fill the dictionary with all the values you would need to find were you searching per frame per object like we currently do
- Search that dictionary inside collectAnimations, instead of calling frame_set a billion times
This would be a massive performance boost for any project that uses lots of keyframes.
See #462 for more discussion about where this idea came from.
One of the largest current time sucks in the exporter is the stupidly inefficient use of
bpy.context.scene.frame_set(frame=self.frame)inside XPlaneKeyframe's constructor. In order to get the location/rotation at each Blender Keyframe we currently do:With the BD-5J, this is currently taking 7 to 10 seconds on my computer repeatedly setting the current frame to frames 1-10!
It would be far better to call frame_set only 1-10 times instead thousands, using this simple algorithm:
This would be a massive performance boost for any project that uses lots of keyframes.
See #462 for more discussion about where this idea came from.