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:
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_mesh.py')
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_mesh.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
index 384cae7d..a3c1bd34 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -58,6 +58,16 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
"""Put all primitive data into the mesh."""
pymesh = gltf.data.meshes[mesh_idx]
+ # Use a class here, to be able to pass data by reference to hook (to be able to change them inside hook)
+ class IMPORT_mesh_options:
+ def __init__(self, skinning: bool = True, skin_into_bind_pose: bool = True, use_auto_smooth: bool = True):
+ self.skinning = skinning
+ self.skin_into_bind_pose = skin_into_bind_pose
+ self.use_auto_smooth = use_auto_smooth
+
+ mesh_options = IMPORT_mesh_options()
+ import_user_extensions('gather_import_mesh_options', gltf, mesh_options, pymesh, skin_idx)
+
# Scan the primitives to find out what we need to create
has_normals = False
@@ -135,6 +145,8 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
print_console('INFO', 'Draco Decoder: Decode primitive {}'.format(pymesh.name or '[unnamed]'))
decode_primitive(gltf, prim)
+ import_user_extensions('gather_import_decode_primitive', gltf, pymesh, prim, skin_idx)
+
if prim.indices is not None:
indices = BinaryData.decode_accessor(gltf, prim.indices)
indices = indices.reshape(len(indices))
@@ -240,7 +252,7 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
for sk_locs in sk_vert_locs:
gltf.locs_batch_gltf_to_blender(sk_locs)
- if num_joint_sets:
+ if num_joint_sets and mesh_options.skin_into_bind_pose:
skin_into_bind_pose(
gltf, skin_idx, vert_joints, vert_weights,
locs=[vert_locs] + sk_vert_locs,
@@ -286,14 +298,14 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
if layer is None:
print("WARNING: Vertex colors are ignored because the maximum number of vertex color layers has been "
- "reached.")
+ "reached.")
break
mesh.color_attributes[layer.name].data.foreach_set('color', squish(loop_cols[col_i]))
# Skinning
# TODO: this is slow :/
- if num_joint_sets:
+ if num_joint_sets and mesh_options.skinning:
pyskin = gltf.data.skins[skin_idx]
for i, node_idx in enumerate(pyskin.joints):
bone = gltf.vnodes[node_idx]
@@ -340,7 +352,7 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
if prim.material is not None:
# Get the material
pymaterial = gltf.data.materials[prim.material]
- vertex_color = 'COLOR_0' if 'COLOR_0' in prim.attributes else None
+ vertex_color = 'COLOR_0' if ('COLOR_0' in prim.attributes) else None
if vertex_color not in pymaterial.blender_material:
BlenderMaterial.create(gltf, prim.material, vertex_color)
material_name = pymaterial.blender_material[vertex_color]
@@ -374,7 +386,7 @@ def do_primitives(gltf, mesh_idx, skin_idx, mesh, ob):
if has_normals:
mesh.create_normals_split()
mesh.normals_split_custom_set_from_vertices(vert_normals)
- mesh.use_auto_smooth = True
+ mesh.use_auto_smooth = mesh_options.use_auto_smooth
def points_edges_tris(mode, indices):