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>2021-01-04 22:55:25 +0300
committerJulien Duroure <julien.duroure@gmail.com>2021-01-04 22:55:25 +0300
commiteb29a12da48e89fa2a3518976e9223f2092ad22d (patch)
tree2a642bd05f5a182f58c7ad96ecc0286b43ed5e1c /io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py
parent48ec56bde5fcb7fc18352559d629ef486f1a5640 (diff)
glTF importer/exporter: Draco decoder + encoder fixes
We can now read Draco compressed files. This also fix exporting vertex color Draco compressed files. Fix #T75550
Diffstat (limited to 'io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py')
-rw-r--r--io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py b/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py
new file mode 100644
index 00000000..51359f82
--- /dev/null
+++ b/io_scene_gltf2/io/com/gltf2_io_draco_compression_extension.py
@@ -0,0 +1,64 @@
+# Copyright 2018-2019 The glTF-Blender-IO authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import sys
+from pathlib import Path
+import bpy
+
+from ...io.com.gltf2_io_debug import print_console
+
+
+def dll_path() -> Path:
+ """
+ Get the DLL path depending on the underlying platform.
+ :return: DLL path.
+ """
+ lib_name = 'extern_draco'
+ blender_root = Path(bpy.app.binary_path).parent
+ python_lib = Path('{v[0]}.{v[1]}/python/lib'.format(v=bpy.app.version))
+ python_version = 'python{v[0]}.{v[1]}'.format(v=sys.version_info)
+
+ path = os.environ.get('BLENDER_EXTERN_DRACO_LIBRARY_PATH')
+ if path is None:
+ path = {
+ 'win32': blender_root / python_lib / 'site-packages',
+ 'linux': blender_root / python_lib / python_version / 'site-packages',
+ 'darwin': blender_root.parent / 'Resources' / python_lib / python_version / 'site-packages'
+ }.get(sys.platform)
+ else:
+ path = Path(path)
+
+ library_name = {
+ 'win32': '{}.dll'.format(lib_name),
+ 'linux': 'lib{}.so'.format(lib_name),
+ 'darwin': 'lib{}.dylib'.format(lib_name)
+ }.get(sys.platform)
+
+ if path is None or library_name is None:
+ print_console('WARNING', 'Unsupported platform {}, Draco mesh compression is unavailable'.format(sys.platform))
+
+ return path / library_name
+
+
+def dll_exists(quiet=False) -> bool:
+ """
+ Checks whether the DLL path exists.
+ :return: True if the DLL exists.
+ """
+ exists = dll_path().exists()
+ if quiet is False:
+ print("'{}' ".format(dll_path().absolute()) + ("exists, draco mesh compression is available" if exists else
+ "does not exist, draco mesh compression not available"))
+ return exists