MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _generate_scene_node

Method _generate_scene_node

modules/fbx/fbx_document.cpp:1614–1677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1612}
1613
1614void FBXDocument::_generate_scene_node(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index, Node *p_scene_parent, Node *p_scene_root) {
1615 Ref<GLTFNode> fbx_node = p_state->nodes[p_node_index];
1616
1617 if (fbx_node->skeleton >= 0) {
1618 _generate_skeleton_bone_node(p_state, p_node_index, p_scene_parent, p_scene_root);
1619 return;
1620 }
1621
1622 Node3D *current_node = nullptr;
1623
1624 // Is our parent a skeleton
1625 Skeleton3D *active_skeleton = Object::cast_to<Skeleton3D>(p_scene_parent);
1626
1627 const bool non_bone_parented_to_skeleton = active_skeleton;
1628
1629 // skinned meshes must not be placed in a bone attachment.
1630 if (non_bone_parented_to_skeleton && fbx_node->skin < 0) {
1631 // Bone Attachment - Parent Case
1632 BoneAttachment3D *bone_attachment = _generate_bone_attachment(p_state, active_skeleton, p_node_index, fbx_node->parent);
1633
1634 p_scene_parent->add_child(bone_attachment, true);
1635 bone_attachment->set_owner(p_scene_root);
1636
1637 // There is no fbx_node that represent this, so just directly create a unique name
1638 bone_attachment->set_name(fbx_node->get_name());
1639
1640 // We change the scene_parent to our bone attachment now. We do not set current_node because we want to make the node
1641 // and attach it to the bone_attachment
1642 p_scene_parent = bone_attachment;
1643 }
1644 if (!current_node) {
1645 if (fbx_node->skin >= 0 && fbx_node->mesh >= 0 && !fbx_node->children.is_empty()) {
1646 current_node = _generate_spatial(p_state, p_node_index);
1647 Node3D *mesh_inst = _generate_mesh_instance(p_state, p_node_index);
1648 mesh_inst->set_name(fbx_node->get_name());
1649
1650 current_node->add_child(mesh_inst, true);
1651 } else if (fbx_node->mesh >= 0) {
1652 current_node = _generate_mesh_instance(p_state, p_node_index);
1653 } else if (fbx_node->camera >= 0) {
1654 current_node = _generate_camera(p_state, p_node_index);
1655 } else if (fbx_node->light >= 0) {
1656 current_node = _generate_light(p_state, p_node_index);
1657 } else {
1658 current_node = _generate_spatial(p_state, p_node_index);
1659 }
1660 }
1661
1662 ERR_FAIL_NULL(current_node);
1663
1664 // Add the node we generated and set the owner to the scene root.
1665 p_scene_parent->add_child(current_node, true);
1666 if (current_node != p_scene_root) {
1667 Array args = { p_scene_root };
1668 current_node->propagate_call(StringName("set_owner"), args);
1669 }
1670 current_node->set_transform(fbx_node->transform);
1671 current_node->set_name(fbx_node->get_name());

Callers

nothing calls this directly

Calls 10

set_ownerMethod · 0.80
propagate_callMethod · 0.80
sizeMethod · 0.65
StringNameClass · 0.50
add_childMethod · 0.45
set_nameMethod · 0.45
get_nameMethod · 0.45
is_emptyMethod · 0.45
set_transformMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected