Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions bms_blender_plugin/exporter/export_lods.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,25 @@ def _recursively_parse_nodes(objects):
current_vertices_index += parsed_nodes.vertices_length
current_vertices_size += parsed_nodes.vertices_size

"""
Certain nodes (dofs, switches) require an _END node which requires the same node index as the "START" node
The above steps have added +1 to the index count, and so we take the len(nodes) -1 to obtain the parent index
If I was going to refactor this I would explicitely calculate the node_index and avoid calculating it in each
Node definition.
"""
parent_node_index = len(nodes) -1

# recursively iterate over all children
if obj.children:
_recursively_parse_nodes(obj.children)

# append the end nodes for Switches, DOFs and Slots
if get_bml_type(obj) == BlenderNodeType.SWITCH and len(obj.children) > 0:
nodes.append(SwitchEnd(len(nodes)))
nodes.append(SwitchEnd(parent_node_index))
elif get_bml_type(obj) == BlenderNodeType.DOF and len(obj.children) > 0:
nodes.append(DofEnd(len(nodes)))
nodes.append(DofEnd(parent_node_index))
elif get_bml_type(obj) == BlenderNodeType.SLOT:
nodes.append(SlotEnd(len(nodes)))
nodes.append(SlotEnd(parent_node_index))

# parse all nodes of the root collection
root_objects = []
Expand Down