Skip to content

Commit

Permalink
Fix #294 fix skinning regression from previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
julienduroure committed Feb 22, 2019
1 parent 9f81747 commit 42b299d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
30 changes: 12 additions & 18 deletions addons/io_scene_gltf2/blender/imp/gltf2_blender_primitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,25 @@ def create(gltf, pyprimitive, verts, edges, faces):
pyprimitive.tmp_indices = indices

# Manage only vertices that are in indices tab
if len(indices) != len(pos):

indice_equivalents = {}
new_pos = []
new_pos_idx = 0
for i in indices:
if i[0] not in indice_equivalents.keys():
indice_equivalents[i[0]] = new_pos_idx
new_pos.append(pos[i[0]])
new_pos_idx += 1

prim_verts = [loc_gltf_to_blender(vert) for vert in new_pos]
else:
prim_verts = [loc_gltf_to_blender(vert) for vert in pos]
indice_equivalents = {}
new_pos = []
new_pos_idx = 0
for i in indices:
if i[0] not in indice_equivalents.keys():
indice_equivalents[i[0]] = new_pos_idx
new_pos.append(pos[i[0]])
new_pos_idx += 1

prim_verts = [loc_gltf_to_blender(vert) for vert in new_pos]

pyprimitive.vertices_length = len(prim_verts)
verts.extend(prim_verts)
prim_faces = []
for i in range(0, len(indices), 3):
vals = indices[i:i + 3]
new_vals = []
for y in vals:
if len(indices) != len(pos):
new_vals.append(indice_equivalents[y[0]] + current_length)
else:
new_vals.append(y[0] + current_length)
new_vals.append(indice_equivalents[y[0]] + current_length)
prim_faces.append(tuple(new_vals))
faces.extend(prim_faces)
pyprimitive.faces_length = len(prim_faces)
Expand Down
23 changes: 21 additions & 2 deletions addons/io_scene_gltf2/blender/imp/gltf2_blender_skin.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,27 @@ def assign_vertex_groups(gltf, skin_id):
idx_already_done = {}

if 'JOINTS_0' in prim.attributes.keys() and 'WEIGHTS_0' in prim.attributes.keys():
joint_ = BinaryData.get_data_from_accessor(gltf, prim.attributes['JOINTS_0'])
weight_ = BinaryData.get_data_from_accessor(gltf, prim.attributes['WEIGHTS_0'])
original_joint_ = BinaryData.get_data_from_accessor(gltf, prim.attributes['JOINTS_0'])
original_weight_ = BinaryData.get_data_from_accessor(gltf, prim.attributes['WEIGHTS_0'])

tmp_indices = {}
tmp_idx = 0
weight_ = []
for i in prim.tmp_indices:
if i[0] not in tmp_indices.keys():
tmp_indices[i[0]] = tmp_idx
tmp_idx += 1
weight_.append(original_weight_[i[0]])

tmp_indices = {}
tmp_idx = 0
joint_ = []
for i in prim.tmp_indices:
if i[0] not in tmp_indices.keys():
tmp_indices[i[0]] = tmp_idx
tmp_idx += 1
joint_.append(original_joint_[i[0]])


for poly in obj.data.polygons:
for loop_idx in range(poly.loop_start, poly.loop_start + poly.loop_total):
Expand Down

0 comments on commit 42b299d

Please sign in to comment.