Skip to content

Commit 23ed730

Browse files
committed
GLTF: Write integer min/max for integer accessors
1 parent 0b5ad6c commit 23ed730

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
@@ -1173,8 +1173,28 @@ Dictionary GLTFAccessor::to_dictionary() const {
11731173
}
11741174
dict["componentType"] = component_type;
11751175
dict["count"] = count;
1176-
dict["max"] = max;
1177-
dict["min"] = min;
1176+
switch (component_type) {
1177+
case COMPONENT_TYPE_NONE: {
1178+
ERR_PRINT("glTF export: Invalid component type 'NONE' for glTF accessor.");
1179+
} break;
1180+
case COMPONENT_TYPE_SIGNED_BYTE:
1181+
case COMPONENT_TYPE_UNSIGNED_BYTE:
1182+
case COMPONENT_TYPE_SIGNED_SHORT:
1183+
case COMPONENT_TYPE_UNSIGNED_SHORT:
1184+
case COMPONENT_TYPE_SIGNED_INT:
1185+
case COMPONENT_TYPE_UNSIGNED_INT:
1186+
case COMPONENT_TYPE_SIGNED_LONG:
1187+
case COMPONENT_TYPE_UNSIGNED_LONG: {
1188+
dict["max"] = PackedInt64Array(Variant(max));
1189+
dict["min"] = PackedInt64Array(Variant(min));
1190+
} break;
1191+
case COMPONENT_TYPE_SINGLE_FLOAT:
1192+
case COMPONENT_TYPE_DOUBLE_FLOAT:
1193+
case COMPONENT_TYPE_HALF_FLOAT: {
1194+
dict["max"] = max;
1195+
dict["min"] = min;
1196+
} break;
1197+
}
11781198
dict["normalized"] = normalized;
11791199
dict["type"] = _get_accessor_type_name();
11801200

0 commit comments

Comments
 (0)