Skip to content

Commit

Permalink
Switch to getting the node by the id rather than looking it up by nam…
Browse files Browse the repository at this point in the history
…e in Blender versions under 3.1.

This allows for nodes without a name to have their components imported and also makes sure the correct node is imported when there are more than one with the same name (Spoke can generate files with duplicate names).
Note: the old way of getting the node by name is left as a fallback, just in case.
  • Loading branch information
Exairnous committed Apr 5, 2024
1 parent 5e79a58 commit 79f20bd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions addons/io_hubs_addon/io/gltf_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,23 @@ def patched_BlenderNode_create_object(gltf, vnode_id):

if vnode.camera_node_idx is not None:
parent_vnode = gltf.vnodes[vnode.parent]
if parent_vnode.name:
node = [n for n in gltf.data.nodes if n.name == parent_vnode.name][0]
node = gltf.data.nodes[vnode.parent]
if node.name != parent_vnode.name:
if parent_vnode.name:
print("Falling back to getting the node from the vnode name.")
node = [n for n in gltf.data.nodes if n.name == parent_vnode.name][0]
else:
print("Couldn't find the equivalent node for the vnode.")


else:
if vnode.name:
node = [n for n in gltf.data.nodes if n.name == vnode.name][0]
node = gltf.data.nodes[vnode_id]
if node.name != vnode.name:
if vnode.name:
print("Falling back to getting the node from the vnode name.")
node = [n for n in gltf.data.nodes if n.name == vnode.name][0]
else:
print("Couldn't find the equivalent node for the vnode.")

import_hubs_components(node, vnode.blender_object, gltf, blender_ob=vnode.blender_object)

Expand Down

0 comments on commit 79f20bd

Please sign in to comment.