Преглед изворни кода

update test scene after blender mesh API change

Jason0214 пре 6 година
родитељ
комит
5aa6ab3b81

+ 22 - 35
io_scene_godot/converters/mesh.py

@@ -178,9 +178,7 @@ class MeshResourceExporter:
         self.object.show_only_shape_key = True
         self.object.active_shape_key_index = 0
 
-        mesh = self.object.to_mesh(bpy.context.view_layer.depsgraph,
-                                   apply_modifiers=apply_modifiers,
-                                   calc_undeformed=True)
+        mesh = self.object.to_mesh()
 
         self.object.show_only_shape_key = False
 
@@ -220,18 +218,6 @@ class MeshResourceExporter:
 
         bpy.data.meshes.remove(mesh)
 
-    @staticmethod
-    def extract_shape_keys(blender_shape_keys):
-        """Return a list of (shape_key_index, shape_key_object) each of them
-        is a shape key needs exported"""
-        # base shape key needn't be exported
-        ret = list()
-        base_key = blender_shape_keys.reference_key
-        for index, shape_key in enumerate(blender_shape_keys.key_blocks):
-            if shape_key != base_key:
-                ret.append((index, shape_key))
-        return ret
-
     @staticmethod
     def validate_morph_mesh_modifiers(mesh_object):
         """Check whether a mesh has modifiers not
@@ -255,9 +241,15 @@ class MeshResourceExporter:
 
         return surfaces_morph_list
 
-    # pylint: disable-msg=R0914
+    # pylint: disable-msg=too-many-locals
     def export_morphs(self, export_settings, surfaces):
         """Export shape keys in mesh node and append them to surfaces"""
+        self.mesh_resource["blend_shape/names"] = Array(
+            prefix="PoolStringArray(", suffix=')'
+        )
+        self.mesh_resource["blend_shape/mode"] = 0
+
+        # toggle shapekey uncompatible modifiers to false
         modifier_config_cache = list()
         if export_settings['use_mesh_modifiers']:
             if not self.validate_morph_mesh_modifiers(
@@ -269,33 +261,25 @@ class MeshResourceExporter:
                 )
 
             for modifier in self.object.modifiers:
-                modifier_config_cache.append(modifier.show_render)
-                modifier.show_render = False
+                modifier_config_cache.append(modifier.show_viewport)
+                modifier.show_viewport = False
 
-        self.mesh_resource["blend_shape/names"] = Array(
-            prefix="PoolStringArray(", suffix=')'
-        )
-        self.mesh_resource["blend_shape/mode"] = 0
+        # turn on shape key mode
+        self.object.show_only_shape_key = True
+        blender_shape_keys = self.object.data.shape_keys
+        for index, shape_key in enumerate(blender_shape_keys.key_blocks):
+            if shape_key == blender_shape_keys.reference_key:
+                continue
 
-        shape_keys_to_export = self.extract_shape_keys(
-            self.object.data.shape_keys
-        )
-        for index, shape_key in shape_keys_to_export:
             self.mesh_resource["blend_shape/names"].append(
                 '"{}"'.format(shape_key.name)
             )
 
-            self.object.show_only_shape_key = True
             self.object.active_shape_key_index = index
-            shape_key.value = 1.0
-
-            shape_key_mesh = self.object.to_mesh(
-                bpy.context.view_layer.depsgraph,
-                apply_modifiers=True,
-                calc_undeformed=True
-            )
 
-            self.object.show_only_shape_key = False
+            bpy.context.view_layer.depsgraph.update()
+            shape_key_mesh = self.object.evaluated_get(
+                bpy.context.view_layer.depsgraph).to_mesh()
 
             triangulate_mesh(shape_key_mesh)
 
@@ -332,6 +316,9 @@ class MeshResourceExporter:
 
             bpy.data.meshes.remove(shape_key_mesh)
 
+        # turn off shape key mode
+        self.object.show_only_shape_key = False
+        # revert modifiers
         if export_settings['use_mesh_modifiers']:
             for index, modifier in enumerate(self.object.modifiers):
                 modifier.show_render = modifier_config_cache[index]

+ 2 - 6
io_scene_godot/converters/physics.py

@@ -121,9 +121,7 @@ def generate_convex_mesh_array(escn_file, export_settings, node):
 
     col_shape = InternalResource("ConvexPolygonShape", mesh.name)
 
-    mesh = node.to_mesh(bpy.context.view_layer.depsgraph,
-                        apply_modifiers=True,
-                        calc_undeformed=True)
+    mesh = node.to_mesh()
 
     # Triangulate
     triangulated_mesh = bmesh.new()
@@ -156,9 +154,7 @@ def generate_triangle_mesh_array(escn_file, export_settings, node):
 
     col_shape = InternalResource("ConcavePolygonShape", mesh.name)
 
-    mesh = node.to_mesh(bpy.context.view_layer.depsgraph,
-                        apply_modifiers=True,
-                        calc_undeformed=True)
+    mesh = node.to_mesh()
 
     # Triangulate
     triangulated_mesh = bmesh.new()

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/action_animation/animation_bone_transform.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/action_with_constraint/constraint_external_IK.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/action_with_constraint/constraint_internal_IK.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/action_with_constraint/constraint_with_undeform_bone.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/action_with_constraint/stashed_constraint.escn


+ 5 - 5
tests/reference_exports/armature/armature_illegal_bone_name.escn

@@ -36,15 +36,15 @@ resource_name = "Cube001"
 surfaces/0 = {
 	"primitive":4,
 	"arrays":[
-		Vector3Array(-0.861623, 1.00707, 0.972223, -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -0.852043, 1.00625, -1.02767, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.14764, 0.992919, -1.00687, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.13742, 0.993741, 0.993087, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -0.852043, 1.00625, -1.02767, 1.13742, 0.993741, 0.993087, 1.14764, 0.992919, -1.00687, -0.861623, 1.00707, 0.972223, -0.852043, 1.00625, -1.02767, -1.0, -1.0, -1.0, -0.852043, 1.00625, -1.02767, 1.14764, 0.992919, -1.00687, 1.0, -1.0, -1.0, 1.14764, 0.992919, -1.00687, 1.13742, 0.993741, 0.993087, 1.0, -1.0, 1.0, 1.13742, 0.993741, 0.993087, -0.861623, 1.00707, 0.972223, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -0.852043, 1.00625, -1.02767, -0.861623, 1.00707, 0.972223, 1.13742, 0.993741, 0.993087),
-		Vector3Array(-0.997632, 0.0687816, 0.0, -0.997632, 0.0687816, 0.0, -0.997632, 0.0687816, 0.0, 0.0, -0.0137889, -0.999905, 0.0, -0.0137889, -0.999905, 0.0, -0.0137889, -0.999905, 0.997267, -0.0738797, 0.0, 0.997267, -0.0738797, 0.0, 0.997267, -0.0738797, 0.0, 0.0, 0.00346724, 0.999994, 0.0, 0.00346724, 0.999994, 0.0, 0.00346724, 0.999994, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.00667129, 0.999978, -0.000377016, 0.00667129, 0.999978, -0.000377016, 0.00667129, 0.999978, -0.000377016, -0.997285, 0.0734815, -0.00480727, -0.997285, 0.0734815, -0.00480727, -0.997285, 0.0734815, -0.00480727, 0.0103709, -0.00421573, -0.999937, 0.0103709, -0.00421573, -0.999937, 0.0103709, -0.00421573, -0.999937, 0.997621, -0.0687459, 0.00512423, 0.997621, -0.0687459, 0.00512423, 0.997621, -0.0687459, 0.00512423, -0.0103384, 0.0145502, 0.999841, -0.0103384, 0.0145502, 0.999841, -0.0103384, 0.0145502, 0.999841, 0.0, -1.0, 0.0, 0.00667049, 0.999978, -0.000376529, 0.00667049, 0.999978, -0.000376529, 0.00667049, 0.999978, -0.000376529),
+		Vector3Array(-1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0),
+		Vector3Array(-1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 0.0, 0.0, -1.0, 1.0, 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0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.923829, 0.076171, 0.0, 0.0, 0.923954, 0.0760457, 0.0, 0.0, 0.926358, 0.0736422, 0.0, 0.0, 0.925511, 0.0744892, 0.0, 0.0, 0.923829, 0.076171, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.923829, 0.076171, 0.0, 0.0, 0.926358, 0.0736422, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.926358, 0.0736422, 0.0, 0.0, 0.923954, 0.0760457, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.923954, 0.0760457, 0.0, 0.0, 0.925511, 0.0744892, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.923829, 0.076171, 0.0, 0.0, 0.925511, 0.0744892, 0.0, 0.0, 0.923954, 0.0760457, 0.0, 0.0),
-		IntArray(0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25, 27, 29, 28, 12, 13, 30, 31, 33, 32)
+		IntArray(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0),
+		FloatArray(0.925511, 0.0744892, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.923829, 0.076171, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.926358, 0.0736422, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.923954, 0.0760457, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.923829, 0.076171, 0.0, 0.0, 0.923954, 0.0760457, 0.0, 0.0, 0.926358, 0.0736422, 0.0, 0.0, 0.923829, 0.076171, 0.0, 0.0, 0.926358, 0.0736422, 0.0, 0.0, 0.923954, 0.0760457, 0.0, 0.0, 0.925511, 0.0744892, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.925511, 0.0744892, 0.0, 0.0),
+		IntArray(0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 0, 1, 18, 3, 4, 19, 6, 7, 20, 9, 10, 21, 12, 13, 22, 15, 16, 23)
 	],
 	"morph_arrays":[]
 }

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/armature/armature_with_mesh.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/armature/armature_with_non_deform_bone.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/armature/armature_with_other_vertex_groups.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/armature/armature_with_physics.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/armature/armature_with_pose.escn


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
tests/reference_exports/misc/invisible_objects.escn


Разлика између датотеке није приказан због своје велике величине
+ 10 - 0
tests/reference_exports/shape_key/shapekey_with_pose.escn


BIN
tests/test_scenes/shape_key/shapekey_with_pose.blend


Неке датотеке нису приказане због велике количине промена