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

Method _generate_skeleton_bone_node

modules/fbx/fbx_document.cpp:1679–1766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1677}
1678
1679void FBXDocument::_generate_skeleton_bone_node(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index, Node *p_scene_parent, Node *p_scene_root) {
1680 Ref<GLTFNode> fbx_node = p_state->nodes[p_node_index];
1681
1682 Node3D *current_node = nullptr;
1683
1684 Skeleton3D *skeleton = p_state->skeletons[fbx_node->skeleton]->godot_skeleton;
1685 // In this case, this node is already a bone in skeleton.
1686 const bool is_skinned_mesh = (fbx_node->skin >= 0 && fbx_node->mesh >= 0);
1687 const bool requires_extra_node = (fbx_node->mesh >= 0 || fbx_node->camera >= 0 || fbx_node->light >= 0);
1688
1689 Skeleton3D *active_skeleton = Object::cast_to<Skeleton3D>(p_scene_parent);
1690 if (active_skeleton != skeleton) {
1691 if (active_skeleton) {
1692 // Should no longer be possible.
1693 ERR_PRINT(vformat("FBX: Generating scene detected direct parented Skeletons at node %d", p_node_index));
1694 BoneAttachment3D *bone_attachment = _generate_bone_attachment(p_state, active_skeleton, p_node_index, fbx_node->parent);
1695 p_scene_parent->add_child(bone_attachment, true);
1696 bone_attachment->set_owner(p_scene_root);
1697 // There is no fbx_node that represent this, so just directly create a unique name
1698 bone_attachment->set_name(_gen_unique_name(p_state->unique_names, "BoneAttachment3D"));
1699 // We change the scene_parent to our bone attachment now. We do not set current_node because we want to make the node
1700 // and attach it to the bone_attachment
1701 p_scene_parent = bone_attachment;
1702 }
1703 if (skeleton->get_parent() == nullptr) {
1704 p_scene_parent->add_child(skeleton, true);
1705 skeleton->set_owner(p_scene_root);
1706 }
1707 }
1708
1709 active_skeleton = skeleton;
1710 current_node = active_skeleton;
1711 if (active_skeleton) {
1712 p_scene_parent = active_skeleton;
1713 }
1714
1715 if (requires_extra_node) {
1716 current_node = nullptr;
1717 // skinned meshes must not be placed in a bone attachment.
1718 if (!is_skinned_mesh) {
1719 // Bone Attachment - Same Node Case
1720 BoneAttachment3D *bone_attachment = _generate_bone_attachment(p_state, active_skeleton, p_node_index, p_node_index);
1721
1722 p_scene_parent->add_child(bone_attachment, true);
1723 bone_attachment->set_owner(p_scene_root);
1724
1725 // There is no fbx_node that represent this, so just directly create a unique name
1726 bone_attachment->set_name(fbx_node->get_name());
1727
1728 // We change the scene_parent to our bone attachment now. We do not set current_node because we want to make the node
1729 // and attach it to the bone_attachment
1730 p_scene_parent = bone_attachment;
1731 }
1732 /// @todo: 20240118 // fire
1733 /// // Check if any GLTFDocumentExtension classes want to generate a node for us.
1734 // for (Ref<GLTFDocumentExtension> ext : document_extensions) {
1735 // ERR_CONTINUE(ext.is_null());
1736 // current_node = ext->generate_scene_node(p_state, fbx_node, p_scene_parent);

Callers

nothing calls this directly

Calls 10

vformatFunction · 0.85
set_ownerMethod · 0.80
propagate_callMethod · 0.80
sizeMethod · 0.65
StringNameClass · 0.50
add_childMethod · 0.45
set_nameMethod · 0.45
get_parentMethod · 0.45
get_nameMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected