diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 80 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFState.xml | 2 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_gltf.cpp | 3 | ||||
-rw-r--r-- | modules/gltf/gltf_document.cpp | 2 | ||||
-rw-r--r-- | modules/gltf/gltf_state.cpp | 11 | ||||
-rw-r--r-- | modules/gltf/gltf_state.h | 4 | ||||
-rw-r--r-- | modules/gridmap/editor/grid_map_editor_plugin.cpp | 6 |
8 files changed, 73 insertions, 39 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index dc6bfbb034..8a5e93eeff 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -290,7 +290,9 @@ void GDScript::_get_script_method_list(List<MethodInfo> *r_list, bool p_include_ #endif mi.arguments.push_back(arginfo); } - +#ifdef TOOLS_ENABLED + mi.default_arguments.append_array(func->get_default_arg_values()); +#endif mi.return_val = func->get_return_type(); r_list->push_back(mi); } diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index d943974ce4..c18412bc63 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -660,7 +660,13 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx, bool } static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_function, int p_arg_idx) { - String arghint = p_function->get_datatype().to_string() + " " + p_function->identifier->name.operator String() + "("; + String arghint; + + if (p_function->get_datatype().builtin_type == Variant::NIL) { + arghint = "void " + p_function->identifier->name.operator String() + "("; + } else { + arghint = p_function->get_datatype().to_string() + " " + p_function->identifier->name.operator String() + "("; + } for (int i = 0; i < p_function->parameters.size(); i++) { if (i > 0) { @@ -671,7 +677,11 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio arghint += String::chr(0xFFFF); } const GDScriptParser::ParameterNode *par = p_function->parameters[i]; - arghint += par->identifier->name.operator String() + ": " + par->get_datatype().to_string(); + if (!par->get_datatype().is_hard_type()) { + arghint += par->identifier->name.operator String() + ": Variant"; + } else { + arghint += par->identifier->name.operator String() + ": " + par->get_datatype().to_string(); + } if (par->default_value) { String def_val = "<unknown>"; @@ -2517,39 +2527,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c GDScriptCompletionIdentifier connect_base; - if (Variant::has_utility_function(call->function_name)) { - MethodInfo info = Variant::get_utility_function_info(call->function_name); - r_arghint = _make_arguments_hint(info, p_argidx); - return; - } else if (GDScriptUtilityFunctions::function_exists(call->function_name)) { - MethodInfo info = GDScriptUtilityFunctions::get_function_info(call->function_name); - r_arghint = _make_arguments_hint(info, p_argidx); - return; - } else if (GDScriptParser::get_builtin_type(call->function_name) < Variant::VARIANT_MAX) { - // Complete constructor. - List<MethodInfo> constructors; - Variant::get_constructor_list(GDScriptParser::get_builtin_type(call->function_name), &constructors); - - int i = 0; - for (const MethodInfo &E : constructors) { - if (p_argidx >= E.arguments.size()) { - continue; - } - if (i > 0) { - r_arghint += "\n"; - } - r_arghint += _make_arguments_hint(E, p_argidx); - i++; - } - return; - } else if (call->is_super || callee_type == GDScriptParser::Node::IDENTIFIER) { - base = p_context.base; - - if (p_context.current_class) { - base_type = p_context.current_class->get_datatype(); - _static = !p_context.current_function || p_context.current_function->is_static; - } - } else if (callee_type == GDScriptParser::Node::SUBSCRIPT) { + if (callee_type == GDScriptParser::Node::SUBSCRIPT) { const GDScriptParser::SubscriptNode *subscript = static_cast<const GDScriptParser::SubscriptNode *>(call->callee); if (subscript->base != nullptr && subscript->base->type == GDScriptParser::Node::IDENTIFIER) { @@ -2589,6 +2567,38 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c _static = base_type.is_meta_type; } + } else if (Variant::has_utility_function(call->function_name)) { + MethodInfo info = Variant::get_utility_function_info(call->function_name); + r_arghint = _make_arguments_hint(info, p_argidx); + return; + } else if (GDScriptUtilityFunctions::function_exists(call->function_name)) { + MethodInfo info = GDScriptUtilityFunctions::get_function_info(call->function_name); + r_arghint = _make_arguments_hint(info, p_argidx); + return; + } else if (GDScriptParser::get_builtin_type(call->function_name) < Variant::VARIANT_MAX) { + // Complete constructor. + List<MethodInfo> constructors; + Variant::get_constructor_list(GDScriptParser::get_builtin_type(call->function_name), &constructors); + + int i = 0; + for (const MethodInfo &E : constructors) { + if (p_argidx >= E.arguments.size()) { + continue; + } + if (i > 0) { + r_arghint += "\n"; + } + r_arghint += _make_arguments_hint(E, p_argidx); + i++; + } + return; + } else if (call->is_super || callee_type == GDScriptParser::Node::IDENTIFIER) { + base = p_context.base; + + if (p_context.current_class) { + base_type = p_context.current_class->get_datatype(); + _static = !p_context.current_function || p_context.current_function->is_static; + } } else { return; } diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index a168e6108f..adf51ab59e 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -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 7e90f198f6..d102970932 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -6899,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); diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index 09f0ff32f0..518e2cf97d 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -896,10 +896,12 @@ void GridMapEditor::update_palette() { } if (selected != -1 && mesh_library_palette->get_item_count() > 0) { - mesh_library_palette->select(selected); + // Make sure that this variable is set correctly. + selected_palette = MIN(selected, mesh_library_palette->get_item_count() - 1); + mesh_library_palette->select(selected_palette); } - last_mesh_library = mesh_library.operator->(); + last_mesh_library = *mesh_library; } void GridMapEditor::edit(GridMap *p_gridmap) { |