[Bf-extensions-cvs] [5aa12449] blender2.8: glTF Exporter: optimizations & fixes

Julien Duroure noreply at git.blender.org
Tue Dec 11 21:53:13 CET 2018


Commit: 5aa12449c934b4ae2d429586be118bc79a17752a
Author: Julien Duroure
Date:   Tue Dec 11 21:51:40 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBA5aa12449c934b4ae2d429586be118bc79a17752a

glTF Exporter: optimizations & fixes

* image optimizations
* options refactoring
* Fix T59047

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_export.py
M	io_scene_gltf2/blender/exp/gltf2_blender_extract.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gltf2_exporter.py
M	io_scene_gltf2/io/com/gltf2_io_debug.py
M	io_scene_gltf2/io/exp/gltf2_io_image_data.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index b57c3bf4..091b8233 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -53,21 +53,6 @@ bl_info = {
 #
 
 
-class GLTF2ExportSettings(bpy.types.Operator):
-    """Save the export settings on export (saved in .blend). """
-    """Toggle off to clear settings"""
-    bl_label = "Save Settings"
-    bl_idname = "scene.gltf2_export_settings_set"
-
-    def execute(self, context):
-        operator = context.active_operator
-        operator.will_save_settings = not operator.will_save_settings
-        if not operator.will_save_settings:
-            # clear settings
-            context.scene.pop(operator.scene_key)
-        return {"FINISHED"}
-
-
 class ExportGLTF2_Base:
 
     # TODO: refactor to avoid boilerplate
@@ -90,6 +75,16 @@ class ExportGLTF2_Base:
         default='GLB'
     )
 
+    ui_tab: EnumProperty(
+        items=(('GENERAL', "General", "General settings"),
+               ('MESHES', "Meshes", "Mesh settings"),
+               ('OBJECTS', "Objects", "Object settings"),
+               ('MATERIALS', "Materials", "Material settings"),
+               ('ANIMATION', "Animation", "Animation settings")),
+        name="ui_tab",
+        description="Export setting categories",
+    )
+
     export_copyright: StringProperty(
         name='Copyright',
         description='Legal rights and conditions for the model',
@@ -214,8 +209,7 @@ class ExportGLTF2_Base:
 
     export_all_influences: BoolProperty(
         name='Include All Bone Influences',
-        description='Allow >4 joint vertex influences. Models may appear' \
-            ' incorrectly in many viewers',
+        description='Allow >4 joint vertex influences. Models may appear incorrectly in many viewers',
         default=False
     )
 
@@ -239,22 +233,22 @@ class ExportGLTF2_Base:
 
     export_lights: BoolProperty(
         name='Punctual Lights',
-        description='Export directional, point, and spot lights. Uses ' \
-            ' "KHR_lights_punctual" glTF extension',
+        description='Export directional, point, and spot lights. '
+                    'Uses "KHR_lights_punctual" glTF extension',
         default=False
     )
 
     export_texture_transform: BoolProperty(
         name='Texture Transforms',
-        description='Export texture or UV position, rotation, and scale.' \
-            ' Uses "KHR_texture_transform" glTF extension',
+        description='Export texture or UV position, rotation, and scale. '
+                    'Uses "KHR_texture_transform" glTF extension',
         default=False
     )
 
     export_displacement: BoolProperty(
         name='Displacement Textures (EXPERIMENTAL)',
-        description='EXPERIMENTAL: Export displacement textures. Uses' \
-            ' incomplete "KHR_materials_displacement" glTF extension',
+        description='EXPERIMENTAL: Export displacement textures. '
+                    'Uses incomplete "KHR_materials_displacement" glTF extension',
         default=False
     )
 
@@ -360,40 +354,47 @@ class ExportGLTF2_Base:
         return gltf2_blender_export.save(context, export_settings)
 
     def draw(self, context):
-        layout = self.layout
-
-        #
-
-        col = layout.box().column()
-        col.label(text='General:', icon='PREFERENCES')
+        self.layout.prop(self, 'ui_tab', expand=True)
+        if self.ui_tab == 'GENERAL':
+            self.draw_general_settings()
+        elif self.ui_tab == 'MESHES':
+            self.draw_mesh_settings()
+        elif self.ui_tab == 'OBJECTS':
+            self.draw_object_settings()
+        elif self.ui_tab == 'MATERIALS':
+            self.draw_material_settings()
+        elif self.ui_tab == 'ANIMATION':
+            self.draw_animation_settings()
+
+    def draw_general_settings(self):
+        col = self.layout.box().column()
         col.prop(self, 'export_format')
         col.prop(self, 'export_selected')
-        #col.prop(self, 'export_layers')
         col.prop(self, 'export_apply')
         col.prop(self, 'export_yup')
         col.prop(self, 'export_extras')
         col.prop(self, 'export_copyright')
 
-        col = layout.box().column()
-        col.label(text='Meshes:', icon='MESH_DATA')
+    def draw_mesh_settings(self):
+        col = self.layout.box().column()
         col.prop(self, 'export_texcoords')
         col.prop(self, 'export_normals')
         if self.export_normals:
             col.prop(self, 'export_tangents')
         col.prop(self, 'export_colors')
 
-        col = layout.box().column()
-        col.label(text='Objects:', icon='OBJECT_DATA')
+    def draw_object_settings(self):
+        col = self.layout.box().column()
         col.prop(self, 'export_cameras')
         col.prop(self, 'export_lights')
 
-        col = layout.box().column()
-        col.label(text='Materials:', icon='MATERIAL_DATA')
+    def draw_material_settings(self):
+        col = self.layout.box().column()
         col.prop(self, 'export_materials')
         col.prop(self, 'export_texture_transform')
 
-        col = layout.box().column()
-        col.label(text='Animation:', icon='ARMATURE_DATA')
+    def draw_animation_settings(self):
+        col = self.layout.box().column()
         col.prop(self, 'export_animations')
         if self.export_animations:
             col.prop(self, 'export_frame_range')
@@ -412,12 +413,6 @@ class ExportGLTF2_Base:
             if self.export_morph_normal:
                 col.prop(self, 'export_morph_tangent')
 
-        row = layout.row()
-        row.operator(
-            GLTF2ExportSettings.bl_idname,
-            text=GLTF2ExportSettings.bl_label,
-            icon="%s" % "PINNED" if self.will_save_settings else "UNPINNED")
-
 
 class ExportGLTF2(bpy.types.Operator, ExportGLTF2_Base, ExportHelper):
     """Export scene as glTF 2.0 file"""
@@ -497,7 +492,6 @@ def menu_func_import(self, context):
 
 
 classes = (
-    GLTF2ExportSettings,
     ExportGLTF2,
     ImportGLTF2
 )
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export.py b/io_scene_gltf2/blender/exp/gltf2_blender_export.py
index f2cc9fa5..1ddeb6a5 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_export.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_export.py
@@ -33,6 +33,7 @@ def save(context, export_settings):
 
 
 def __export(export_settings):
+    export_settings['gltf_channelcache'] = dict()
     exporter = GlTF2Exporter(__get_copyright(export_settings))
     __add_root_objects(exporter, export_settings)
     buffer = __create_buffer(exporter, export_settings)
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index c26429d3..8762a90f 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -975,10 +975,10 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
 
         if max_index >= range_indices:
             #
-            # Spliting result_primitives.
+            # Splitting result_primitives.
             #
 
-            # At start, all indicees are pending.
+            # At start, all indices are pending.
             pending_attributes = {
                 POSITION_ATTRIBUTE: [],
                 NORMAL_ATTRIBUTE: []
@@ -1038,6 +1038,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
             while len(pending_indices) > 0:
 
                 process_indices = pending_primitive[INDICES_ID]
+                max_index = max(process_indices)
 
                 pending_indices = []
 
@@ -1046,7 +1047,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
 
                 all_local_indices = []
 
-                for i in range(0, (max(process_indices) // range_indices) + 1):
+                for i in range(0, (max_index // range_indices) + 1):
                     all_local_indices.append([])
 
                 #
@@ -1063,7 +1064,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
                                          process_indices[face_index + 2])
 
                     # ... check if it can be but in a range of maximum indices.
-                    for i in range(0, (max(process_indices) // range_indices) + 1):
+                    for i in range(0, (max_index // range_indices) + 1):
                         offset = i * range_indices
 
                         # Yes, so store the primitive with its indices.
@@ -1075,7 +1076,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
                             written = True
                             break
 
-                    # If not written, the triangel face has indices from different ranges.
+                    # If not written, the triangle face has indices from different ranges.
                     if not written:
                         pending_indices.extend([process_indices[face_index + 0], process_indices[face_index + 1],
                                                 process_indices[face_index + 2]])
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
index d9583d08..b6131a59 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_image.py
@@ -49,7 +49,7 @@ def __filter_image(sockets_or_slots, export_settings):
 
 def __gather_buffer_view(sockets_or_slots, export_settings):
     if export_settings[gltf2_blender_export_keys.FORMAT] != 'GLTF_SEPARATE':
-        image = __get_image_data(sockets_or_slots)
+        image = __get_image_data(sockets_or_slots, export_settings)
         return gltf2_io_binary_data.BinaryData(
             data=image.to_image_data(__gather_mime_type(sockets_or_slots, export_settings)))
     return None
@@ -81,7 +81,7 @@ def __gather_name(sockets_or_slots, export_settings):
 def __gather_uri(sockets_or_slots, export_settings):
     if export_settings[gltf2_blender_export_keys.FORMAT] == 'GLTF_SEPARATE':
         # as usual we just store the data in place instead of already resolvi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list