How are Keyframe Interpolation Modes Converted from .blend Files with Bone Constraints?

Godot Version

Godot v4.5.1.rc2 - Windows 10 (build 19044) - Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 32.0.15.7247) - AMD Ryzen 7 3700X 8-Core Processor (16 threads) - 31.89 GiB memory

Question

Alright, highly specific tech-art question time.

When using automatic .blend conversion, how do actions affected by bone constraints get baked down into animations on import? By the looks of things, bones affected by constraints get their keyframes flattened down into game-friendly transformations on import, which is expected and nice, but the keys generated by that process seem to all get set to linear interpolation, even if the keyframes for that bone are set to a different interpolation mode in blender - for my use case, not so nice.

Tangentially, is there a way to work around this by setting the keyframe interpolation modes of imported animations via script? Ideally, this is either something that runs on import, or can be run manually post-import - so long as it doesn’t require a custom editor build, it’s cool.

Potentially related issue: Animation interpolation type getting overriden when reopening engine - #2 by En00bb

Got tipped onto this, looks like a EditorScenePostImport script is a good way to work around the problem.

Here’s the one I wrote up based on the sample on the doc page:

@tool
extends EditorScenePostImport

func _post_import(scene):
	if scene.get_node("AnimationPlayer"):
		mark_all_anims_constant(scene.get_node("AnimationPlayer"))
	return scene # Remember to return the imported scene

func mark_all_anims_constant(animation_player : AnimationPlayer):
	for animation_name in animation_player.get_animation_list():
		var animation := animation_player.get_animation(animation_name)
		for track_index in animation.get_track_count():
			animation.track_set_interpolation_type(track_index, Animation.INTERPOLATION_NEAREST)