diff options
Diffstat (limited to 'modules/gltf')
-rw-r--r-- | modules/gltf/SCsub | 2 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFDocument.xml | 38 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFDocumentExtension.xml | 28 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFSkeleton.xml | 6 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFSkin.xml | 6 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFState.xml | 38 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_gltf.cpp | 3 | ||||
-rw-r--r-- | modules/gltf/gltf_document.cpp | 5 | ||||
-rw-r--r-- | modules/gltf/gltf_state.cpp | 11 | ||||
-rw-r--r-- | modules/gltf/gltf_state.h | 4 |
10 files changed, 81 insertions, 60 deletions
diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub index 6634d5df7b..71f3ba58d9 100644 --- a/modules/gltf/SCsub +++ b/modules/gltf/SCsub @@ -5,7 +5,7 @@ Import("env_modules") env_gltf = env_modules.Clone() -# Godot's own source files +# Godot source files env_gltf.add_source_files(env.modules_sources, "*.cpp") env_gltf.add_source_files(env.modules_sources, "extensions/*.cpp") env_gltf.add_source_files(env.modules_sources, "structures/*.cpp") diff --git a/modules/gltf/doc_classes/GLTFDocument.xml b/modules/gltf/doc_classes/GLTFDocument.xml index cb0e3b6754..3cd0f5c0f9 100644 --- a/modules/gltf/doc_classes/GLTFDocument.xml +++ b/modules/gltf/doc_classes/GLTFDocument.xml @@ -10,50 +10,50 @@ <methods> <method name="append_from_buffer"> <return type="int" enum="Error" /> - <argument index="0" name="bytes" type="PackedByteArray" /> - <argument index="1" name="base_path" type="String" /> - <argument index="2" name="state" type="GLTFState" /> - <argument index="3" name="flags" type="int" default="0" /> - <argument index="4" name="bake_fps" type="int" default="30" /> + <param index="0" name="bytes" type="PackedByteArray" /> + <param index="1" name="base_path" type="String" /> + <param index="2" name="state" type="GLTFState" /> + <param index="3" name="flags" type="int" default="0" /> + <param index="4" name="bake_fps" type="int" default="30" /> <description> </description> </method> <method name="append_from_file"> <return type="int" enum="Error" /> - <argument index="0" name="path" type="String" /> - <argument index="1" name="state" type="GLTFState" /> - <argument index="2" name="flags" type="int" default="0" /> - <argument index="3" name="bake_fps" type="int" default="30" /> - <argument index="4" name="base_path" type="String" default="""" /> + <param index="0" name="path" type="String" /> + <param index="1" name="state" type="GLTFState" /> + <param index="2" name="flags" type="int" default="0" /> + <param index="3" name="bake_fps" type="int" default="30" /> + <param index="4" name="base_path" type="String" default="""" /> <description> </description> </method> <method name="append_from_scene"> <return type="int" enum="Error" /> - <argument index="0" name="node" type="Node" /> - <argument index="1" name="state" type="GLTFState" /> - <argument index="2" name="flags" type="int" default="0" /> - <argument index="3" name="bake_fps" type="int" default="30" /> + <param index="0" name="node" type="Node" /> + <param index="1" name="state" type="GLTFState" /> + <param index="2" name="flags" type="int" default="0" /> + <param index="3" name="bake_fps" type="int" default="30" /> <description> </description> </method> <method name="generate_buffer"> <return type="PackedByteArray" /> - <argument index="0" name="state" type="GLTFState" /> + <param index="0" name="state" type="GLTFState" /> <description> </description> </method> <method name="generate_scene"> <return type="Node" /> - <argument index="0" name="state" type="GLTFState" /> - <argument index="1" name="bake_fps" type="int" default="30" /> + <param index="0" name="state" type="GLTFState" /> + <param index="1" name="bake_fps" type="int" default="30" /> <description> </description> </method> <method name="write_to_filesystem"> <return type="int" enum="Error" /> - <argument index="0" name="state" type="GLTFState" /> - <argument index="1" name="path" type="String" /> + <param index="0" name="state" type="GLTFState" /> + <param index="1" name="path" type="String" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFDocumentExtension.xml b/modules/gltf/doc_classes/GLTFDocumentExtension.xml index 3c28546ad7..d2a9022445 100644 --- a/modules/gltf/doc_classes/GLTFDocumentExtension.xml +++ b/modules/gltf/doc_classes/GLTFDocumentExtension.xml @@ -9,50 +9,50 @@ <methods> <method name="_export_node" qualifiers="virtual"> <return type="int" /> - <argument index="0" name="state" type="GLTFState" /> - <argument index="1" name="gltf_node" type="GLTFNode" /> - <argument index="2" name="json" type="Dictionary" /> - <argument index="3" name="node" type="Node" /> + <param index="0" name="state" type="GLTFState" /> + <param index="1" name="gltf_node" type="GLTFNode" /> + <param index="2" name="json" type="Dictionary" /> + <param index="3" name="node" type="Node" /> <description> </description> </method> <method name="_export_post" qualifiers="virtual"> <return type="int" /> - <argument index="0" name="state" type="GLTFState" /> + <param index="0" name="state" type="GLTFState" /> <description> </description> </method> <method name="_export_preflight" qualifiers="virtual"> <return type="int" /> - <argument index="0" name="root" type="Node" /> + <param index="0" name="root" type="Node" /> <description> </description> </method> <method name="_import_node" qualifiers="virtual"> <return type="int" /> - <argument index="0" name="state" type="GLTFState" /> - <argument index="1" name="gltf_node" type="GLTFNode" /> - <argument index="2" name="json" type="Dictionary" /> - <argument index="3" name="node" type="Node" /> + <param index="0" name="state" type="GLTFState" /> + <param index="1" name="gltf_node" type="GLTFNode" /> + <param index="2" name="json" type="Dictionary" /> + <param index="3" name="node" type="Node" /> <description> </description> </method> <method name="_import_post" qualifiers="virtual"> <return type="int" /> - <argument index="0" name="state" type="GLTFState" /> - <argument index="1" name="root" type="Node" /> + <param index="0" name="state" type="GLTFState" /> + <param index="1" name="root" type="Node" /> <description> </description> </method> <method name="_import_post_parse" qualifiers="virtual"> <return type="int" /> - <argument index="0" name="state" type="GLTFState" /> + <param index="0" name="state" type="GLTFState" /> <description> </description> </method> <method name="_import_preflight" qualifiers="virtual"> <return type="int" /> - <argument index="0" name="state" type="GLTFState" /> + <param index="0" name="state" type="GLTFState" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml index dad985e886..e1276d0e21 100644 --- a/modules/gltf/doc_classes/GLTFSkeleton.xml +++ b/modules/gltf/doc_classes/GLTFSkeleton.xml @@ -9,7 +9,7 @@ <methods> <method name="get_bone_attachment"> <return type="BoneAttachment3D" /> - <argument index="0" name="idx" type="int" /> + <param index="0" name="idx" type="int" /> <description> </description> </method> @@ -35,13 +35,13 @@ </method> <method name="set_godot_bone_node"> <return type="void" /> - <argument index="0" name="godot_bone_node" type="Dictionary" /> + <param index="0" name="godot_bone_node" type="Dictionary" /> <description> </description> </method> <method name="set_unique_names"> <return type="void" /> - <argument index="0" name="unique_names" type="Array" /> + <param index="0" name="unique_names" type="Array" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml index b6a2bdb957..5abdf33360 100644 --- a/modules/gltf/doc_classes/GLTFSkin.xml +++ b/modules/gltf/doc_classes/GLTFSkin.xml @@ -24,19 +24,19 @@ </method> <method name="set_inverse_binds"> <return type="void" /> - <argument index="0" name="inverse_binds" type="Array" /> + <param index="0" name="inverse_binds" type="Array" /> <description> </description> </method> <method name="set_joint_i_to_bone_i"> <return type="void" /> - <argument index="0" name="joint_i_to_bone_i" type="Dictionary" /> + <param index="0" name="joint_i_to_bone_i" type="Dictionary" /> <description> </description> </method> <method name="set_joint_i_to_name"> <return type="void" /> - <argument index="0" name="joint_i_to_name" type="Dictionary" /> + <param index="0" name="joint_i_to_name" type="Dictionary" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index 44a1723563..adf51ab59e 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -14,13 +14,13 @@ </method> <method name="get_animation_player"> <return type="AnimationPlayer" /> - <argument index="0" name="idx" type="int" /> + <param index="0" name="idx" type="int" /> <description> </description> </method> <method name="get_animation_players_count"> <return type="int" /> - <argument index="0" name="idx" type="int" /> + <param index="0" name="idx" type="int" /> <description> </description> </method> @@ -66,7 +66,7 @@ </method> <method name="get_scene_node"> <return type="Node" /> - <argument index="0" name="idx" type="int" /> + <param index="0" name="idx" type="int" /> <description> </description> </method> @@ -102,91 +102,91 @@ </method> <method name="set_accessors"> <return type="void" /> - <argument index="0" name="accessors" type="Array" /> + <param index="0" name="accessors" type="Array" /> <description> </description> </method> <method name="set_animations"> <return type="void" /> - <argument index="0" name="animations" type="Array" /> + <param index="0" name="animations" type="Array" /> <description> </description> </method> <method name="set_buffer_views"> <return type="void" /> - <argument index="0" name="buffer_views" type="Array" /> + <param index="0" name="buffer_views" type="Array" /> <description> </description> </method> <method name="set_cameras"> <return type="void" /> - <argument index="0" name="cameras" type="Array" /> + <param index="0" name="cameras" type="Array" /> <description> </description> </method> <method name="set_images"> <return type="void" /> - <argument index="0" name="images" type="Array" /> + <param index="0" name="images" type="Array" /> <description> </description> </method> <method name="set_lights"> <return type="void" /> - <argument index="0" name="lights" type="Array" /> + <param index="0" name="lights" type="Array" /> <description> </description> </method> <method name="set_materials"> <return type="void" /> - <argument index="0" name="materials" type="Array" /> + <param index="0" name="materials" type="Array" /> <description> </description> </method> <method name="set_meshes"> <return type="void" /> - <argument index="0" name="meshes" type="Array" /> + <param index="0" name="meshes" type="Array" /> <description> </description> </method> <method name="set_nodes"> <return type="void" /> - <argument index="0" name="nodes" type="Array" /> + <param index="0" name="nodes" type="Array" /> <description> </description> </method> <method name="set_skeleton_to_node"> <return type="void" /> - <argument index="0" name="skeleton_to_node" type="Dictionary" /> + <param index="0" name="skeleton_to_node" type="Dictionary" /> <description> </description> </method> <method name="set_skeletons"> <return type="void" /> - <argument index="0" name="skeletons" type="Array" /> + <param index="0" name="skeletons" type="Array" /> <description> </description> </method> <method name="set_skins"> <return type="void" /> - <argument index="0" name="skins" type="Array" /> + <param index="0" name="skins" type="Array" /> <description> </description> </method> <method name="set_textures"> <return type="void" /> - <argument index="0" name="textures" type="Array" /> + <param index="0" name="textures" type="Array" /> <description> </description> </method> <method name="set_unique_animation_names"> <return type="void" /> - <argument index="0" name="unique_animation_names" type="Array" /> + <param index="0" name="unique_animation_names" type="Array" /> <description> </description> </method> <method name="set_unique_names"> <return type="void" /> - <argument index="0" name="unique_names" type="Array" /> + <param index="0" name="unique_names" type="Array" /> <description> </description> </method> @@ -196,6 +196,8 @@ </member> <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]"> </member> + <member name="create_animations" type="bool" setter="set_create_animations" getter="get_create_animations" default="true"> + </member> <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()"> </member> <member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}"> diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp index 3fadec5167..161808aade 100644 --- a/modules/gltf/editor/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp @@ -60,6 +60,9 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t } return nullptr; } + if (p_options.has("animation/import")) { + state->set_create_animations(bool(p_options["animation/import"])); + } return doc->generate_scene(state, p_bake_fps); } diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 4ca8482ba3..d102970932 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -4938,7 +4938,8 @@ Error GLTFDocument::_parse_animations(Ref<GLTFState> state) { if (d.has("name")) { const String name = d["name"]; - if (name.begins_with("loop") || name.ends_with("loop") || name.begins_with("cycle") || name.ends_with("cycle")) { + const String name_lower = name.to_lower(); + if (name_lower.begins_with("loop") || name_lower.ends_with("loop") || name_lower.begins_with("cycle") || name_lower.ends_with("cycle")) { animation->set_loop(true); } animation->set_name(_gen_unique_animation_name(state, name)); @@ -6898,7 +6899,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) { Node *root = gltf_root_node->get_parent(); ERR_FAIL_NULL_V(root, nullptr); _process_mesh_instances(state, root); - if (state->animations.size()) { + if (state->get_create_animations() && state->animations.size()) { AnimationPlayer *ap = memnew(AnimationPlayer); root->add_child(ap, true); ap->set_owner(root); diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index a5f7bcf9d6..8212e4c22f 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -79,6 +79,8 @@ void GLTFState::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons); ClassDB::bind_method(D_METHOD("get_skeleton_to_node"), &GLTFState::get_skeleton_to_node); ClassDB::bind_method(D_METHOD("set_skeleton_to_node", "skeleton_to_node"), &GLTFState::set_skeleton_to_node); + ClassDB::bind_method(D_METHOD("get_create_animations"), &GLTFState::get_create_animations); + ClassDB::bind_method(D_METHOD("set_create_animations", "create_animations"), &GLTFState::set_create_animations); ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations); ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations); ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node); @@ -106,6 +108,7 @@ void GLTFState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>> ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "skeleton_to_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeleton_to_node", "get_skeleton_to_node"); // RBMap<GLTFSkeletonIndex, + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "create_animations"), "set_create_animations", "get_create_animations"); // bool ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>> } @@ -285,6 +288,14 @@ void GLTFState::set_skeleton_to_node(Dictionary p_skeleton_to_node) { GLTFTemplateConvert::set_from_dict(skeleton_to_node, p_skeleton_to_node); } +bool GLTFState::get_create_animations() { + return create_animations; +} + +void GLTFState::set_create_animations(bool p_create_animations) { + create_animations = p_create_animations; +} + Array GLTFState::get_animations() { return GLTFTemplateConvert::to_array(animations); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index d2a4948f06..c08132f874 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -61,6 +61,7 @@ class GLTFState : public Resource { bool use_named_skin_binds = false; bool use_khr_texture_transform = false; bool discard_meshes_and_materials = false; + bool create_animations = true; Vector<Ref<GLTFNode>> nodes; Vector<Vector<uint8_t>> buffers; @@ -168,6 +169,9 @@ public: Dictionary get_skeleton_to_node(); void set_skeleton_to_node(Dictionary p_skeleton_to_node); + bool get_create_animations(); + void set_create_animations(bool p_create_animations); + Array get_animations(); void set_animations(Array p_animations); |