Repository: godotengine/godot
File: modules/gltf/gltf_document.cpp (C++)

Code before:
		// We have a Skeleton3D, check if it has a bone with the same name as this subpath.
		const String &bone_name = p_node_subpath[0];
		const int32_t bone_index = skeleton->find_bone(bone_name);
		if (bone_index != -1) {
			// A bone was found! But we still need to figure out which glTF node it corresponds to.
			for (GLTFSkeletonIndex skeleton_i = 0; skeleton_i < p_state->skeletons.size(); skeleton_i++) {
				const Ref<GLTFSkeleton> &skeleton_gltf = p_state->skeletons[skeleton_i];
				if (skeleton == skeleton_gltf->godot_skeleton) {
					GLTFNodeIndex node_i = skeleton_gltf->godot_bone_node[bone_index];
					return node_i;
				}
			}
			ERR_FAIL_V_MSG(-1, vformat("glTF: Found a bone %s in a Skeleton3D that wasn't in the GLTFState. Ensure that all nodes referenced by the AnimationPlayer are in the scene you are exporting.", bone_name));
		}
	}
	// General case: Not a skeleton bone, usually this means a normal node, or it could be the Skeleton3D itself.
	for (const KeyValue<GLTFNodeIndex, Node *> &scene_node_i : p_state->scene_nodes) {
		if (scene_node_i.value == p_godot_node) {
			return scene_node_i.key;
		}
	}
	ERR_FAIL_V_MSG(-1, vformat("glTF: A node was animated, but it wasn't found in the GLTFState. Ensure that all nodes referenced by the AnimationPlayer are in the scene you are exporting."));
}

template <typename T>
static inline Error try_interpolate_value_track(const Ref<Animation> &p_godot_animation, int32_t p_godot_anim_track_index, double p_time, T &r_value) {
	Variant val = p_godot_animation->value_track_interpolate(p_godot_anim_track_index, p_time, false);
	if (val.get_type() != Variant(T()).get_type()) {
		return ERR_INVALID_PARAMETER;
	}
	r_value = val;
	return OK;
}

bool GLTFDocument::_convert_animation_node_track(Ref<GLTFState> p_state, GLTFAnimation::NodeTrack &p_gltf_node_track, const Ref<Animation> &p_godot_animation, int32_t p_godot_anim_track_index, Vector<double> &p_times) {
	GLTFAnimation::Interpolation gltf_interpolation = GLTFAnimation::godot_to_gltf_interpolation(p_godot_animation, p_godot_anim_track_index);
	const Animation::TrackType track_type = p_godot_animation->track_get_type(p_godot_anim_track_index);
	const int32_t key_count = p_godot_animation->track_get_key_count(p_godot_anim_track_index);
	const NodePath node_path = p_godot_animation->track_get_path(p_godot_anim_track_index);
	const Vector<StringName> subpath = node_path.get_subnames();
	double anim_end = p_godot_animation->get_length();
	if (track_type == Animation::TYPE_SCALE_3D) {
		if (gltf_interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE) {
			gltf_interpolation = GLTFAnimation::INTERP_LINEAR;
			p_gltf_node_track.scale_track.times.clear();
			p_gltf_node_track.scale_track.values.clear();
			// CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
			const double increment = 1.0 / p_state->get_bake_fps();
			double time = 0.0;
			bool last = false;
			while (true) {

Review comment (suggestion):
```suggestion
static inline Error _try_interpolate_value_track(const Ref<Animation> &p_godot_animation, int32_t p_godot_anim_track_index, double p_time, T &r_value) {
```
Standard naming 

Code after:
		// We have a Skeleton3D, check if it has a bone with the same name as this subpath.
		const String &bone_name = p_node_subpath[0];
		const int32_t bone_index = skeleton->find_bone(bone_name);
		if (bone_index != -1) {
			// A bone was found! But we still need to figure out which glTF node it corresponds to.
			for (GLTFSkeletonIndex skeleton_i = 0; skeleton_i < p_state->skeletons.size(); skeleton_i++) {
				const Ref<GLTFSkeleton> &skeleton_gltf = p_state->skeletons[skeleton_i];
				if (skeleton == skeleton_gltf->godot_skeleton) {
					GLTFNodeIndex node_i = skeleton_gltf->godot_bone_node[bone_index];
					return node_i;
				}
			}
			ERR_FAIL_V_MSG(-1, vformat("glTF: Found a bone %s in a Skeleton3D that wasn't in the GLTFState. Ensure that all nodes referenced by the AnimationPlayer are in the scene you are exporting.", bone_name));
		}
	}
	// General case: Not a skeleton bone, usually this means a normal node, or it could be the Skeleton3D itself.
	for (const KeyValue<GLTFNodeIndex, Node *> &scene_node_i : p_state->scene_nodes) {
		if (scene_node_i.value == p_godot_node) {
			return scene_node_i.key;
		}
	}
	ERR_FAIL_V_MSG(-1, vformat("glTF: A node was animated, but it wasn't found in the GLTFState. Ensure that all nodes referenced by the AnimationPlayer are in the scene you are exporting."));
}

template <typename T>
static inline Error _try_interpolate_value_track(const Ref<Animation> &p_godot_animation, int32_t p_godot_anim_track_index, double p_time, T &r_value) {
	Variant val = p_godot_animation->value_track_interpolate(p_godot_anim_track_index, p_time, false);
	if (val.get_type() != GetTypeInfo<T>::VARIANT_TYPE) {
		return ERR_INVALID_PARAMETER;
	}
	r_value = val;
	return OK;
}

bool GLTFDocument::_convert_animation_node_track(Ref<GLTFState> p_state, GLTFAnimation::NodeTrack &p_gltf_node_track, const Ref<Animation> &p_godot_animation, int32_t p_godot_anim_track_index, Vector<double> &p_times) {
	GLTFAnimation::Interpolation gltf_interpolation = GLTFAnimation::godot_to_gltf_interpolation(p_godot_animation, p_godot_anim_track_index);
	const Animation::TrackType track_type = p_godot_animation->track_get_type(p_godot_anim_track_index);
	const int32_t key_count = p_godot_animation->track_get_key_count(p_godot_anim_track_index);
	const NodePath node_path = p_godot_animation->track_get_path(p_godot_anim_track_index);
	const Vector<StringName> subpath = node_path.get_subnames();
	double anim_end = p_godot_animation->get_length();
	if (track_type == Animation::TYPE_SCALE_3D) {
		if (gltf_interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE) {
			gltf_interpolation = GLTFAnimation::INTERP_LINEAR;
			p_gltf_node_track.scale_track.times.clear();
			p_gltf_node_track.scale_track.values.clear();
			// CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
			const double increment = 1.0 / p_state->get_bake_fps();
			double time = 0.0;
			bool last = false;
			while (true) {