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>2020-07-21 21:30:30 +0300
committerJulien Duroure <julien.duroure@gmail.com>2020-07-21 21:30:30 +0300
commit9313b3a155bbe5b84dca81431ca9167cda94035d (patch)
treed9ab42dbbcd45ebf98755248189cb154434d1501
parent47ea656bdd61e5d19f577b1155789e443e26e3e3 (diff)
glTF exporter: refactoring: remove no more needed functions after 2.79
-rwxr-xr-xio_scene_gltf2/__init__.py2
-rwxr-xr-xio_scene_gltf2/blender/com/gltf2_blender_math.py13
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_extract.py6
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py8
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py13
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py6
-rwxr-xr-xio_scene_gltf2/blender/exp/gltf2_blender_gather_skins.py9
7 files changed, 23 insertions, 34 deletions
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 92d828bb..57bdf3d5 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": (1, 3, 38),
+ "version": (1, 3, 39),
'blender': (2, 90, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/com/gltf2_blender_math.py b/io_scene_gltf2/blender/com/gltf2_blender_math.py
index 72eb124a..bddc79a6 100755
--- a/io_scene_gltf2/blender/com/gltf2_blender_math.py
+++ b/io_scene_gltf2/blender/com/gltf2_blender_math.py
@@ -19,11 +19,6 @@ from mathutils import Matrix, Vector, Quaternion, Euler
from io_scene_gltf2.blender.com.gltf2_blender_data_path import get_target_property_name
-def multiply(a, b):
- """Multiplication."""
- return a @ b
-
-
def list_to_mathutils(values: typing.List[float], data_path: str) -> typing.Union[Vector, Quaternion, Euler]:
"""Transform a list to blender py object."""
target = get_target_property_name(data_path)
@@ -31,7 +26,7 @@ def list_to_mathutils(values: typing.List[float], data_path: str) -> typing.Unio
if target == 'delta_location':
return Vector(values) # TODO Should be Vector(values) - Vector(something)?
elif target == 'delta_rotation_euler':
- return Euler(values).to_quaternion() # TODO Should be multiply(Euler(values).to_quaternion(), something)?
+ return Euler(values).to_quaternion() # TODO Should be Euler(values).to_quaternion() @ something?
elif target == 'location':
return Vector(values)
elif target == 'rotation_axis_angle':
@@ -138,7 +133,7 @@ def transform(v: typing.Union[Vector, Quaternion], data_path: str, transform: Ma
def transform_location(location: Vector, transform: Matrix = Matrix.Identity(4)) -> Vector:
"""Transform location."""
m = Matrix.Translation(location)
- m = multiply(transform, m)
+ m = transform @ m
return m.to_translation()
@@ -146,7 +141,7 @@ def transform_rotation(rotation: Quaternion, transform: Matrix = Matrix.Identity
"""Transform rotation."""
rotation.normalize()
m = rotation.to_matrix().to_4x4()
- m = multiply(transform, m)
+ m = transform @ m
return m.to_quaternion()
@@ -156,7 +151,7 @@ def transform_scale(scale: Vector, transform: Matrix = Matrix.Identity(4)) -> Ve
m[0][0] = scale.x
m[1][1] = scale.y
m[2][2] = scale.z
- m = multiply(transform, m)
+ m = transform @ m
return m.to_scale()
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index c28fddf9..6389d9dc 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -122,12 +122,6 @@ def convert_swizzle_scale(scale, export_settings):
return Vector((scale[0], scale[1], scale[2]))
-def decompose_transition(matrix, export_settings):
- translation, rotation, scale = matrix.decompose()
-
- return translation, rotation, scale
-
-
def extract_primitives(glTF, blender_mesh, library, blender_object, blender_vertex_groups, modifiers, export_settings):
"""
Extract primitives from a mesh. Polygons are triangulated and sorted by material.
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
index f2375bb1..c3913367 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_samplers.py
@@ -343,10 +343,12 @@ def __gather_output(channels: typing.Tuple[bpy.types.FCurve],
(0.0, 0.0, 1.0, 0.0),
(0.0, -1.0, 0.0, 0.0),
(0.0, 0.0, 0.0, 1.0)))
- correction_matrix_local = gltf2_blender_math.multiply(axis_basis_change, bone.bone.matrix_local)
+ correction_matrix_local = axis_basis_change @ bone.bone.matrix_local
else:
- correction_matrix_local = gltf2_blender_math.multiply(
- bone.parent.bone.matrix_local.inverted(), bone.bone.matrix_local)
+ correction_matrix_local = (
+ bone.parent.bone.matrix_local.inverted() @
+ bone.bone.matrix_local
+ )
transform = correction_matrix_local
else:
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py
index 1cb26551..dff55d17 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py
@@ -17,8 +17,6 @@ import mathutils
from . import gltf2_blender_export_keys
from io_scene_gltf2.blender.exp.gltf2_blender_gather_cache import cached
from io_scene_gltf2.io.com import gltf2_io
-from io_scene_gltf2.blender.exp import gltf2_blender_extract
-from io_scene_gltf2.blender.com import gltf2_blender_math
from io_scene_gltf2.blender.exp import gltf2_blender_gather_skins
from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions
from ..com.gltf2_blender_extras import generate_extras
@@ -39,10 +37,12 @@ def gather_joint(blender_object, blender_bone, export_settings):
# extract bone transform
if blender_bone.parent is None:
- correction_matrix_local = gltf2_blender_math.multiply(axis_basis_change, blender_bone.bone.matrix_local)
+ correction_matrix_local = axis_basis_change @ blender_bone.bone.matrix_local
else:
- correction_matrix_local = gltf2_blender_math.multiply(
- blender_bone.parent.bone.matrix_local.inverted(), blender_bone.bone.matrix_local)
+ correction_matrix_local = (
+ blender_bone.parent.bone.matrix_local.inverted() @
+ blender_bone.bone.matrix_local
+ )
if (blender_bone.bone.use_inherit_rotation == False or blender_bone.bone.inherit_scale != "FULL") and blender_bone.parent != None:
rest_mat = (blender_bone.parent.bone.matrix_local.inverted_safe() @ blender_bone.bone.matrix_local)
@@ -51,8 +51,7 @@ def gather_joint(blender_object, blender_bone, export_settings):
matrix_basis = blender_bone.matrix
matrix_basis = blender_object.convert_space(pose_bone=blender_bone, matrix=matrix_basis, from_space='POSE', to_space='LOCAL')
- trans, rot, sca = gltf2_blender_extract.decompose_transition(
- gltf2_blender_math.multiply(correction_matrix_local, matrix_basis), export_settings)
+ trans, rot, sca = (correction_matrix_local @ matrix_basis).decompose()
translation, rotation, scale = (None, None, None)
if trans[0] != 0.0 or trans[1] != 0.0 or trans[2] != 0.0:
translation = [trans[0], trans[1], trans[2]]
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
index b2ca5be5..b09e7aa1 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
@@ -189,8 +189,8 @@ def __gather_children(blender_object, blender_scene, export_settings):
rot_quat = Quaternion(rot)
axis_basis_change = Matrix(
((1.0, 0.0, 0.0, 0.0), (0.0, 0.0, -1.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0)))
- mat = gltf2_blender_math.multiply(child.matrix_parent_inverse, child.matrix_basis)
- mat = gltf2_blender_math.multiply(mat, axis_basis_change)
+ mat = child.matrix_parent_inverse @ child.matrix_basis
+ mat = mat @ axis_basis_change
_, rot_quat, _ = mat.decompose()
child_node.rotation = [rot_quat[1], rot_quat[2], rot_quat[3], rot_quat[0]]
@@ -404,7 +404,7 @@ def __gather_trans_rot_scale(blender_object, export_settings):
if blender_object.matrix_local[3][3] != 0.0:
- trans, rot, sca = gltf2_blender_extract.decompose_transition(blender_object.matrix_local, export_settings)
+ trans, rot, sca = blender_object.matrix_local.decompose()
else:
# Some really weird cases, scale is null (if parent is null when evaluation is done)
print_console('WARNING', 'Some nodes are 0 scaled during evaluation. Result can be wrong')
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_skins.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_skins.py
index fa95e543..7f645272 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_skins.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_skins.py
@@ -20,7 +20,6 @@ from io_scene_gltf2.io.exp import gltf2_io_binary_data
from io_scene_gltf2.io.com import gltf2_io_constants
from io_scene_gltf2.blender.exp import gltf2_blender_gather_accessors
from io_scene_gltf2.blender.exp import gltf2_blender_gather_joints
-from io_scene_gltf2.blender.com import gltf2_blender_math
from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions
@@ -85,10 +84,10 @@ def __gather_inverse_bind_matrices(blender_object, export_settings):
# traverse the matrices in the same order as the joints and compute the inverse bind matrix
def __collect_matrices(bone):
- inverse_bind_matrix = gltf2_blender_math.multiply(
- axis_basis_change,
- gltf2_blender_math.multiply(
- blender_object.matrix_world,
+ inverse_bind_matrix = (
+ axis_basis_change @
+ (
+ blender_object.matrix_world @
bone.bone.matrix_local
)
).inverted()