Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/gltf/gltf_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3764,9 +3764,10 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> p_state) {
Dictionary sampler;
sampler["input"] = GLTFAccessor::encode_new_accessor_from_float64s(p_state, pointer_track.times);
sampler["interpolation"] = interpolation_to_string(pointer_track.interpolation);
GLTFAccessor::GLTFComponentType component_type = obj_model_prop->get_component_type(pointer_track.values);
// TODO: This can be made faster after this pull request is merged: https://github.com/godotengine/godot/pull/109003
Array values_arr = GLTFTemplateConvert::to_array(pointer_track.values);
sampler["output"] = GLTFAccessor::encode_new_accessor_from_variants(p_state, values_arr, obj_model_prop->get_variant_type(), obj_model_prop->get_accessor_type());
sampler["output"] = GLTFAccessor::encode_new_accessor_from_variants(p_state, values_arr, obj_model_prop->get_variant_type(), obj_model_prop->get_accessor_type(), component_type);
samplers.push_back(sampler);
}
}
Expand Down
19 changes: 19 additions & 0 deletions modules/gltf/structures/gltf_object_model_property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,25 @@ GLTFAccessor::GLTFAccessorType GLTFObjectModelProperty::get_accessor_type() cons
}
}

GLTFAccessor::GLTFComponentType GLTFObjectModelProperty::get_component_type(const Vector<Variant> &p_values) const {
switch (object_model_type) {
case GLTFObjectModelProperty::GLTF_OBJECT_MODEL_TYPE_BOOL: {
return GLTFAccessor::COMPONENT_TYPE_UNSIGNED_BYTE;
} break;
case GLTFObjectModelProperty::GLTF_OBJECT_MODEL_TYPE_INT: {
PackedInt64Array int_values;
for (int i = 0; i < p_values.size(); i++) {
int_values.append(p_values[i]);
}
return GLTFAccessor::get_minimal_integer_component_type_from_ints(int_values);
} break;
default: {
// The base glTF specification only supports 32-bit float accessors for floating point data.
return GLTFAccessor::COMPONENT_TYPE_SINGLE_FLOAT;
} break;
}
}

Ref<Expression> GLTFObjectModelProperty::get_gltf_to_godot_expression() const {
return gltf_to_godot_expr;
}
Expand Down
1 change: 1 addition & 0 deletions modules/gltf/structures/gltf_object_model_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class GLTFObjectModelProperty : public RefCounted {
void append_path_to_property(const NodePath &p_node_path, const StringName &p_prop_name);

GLTFAccessor::GLTFAccessorType get_accessor_type() const;
GLTFAccessor::GLTFComponentType get_component_type(const Vector<Variant> &p_values) const;

Ref<Expression> get_gltf_to_godot_expression() const;
void set_gltf_to_godot_expression(const Ref<Expression> &p_gltf_to_godot_expr);
Expand Down