Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2019-05-14 21:38:46 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-05-14 21:38:46 +0300
commit11bb2337e021efb6463fcbbb704c955366f0319a (patch)
tree030d6e9f183b68b60089acc55faddc483b9e3052
parentee97a837ccc78ffa9660f5686580293100744da3 (diff)
glTF exporter: fix exporting with Draco compression
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rw-r--r--io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py38
2 files changed, 28 insertions, 12 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 35d80a91..cacf2dca 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
- "version": (0, 9, 7),
+ "version": (0, 9, 8),
'blender': (2, 80, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py b/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py
index 845e2d2d..1eb8affb 100644
--- a/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py
+++ b/io_scene_gltf2/io/exp/gltf2_io_draco_compression_extension.py
@@ -4,6 +4,7 @@ from ctypes import *
from pathlib import Path
from io_scene_gltf2.io.exp.gltf2_io_binary_data import BinaryData
+from ...io.com.gltf2_io_debug import print_console
def dll_path() -> Path:
@@ -111,18 +112,40 @@ def compress_scene_primitives(scenes, export_settings):
for scene in scenes:
for node in scene.nodes:
- __traverse_node(node, dll, export_settings)
+ __traverse_node(node, lambda node: __compress_node(node, dll, export_settings))
+ for scene in scenes:
+ for node in scene.nodes:
+ __traverse_node(node, __dispose_memory)
+
+def __dispose_memory(node):
+ """Remove buffers from attribute, since the data now resides inside the compressed Draco buffer."""
+ if not (node.mesh is None):
+ for primitive in node.mesh.primitives:
+
+ # Drop indices.
+ primitive.indices.buffer_view = None
-def __traverse_node(node, dll, export_settings):
+ # Drop attributes.
+ attributes = primitive.attributes
+ attributes['POSITION'].buffer_view = None
+ attributes['NORMAL'].buffer_view = None
+ for attribute in [attributes[attr] for attr in attributes if attr.startswith('TEXCOORD_')]:
+ attribute.buffer_view = None
+
+def __compress_node(node, dll, export_settings):
+ """Compress a single node."""
if not (node.mesh is None):
- print("Compressing mesh " + node.name)
+ print_console("INFO", "Compressing mesh " + node.name)
for primitive in node.mesh.primitives:
__compress_primitive(primitive, dll, export_settings)
+def __traverse_node(node, f):
+ """Calls f for each node and all child nodes, recursively."""
+ f(node)
if not (node.children is None):
for child in node.children:
- __traverse_node(child, dll, export_settings)
+ __traverse_node(child)
def __compress_primitive(primitive, dll, export_settings):
@@ -151,7 +174,6 @@ def __compress_primitive(primitive, dll, export_settings):
}
indices = primitive.indices
dll.setFaces(compressor, indices.count, index_byte_length[indices.component_type.name], indices.buffer_view.data)
- indices.buffer_view = None
# Set compression parameters.
dll.setCompressionLevel(compressor, export_settings['gltf_draco_mesh_compression_level'])
@@ -199,12 +221,6 @@ def __compress_primitive(primitive, dll, export_settings):
# Set to triangle list mode.
primitive.mode = 4
- # Remove buffers from attribute, since the data now resides inside the compressed Draco buffer.
- attributes['POSITION'].buffer_view = None
- attributes['NORMAL'].buffer_view = None
- for attribute in [attributes[attr] for attr in attributes if attr.startswith('TEXCOORD_')]:
- attribute.buffer_view = None
-
# Afterwards, the compressor can be released.
dll.disposeCompressor(compressor)