Skip to content

Commit aa248bf

Browse files
committed
Merge pull request #111612 from aaronfranke/gltf-accessor-min-max-int
GLTF: Write integer min/max for integer accessors
2 parents e46c2ea + 23ed730 commit aa248bf

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

modules/gltf/structures/gltf_accessor.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,8 +1770,28 @@ Dictionary GLTFAccessor::to_dictionary() const {
17701770
}
17711771
dict["componentType"] = component_type;
17721772
dict["count"] = count;
1773-
dict["max"] = max;
1774-
dict["min"] = min;
1773+
switch (component_type) {
1774+
case COMPONENT_TYPE_NONE: {
1775+
ERR_PRINT("glTF export: Invalid component type 'NONE' for glTF accessor.");
1776+
} break;
1777+
case COMPONENT_TYPE_SIGNED_BYTE:
1778+
case COMPONENT_TYPE_UNSIGNED_BYTE:
1779+
case COMPONENT_TYPE_SIGNED_SHORT:
1780+
case COMPONENT_TYPE_UNSIGNED_SHORT:
1781+
case COMPONENT_TYPE_SIGNED_INT:
1782+
case COMPONENT_TYPE_UNSIGNED_INT:
1783+
case COMPONENT_TYPE_SIGNED_LONG:
1784+
case COMPONENT_TYPE_UNSIGNED_LONG: {
1785+
dict["max"] = PackedInt64Array(Variant(max));
1786+
dict["min"] = PackedInt64Array(Variant(min));
1787+
} break;
1788+
case COMPONENT_TYPE_SINGLE_FLOAT:
1789+
case COMPONENT_TYPE_DOUBLE_FLOAT:
1790+
case COMPONENT_TYPE_HALF_FLOAT: {
1791+
dict["max"] = max;
1792+
dict["min"] = min;
1793+
} break;
1794+
}
17751795
dict["normalized"] = normalized;
17761796
dict["type"] = _get_accessor_type_name();
17771797

0 commit comments

Comments
 (0)