GLTF: Determine the component type when encoding object model properties

This commit is contained in:
Aaron Franke 2025-10-13 11:27:04 -07:00
parent ef34c3d534
commit e9bfc5a346
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
3 changed files with 22 additions and 1 deletions

View file

@ -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;
}

View file

@ -71,6 +71,7 @@ public:
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);