Skip to content

Commit 7d7d479

Browse files
committed
Merge pull request #111615 from aaronfranke/gltf-anim-ptr-int-erpolate
GLTF: Enforce `STEP` interpolation for integer and boolean animations
2 parents ee6fb9e + 963b33a commit 7d7d479

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

modules/gltf/gltf_document.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8204,7 +8204,20 @@ void GLTFDocument::_convert_animation(Ref<GLTFState> p_state, AnimationPlayer *p
82048204
if (obj_model_prop.is_valid() && obj_model_prop->has_json_pointers()) {
82058205
// Insert the property track into the KHR_animation_pointer pointer tracks.
82068206
GLTFAnimation::Channel<Variant> channel;
8207-
channel.interpolation = gltf_interpolation;
8207+
// Animation samplers used with `int` or `bool` Object Model Data Types **MUST** use `STEP` interpolation.
8208+
// https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_animation_pointer
8209+
switch (obj_model_prop->get_object_model_type()) {
8210+
case GLTFObjectModelProperty::GLTF_OBJECT_MODEL_TYPE_BOOL:
8211+
case GLTFObjectModelProperty::GLTF_OBJECT_MODEL_TYPE_INT: {
8212+
channel.interpolation = GLTFAnimation::INTERP_STEP;
8213+
if (gltf_interpolation != GLTFAnimation::INTERP_STEP) {
8214+
WARN_PRINT(vformat("glTF export: Animation track %d on property %s is animating an int or bool, so it MUST use STEP interpolation (Godot \"Nearest\"), but the track in the Godot AnimationPlayer is using a different interpolation. Forcing STEP interpolation. Correct this track's interpolation in the source AnimationPlayer to avoid this warning.", track_index, String(track_path)));
8215+
}
8216+
} break;
8217+
default: {
8218+
channel.interpolation = gltf_interpolation;
8219+
} break;
8220+
}
82088221
channel.times = times;
82098222
channel.values.resize(anim_key_count);
82108223
// If using an expression, determine the base instance to pass to the expression.

0 commit comments

Comments
 (0)