diff options
Diffstat (limited to 'servers')
16 files changed, 133 insertions, 49 deletions
diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index 7b70483571..591023c820 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -786,7 +786,7 @@ void RendererCanvasCull::canvas_item_add_texture_rect(RID p_item, const Rect2 &p if (p_tile) { rect->flags |= RendererCanvasRender::CANVAS_RECT_TILE; rect->flags |= RendererCanvasRender::CANVAS_RECT_REGION; - rect->source = Rect2(0, 0, fabsf(p_rect.size.width), fabsf(p_rect.size.height)); + rect->source = Rect2(0, 0, ABS(p_rect.size.width), ABS(p_rect.size.height)); } if (p_rect.size.x < 0) { diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 768bd1de9d..71753f9694 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -44,7 +44,7 @@ void SceneShaderForwardClustered::ShaderData::set_code(const String &p_code) { uniforms.clear(); uses_screen_texture = false; - if (code == String()) { + if (code.is_empty()) { return; //just invalid, but no error } diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index e6d9a60f94..8807ebf134 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -47,7 +47,7 @@ void SceneShaderForwardMobile::ShaderData::set_code(const String &p_code) { uniforms.clear(); uses_screen_texture = false; - if (code == String()) { + if (code.is_empty()) { return; //just invalid, but no error } diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index d013099cce..2ff7f27d33 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -1953,7 +1953,7 @@ void RendererCanvasRenderRD::ShaderData::set_code(const String &p_code) { uses_sdf = false; uses_time = false; - if (code == String()) { + if (code.is_empty()) { return; //just invalid, but no error } diff --git a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp index 522a8e8112..d310becd1e 100644 --- a/servers/rendering/renderer_rd/renderer_compositor_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_compositor_rd.cpp @@ -240,7 +240,7 @@ RendererCompositorRD *RendererCompositorRD::singleton = nullptr; RendererCompositorRD::RendererCompositorRD() { { String shader_cache_dir = Engine::get_singleton()->get_shader_cache_path(); - if (shader_cache_dir == String()) { + if (shader_cache_dir.is_empty()) { shader_cache_dir = "user://"; } DirAccessRef da = DirAccess::open(shader_cache_dir); @@ -261,7 +261,7 @@ RendererCompositorRD::RendererCompositorRD() { shader_cache_dir = String(); //disable only if not editor } - if (shader_cache_dir != String()) { + if (!shader_cache_dir.is_empty()) { bool compress = GLOBAL_GET("rendering/shader_compiler/shader_cache/compress"); bool use_zstd = GLOBAL_GET("rendering/shader_compiler/shader_cache/use_zstd_compression"); bool strip_debug = GLOBAL_GET("rendering/shader_compiler/shader_cache/strip_debug"); diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index ae8d91a73b..7c35b01b50 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -3581,7 +3581,7 @@ void RendererSceneRenderRD::FogShaderData::set_code(const String &p_code) { ubo_size = 0; uniforms.clear(); - if (code == String()) { + if (code.is_empty()) { return; //just invalid, but no error } @@ -4417,9 +4417,9 @@ void RendererSceneRenderRD::_update_volumetric_fog(RID p_render_buffers, RID p_e uint32_t cluster_screen_width = (rb->width - 1) / cluster_size + 1; uint32_t cluster_screen_height = (rb->height - 1) / cluster_size + 1; - params.cluster_type_size = cluster_screen_width * cluster_screen_height * (32 + 32); - params.cluster_width = cluster_screen_width; params.max_cluster_element_count_div_32 = max_cluster_elements / 32; + params.cluster_type_size = cluster_screen_width * cluster_screen_height * (params.max_cluster_element_count_div_32 + 32); + params.cluster_width = cluster_screen_width; params.screen_size[0] = rb->width; params.screen_size[1] = rb->height; diff --git a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp index a9c39fb937..f595edb225 100644 --- a/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_sky_rd.cpp @@ -46,7 +46,7 @@ void RendererSceneSkyRD::SkyShaderData::set_code(const String &p_code) { ubo_size = 0; uniforms.clear(); - if (code == String()) { + if (code.is_empty()) { return; //just invalid, but no error } diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp index f8d0aad4fa..79728169ae 100644 --- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp @@ -2861,7 +2861,7 @@ void RendererStorageRD::MaterialData::update_textures(const Map<StringName, Vari } } #ifdef TOOLS_ENABLED - if (roughness_detect_texture && normal_detect_texture && normal_detect_texture->path != String()) { + if (roughness_detect_texture && normal_detect_texture && !normal_detect_texture->path.is_empty()) { roughness_detect_texture->detect_roughness_callback(roughness_detect_texture->detect_roughness_callback_ud, normal_detect_texture->path, roughness_channel); } #endif @@ -2901,7 +2901,7 @@ void RendererStorageRD::MaterialData::update_textures(const Map<StringName, Vari rd_texture = singleton->texture_rd_get_default(DEFAULT_RD_TEXTURE_WHITE); } #ifdef TOOLS_ENABLED - if (roughness_detect_texture && normal_detect_texture && normal_detect_texture->path != String()) { + if (roughness_detect_texture && normal_detect_texture && !normal_detect_texture->path.is_empty()) { roughness_detect_texture->detect_roughness_callback(roughness_detect_texture->detect_roughness_callback_ud, normal_detect_texture->path, roughness_channel); } #endif @@ -5820,7 +5820,7 @@ void RendererStorageRD::ParticlesShaderData::set_code(const String &p_code) { uniforms.clear(); uses_collision = false; - if (code == String()) { + if (code.is_empty()) { return; //just invalid, but no error } diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index 2568090918..438e78ba8c 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -79,7 +79,7 @@ void ShaderRD::_add_stage(const char *p_code, StageType p_stage_type) { } if (push_chunk) { - if (text != String()) { + if (!text.is_empty()) { StageTemplate::Chunk text_chunk; text_chunk.type = StageTemplate::Chunk::TYPE_TEXT; text_chunk.text = text.utf8(); @@ -90,7 +90,7 @@ void ShaderRD::_add_stage(const char *p_code, StageType p_stage_type) { } } - if (text != String()) { + if (!text.is_empty()) { StageTemplate::Chunk text_chunk; text_chunk.type = StageTemplate::Chunk::TYPE_TEXT; text_chunk.text = text.utf8(); @@ -638,7 +638,7 @@ void ShaderRD::initialize(const Vector<String> &p_variant_defines, const String variants_enabled.push_back(true); } - if (shader_cache_dir != String()) { + if (!shader_cache_dir.is_empty()) { StringBuilder hash_build; hash_build.append("[base_hash]"); diff --git a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl index 747f88960c..999e8d0844 100644 --- a/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl +++ b/servers/rendering/renderer_rd/shaders/volumetric_fog_process.glsl @@ -581,16 +581,29 @@ void main() { if (spot_lights.data[light_index].shadow_enabled) { //has shadow - vec4 v = vec4(view_pos, 1.0); + vec4 uv_rect = spot_lights.data[light_index].atlas_rect; + vec2 flip_offset = spot_lights.data[light_index].direction.xy; - vec4 splane = (spot_lights.data[light_index].shadow_matrix * v); - splane /= splane.w; + vec3 local_vert = (spot_lights.data[light_index].shadow_matrix * vec4(view_pos, 1.0)).xyz; - float depth = texture(sampler2D(shadow_atlas, linear_sampler), splane.xy).r; + float shadow_len = length(local_vert); //need to remember shadow len from here + vec3 shadow_sample = normalize(local_vert); - shadow_attenuation = exp(min(0.0, (depth - splane.z)) / spot_lights.data[light_index].inv_radius * spot_lights.data[light_index].shadow_volumetric_fog_fade); - } + if (shadow_sample.z >= 0.0) { + uv_rect.xy += flip_offset; + } + + shadow_sample.z = 1.0 + abs(shadow_sample.z); + vec3 pos = vec3(shadow_sample.xy / shadow_sample.z, shadow_len - spot_lights.data[light_index].shadow_bias); + pos.z *= spot_lights.data[light_index].inv_radius; + + pos.xy = pos.xy * 0.5 + 0.5; + pos.xy = uv_rect.xy + pos.xy * uv_rect.zw; + float depth = texture(sampler2D(shadow_atlas, linear_sampler), pos.xy).r; + + shadow_attenuation = exp(min(0.0, (depth - pos.z)) / spot_lights.data[light_index].inv_radius * spot_lights.data[light_index].shadow_volumetric_fog_fade); + } total_light += light * attenuation * shadow_attenuation * henyey_greenstein(dot(normalize(light_rel_vec), normalize(view_pos)), params.phase_g); } } diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 5602bb197b..38f57b4624 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -205,7 +205,7 @@ Vector<uint8_t> RenderingDevice::_shader_compile_binary_from_spirv(const Ref<RDS ShaderStageSPIRVData sd; sd.shader_stage = stage; String error = p_spirv->get_stage_compile_error(stage); - ERR_FAIL_COND_V_MSG(error != String(), Vector<uint8_t>(), "Can't create a shader from an errored bytecode. Check errors in source bytecode."); + ERR_FAIL_COND_V_MSG(!error.is_empty(), Vector<uint8_t>(), "Can't create a shader from an errored bytecode. Check errors in source bytecode."); sd.spir_v = p_spirv->get_stage_bytecode(stage); if (sd.spir_v.is_empty()) { continue; @@ -225,7 +225,7 @@ RID RenderingDevice::_shader_create_from_spirv(const Ref<RDShaderSPIRV> &p_spirv ShaderStageSPIRVData sd; sd.shader_stage = stage; String error = p_spirv->get_stage_compile_error(stage); - ERR_FAIL_COND_V_MSG(error != String(), RID(), "Can't create a shader from an errored bytecode. Check errors in source bytecode."); + ERR_FAIL_COND_V_MSG(!error.is_empty(), RID(), "Can't create a shader from an errored bytecode. Check errors in source bytecode."); sd.spir_v = p_spirv->get_stage_bytecode(stage); if (sd.spir_v.is_empty()) { continue; diff --git a/servers/rendering/rendering_device_binds.cpp b/servers/rendering/rendering_device_binds.cpp index a21f28989b..3d09d83601 100644 --- a/servers/rendering/rendering_device_binds.cpp +++ b/servers/rendering/rendering_device_binds.cpp @@ -80,7 +80,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String } } - if (base_error != String()) { + if (!base_error.is_empty()) { break; } } @@ -89,7 +89,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String } } - if (stage == RD::SHADER_STAGE_MAX && line.strip_edges() != "") { + if (stage == RD::SHADER_STAGE_MAX && !line.strip_edges().is_empty()) { line = line.strip_edges(); if (line.begins_with("//") || line.begins_with("/*")) { continue; //assuming comment (single line) @@ -98,7 +98,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String if (reading_versions) { String l = line.strip_edges(); - if (l != "") { + if (!l.is_empty()) { if (l.find("=") == -1) { base_error = "Missing `=` in '" + l + "'. Version syntax is `version = \"<defines with C escaping>\";`."; break; @@ -124,7 +124,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String version_texts[version] = define + "\n" + p_defines; } } else { - if (stage == RD::SHADER_STAGE_MAX && line.strip_edges() != "") { + if (stage == RD::SHADER_STAGE_MAX && !line.strip_edges().is_empty()) { base_error = "Text was found that does not belong to a valid section: " + line; break; } @@ -140,7 +140,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String } include = include.substr(1, include.length() - 2).strip_edges(); String include_text = p_include_func(include, p_include_func_userdata); - if (include_text != String()) { + if (!include_text.is_empty()) { stage_code[stage] += "\n" + include_text + "\n"; } else { base_error = "#include failed for file '" + include + "'"; @@ -158,7 +158,7 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String Ref<RDShaderFile> shader_file; shader_file.instantiate(); - if (base_error == "") { + if (base_error.is_empty()) { if (stage_found[RD::SHADER_STAGE_COMPUTE] && stages_found > 1) { ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "When writing compute shaders, [compute] mustbe the only stage present."); } @@ -177,14 +177,14 @@ Error RDShaderFile::parse_versions_from_text(const String &p_text, const String for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { String code = stage_code[i]; - if (code == String()) { + if (code.is_empty()) { continue; } code = code.replace("VERSION_DEFINES", E.value); String error; Vector<uint8_t> spirv = RenderingDevice::get_singleton()->shader_compile_spirv_from_source(RD::ShaderStage(i), code, RD::SHADER_LANGUAGE_GLSL, &error, false); bytecode->set_stage_bytecode(RD::ShaderStage(i), spirv); - if (error != "") { + if (!error.is_empty()) { error += String() + "\n\nStage '" + stage_str[i] + "' source code: \n\n"; Vector<String> sclines = code.split("\n"); for (int j = 0; j < sclines.size(); j++) { diff --git a/servers/rendering/rendering_device_binds.h b/servers/rendering/rendering_device_binds.h index 2cf7821668..651c9b0090 100644 --- a/servers/rendering/rendering_device_binds.h +++ b/servers/rendering/rendering_device_binds.h @@ -368,13 +368,13 @@ public: } void print_errors(const String &p_file) { - if (base_error != "") { + if (!base_error.is_empty()) { ERR_PRINT("Error parsing shader '" + p_file + "':\n\n" + base_error); } else { for (KeyValue<StringName, Ref<RDShaderSPIRV>> &E : versions) { for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) { String error = E.value->get_stage_compile_error(RD::ShaderStage(i)); - if (error != String()) { + if (!error.is_empty()) { static const char *stage_str[RD::SHADER_STAGE_MAX] = { "vertex", "fragment", diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 6acadc6882..ca911d995a 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -914,8 +914,10 @@ void ShaderLanguage::clear() { completion_type = COMPLETION_NONE; completion_block = nullptr; completion_function = StringName(); - completion_class = SubClassTag::TAG_GLOBAL; + completion_class = TAG_GLOBAL; completion_struct = StringName(); + completion_base = TYPE_VOID; + completion_base_array = false; unknown_varying_usages.clear(); @@ -2999,7 +3001,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI } FunctionNode *pfunc = shader->functions[i].function; - if (arg_list == "") { + if (arg_list.is_empty()) { for (int j = 0; j < pfunc->arguments.size(); j++) { if (j > 0) { arg_list += ", "; @@ -3235,6 +3237,10 @@ bool ShaderLanguage::is_token_operator_assign(TokenType p_type) { p_type == TK_OP_ASSIGN_BIT_XOR); } +bool ShaderLanguage::is_token_hint(TokenType p_type) { + return int(p_type) > int(TK_RENDER_MODE) && int(p_type) < int(TK_SHADER_TYPE); +} + bool ShaderLanguage::convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value) { if (p_constant->datatype == p_to_type) { if (p_value) { @@ -7236,7 +7242,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun if (tk.type == TK_SEMICOLON) { //all is good if (b->parent_function->return_type != TYPE_VOID) { - _set_error("Expected return with an expression of type '" + (return_struct_name != "" ? return_struct_name : get_datatype_name(b->parent_function->return_type)) + array_size_string + "'"); + _set_error("Expected return with an expression of type '" + (!return_struct_name.is_empty() ? return_struct_name : get_datatype_name(b->parent_function->return_type)) + array_size_string + "'"); return ERR_PARSE_ERROR; } } else { @@ -7248,7 +7254,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun } if (b->parent_function->return_type != expr->get_datatype() || b->parent_function->return_array_size != expr->get_array_size() || return_struct_name != expr->get_datatype_name()) { - _set_error("Expected return with an expression of type '" + (return_struct_name != "" ? return_struct_name : get_datatype_name(b->parent_function->return_type)) + array_size_string + "'"); + _set_error("Expected return with an expression of type '" + (!return_struct_name.is_empty() ? return_struct_name : get_datatype_name(b->parent_function->return_type)) + array_size_string + "'"); return ERR_PARSE_ERROR; } @@ -7370,7 +7376,7 @@ String ShaderLanguage::_get_shader_type_list(const Set<String> &p_shader_types) // Return a list of shader types as an human-readable string String valid_types; for (const Set<String>::Element *E = p_shader_types.front(); E; E = E->next()) { - if (valid_types != String()) { + if (!valid_types.is_empty()) { valid_types += ", "; } @@ -7829,9 +7835,19 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct int custom_instance_index = -1; if (tk.type == TK_COLON) { + completion_type = COMPLETION_HINT; + completion_base = type; + completion_base_array = uniform2.array_size > 0; + //hint do { tk = _get_token(); + completion_line = tk.line; + + if (!is_token_hint(tk.type)) { + _set_error("Expected valid type hint after ':'."); + return ERR_PARSE_ERROR; + } if (uniform2.array_size > 0) { if (tk.type != TK_HINT_COLOR) { @@ -8001,8 +8017,6 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct uniform2.repeat = REPEAT_DISABLE; } else if (tk.type == TK_REPEAT_ENABLE) { uniform2.repeat = REPEAT_ENABLE; - } else { - _set_error("Expected valid type hint after ':'."); } if (uniform2.hint != ShaderNode::Uniform::HINT_RANGE && uniform2.hint != ShaderNode::Uniform::HINT_NONE && uniform2.hint != ShaderNode::Uniform::HINT_COLOR && type <= TYPE_MAT4) { @@ -8069,6 +8083,8 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct _set_error("Expected ';'"); return ERR_PARSE_ERROR; } + + completion_type = COMPLETION_NONE; } else { // varying ShaderNode::Varying varying; varying.type = type; @@ -8933,7 +8949,7 @@ String ShaderLanguage::get_shader_type(const String &p_code) { break; } else if (p_code[i] <= 32) { - if (cur_identifier != String()) { + if (!cur_identifier.is_empty()) { if (!reading_type) { if (cur_identifier != "shader_type") { return String(); @@ -9426,6 +9442,57 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ } } break; + case COMPLETION_HINT: { + if (completion_base == DataType::TYPE_VEC4) { + ScriptCodeCompletionOption option("hint_color", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + r_options->push_back(option); + } else if ((completion_base == DataType::TYPE_INT || completion_base == DataType::TYPE_FLOAT) && !completion_base_array) { + ScriptCodeCompletionOption option("hint_range", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + + if (completion_base == DataType::TYPE_INT) { + option.insert_text = "hint_range(0, 100, 1)"; + } else { + option.insert_text = "hint_range(0.0, 1.0, 0.1)"; + } + + r_options->push_back(option); + } else if ((int(completion_base) > int(TYPE_MAT4) && int(completion_base) < int(TYPE_STRUCT)) && !completion_base_array) { + static Vector<String> options; + + if (options.is_empty()) { + options.push_back("filter_linear"); + options.push_back("filter_linear_mipmap"); + options.push_back("filter_linear_mipmap_aniso"); + options.push_back("filter_nearest"); + options.push_back("filter_nearest_mipmap"); + options.push_back("filter_nearest_mipmap_aniso"); + options.push_back("hint_albedo"); + options.push_back("hint_aniso"); + options.push_back("hint_black"); + options.push_back("hint_black_albedo"); + options.push_back("hint_normal"); + options.push_back("hint_roughness_a"); + options.push_back("hint_roughness_b"); + options.push_back("hint_roughness_g"); + options.push_back("hint_roughness_gray"); + options.push_back("hint_roughness_normal"); + options.push_back("hint_roughness_r"); + options.push_back("hint_white"); + options.push_back("repeat_enable"); + options.push_back("repeat_disable"); + } + + for (int i = 0; i < options.size(); i++) { + ScriptCodeCompletionOption option(options[i], ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + r_options->push_back(option); + } + } + if (!completion_base_array) { + ScriptCodeCompletionOption option("instance_index", ScriptCodeCompletionOption::KIND_PLAIN_TEXT); + option.insert_text = "instance_index(0)"; + r_options->push_back(option); + } + } break; } return ERR_PARSE_ERROR; diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index ed218975cd..9c456d56ba 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -748,6 +748,7 @@ public: COMPLETION_CALL_ARGUMENTS, COMPLETION_INDEX, COMPLETION_STRUCT, + COMPLETION_HINT, }; struct Token { @@ -772,6 +773,7 @@ public: static bool is_token_nonvoid_datatype(TokenType p_type); static bool is_token_operator(TokenType p_type); static bool is_token_operator_assign(TokenType p_type); + static bool is_token_hint(TokenType p_type); static bool convert_constant(ConstantNode *p_constant, DataType p_to_type, ConstantNode::Value *p_value = nullptr); static DataType get_scalar_type(DataType p_type); @@ -966,10 +968,12 @@ private: int completion_line; BlockNode *completion_block; DataType completion_base; + bool completion_base_array; SubClassTag completion_class; StringName completion_function; StringName completion_struct; int completion_argument; + const Map<StringName, FunctionInfo> *stages = nullptr; bool _get_completable_identifier(BlockNode *p_block, CompletionType p_type, StringName &identifier); diff --git a/servers/text_server.cpp b/servers/text_server.cpp index edc6e66042..2303f27495 100644 --- a/servers/text_server.cpp +++ b/servers/text_server.cpp @@ -649,13 +649,13 @@ PackedInt32Array TextServer::shaped_text_get_line_breaks_adv(RID p_shaped, const return lines; } -PackedInt32Array TextServer::shaped_text_get_line_breaks(RID p_shaped, real_t p_width, int p_start, uint16_t /*TextBreakFlag*/ p_break_flags) const { +PackedInt32Array TextServer::shaped_text_get_line_breaks(RID p_shaped, float p_width, int p_start, uint16_t /*TextBreakFlag*/ p_break_flags) const { PackedInt32Array lines; const_cast<TextServer *>(this)->shaped_text_update_breaks(p_shaped); const Vector2i &range = shaped_text_get_range(p_shaped); - real_t width = 0.f; + float width = 0.f; int line_start = MAX(p_start, range.x); int last_safe_break = -1; int word_count = 0; @@ -1035,9 +1035,9 @@ Vector<Vector2> TextServer::shaped_text_get_selection(RID p_shaped, int p_start, return ranges; } -int TextServer::shaped_text_hit_test_grapheme(RID p_shaped, real_t p_coords) const { +int TextServer::shaped_text_hit_test_grapheme(RID p_shaped, float p_coords) const { // Exact grapheme hit test, return -1 if missed. - real_t off = 0.0f; + float off = 0.0f; int v_size = shaped_text_get_glyph_count(p_shaped); const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); @@ -1053,7 +1053,7 @@ int TextServer::shaped_text_hit_test_grapheme(RID p_shaped, real_t p_coords) con return -1; } -int TextServer::shaped_text_hit_test_position(RID p_shaped, real_t p_coords) const { +int TextServer::shaped_text_hit_test_position(RID p_shaped, float p_coords) const { int v_size = shaped_text_get_glyph_count(p_shaped); const Glyph *glyphs = shaped_text_get_glyphs(p_shaped); @@ -1165,7 +1165,7 @@ int TextServer::shaped_text_prev_grapheme_pos(RID p_shaped, int p_pos) const { return p_pos; } -void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, real_t p_clip_l, real_t p_clip_r, const Color &p_color) const { +void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, const Color &p_color) const { TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped); bool hex_codes = shaped_text_get_preserve_control(p_shaped) || shaped_text_get_preserve_invalid(p_shaped); @@ -1262,7 +1262,7 @@ void TextServer::shaped_text_draw(RID p_shaped, RID p_canvas, const Vector2 &p_p } } -void TextServer::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, real_t p_clip_l, real_t p_clip_r, int p_outline_size, const Color &p_color) const { +void TextServer::shaped_text_draw_outline(RID p_shaped, RID p_canvas, const Vector2 &p_pos, float p_clip_l, float p_clip_r, int p_outline_size, const Color &p_color) const { TextServer::Orientation orientation = shaped_text_get_orientation(p_shaped); bool rtl = (shaped_text_get_direction(p_shaped) == DIRECTION_RTL); |