mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
tests: glTF: simple tests for glTF files compressed with meshopt or Draco
Decompressing the buffers of glTF files needs lots of code that can leads to own bugs & errors. And may differ from an environment to another, due to algorithm natures. So, for glTF files with meshopt compression extensions (KHR_meshopt_compression or EXT_meshopt_compression), or with KHR_draco_mesh_compression, we are going to compare only a few part of the export. - Comparing the list of extension used, to be sure that the roundtrip can import & export with compression - For meshopt, check that we have 2 buffers, 1 compressed and the other one for fallback Pull Request: https://projects.blender.org/blender/blender/pulls/158693
This commit is contained in:
parent
bb8a218dd4
commit
c01060dd2d
5 changed files with 56 additions and 1 deletions
|
|
@ -0,0 +1,4 @@
|
|||
None
|
||||
None
|
||||
None
|
||||
KHR_draco_mesh_compression
|
||||
3
tests/files/io_tests/gltf/roundtrip/simple_draco.bin
Normal file
3
tests/files/io_tests/gltf/roundtrip/simple_draco.bin
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:542b72706674ff8339b3417db146a5b2f0cc99341f9abd457b513adc9e2a8d19
|
||||
size 264
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"export_draco_mesh_compression_enable": true
|
||||
}
|
||||
3
tests/files/io_tests/gltf/roundtrip/simple_draco.gltf
Normal file
3
tests/files/io_tests/gltf/roundtrip/simple_draco.gltf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a377b9e6c570172f72c9b60960cd3abb8d1b70c3be0cc85b4c7698871d33051b
|
||||
size 1522
|
||||
|
|
@ -13,6 +13,24 @@ from enum import IntEnum
|
|||
sys.path.append(str(pathlib.Path(__file__).parent.absolute()))
|
||||
|
||||
|
||||
def is_meshopt_compare(json_):
|
||||
"""Check if we need to avoid full comparison of the data"""
|
||||
if 'extensionsUsed' in json_:
|
||||
if 'KHR_meshopt_compression' in json_['extensionsUsed']:
|
||||
return True
|
||||
if 'EXT_meshopt_compression' in json_['extensionsUsed']:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_draco_compare(json_):
|
||||
"""Check if we need to avoid full comparison of the data"""
|
||||
if 'extensionsUsed' in json_:
|
||||
if 'KHR_draco_mesh_compression' in json_['extensionsUsed']:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def gltf_generate_descr(output_datafile: pathlib.Path) -> str:
|
||||
gltf = glTFDataExtractor(output_datafile)
|
||||
gltf.load()
|
||||
|
|
@ -38,7 +56,27 @@ def gltf_generate_descr(output_datafile: pathlib.Path) -> str:
|
|||
return [round_floats(x) for x in o]
|
||||
return o
|
||||
|
||||
text += json.dumps(round_floats(gltf.json), indent=2, ensure_ascii=False)
|
||||
if is_meshopt_compare(gltf.json):
|
||||
# Avoid comparing data when meshopt compression is used, as it can lead to
|
||||
# small differences that are not relevant.
|
||||
# Simple comparison : check the extensions, and that there are 2 buffers
|
||||
for extension_used in sorted(gltf.json['extensionsUsed']):
|
||||
text += extension_used + "\n"
|
||||
for idx, buffer in enumerate(gltf.json.get('buffers', [])):
|
||||
text += f"buffer {idx} with extension fallback {
|
||||
buffer.get(
|
||||
'extensions', {}).get(
|
||||
'KHR_meshopt_compression', {}).get(
|
||||
'fallback', False)}\n"
|
||||
|
||||
elif is_draco_compare(gltf.json):
|
||||
# Avoid comparing data when draco compression is used, as it can lead to
|
||||
# small differences that are not relevant.
|
||||
# Simple comparison : check the extensions
|
||||
for extension_used in gltf.json['extensionsUsed']:
|
||||
text += extension_used + "\n"
|
||||
else:
|
||||
text += json.dumps(round_floats(gltf.json), indent=2, ensure_ascii=False)
|
||||
for accessor in gltf.accessors_data:
|
||||
text += accessor + "\n"
|
||||
return text
|
||||
|
|
@ -71,6 +109,10 @@ class glTFDataExtractor:
|
|||
# glTF + bin + textures
|
||||
self.json = glTFDataExtractor.load_json(content)
|
||||
|
||||
# Let's ignore buffers and binary data when the file has meshopt compression
|
||||
if is_meshopt_compare(self.json) or is_draco_compare(self.json):
|
||||
return
|
||||
|
||||
# Get buffers
|
||||
for buffer in self.json.get('buffers', []):
|
||||
uri = buffer.get('uri', '')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue