Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4f6bb93
TinyGltfImporter: keep original buffer length for .glb conversion
pezcode Oct 8, 2021
ac8525a
TinyGltfImporter: doc++
pezcode Oct 8, 2021
fba9700
TinyGltfImporter: document missing URI decoding
pezcode Oct 8, 2021
e85f528
TinyGltfImporter: document handling (or not) of extensionsRequired
pezcode Oct 8, 2021
210e0b1
TinyGltfImporter: test asset version
pezcode Oct 8, 2021
0cc0661
TinyGltfImporter: check for invalid scene hierarchies
pezcode Oct 8, 2021
e14551f
TinyGltfImporter: mesh spanning multiple buffers is now an error
pezcode Oct 8, 2021
fb14494
TinyGltfImporter: support KHR_texture_basisu
pezcode Oct 8, 2021
26d50e5
TinyGltfImporter: warn about non-contiguous numbered mesh attributes
pezcode Oct 8, 2021
53c7fd2
TinyGltfImporter: check skin attribute types
pezcode Oct 8, 2021
4bf7267
TinyGltfImporter: test skin attribute import
pezcode Oct 8, 2021
18ab4dc
TinyGltfImporter: don't import tangents as custom attributes
pezcode Oct 8, 2021
12ec21a
TinyGltfImporter: add missing asset object to glTF test files
pezcode Oct 8, 2021
b95e7a2
TinyGltfImporter: cleanup
pezcode Oct 8, 2021
c7e5375
TinyGltfImporter: test more invalid accessors
pezcode Oct 8, 2021
d86ee94
TinyGltfImporter: move non-OOB tests back to mesh-invalid.gltf
pezcode Oct 8, 2021
9c4711f
TinyGltfImporter: fix compilation with MSVC 2015 and 2017
pezcode Oct 8, 2021
ea6db96
TinyGltfImporter: check for out-of-bounds image in texture()
pezcode Oct 8, 2021
25b809d
TinyGltfImporter: check for out-of-bounds sampler in texture()
pezcode Oct 8, 2021
f74b5c7
TinyGltfImporter: check for normalized int mesh attributes
pezcode Oct 8, 2021
3aac997
TinyGltfImporter: doc++
pezcode Oct 11, 2021
deffad9
TinyGltfImporter: prefer strtol over atoi
pezcode Oct 11, 2021
2bdc698
TinyGltfImporter: we don't need unordered_map here
pezcode Oct 11, 2021
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
18 changes: 14 additions & 4 deletions src/MagnumPlugins/TinyGltfImporter/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@ corrade_add_test(TinyGltfImporterTest
mesh-invalid.bin
mesh-invalid.gltf
mesh-invalid-accessor-oob.gltf
mesh-invalid-accessor-short.gltf
mesh-invalid-buffer-oob.gltf
mesh-invalid-bufferview-oob.gltf
mesh-invalid-bufferview-short.gltf
mesh-invalid-mismatching-attribute-count.gltf
mesh-multiple-primitives.gltf
mesh-primitives-types.gltf
mesh-primitives-types.bin
mesh-skin-attributes.gltf
mesh-skin-attributes.bin
mesh-unordered-attributes.gltf
přívodní-šňůra.gltf
přívodní-šňůra.bin
Expand All @@ -162,12 +161,14 @@ corrade_add_test(TinyGltfImporterTest
scene-nodefault.gltf
scene-nodefault.glb
scene-invalid-camera-oob.gltf
scene-invalid-child-not-root.gltf
scene-invalid-child-oob.gltf
scene-invalid-default-oob.gltf
scene-invalid-light-oob.gltf
scene-invalid-material-oob-multi-primitive.gltf
scene-invalid-material-oob.gltf
scene-invalid-mesh-oob.gltf
scene-invalid-multiple-parents.gltf
scene-invalid-node-oob.gltf
scene-invalid-skin-oob-multi-primitive.gltf
scene-invalid-skin-oob.gltf
Expand All @@ -191,8 +192,17 @@ corrade_add_test(TinyGltfImporterTest
texture-default-sampler.glb
texture-empty-sampler.gltf
texture-empty-sampler.glb
texture-extensions.gltf
texture-extensions-invalid.gltf
texture-extensions-invalid-basisu-oob.gltf
texture-invalid.gltf
texture-missing-source.gltf)
texture-invalid-image-oob.gltf
texture-invalid-sampler-oob.gltf
texture-missing-source.gltf
version-legacy.gltf
version-supported.gltf
version-unsupported.gltf
version-unsupported-min.gltf)
target_include_directories(TinyGltfImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
if(MAGNUM_TINYGLTFIMPORTER_BUILD_STATIC)
target_link_libraries(TinyGltfImporterTest PRIVATE TinyGltfImporter)
Expand Down
265 changes: 234 additions & 31 deletions src/MagnumPlugins/TinyGltfImporter/Test/TinyGltfImporterTest.cpp

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions src/MagnumPlugins/TinyGltfImporter/Test/animation-invalid.gltf
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,44 @@
"output": 0
}
]
},
{
"name": "invalid input accessor",
"channels": [
{
"sampler": 0,
"target": {
"node": 0,
"path": "translation"
}
}
],
"samplers": [
{
"input": 3,
"interpolation": "STEP",
"output": 2
}
]
},
{
"name": "invalid output accessor",
"channels": [
{
"sampler": 0,
"target": {
"node": 0,
"path": "translation"
}
}
],
"samplers": [
{
"input": 1,
"interpolation": "STEP",
"output": 4
}
]
}
],
"note": "additional accessor bounds checks are tested inside mesh-invalid.gltf",
Expand All @@ -143,6 +181,20 @@
"componentType": 5126,
"count": 0,
"type": "VEC3"
},
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5126,
"count": 10,
"type": "SCALAR"
},
{
"bufferView": 0,
"byteOffset": 0,
"componentType": 5126,
"count": 10,
"type": "VEC3"
}
],
"bufferViews": [
Expand Down
Binary file modified src/MagnumPlugins/TinyGltfImporter/Test/buffer-wrong-size.glb
Binary file not shown.
6 changes: 5 additions & 1 deletion src/MagnumPlugins/TinyGltfImporter/Test/gltf2glb.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def pad_size_32b(size): return (4 - size%4)%4
with open(file_in) as f:
data = json.load(f)

bin_length = 0
bin_data = bytearray()

if not args.no_embed and "buffers" in data:
Expand All @@ -66,6 +67,7 @@ def pad_size_32b(size): return (4 - size%4)%4
else:
with open(uri, 'rb') as bf:
d = bf.read()
bin_length = data['buffers'][0]['byteLength']
bin_data.extend(d)

if args.bundle_images:
Expand Down Expand Up @@ -99,12 +101,14 @@ def pad_size_32b(size): return (4 - size%4)%4
del image['uri']
image['bufferView'] = len(data['bufferViews']) - 1

bin_length = len(bin_data)

# Pad the buffer, update its length
if not args.no_embed and 'buffers' in data and data['buffers']:
bin_data.extend(b' '*pad_size_32b(len(bin_data)))

del data['buffers'][0]['uri']
data['buffers'][0]['byteLength'] = len(bin_data)
data['buffers'][0]['byteLength'] = bin_length

json_data = json.dumps(data, separators=(',', ':')).encode('utf-8')
# Append padding bytes so that BIN chunk is aligned to 4 bytes
Expand Down
Binary file modified src/MagnumPlugins/TinyGltfImporter/Test/image-basis-embedded.glb
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"textures":[{"extensions":{"GOOGLE_texture_basis":{"source":1}}}],"images":[{"mimeType":"image/png","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAADCAYAAABbNsX4AAAACXBIWXMAAAsTAAALEwEAmpwYAAAASElEQVQIHQ3JOwqAMBBAwWfwgyIpJJWQ+/fBxhO5iHUQ42Z12mnStlvfOcZpoDzKW5S2qiKXYGbEuBLCgrtzRqvh/fwHHHLyAZ75HS8LboO+AAAAAElFTkSuQmCC"},{"mimeType":"image/x-basis","uri":"data:application/octet-stream;base64,c0ITAE0AtAyTAAAA0MECAAABAAAAAwAAAAAAAAAAAAAAAAAAAAAAAwB7AAAAKwAAAwCmAAAADQAAswAAACsAAABNAAAAAAAAAAAAAAAAAAAAAAUAAwACAAEA3gAAAAEAAABbegAAAAEAAgABAAEAAQDfAAAAAQAAAOCuAcAEAAAAAAAAwgCIABAAAAAAOQeACQABAAAAAIQIwBQAAQAAAACShR+4AFT9V1WNFvb3p6KiogIAwUQAAAAAAADyX20AmAAAAAAAAEFGAEwAEAAAAIBAcQAwAQAAAAAAgAACagw="}],"extensionsUsed":["GOOGLE_texture_basis"],"extensionsRequired":["GOOGLE_texture_basis"]}
{"asset":{"version":"2.0"},"textures":[{"extensions":{"GOOGLE_texture_basis":{"source":1}}}],"images":[{"mimeType":"image/png","uri":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAADCAYAAABbNsX4AAAACXBIWXMAAAsTAAALEwEAmpwYAAAASElEQVQIHQ3JOwqAMBBAwWfwgyIpJJWQ+/fBxhO5iHUQ42Z12mnStlvfOcZpoDzKW5S2qiKXYGbEuBLCgrtzRqvh/fwHHHLyAZ75HS8LboO+AAAAAElFTkSuQmCC"},{"mimeType":"image/x-basis","uri":"data:application/octet-stream;base64,c0ITAE0AtAyTAAAA0MECAAABAAAAAwAAAAAAAAAAAAAAAAAAAAAAAwB7AAAAKwAAAwCmAAAADQAAswAAACsAAABNAAAAAAAAAAAAAAAAAAAAAAUAAwACAAEA3gAAAAEAAABbegAAAAEAAgABAAEAAQDfAAAAAQAAAOCuAcAEAAAAAAAAwgCIABAAAAAAOQeACQABAAAAAIQIwBQAAQAAAACShR+4AFT9V1WNFvb3p6KiogIAwUQAAAAAAADyX20AmAAAAAAAAEFGAEwAEAAAAIBAcQAwAQAAAAAAgAACagw="}],"extensionsUsed":["GOOGLE_texture_basis"],"extensionsRequired":["GOOGLE_texture_basis"]}
Binary file not shown.
Binary file modified src/MagnumPlugins/TinyGltfImporter/Test/image-buffer.glb
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Loading