Merge pull request #60386 from bruvzg/label3d
This commit is contained in:
commit
63a052d96b
59 changed files with 2270 additions and 251 deletions
|
@ -63,6 +63,9 @@
|
|||
<member name="albedo_tex_force_srgb" type="bool" setter="set_flag" getter="get_flag" default="false">
|
||||
Forces a conversion of the [member albedo_texture] from sRGB space to linear space.
|
||||
</member>
|
||||
<member name="albedo_tex_msdf" type="bool" setter="set_flag" getter="get_flag" default="false">
|
||||
Enables multichannel signed distance field rendering shader. Use [member msdf_pixel_range] and [member msdf_outline_size] to configure MSDF paramenters.
|
||||
</member>
|
||||
<member name="albedo_texture" type="Texture2D" setter="set_texture" getter="get_texture">
|
||||
Texture to multiply by [member albedo_color]. Used for basic texturing of objects.
|
||||
</member>
|
||||
|
@ -243,6 +246,12 @@
|
|||
<member name="metallic_texture_channel" type="int" setter="set_metallic_texture_channel" getter="get_metallic_texture_channel" enum="BaseMaterial3D.TextureChannel" default="0">
|
||||
Specifies the channel of the [member metallic_texture] in which the metallic information is stored. This is useful when you store the information for multiple effects in a single texture. For example if you stored metallic in the red channel, roughness in the blue, and ambient occlusion in the green you could reduce the number of textures you use.
|
||||
</member>
|
||||
<member name="msdf_outline_size" type="float" setter="set_msdf_outline_size" getter="get_msdf_outline_size" default="0.0">
|
||||
The width of the shape outine.
|
||||
</member>
|
||||
<member name="msdf_pixel_range" type="float" setter="set_msdf_pixel_range" getter="get_msdf_pixel_range" default="4.0">
|
||||
The width of the range around the shape between the minimum and maximum representable signed distance.
|
||||
</member>
|
||||
<member name="no_depth_test" type="bool" setter="set_flag" getter="get_flag" default="false">
|
||||
If [code]true[/code], depth testing is disabled and the object will be drawn in render order.
|
||||
</member>
|
||||
|
@ -647,7 +656,10 @@
|
|||
</constant>
|
||||
<constant name="FLAG_PARTICLE_TRAILS_MODE" value="19" enum="Flags">
|
||||
</constant>
|
||||
<constant name="FLAG_MAX" value="20" enum="Flags">
|
||||
<constant name="FLAG_ALBEDO_TEXTURE_MSDF" value="20" enum="Flags">
|
||||
Enables multichannel signed distance field rendering shader.
|
||||
</constant>
|
||||
<constant name="FLAG_MAX" value="21" enum="Flags">
|
||||
Represents the size of the [enum Flags] enum.
|
||||
</constant>
|
||||
<constant name="DIFFUSE_BURLEY" value="0" enum="DiffuseMode">
|
||||
|
|
|
@ -1358,27 +1358,5 @@
|
|||
<constant name="TEXT_DIRECTION_RTL" value="2" enum="TextDirection">
|
||||
Right-to-left text writing direction.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_DEFAULT" value="0" enum="StructuredTextParser">
|
||||
Use default behavior. Same as [code]STRUCTURED_TEXT_NONE[/code] unless specified otherwise in the control description.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_URI" value="1" enum="StructuredTextParser">
|
||||
BiDi override for URI.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_FILE" value="2" enum="StructuredTextParser">
|
||||
BiDi override for file path.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_EMAIL" value="3" enum="StructuredTextParser">
|
||||
BiDi override for email.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_LIST" value="4" enum="StructuredTextParser">
|
||||
BiDi override for lists.
|
||||
Structured text options: list separator [code]String[/code].
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_NONE" value="5" enum="StructuredTextParser">
|
||||
Use default Unicode BiDi algorithm.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_CUSTOM" value="6" enum="StructuredTextParser">
|
||||
User defined structured text BiDi override function.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
||||
|
|
|
@ -582,6 +582,9 @@
|
|||
<member name="force_autohinter" type="bool" setter="set_force_autohinter" getter="is_force_autohinter" default="false">
|
||||
If set to [code]true[/code], auto-hinting is supported and preferred over font built-in hinting. Used by dynamic fonts only.
|
||||
</member>
|
||||
<member name="generate_mipmaps" type="bool" setter="set_generate_mipmaps" getter="get_generate_mipmaps" default="false">
|
||||
If set to [code]true[/code], generate mipmaps for the font textures.
|
||||
</member>
|
||||
<member name="hinting" type="int" setter="set_hinting" getter="get_hinting" enum="TextServer.Hinting" default="1">
|
||||
Font hinting mode. Used by dynamic fonts only.
|
||||
</member>
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
[b]Note:[/b] Setting this property updates [member visible_characters] based on current [method get_total_character_count].
|
||||
</member>
|
||||
<member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" overrides="Control" default="4" />
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="TextServer.StructuredTextParser" default="0">
|
||||
Set BiDi algorithm override for the structured text.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
|
||||
|
|
173
doc/classes/Label3D.xml
Normal file
173
doc/classes/Label3D.xml
Normal file
|
@ -0,0 +1,173 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="Label3D" inherits="GeometryInstance3D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
||||
<brief_description>
|
||||
Displays plain text in a 3D world.
|
||||
</brief_description>
|
||||
<description>
|
||||
Label3D displays plain text in a 3D world. It gives you control over the horizontal and vertical alignment.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="clear_opentype_features">
|
||||
<return type="void" />
|
||||
<description>
|
||||
Removes all OpenType features.
|
||||
</description>
|
||||
</method>
|
||||
<method name="generate_triangle_mesh" qualifiers="const">
|
||||
<return type="TriangleMesh" />
|
||||
<description>
|
||||
Returns a [TriangleMesh] with the label's vertices following its current configuration (such as its [member pixel_size]).
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_draw_flag" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="flag" type="int" enum="Label3D.DrawFlags" />
|
||||
<description>
|
||||
Returns the value of the specified flag.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_opentype_feature" qualifiers="const">
|
||||
<return type="int" />
|
||||
<argument index="0" name="tag" type="String" />
|
||||
<description>
|
||||
Returns OpenType feature [code]tag[/code].
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_draw_flag">
|
||||
<return type="void" />
|
||||
<argument index="0" name="flag" type="int" enum="Label3D.DrawFlags" />
|
||||
<argument index="1" name="enabled" type="bool" />
|
||||
<description>
|
||||
If [code]true[/code], the specified flag will be enabled. See [enum Label3D.DrawFlags] for a list of flags.
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_opentype_feature">
|
||||
<return type="void" />
|
||||
<argument index="0" name="tag" type="String" />
|
||||
<argument index="1" name="value" type="int" />
|
||||
<description>
|
||||
Returns OpenType feature [code]tag[/code]. More info: [url=https://docs.microsoft.com/en-us/typography/opentype/spec/featuretags]OpenType feature tags[/url].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="alpha_cut" type="int" setter="set_alpha_cut_mode" getter="get_alpha_cut_mode" enum="Label3D.AlphaCutMode" default="0">
|
||||
The alpha cutting mode to use for the sprite. See [enum AlphaCutMode] for possible values.
|
||||
</member>
|
||||
<member name="alpha_scissor_threshold" type="float" setter="set_alpha_scissor_threshold" getter="get_alpha_scissor_threshold" default="0.5">
|
||||
Threshold at which the alpha scissor will discard values.
|
||||
</member>
|
||||
<member name="autowrap_mode" type="int" setter="set_autowrap_mode" getter="get_autowrap_mode" enum="Label3D.AutowrapMode" default="0">
|
||||
If set to something other than [constant AUTOWRAP_OFF], the text gets wrapped inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text. To see how each mode behaves, see [enum AutowrapMode].
|
||||
</member>
|
||||
<member name="billboard" type="int" setter="set_billboard_mode" getter="get_billboard_mode" enum="BaseMaterial3D.BillboardMode" default="0">
|
||||
The billboard mode to use for the label. See [enum BaseMaterial3D.BillboardMode] for possible values.
|
||||
</member>
|
||||
<member name="double_sided" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="true">
|
||||
If [code]true[/code], text can be seen from the back as well, if [code]false[/code], it is invisible when looking at it from behind.
|
||||
</member>
|
||||
<member name="fixed_size" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="false">
|
||||
If [code]true[/code], the label is rendered at the same size regardless of distance.
|
||||
</member>
|
||||
<member name="font" type="Font" setter="set_font" getter="get_font">
|
||||
[Font] used for the [Label3D]'s text.
|
||||
</member>
|
||||
<member name="font_size" type="int" setter="set_font_size" getter="get_font_size" default="16">
|
||||
Font size of the [Label3D]'s text.
|
||||
</member>
|
||||
<member name="horizontal_alignment" type="int" setter="set_horizontal_alignment" getter="get_horizontal_alignment" enum="HorizontalAlignment" default="1">
|
||||
Controls the text's horizontal alignment. Supports left, center, right. Set it to one of the [enum HorizontalAlignment] constants.
|
||||
</member>
|
||||
<member name="language" type="String" setter="set_language" getter="get_language" default="""">
|
||||
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
|
||||
</member>
|
||||
<member name="line_spacing" type="float" setter="set_line_spacing" getter="get_line_spacing" default="0.0">
|
||||
Vertical space between lines in multiline [Label3D].
|
||||
</member>
|
||||
<member name="modulate" type="Color" setter="set_modulate" getter="get_modulate" default="Color(1, 1, 1, 1)">
|
||||
Text [Color] of the [Label3D].
|
||||
</member>
|
||||
<member name="no_depth_test" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="false">
|
||||
If [code]true[/code], depth testing is disabled and the object will be drawn in render order.
|
||||
</member>
|
||||
<member name="outline_modulate" type="Color" setter="set_outline_modulate" getter="get_outline_modulate" default="Color(0, 0, 0, 1)">
|
||||
The tint of [Font]'s outline.
|
||||
</member>
|
||||
<member name="outline_size" type="int" setter="set_outline_size" getter="get_outline_size" default="0">
|
||||
Text outline size.
|
||||
</member>
|
||||
<member name="pixel_size" type="float" setter="set_pixel_size" getter="get_pixel_size" default="0.01">
|
||||
The size of one pixel's width on the label to scale it in 3D.
|
||||
</member>
|
||||
<member name="shaded" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="false">
|
||||
If [code]true[/code], the [Light3D] in the [Environment] has effects on the label.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="TextServer.StructuredTextParser" default="0">
|
||||
Set BiDi algorithm override for the structured text.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
|
||||
Set additional options for BiDi override.
|
||||
</member>
|
||||
<member name="text" type="String" setter="set_text" getter="get_text" default="""">
|
||||
The text to display on screen.
|
||||
</member>
|
||||
<member name="text_direction" type="int" setter="set_text_direction" getter="get_text_direction" enum="TextServer.Direction" default="0">
|
||||
Base text writing direction.
|
||||
</member>
|
||||
<member name="texture_filter" type="int" setter="set_texture_filter" getter="get_texture_filter" enum="BaseMaterial3D.TextureFilter" default="3">
|
||||
Filter flags for the texture. See [enum BaseMaterial3D.TextureFilter] for options.
|
||||
</member>
|
||||
<member name="uppercase" type="bool" setter="set_uppercase" getter="is_uppercase" default="false">
|
||||
If [code]true[/code], all the text displays as UPPERCASE.
|
||||
</member>
|
||||
<member name="vertical_alignment" type="int" setter="set_vertical_alignment" getter="get_vertical_alignment" enum="VerticalAlignment" default="1">
|
||||
Controls the text's vertical alignment. Supports top, center, bottom. Set it to one of the [enum VerticalAlignment] constants.
|
||||
</member>
|
||||
<member name="width" type="float" setter="set_width" getter="get_width" default="500.0">
|
||||
Text width (in pixels), used for autowrap and fill alignment.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="AUTOWRAP_OFF" value="0" enum="AutowrapMode">
|
||||
Autowrap is disabled.
|
||||
</constant>
|
||||
<constant name="AUTOWRAP_ARBITRARY" value="1" enum="AutowrapMode">
|
||||
Wraps the text inside the node's bounding rectangle by allowing to break lines at arbitrary positions, which is useful when very limited space is available.
|
||||
</constant>
|
||||
<constant name="AUTOWRAP_WORD" value="2" enum="AutowrapMode">
|
||||
Wraps the text inside the node's bounding rectangle by soft-breaking between words.
|
||||
</constant>
|
||||
<constant name="AUTOWRAP_WORD_SMART" value="3" enum="AutowrapMode">
|
||||
Behaves similarly to [constant AUTOWRAP_WORD], but force-breaks a word if that single word does not fit in one line.
|
||||
</constant>
|
||||
<constant name="FLAG_SHADED" value="0" enum="DrawFlags">
|
||||
If set, lights in the environment affect the label.
|
||||
</constant>
|
||||
<constant name="FLAG_DOUBLE_SIDED" value="1" enum="DrawFlags">
|
||||
If set, text can be seen from the back as well. If not, the texture is invisible when looking at it from behind.
|
||||
</constant>
|
||||
<constant name="FLAG_DISABLE_DEPTH_TEST" value="2" enum="DrawFlags">
|
||||
Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it.
|
||||
</constant>
|
||||
<constant name="FLAG_FIXED_SIZE" value="3" enum="DrawFlags">
|
||||
Label is scaled by depth so that it always appears the same size on screen.
|
||||
</constant>
|
||||
<constant name="FLAG_MAX" value="4" enum="DrawFlags">
|
||||
Represents the size of the [enum DrawFlags] enum.
|
||||
</constant>
|
||||
<constant name="ALPHA_CUT_DISABLED" value="0" enum="AlphaCutMode">
|
||||
This mode performs standard alpha blending. It can display translucent areas, but transparency sorting issues may be visible when multiple transparent materials are overlapping.
|
||||
</constant>
|
||||
<constant name="ALPHA_CUT_DISCARD" value="1" enum="AlphaCutMode">
|
||||
This mode only allows fully transparent or fully opaque pixels. Harsh edges will be visible unless some form of screen-space antialiasing is enabled (see [member ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa]). This mode is also known as [i]alpha testing[/i] or [i]1-bit transparency[/i].
|
||||
[b]Note:[/b] This mode might have issues with anti-aliased fonts and outlines, try adjusting [member alpha_scissor_threshold] or using MSDF font.
|
||||
[b]Note:[/b] When using text with overlapping glyphs (e.g., cursive scripts), this mode might have transparency sorting issues between the main text and the outline.
|
||||
</constant>
|
||||
<constant name="ALPHA_CUT_OPAQUE_PREPASS" value="2" enum="AlphaCutMode">
|
||||
This mode draws fully opaque pixels in the depth prepass. This is slower than [constant ALPHA_CUT_DISABLED] or [constant ALPHA_CUT_DISCARD], but it allows displaying translucent areas and smooth edges while using proper sorting.
|
||||
[b]Note:[/b] When using text with overlapping glyphs (e.g., cursive scripts), this mode might have transparency sorting issues between the main text and the outline.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
|
@ -251,7 +251,7 @@
|
|||
<member name="shortcut_keys_enabled" type="bool" setter="set_shortcut_keys_enabled" getter="is_shortcut_keys_enabled" default="true">
|
||||
If [code]false[/code], using shortcuts will be disabled.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="TextServer.StructuredTextParser" default="0">
|
||||
Set BiDi algorithm override for the structured text.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<member name="language" type="String" setter="set_language" getter="get_language" default="""">
|
||||
Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="TextServer.StructuredTextParser" default="0">
|
||||
Set BiDi algorithm override for the structured text.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
|
||||
|
|
|
@ -342,7 +342,7 @@
|
|||
<argument index="0" name="alignment" type="int" enum="HorizontalAlignment" />
|
||||
<argument index="1" name="base_direction" type="int" enum="Control.TextDirection" default="0" />
|
||||
<argument index="2" name="language" type="String" default="""" />
|
||||
<argument index="3" name="st_parser" type="int" enum="Control.StructuredTextParser" default="0" />
|
||||
<argument index="3" name="st_parser" type="int" enum="TextServer.StructuredTextParser" default="0" />
|
||||
<description>
|
||||
Adds a [code][p][/code] tag to the tag stack.
|
||||
</description>
|
||||
|
@ -488,7 +488,7 @@
|
|||
<member name="shortcut_keys_enabled" type="bool" setter="set_shortcut_keys_enabled" getter="is_shortcut_keys_enabled" default="true">
|
||||
If [code]true[/code], shortcut keys for context menu items are enabled, even if the context menu is disabled.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="TextServer.StructuredTextParser" default="0">
|
||||
Set BiDi algorithm override for the structured text.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
|
||||
|
|
|
@ -53,6 +53,9 @@
|
|||
<member name="double_sided" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="true">
|
||||
If [code]true[/code], texture can be seen from the back as well, if [code]false[/code], it is invisible when looking at it from behind.
|
||||
</member>
|
||||
<member name="fixed_size" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="false">
|
||||
If [code]true[/code], the label is rendered at the same size regardless of distance.
|
||||
</member>
|
||||
<member name="flip_h" type="bool" setter="set_flip_h" getter="is_flipped_h" default="false">
|
||||
If [code]true[/code], texture is flipped horizontally.
|
||||
</member>
|
||||
|
@ -63,6 +66,9 @@
|
|||
A color value used to [i]multiply[/i] the texture's colors. Can be used for mood-coloring or to simulate the color of light.
|
||||
[b]Note:[/b] If a [member GeometryInstance3D.material_override] is defined on the [SpriteBase3D], the material override must be configured to take vertex colors into account for albedo. Otherwise, the color defined in [member modulate] will be ignored. For a [BaseMaterial3D], [member BaseMaterial3D.vertex_color_use_as_albedo] must be [code]true[/code]. For a [ShaderMaterial], [code]ALBEDO *= COLOR.rgb;[/code] must be inserted in the shader's [code]fragment()[/code] function.
|
||||
</member>
|
||||
<member name="no_depth_test" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="false">
|
||||
If [code]true[/code], depth testing is disabled and the object will be drawn in render order.
|
||||
</member>
|
||||
<member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2(0, 0)">
|
||||
The texture's drawing offset.
|
||||
</member>
|
||||
|
@ -72,6 +78,9 @@
|
|||
<member name="shaded" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="false">
|
||||
If [code]true[/code], the [Light3D] in the [Environment] has effects on the sprite.
|
||||
</member>
|
||||
<member name="texture_filter" type="int" setter="set_texture_filter" getter="get_texture_filter" enum="BaseMaterial3D.TextureFilter" default="3">
|
||||
Filter flags for the texture. See [enum BaseMaterial3D.TextureFilter] for options.
|
||||
</member>
|
||||
<member name="transparent" type="bool" setter="set_draw_flag" getter="get_draw_flag" default="true">
|
||||
If [code]true[/code], the texture's transparency and the opacity are used to make those parts of the sprite invisible.
|
||||
</member>
|
||||
|
@ -86,7 +95,13 @@
|
|||
<constant name="FLAG_DOUBLE_SIDED" value="2" enum="DrawFlags">
|
||||
If set, texture can be seen from the back as well. If not, the texture is invisible when looking at it from behind.
|
||||
</constant>
|
||||
<constant name="FLAG_MAX" value="3" enum="DrawFlags">
|
||||
<constant name="FLAG_DISABLE_DEPTH_TEST" value="3" enum="DrawFlags">
|
||||
Disables the depth test, so this object is drawn on top of all others. However, objects drawn after it in the draw order may cover it.
|
||||
</constant>
|
||||
<constant name="FLAG_FIXED_SIZE" value="4" enum="DrawFlags">
|
||||
Label is scaled by depth so that it always appears the same size on screen.
|
||||
</constant>
|
||||
<constant name="FLAG_MAX" value="5" enum="DrawFlags">
|
||||
Represents the size of the [enum DrawFlags] enum.
|
||||
</constant>
|
||||
<constant name="ALPHA_CUT_DISABLED" value="0" enum="AlphaCutMode">
|
||||
|
|
|
@ -1017,7 +1017,7 @@
|
|||
<member name="shortcut_keys_enabled" type="bool" setter="set_shortcut_keys_enabled" getter="is_shortcut_keys_enabled" default="true">
|
||||
If [code]true[/code], shortcut keys for context menu items are enabled, even if the context menu is disabled.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="Control.StructuredTextParser" default="0">
|
||||
<member name="structured_text_bidi_override" type="int" setter="set_structured_text_bidi_override" getter="get_structured_text_bidi_override" enum="TextServer.StructuredTextParser" default="0">
|
||||
Set BiDi algorithm override for the structured text.
|
||||
</member>
|
||||
<member name="structured_text_bidi_override_options" type="Array" setter="set_structured_text_bidi_override_options" getter="get_structured_text_bidi_override_options" default="[]">
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
<description>
|
||||
Draws single glyph into a canvas item at the position, using [code]font_rid[/code] at the size [code]size[/code].
|
||||
[b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index].
|
||||
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_draw_glyph_outline" qualifiers="const">
|
||||
|
@ -94,6 +95,7 @@
|
|||
<description>
|
||||
Draws single glyph outline of size [code]outline_size[/code] into a canvas item at the position, using [code]font_rid[/code] at the size [code]size[/code].
|
||||
[b]Note:[/b] Glyph index is specific to the font, use glyphs indices returned by [method shaped_text_get_glyphs] or [method font_get_glyph_index].
|
||||
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_ascent" qualifiers="const">
|
||||
|
@ -126,6 +128,13 @@
|
|||
Returns bitmap font fixed size.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_generate_mipmaps" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<description>
|
||||
Returns [code]true[/code] if font texture mipmap generation is enabled.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_global_oversampling" qualifiers="const">
|
||||
<return type="float" />
|
||||
<description>
|
||||
|
@ -199,6 +208,26 @@
|
|||
Returns index of the cache texture containing the glyph.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_glyph_texture_rid" qualifiers="const">
|
||||
<return type="RID" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="size" type="Vector2i" />
|
||||
<argument index="2" name="glyph" type="int" />
|
||||
<description>
|
||||
Returns resource id of the cache texture containing the glyph.
|
||||
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_glyph_texture_size" qualifiers="const">
|
||||
<return type="Vector2" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="size" type="Vector2i" />
|
||||
<argument index="2" name="glyph" type="int" />
|
||||
<description>
|
||||
Returns size of the cache texture containing the glyph.
|
||||
[b]Note:[/b] If there are pending glyphs to render, calling this function might trigger the texture cache update.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_glyph_uv_rect" qualifiers="const">
|
||||
<return type="Rect2" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
|
@ -580,6 +609,14 @@
|
|||
If set to [code]true[/code] auto-hinting is preferred over font built-in hinting.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_set_generate_mipmaps">
|
||||
<return type="void" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="generate_mipmaps" type="bool" />
|
||||
<description>
|
||||
If set to [code]true[/code] font texture mipmap generation is enabled.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_set_global_oversampling">
|
||||
<return type="void" />
|
||||
<argument index="0" name="oversampling" type="float" />
|
||||
|
@ -927,6 +964,15 @@
|
|||
Converts a number from the numeral systems used in [code]language[/code] to Western Arabic (0..9).
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_structured_text" qualifiers="const">
|
||||
<return type="Array" />
|
||||
<argument index="0" name="parser_type" type="int" enum="TextServer.StructuredTextParser" />
|
||||
<argument index="1" name="args" type="Array" />
|
||||
<argument index="2" name="text" type="String" />
|
||||
<description>
|
||||
Default implementation of the BiDi algorithm override function. See [enum StructuredTextParser] for more info.
|
||||
</description>
|
||||
</method>
|
||||
<method name="percent_sign" qualifiers="const">
|
||||
<return type="String" />
|
||||
<argument index="0" name="language" type="String" default="""" />
|
||||
|
@ -1630,5 +1676,27 @@
|
|||
<constant name="FONT_FIXED_WIDTH" value="4" enum="FontStyle">
|
||||
Font have fixed-width characters.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_DEFAULT" value="0" enum="StructuredTextParser">
|
||||
Use default behavior. Same as [code]STRUCTURED_TEXT_NONE[/code] unless specified otherwise in the control description.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_URI" value="1" enum="StructuredTextParser">
|
||||
BiDi override for URI.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_FILE" value="2" enum="StructuredTextParser">
|
||||
BiDi override for file path.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_EMAIL" value="3" enum="StructuredTextParser">
|
||||
BiDi override for email.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_LIST" value="4" enum="StructuredTextParser">
|
||||
BiDi override for lists.
|
||||
Structured text options: list separator [code]String[/code].
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_NONE" value="5" enum="StructuredTextParser">
|
||||
Use default Unicode BiDi algorithm.
|
||||
</constant>
|
||||
<constant name="STRUCTURED_TEXT_CUSTOM" value="6" enum="StructuredTextParser">
|
||||
User defined structured text BiDi override function.
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
||||
|
|
|
@ -121,6 +121,13 @@
|
|||
Returns bitmap font fixed size.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_generate_mipmaps" qualifiers="virtual const">
|
||||
<return type="bool" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<description>
|
||||
Returns [code]true[/code] if font texture mipmap generation is enabled.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_global_oversampling" qualifiers="virtual const">
|
||||
<return type="float" />
|
||||
<description>
|
||||
|
@ -193,6 +200,24 @@
|
|||
Returns index of the cache texture containing the glyph.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_glyph_texture_rid" qualifiers="virtual const">
|
||||
<return type="RID" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="size" type="Vector2i" />
|
||||
<argument index="2" name="glyph" type="int" />
|
||||
<description>
|
||||
Returns resource id of the cache texture containing the glyph.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_glyph_texture_size" qualifiers="virtual const">
|
||||
<return type="Vector2" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="size" type="Vector2i" />
|
||||
<argument index="2" name="glyph" type="int" />
|
||||
<description>
|
||||
Returns size of the cache texture containing the glyph.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_get_glyph_uv_rect" qualifiers="virtual const">
|
||||
<return type="Rect2" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
|
@ -581,6 +606,14 @@
|
|||
If set to [code]true[/code] auto-hinting is preferred over font built-in hinting.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_set_generate_mipmaps" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="font_rid" type="RID" />
|
||||
<argument index="1" name="generate_mipmaps" type="bool" />
|
||||
<description>
|
||||
If set to [code]true[/code] font texture mipmap generation is enabled.
|
||||
</description>
|
||||
</method>
|
||||
<method name="font_set_global_oversampling" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="oversampling" type="float" />
|
||||
|
@ -927,6 +960,14 @@
|
|||
Converts a number from the numeral systems used in [code]language[/code] to Western Arabic (0..9).
|
||||
</description>
|
||||
</method>
|
||||
<method name="parse_structured_text" qualifiers="virtual const">
|
||||
<return type="Array" />
|
||||
<argument index="0" name="parser_type" type="int" enum="TextServer.StructuredTextParser" />
|
||||
<argument index="1" name="args" type="Array" />
|
||||
<argument index="2" name="text" type="String" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="percent_sign" qualifiers="virtual const">
|
||||
<return type="String" />
|
||||
<argument index="0" name="language" type="String" />
|
||||
|
|
|
@ -284,7 +284,7 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="get_structured_text_bidi_override" qualifiers="const">
|
||||
<return type="int" enum="Control.StructuredTextParser" />
|
||||
<return type="int" enum="TextServer.StructuredTextParser" />
|
||||
<argument index="0" name="column" type="int" />
|
||||
<description>
|
||||
</description>
|
||||
|
@ -620,7 +620,7 @@
|
|||
<method name="set_structured_text_bidi_override">
|
||||
<return type="void" />
|
||||
<argument index="0" name="column" type="int" />
|
||||
<argument index="1" name="parser" type="int" enum="Control.StructuredTextParser" />
|
||||
<argument index="1" name="parser" type="int" enum="TextServer.StructuredTextParser" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
|
|
|
@ -478,10 +478,6 @@ float msdf_median(float r, float g, float b, float a) {
|
|||
return min(max(min(r, g), min(max(r, g), b)), a);
|
||||
}
|
||||
|
||||
vec2 msdf_map(vec2 value, vec2 in_min, vec2 in_max, vec2 out_min, vec2 out_max) {
|
||||
return out_min + (out_max - out_min) * (value - in_min) / (in_max - in_min);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color = color_interp;
|
||||
vec2 uv = uv_interp;
|
||||
|
|
|
@ -1631,7 +1631,7 @@ EditorFileDialog::EditorFileDialog() {
|
|||
pathhb->add_child(drives_container);
|
||||
|
||||
dir = memnew(LineEdit);
|
||||
dir->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
dir->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
pathhb->add_child(dir);
|
||||
dir->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
||||
|
@ -1782,7 +1782,7 @@ EditorFileDialog::EditorFileDialog() {
|
|||
file_box->add_child(l);
|
||||
|
||||
file = memnew(LineEdit);
|
||||
file->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
file->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
file->set_stretch_ratio(4);
|
||||
file->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
file_box->add_child(file);
|
||||
|
@ -1826,7 +1826,7 @@ EditorFileDialog::EditorFileDialog() {
|
|||
makedialog->add_child(makevb);
|
||||
|
||||
makedirname = memnew(LineEdit);
|
||||
makedirname->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
makedirname->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
makevb->add_margin_child(TTR("Name:"), makedirname);
|
||||
add_child(makedialog);
|
||||
makedialog->register_text_enter(makedirname);
|
||||
|
|
|
@ -485,7 +485,7 @@ EditorPropertyPath::EditorPropertyPath() {
|
|||
HBoxContainer *path_hb = memnew(HBoxContainer);
|
||||
add_child(path_hb);
|
||||
path = memnew(LineEdit);
|
||||
path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
path_hb->add_child(path);
|
||||
path->connect("text_submitted", callable_mp(this, &EditorPropertyPath::_path_selected));
|
||||
path->connect("focus_exited", callable_mp(this, &EditorPropertyPath::_path_focus_exited));
|
||||
|
|
|
@ -73,7 +73,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
|
|||
}
|
||||
|
||||
subdirectory_item->set_text(0, dname);
|
||||
subdirectory_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE);
|
||||
subdirectory_item->set_structured_text_bidi_override(0, TextServer::STRUCTURED_TEXT_FILE);
|
||||
subdirectory_item->set_icon(0, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")));
|
||||
subdirectory_item->set_icon_modulate(0, get_theme_color(SNAME("folder_icon_modulate"), SNAME("FileDialog")));
|
||||
subdirectory_item->set_selectable(0, true);
|
||||
|
@ -143,7 +143,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory
|
|||
for (const FileInfo &fi : file_list) {
|
||||
TreeItem *file_item = tree->create_item(subdirectory_item);
|
||||
file_item->set_text(0, fi.name);
|
||||
file_item->set_structured_text_bidi_override(0, STRUCTURED_TEXT_FILE);
|
||||
file_item->set_structured_text_bidi_override(0, TextServer::STRUCTURED_TEXT_FILE);
|
||||
file_item->set_icon(0, _get_tree_item_icon(!fi.import_broken, fi.type));
|
||||
String file_metadata = lpath.plus_file(fi.name);
|
||||
file_item->set_metadata(0, file_metadata);
|
||||
|
@ -3026,7 +3026,7 @@ FileSystemDock::FileSystemDock() {
|
|||
toolbar_hbc->add_child(button_hist_next);
|
||||
|
||||
current_path = memnew(LineEdit);
|
||||
current_path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
current_path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
current_path->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
_set_current_path_text(path);
|
||||
toolbar_hbc->add_child(current_path);
|
||||
|
|
1
editor/icons/Label3D.svg
Normal file
1
editor/icons/Label3D.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg stroke-miterlimit="10" style="fill-rule:nonzero;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round" viewBox="0 0 16 16" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:vectornator="http://vectornator.io"><path d="M6 3a1 1 0 0 0-.707.293l-4 4a1 1 0 0 0 0 1.414l4 4A1 1 0 0 0 6 13h8a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1H6ZM5 7a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z" fill="#fc7f7f" fill-rule="evenodd" vectornator:layerName="Untitled"/></svg>
|
After Width: | Height: | Size: 453 B |
|
@ -458,6 +458,10 @@ void DynamicFontImportSettings::_main_prop_changed(const String &p_edited_proper
|
|||
if (font_preview->get_data_count() > 0) {
|
||||
font_preview->get_data(0)->set_antialiased(import_settings_data->get("antialiased"));
|
||||
}
|
||||
} else if (p_edited_property == "generate_mipmaps") {
|
||||
if (font_preview->get_data_count() > 0) {
|
||||
font_preview->get_data(0)->set_generate_mipmaps(import_settings_data->get("generate_mipmaps"));
|
||||
}
|
||||
} else if (p_edited_property == "multichannel_signed_distance_field") {
|
||||
if (font_preview->get_data_count() > 0) {
|
||||
font_preview->get_data(0)->set_multichannel_signed_distance_field(import_settings_data->get("multichannel_signed_distance_field"));
|
||||
|
@ -926,6 +930,7 @@ void DynamicFontImportSettings::_re_import() {
|
|||
Map<StringName, Variant> main_settings;
|
||||
|
||||
main_settings["antialiased"] = import_settings_data->get("antialiased");
|
||||
main_settings["generate_mipmaps"] = import_settings_data->get("generate_mipmaps");
|
||||
main_settings["multichannel_signed_distance_field"] = import_settings_data->get("multichannel_signed_distance_field");
|
||||
main_settings["msdf_pixel_range"] = import_settings_data->get("msdf_pixel_range");
|
||||
main_settings["msdf_size"] = import_settings_data->get("msdf_size");
|
||||
|
@ -1340,6 +1345,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
|
|||
singleton = this;
|
||||
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "generate_mipmaps"), false));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8));
|
||||
options_general.push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48));
|
||||
|
|
|
@ -102,6 +102,7 @@ void ResourceImporterDynamicFont::get_import_options(const String &p_path, List<
|
|||
bool msdf = p_preset == PRESET_MSDF;
|
||||
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "antialiased"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "generate_mipmaps"), false));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "multichannel_signed_distance_field", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), (msdf) ? true : false));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), 8));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "msdf_size", PROPERTY_HINT_RANGE, "1,250,1"), 48));
|
||||
|
@ -179,6 +180,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str
|
|||
print_verbose("Importing dynamic font from: " + p_source_file);
|
||||
|
||||
bool antialiased = p_options["antialiased"];
|
||||
bool generate_mipmaps = p_options["generate_mipmaps"];
|
||||
bool msdf = p_options["multichannel_signed_distance_field"];
|
||||
int px_range = p_options["msdf_pixel_range"];
|
||||
int px_size = p_options["msdf_size"];
|
||||
|
@ -199,6 +201,7 @@ Error ResourceImporterDynamicFont::import(const String &p_source_file, const Str
|
|||
font.instantiate();
|
||||
font->set_data(data);
|
||||
font->set_antialiased(antialiased);
|
||||
font->set_generate_mipmaps(generate_mipmaps);
|
||||
font->set_multichannel_signed_distance_field(msdf);
|
||||
font->set_msdf_pixel_range(px_range);
|
||||
font->set_msdf_size(px_size);
|
||||
|
|
|
@ -96,6 +96,7 @@ Error ResourceImporterImageFont::import(const String &p_source_file, const Strin
|
|||
Ref<FontData> font;
|
||||
font.instantiate();
|
||||
font->set_antialiased(false);
|
||||
font->set_generate_mipmaps(false);
|
||||
font->set_multichannel_signed_distance_field(false);
|
||||
font->set_fixed_size(base_size);
|
||||
font->set_subpixel_positioning(TextServer::SUBPIXEL_POSITIONING_DISABLED);
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "scene/3d/gpu_particles_3d.h"
|
||||
#include "scene/3d/gpu_particles_collision_3d.h"
|
||||
#include "scene/3d/joint_3d.h"
|
||||
#include "scene/3d/label_3d.h"
|
||||
#include "scene/3d/light_3d.h"
|
||||
#include "scene/3d/lightmap_gi.h"
|
||||
#include "scene/3d/lightmap_probe.h"
|
||||
|
@ -2170,6 +2171,38 @@ void Sprite3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
|||
|
||||
///
|
||||
|
||||
Label3DGizmoPlugin::Label3DGizmoPlugin() {
|
||||
}
|
||||
|
||||
bool Label3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
|
||||
return Object::cast_to<Label3D>(p_spatial) != nullptr;
|
||||
}
|
||||
|
||||
String Label3DGizmoPlugin::get_gizmo_name() const {
|
||||
return "Label3D";
|
||||
}
|
||||
|
||||
int Label3DGizmoPlugin::get_priority() const {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool Label3DGizmoPlugin::can_be_hidden() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Label3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
|
||||
Label3D *label = Object::cast_to<Label3D>(p_gizmo->get_spatial_node());
|
||||
|
||||
p_gizmo->clear();
|
||||
|
||||
Ref<TriangleMesh> tm = label->generate_triangle_mesh();
|
||||
if (tm.is_valid()) {
|
||||
p_gizmo->add_collision_triangles(tm);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
Position3DGizmoPlugin::Position3DGizmoPlugin() {
|
||||
pos3d_mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
|
||||
cursor_points = Vector<Vector3>();
|
||||
|
|
|
@ -321,6 +321,19 @@ public:
|
|||
Sprite3DGizmoPlugin();
|
||||
};
|
||||
|
||||
class Label3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
GDCLASS(Label3DGizmoPlugin, EditorNode3DGizmoPlugin);
|
||||
|
||||
public:
|
||||
bool has_gizmo(Node3D *p_spatial) override;
|
||||
String get_gizmo_name() const override;
|
||||
int get_priority() const override;
|
||||
bool can_be_hidden() const override;
|
||||
void redraw(EditorNode3DGizmo *p_gizmo) override;
|
||||
|
||||
Label3DGizmoPlugin();
|
||||
};
|
||||
|
||||
class Position3DGizmoPlugin : public EditorNode3DGizmoPlugin {
|
||||
GDCLASS(Position3DGizmoPlugin, EditorNode3DGizmoPlugin);
|
||||
|
||||
|
|
|
@ -7278,6 +7278,7 @@ void Node3DEditor::_register_all_gizmos() {
|
|||
add_gizmo_plugin(Ref<OccluderInstance3DGizmoPlugin>(memnew(OccluderInstance3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<SoftDynamicBody3DGizmoPlugin>(memnew(SoftDynamicBody3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Sprite3DGizmoPlugin>(memnew(Sprite3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Label3DGizmoPlugin>(memnew(Label3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<Position3DGizmoPlugin>(memnew(Position3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<RayCast3DGizmoPlugin>(memnew(RayCast3DGizmoPlugin)));
|
||||
add_gizmo_plugin(Ref<SpringArm3DGizmoPlugin>(memnew(SpringArm3DGizmoPlugin)));
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "ot_features_plugin.h"
|
||||
|
||||
#include "scene/3d/label_3d.h"
|
||||
|
||||
void OpenTypeFeaturesEditor::_value_changed(double val) {
|
||||
if (setting) {
|
||||
return;
|
||||
|
@ -116,7 +118,25 @@ void OpenTypeFeaturesAdd::setup(Object *p_object) {
|
|||
bool have_ss = false;
|
||||
bool have_cv = false;
|
||||
bool have_cu = false;
|
||||
Dictionary features = Object::cast_to<Control>(edited_object)->get_theme_font(SNAME("font"))->get_feature_list();
|
||||
|
||||
Ref<Font> font;
|
||||
|
||||
Control *ctrl = Object::cast_to<Control>(edited_object);
|
||||
if (ctrl != nullptr) {
|
||||
font = ctrl->get_theme_font(SNAME("font"));
|
||||
} else {
|
||||
Label3D *l3d = Object::cast_to<Label3D>(edited_object);
|
||||
if (l3d != nullptr) {
|
||||
font = l3d->_get_font_or_default();
|
||||
}
|
||||
}
|
||||
|
||||
if (font.is_null()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary features = font->get_feature_list();
|
||||
|
||||
for (const Variant *ftr = features.next(nullptr); ftr != nullptr; ftr = features.next(ftr)) {
|
||||
String ftr_name = TS->tag_to_name(*ftr);
|
||||
if (ftr_name.begins_with("stylistic_set_")) {
|
||||
|
@ -185,7 +205,7 @@ OpenTypeFeaturesAdd::OpenTypeFeaturesAdd() {
|
|||
/*************************************************************************/
|
||||
|
||||
bool EditorInspectorPluginOpenTypeFeatures::can_handle(Object *p_object) {
|
||||
return (Object::cast_to<Control>(p_object) != nullptr);
|
||||
return (Object::cast_to<Control>(p_object) != nullptr) || (Object::cast_to<Label3D>(p_object) != nullptr);
|
||||
}
|
||||
|
||||
bool EditorInspectorPluginOpenTypeFeatures::parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const uint32_t p_usage, const bool p_wide) {
|
||||
|
|
|
@ -802,7 +802,7 @@ public:
|
|||
|
||||
project_path = memnew(LineEdit);
|
||||
project_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
project_path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
project_path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
pphb->add_child(project_path);
|
||||
|
||||
install_path_container = memnew(VBoxContainer);
|
||||
|
@ -817,7 +817,7 @@ public:
|
|||
|
||||
install_path = memnew(LineEdit);
|
||||
install_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
install_path->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
install_path->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
iphb->add_child(install_path);
|
||||
|
||||
// status icon
|
||||
|
@ -1440,7 +1440,7 @@ void ProjectList::create_project_item_control(int p_index) {
|
|||
}
|
||||
|
||||
Label *fpath = memnew(Label(item.path));
|
||||
fpath->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
fpath->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
path_hb->add_child(fpath);
|
||||
fpath->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
fpath->set_modulate(Color(1, 1, 1, 0.5));
|
||||
|
|
|
@ -994,8 +994,8 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(
|
|||
int w = (bounds.r - bounds.l);
|
||||
int h = (bounds.t - bounds.b);
|
||||
|
||||
int mw = w + p_rect_margin * 2;
|
||||
int mh = h + p_rect_margin * 2;
|
||||
int mw = w + p_rect_margin * 4;
|
||||
int mh = h + p_rect_margin * 4;
|
||||
|
||||
ERR_FAIL_COND_V(mw > 4096, FontGlyph());
|
||||
ERR_FAIL_COND_V(mh > 4096, FontGlyph());
|
||||
|
@ -1029,7 +1029,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(
|
|||
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin) * tex.texture_w + j + tex_pos.x + p_rect_margin) * 4;
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * 4;
|
||||
ERR_FAIL_COND_V(ofs >= tex.imgdata.size(), FontGlyph());
|
||||
wr[ofs + 0] = (uint8_t)(CLAMP(image(j, i)[0] * 256.f, 0.f, 255.f));
|
||||
wr[ofs + 1] = (uint8_t)(CLAMP(image(j, i)[1] * 256.f, 0.f, 255.f));
|
||||
|
@ -1049,8 +1049,9 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(
|
|||
|
||||
chr.texture_idx = tex_pos.index;
|
||||
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w, h);
|
||||
chr.rect.position = Vector2(bounds.l, -bounds.t);
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w + p_rect_margin * 2, h + p_rect_margin * 2);
|
||||
chr.rect.position = Vector2(bounds.l - p_rect_margin, -bounds.t - p_rect_margin);
|
||||
|
||||
chr.rect.size = chr.uv_rect.size;
|
||||
}
|
||||
return chr;
|
||||
|
@ -1062,8 +1063,8 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma
|
|||
int w = bitmap.width;
|
||||
int h = bitmap.rows;
|
||||
|
||||
int mw = w + p_rect_margin * 2;
|
||||
int mh = h + p_rect_margin * 2;
|
||||
int mw = w + p_rect_margin * 4;
|
||||
int mh = h + p_rect_margin * 4;
|
||||
|
||||
ERR_FAIL_COND_V(mw > 4096, FontGlyph());
|
||||
ERR_FAIL_COND_V(mh > 4096, FontGlyph());
|
||||
|
@ -1083,7 +1084,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma
|
|||
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin) * tex.texture_w + j + tex_pos.x + p_rect_margin) * color_size;
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * color_size;
|
||||
ERR_FAIL_COND_V(ofs >= tex.imgdata.size(), FontGlyph());
|
||||
switch (bitmap.pixel_mode) {
|
||||
case FT_PIXEL_MODE_MONO: {
|
||||
|
@ -1124,8 +1125,8 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma
|
|||
chr.texture_idx = tex_pos.index;
|
||||
chr.found = true;
|
||||
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w, h);
|
||||
chr.rect.position = Vector2(xofs, -yofs) * p_data->scale / p_data->oversampling;
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w + p_rect_margin * 2, h + p_rect_margin * 2);
|
||||
chr.rect.position = Vector2(xofs - p_rect_margin, -yofs - p_rect_margin) * p_data->scale / p_data->oversampling;
|
||||
chr.rect.size = chr.uv_rect.size * p_data->scale / p_data->oversampling;
|
||||
return chr;
|
||||
}
|
||||
|
@ -1796,6 +1797,29 @@ bool TextServerAdvanced::font_is_antialiased(const RID &p_font_rid) const {
|
|||
return fd->antialiased;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) {
|
||||
FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND(!fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
if (fd->mipmaps != p_generate_mipmaps) {
|
||||
for (KeyValue<Vector2i, FontDataForSizeAdvanced *> &E : fd->cache) {
|
||||
for (int i = 0; i < E.value->textures.size(); i++) {
|
||||
E.value->textures.write[i].dirty = true;
|
||||
}
|
||||
}
|
||||
fd->mipmaps = p_generate_mipmaps;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextServerAdvanced::font_get_generate_mipmaps(const RID &p_font_rid) const {
|
||||
FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, false);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
return fd->mipmaps;
|
||||
}
|
||||
|
||||
void TextServerAdvanced::font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) {
|
||||
FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND(!fd);
|
||||
|
@ -2276,6 +2300,9 @@ void TextServerAdvanced::font_set_texture_image(const RID &p_font_rid, const Vec
|
|||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
|
||||
tex.texture = Ref<ImageTexture>();
|
||||
tex.texture.instantiate();
|
||||
|
@ -2559,6 +2586,86 @@ void TextServerAdvanced::font_set_glyph_texture_idx(const RID &p_font_rid, const
|
|||
gl[p_glyph].found = true;
|
||||
}
|
||||
|
||||
RID TextServerAdvanced::font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const {
|
||||
FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, RID());
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
Vector2i size = _get_size_outline(fd, p_size);
|
||||
|
||||
ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), RID());
|
||||
if (!_ensure_glyph(fd, size, p_glyph)) {
|
||||
return RID(); // Invalid or non graphicl glyph, do not display errors.
|
||||
}
|
||||
|
||||
const HashMap<int32_t, FontGlyph> &gl = fd->cache[size]->glyph_map;
|
||||
ERR_FAIL_COND_V(gl[p_glyph].texture_idx < -1 || gl[p_glyph].texture_idx >= fd->cache[size]->textures.size(), RID());
|
||||
|
||||
if (RenderingServer::get_singleton() != nullptr) {
|
||||
if (gl[p_glyph].texture_idx != -1) {
|
||||
if (fd->cache[size]->textures[gl[p_glyph].texture_idx].dirty) {
|
||||
FontTexture &tex = fd->cache[size]->textures.write[gl[p_glyph].texture_idx];
|
||||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
} else {
|
||||
tex.texture->update(img);
|
||||
}
|
||||
tex.dirty = false;
|
||||
}
|
||||
return fd->cache[size]->textures[gl[p_glyph].texture_idx].texture->get_rid();
|
||||
}
|
||||
}
|
||||
|
||||
return RID();
|
||||
}
|
||||
|
||||
Size2 TextServerAdvanced::font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const {
|
||||
FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, Size2());
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
Vector2i size = _get_size_outline(fd, p_size);
|
||||
|
||||
ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Size2());
|
||||
if (!_ensure_glyph(fd, size, p_glyph)) {
|
||||
return Size2(); // Invalid or non graphicl glyph, do not display errors.
|
||||
}
|
||||
|
||||
const HashMap<int32_t, FontGlyph> &gl = fd->cache[size]->glyph_map;
|
||||
ERR_FAIL_COND_V(gl[p_glyph].texture_idx < -1 || gl[p_glyph].texture_idx >= fd->cache[size]->textures.size(), Size2());
|
||||
|
||||
if (RenderingServer::get_singleton() != nullptr) {
|
||||
if (gl[p_glyph].texture_idx != -1) {
|
||||
if (fd->cache[size]->textures[gl[p_glyph].texture_idx].dirty) {
|
||||
FontTexture &tex = fd->cache[size]->textures.write[gl[p_glyph].texture_idx];
|
||||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
} else {
|
||||
tex.texture->update(img);
|
||||
}
|
||||
tex.dirty = false;
|
||||
}
|
||||
return fd->cache[size]->textures[gl[p_glyph].texture_idx].texture->get_size();
|
||||
}
|
||||
}
|
||||
|
||||
return Size2();
|
||||
}
|
||||
|
||||
Dictionary TextServerAdvanced::font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const {
|
||||
FontDataAdvanced *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, Dictionary());
|
||||
|
@ -2865,6 +2972,9 @@ void TextServerAdvanced::font_draw_glyph(const RID &p_font_rid, const RID &p_can
|
|||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
|
@ -2941,6 +3051,9 @@ void TextServerAdvanced::font_draw_glyph_outline(const RID &p_font_rid, const RI
|
|||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
|
@ -3304,7 +3417,9 @@ void TextServerAdvanced::shaped_text_set_bidi_override(const RID &p_shaped, cons
|
|||
}
|
||||
sd->bidi_override.clear();
|
||||
for (int i = 0; i < p_override.size(); i++) {
|
||||
sd->bidi_override.push_back(p_override[i]);
|
||||
if (p_override[i].get_type() == Variant::VECTOR2I) {
|
||||
sd->bidi_override.push_back(p_override[i]);
|
||||
}
|
||||
}
|
||||
invalidate(sd, false);
|
||||
}
|
||||
|
|
|
@ -216,6 +216,7 @@ class TextServerAdvanced : public TextServerExtension {
|
|||
Mutex mutex;
|
||||
|
||||
bool antialiased = true;
|
||||
bool mipmaps = false;
|
||||
bool msdf = false;
|
||||
int msdf_range = 14;
|
||||
int msdf_source_size = 48;
|
||||
|
@ -483,6 +484,9 @@ public:
|
|||
virtual void font_set_antialiased(const RID &p_font_rid, bool p_antialiased) override;
|
||||
virtual bool font_is_antialiased(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) override;
|
||||
virtual bool font_get_generate_mipmaps(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) override;
|
||||
virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const override;
|
||||
|
||||
|
@ -567,6 +571,9 @@ public:
|
|||
virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) override;
|
||||
|
||||
virtual RID font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
virtual Size2 font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
|
||||
virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const override;
|
||||
|
||||
virtual Array font_get_kerning_list(const RID &p_font_rid, int64_t p_size) const override;
|
||||
|
|
|
@ -438,8 +438,8 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(
|
|||
int w = (bounds.r - bounds.l);
|
||||
int h = (bounds.t - bounds.b);
|
||||
|
||||
int mw = w + p_rect_margin * 2;
|
||||
int mh = h + p_rect_margin * 2;
|
||||
int mw = w + p_rect_margin * 4;
|
||||
int mh = h + p_rect_margin * 4;
|
||||
|
||||
ERR_FAIL_COND_V(mw > 4096, FontGlyph());
|
||||
ERR_FAIL_COND_V(mh > 4096, FontGlyph());
|
||||
|
@ -473,7 +473,7 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(
|
|||
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin) * tex.texture_w + j + tex_pos.x + p_rect_margin) * 4;
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * 4;
|
||||
ERR_FAIL_COND_V(ofs >= tex.imgdata.size(), FontGlyph());
|
||||
wr[ofs + 0] = (uint8_t)(CLAMP(image(j, i)[0] * 256.f, 0.f, 255.f));
|
||||
wr[ofs + 1] = (uint8_t)(CLAMP(image(j, i)[1] * 256.f, 0.f, 255.f));
|
||||
|
@ -493,8 +493,8 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_msdf(
|
|||
|
||||
chr.texture_idx = tex_pos.index;
|
||||
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w, h);
|
||||
chr.rect.position = Vector2(bounds.l, -bounds.t);
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w + p_rect_margin * 2, h + p_rect_margin * 2);
|
||||
chr.rect.position = Vector2(bounds.l - p_rect_margin, -bounds.t - p_rect_margin);
|
||||
chr.rect.size = chr.uv_rect.size;
|
||||
}
|
||||
return chr;
|
||||
|
@ -506,8 +506,8 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma
|
|||
int w = bitmap.width;
|
||||
int h = bitmap.rows;
|
||||
|
||||
int mw = w + p_rect_margin * 2;
|
||||
int mh = h + p_rect_margin * 2;
|
||||
int mw = w + p_rect_margin * 4;
|
||||
int mh = h + p_rect_margin * 4;
|
||||
|
||||
ERR_FAIL_COND_V(mw > 4096, FontGlyph());
|
||||
ERR_FAIL_COND_V(mh > 4096, FontGlyph());
|
||||
|
@ -527,7 +527,7 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma
|
|||
|
||||
for (int i = 0; i < h; i++) {
|
||||
for (int j = 0; j < w; j++) {
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin) * tex.texture_w + j + tex_pos.x + p_rect_margin) * color_size;
|
||||
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * color_size;
|
||||
ERR_FAIL_COND_V(ofs >= tex.imgdata.size(), FontGlyph());
|
||||
switch (bitmap.pixel_mode) {
|
||||
case FT_PIXEL_MODE_MONO: {
|
||||
|
@ -568,8 +568,8 @@ _FORCE_INLINE_ TextServerFallback::FontGlyph TextServerFallback::rasterize_bitma
|
|||
chr.texture_idx = tex_pos.index;
|
||||
chr.found = true;
|
||||
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w, h);
|
||||
chr.rect.position = Vector2(xofs, -yofs) * p_data->scale / p_data->oversampling;
|
||||
chr.uv_rect = Rect2(tex_pos.x + p_rect_margin, tex_pos.y + p_rect_margin, w + p_rect_margin * 2, h + p_rect_margin * 2);
|
||||
chr.rect.position = Vector2(xofs - p_rect_margin, -yofs - p_rect_margin) * p_data->scale / p_data->oversampling;
|
||||
chr.rect.size = chr.uv_rect.size * p_data->scale / p_data->oversampling;
|
||||
return chr;
|
||||
}
|
||||
|
@ -959,6 +959,29 @@ bool TextServerFallback::font_is_antialiased(const RID &p_font_rid) const {
|
|||
return fd->antialiased;
|
||||
}
|
||||
|
||||
void TextServerFallback::font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) {
|
||||
FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND(!fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
if (fd->mipmaps != p_generate_mipmaps) {
|
||||
for (KeyValue<Vector2i, FontDataForSizeFallback *> &E : fd->cache) {
|
||||
for (int i = 0; i < E.value->textures.size(); i++) {
|
||||
E.value->textures.write[i].dirty = true;
|
||||
}
|
||||
}
|
||||
fd->mipmaps = p_generate_mipmaps;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextServerFallback::font_get_generate_mipmaps(const RID &p_font_rid) const {
|
||||
FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, false);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
return fd->mipmaps;
|
||||
}
|
||||
|
||||
void TextServerFallback::font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) {
|
||||
FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND(!fd);
|
||||
|
@ -1439,6 +1462,9 @@ void TextServerFallback::font_set_texture_image(const RID &p_font_rid, const Vec
|
|||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
|
||||
tex.texture = Ref<ImageTexture>();
|
||||
tex.texture.instantiate();
|
||||
|
@ -1708,6 +1734,86 @@ void TextServerFallback::font_set_glyph_texture_idx(const RID &p_font_rid, const
|
|||
gl[p_glyph].found = true;
|
||||
}
|
||||
|
||||
RID TextServerFallback::font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const {
|
||||
FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, RID());
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
Vector2i size = _get_size_outline(fd, p_size);
|
||||
|
||||
ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), RID());
|
||||
if (!_ensure_glyph(fd, size, p_glyph)) {
|
||||
return RID(); // Invalid or non graphicl glyph, do not display errors.
|
||||
}
|
||||
|
||||
const HashMap<int32_t, FontGlyph> &gl = fd->cache[size]->glyph_map;
|
||||
ERR_FAIL_COND_V(gl[p_glyph].texture_idx < -1 || gl[p_glyph].texture_idx >= fd->cache[size]->textures.size(), RID());
|
||||
|
||||
if (RenderingServer::get_singleton() != nullptr) {
|
||||
if (gl[p_glyph].texture_idx != -1) {
|
||||
if (fd->cache[size]->textures[gl[p_glyph].texture_idx].dirty) {
|
||||
FontTexture &tex = fd->cache[size]->textures.write[gl[p_glyph].texture_idx];
|
||||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
} else {
|
||||
tex.texture->update(img);
|
||||
}
|
||||
tex.dirty = false;
|
||||
}
|
||||
return fd->cache[size]->textures[gl[p_glyph].texture_idx].texture->get_rid();
|
||||
}
|
||||
}
|
||||
|
||||
return RID();
|
||||
}
|
||||
|
||||
Size2 TextServerFallback::font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const {
|
||||
FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, Size2());
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
Vector2i size = _get_size_outline(fd, p_size);
|
||||
|
||||
ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, size), Size2());
|
||||
if (!_ensure_glyph(fd, size, p_glyph)) {
|
||||
return Size2(); // Invalid or non graphicl glyph, do not display errors.
|
||||
}
|
||||
|
||||
const HashMap<int32_t, FontGlyph> &gl = fd->cache[size]->glyph_map;
|
||||
ERR_FAIL_COND_V(gl[p_glyph].texture_idx < -1 || gl[p_glyph].texture_idx >= fd->cache[size]->textures.size(), Size2());
|
||||
|
||||
if (RenderingServer::get_singleton() != nullptr) {
|
||||
if (gl[p_glyph].texture_idx != -1) {
|
||||
if (fd->cache[size]->textures[gl[p_glyph].texture_idx].dirty) {
|
||||
FontTexture &tex = fd->cache[size]->textures.write[gl[p_glyph].texture_idx];
|
||||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
} else {
|
||||
tex.texture->update(img);
|
||||
}
|
||||
tex.dirty = false;
|
||||
}
|
||||
return fd->cache[size]->textures[gl[p_glyph].texture_idx].texture->get_size();
|
||||
}
|
||||
}
|
||||
|
||||
return Size2();
|
||||
}
|
||||
|
||||
Dictionary TextServerFallback::font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const {
|
||||
FontDataFallback *fd = font_owner.get_or_null(p_font_rid);
|
||||
ERR_FAIL_COND_V(!fd, Dictionary());
|
||||
|
@ -1996,6 +2102,9 @@ void TextServerFallback::font_draw_glyph(const RID &p_font_rid, const RID &p_can
|
|||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
|
@ -2072,6 +2181,9 @@ void TextServerFallback::font_draw_glyph_outline(const RID &p_font_rid, const RI
|
|||
Ref<Image> img;
|
||||
img.instantiate();
|
||||
img->create_from_data(tex.texture_w, tex.texture_h, false, tex.format, tex.imgdata);
|
||||
if (fd->mipmaps) {
|
||||
img->generate_mipmaps();
|
||||
}
|
||||
if (tex.texture.is_null()) {
|
||||
tex.texture.instantiate();
|
||||
tex.texture->create_from_image(img);
|
||||
|
|
|
@ -179,6 +179,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
Mutex mutex;
|
||||
|
||||
bool antialiased = true;
|
||||
bool mipmaps = false;
|
||||
bool msdf = false;
|
||||
int msdf_range = 14;
|
||||
int msdf_source_size = 48;
|
||||
|
@ -375,6 +376,9 @@ public:
|
|||
virtual void font_set_antialiased(const RID &p_font_rid, bool p_antialiased) override;
|
||||
virtual bool font_is_antialiased(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) override;
|
||||
virtual bool font_get_generate_mipmaps(const RID &p_font_rid) const override;
|
||||
|
||||
virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) override;
|
||||
virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const override;
|
||||
|
||||
|
@ -458,6 +462,8 @@ public:
|
|||
|
||||
virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) override;
|
||||
virtual RID font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
virtual Size2 font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
|
||||
virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const override;
|
||||
|
||||
|
|
962
scene/3d/label_3d.cpp
Normal file
962
scene/3d/label_3d.cpp
Normal file
|
@ -0,0 +1,962 @@
|
|||
/*************************************************************************/
|
||||
/* label_3d.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "label_3d.h"
|
||||
|
||||
#include "core/core_string_names.h"
|
||||
#include "scene/resources/theme.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
|
||||
void Label3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_horizontal_alignment", "alignment"), &Label3D::set_horizontal_alignment);
|
||||
ClassDB::bind_method(D_METHOD("get_horizontal_alignment"), &Label3D::get_horizontal_alignment);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_vertical_alignment", "alignment"), &Label3D::set_vertical_alignment);
|
||||
ClassDB::bind_method(D_METHOD("get_vertical_alignment"), &Label3D::get_vertical_alignment);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_modulate", "modulate"), &Label3D::set_modulate);
|
||||
ClassDB::bind_method(D_METHOD("get_modulate"), &Label3D::get_modulate);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_outline_modulate", "modulate"), &Label3D::set_outline_modulate);
|
||||
ClassDB::bind_method(D_METHOD("get_outline_modulate"), &Label3D::get_outline_modulate);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_text", "text"), &Label3D::set_text);
|
||||
ClassDB::bind_method(D_METHOD("get_text"), &Label3D::get_text);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_text_direction", "direction"), &Label3D::set_text_direction);
|
||||
ClassDB::bind_method(D_METHOD("get_text_direction"), &Label3D::get_text_direction);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_opentype_feature", "tag", "value"), &Label3D::set_opentype_feature);
|
||||
ClassDB::bind_method(D_METHOD("get_opentype_feature", "tag"), &Label3D::get_opentype_feature);
|
||||
ClassDB::bind_method(D_METHOD("clear_opentype_features"), &Label3D::clear_opentype_features);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_language", "language"), &Label3D::set_language);
|
||||
ClassDB::bind_method(D_METHOD("get_language"), &Label3D::get_language);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_structured_text_bidi_override", "parser"), &Label3D::set_structured_text_bidi_override);
|
||||
ClassDB::bind_method(D_METHOD("get_structured_text_bidi_override"), &Label3D::get_structured_text_bidi_override);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_structured_text_bidi_override_options", "args"), &Label3D::set_structured_text_bidi_override_options);
|
||||
ClassDB::bind_method(D_METHOD("get_structured_text_bidi_override_options"), &Label3D::get_structured_text_bidi_override_options);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_uppercase", "enable"), &Label3D::set_uppercase);
|
||||
ClassDB::bind_method(D_METHOD("is_uppercase"), &Label3D::is_uppercase);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_font", "font"), &Label3D::set_font);
|
||||
ClassDB::bind_method(D_METHOD("get_font"), &Label3D::get_font);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_font_size", "size"), &Label3D::set_font_size);
|
||||
ClassDB::bind_method(D_METHOD("get_font_size"), &Label3D::get_font_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_outline_size", "outline_size"), &Label3D::set_outline_size);
|
||||
ClassDB::bind_method(D_METHOD("get_outline_size"), &Label3D::get_outline_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_line_spacing", "line_spacing"), &Label3D::set_line_spacing);
|
||||
ClassDB::bind_method(D_METHOD("get_line_spacing"), &Label3D::get_line_spacing);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_autowrap_mode", "autowrap_mode"), &Label3D::set_autowrap_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_autowrap_mode"), &Label3D::get_autowrap_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_width", "width"), &Label3D::set_width);
|
||||
ClassDB::bind_method(D_METHOD("get_width"), &Label3D::get_width);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_pixel_size", "pixel_size"), &Label3D::set_pixel_size);
|
||||
ClassDB::bind_method(D_METHOD("get_pixel_size"), &Label3D::get_pixel_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_draw_flag", "flag", "enabled"), &Label3D::set_draw_flag);
|
||||
ClassDB::bind_method(D_METHOD("get_draw_flag", "flag"), &Label3D::get_draw_flag);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &Label3D::set_billboard_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_billboard_mode"), &Label3D::get_billboard_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_alpha_cut_mode", "mode"), &Label3D::set_alpha_cut_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_alpha_cut_mode"), &Label3D::get_alpha_cut_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &Label3D::set_alpha_scissor_threshold);
|
||||
ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &Label3D::get_alpha_scissor_threshold);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_texture_filter", "mode"), &Label3D::set_texture_filter);
|
||||
ClassDB::bind_method(D_METHOD("get_texture_filter"), &Label3D::get_texture_filter);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("generate_triangle_mesh"), &Label3D::generate_triangle_mesh);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_queue_update"), &Label3D::_queue_update);
|
||||
ClassDB::bind_method(D_METHOD("_font_changed"), &Label3D::_font_changed);
|
||||
ClassDB::bind_method(D_METHOD("_im_update"), &Label3D::_im_update);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pixel_size", PROPERTY_HINT_RANGE, "0.0001,128,0.0001"), "set_pixel_size", "get_pixel_size");
|
||||
|
||||
ADD_GROUP("Flags", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "billboard", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard"), "set_billboard_mode", "get_billboard_mode");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "shaded"), "set_draw_flag", "get_draw_flag", FLAG_SHADED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "double_sided"), "set_draw_flag", "get_draw_flag", FLAG_DOUBLE_SIDED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "no_depth_test"), "set_draw_flag", "get_draw_flag", FLAG_DISABLE_DEPTH_TEST);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_size"), "set_draw_flag", "get_draw_flag", FLAG_FIXED_SIZE);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "alpha_cut", PROPERTY_HINT_ENUM, "Disabled,Discard,Opaque Pre-Pass"), "set_alpha_cut_mode", "get_alpha_cut_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "alpha_scissor_threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_alpha_scissor_threshold", "get_alpha_scissor_threshold");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,Nearest Mipmap,Linear Mipmap,Nearest Mipmap Anisotropic,Linear Mipmap Anisotropic"), "set_texture_filter", "get_texture_filter");
|
||||
|
||||
ADD_GROUP("Text", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "modulate"), "set_modulate", "get_modulate");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "outline_modulate"), "set_outline_modulate", "get_outline_modulate");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT, ""), "set_text", "get_text");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "font", PROPERTY_HINT_RESOURCE_TYPE, "Font"), "set_font", "get_font");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "font_size", PROPERTY_HINT_RANGE, "1,127,1"), "set_font_size", "get_font_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_RANGE, "0,127,1"), "set_outline_size", "get_outline_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_alignment", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_horizontal_alignment", "get_horizontal_alignment");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "vertical_alignment", PROPERTY_HINT_ENUM, "Top,Center,Bottom"), "set_vertical_alignment", "get_vertical_alignment");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "uppercase"), "set_uppercase", "is_uppercase");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "line_spacing"), "set_line_spacing", "get_line_spacing");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "autowrap_mode", PROPERTY_HINT_ENUM, "Off,Arbitrary,Word,Word (Smart)"), "set_autowrap_mode", "get_autowrap_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "width"), "set_width", "get_width");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "structured_text_bidi_override", PROPERTY_HINT_ENUM, "Default,URI,File,Email,List,None,Custom"), "set_structured_text_bidi_override", "get_structured_text_bidi_override");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "structured_text_bidi_override_options"), "set_structured_text_bidi_override_options", "get_structured_text_bidi_override_options");
|
||||
|
||||
ADD_GROUP("Locale", "");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left"), "set_text_direction", "get_text_direction");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "language", PROPERTY_HINT_LOCALE_ID, ""), "set_language", "get_language");
|
||||
|
||||
BIND_ENUM_CONSTANT(AUTOWRAP_OFF);
|
||||
BIND_ENUM_CONSTANT(AUTOWRAP_ARBITRARY);
|
||||
BIND_ENUM_CONSTANT(AUTOWRAP_WORD);
|
||||
BIND_ENUM_CONSTANT(AUTOWRAP_WORD_SMART);
|
||||
|
||||
BIND_ENUM_CONSTANT(FLAG_SHADED);
|
||||
BIND_ENUM_CONSTANT(FLAG_DOUBLE_SIDED);
|
||||
BIND_ENUM_CONSTANT(FLAG_DISABLE_DEPTH_TEST);
|
||||
BIND_ENUM_CONSTANT(FLAG_FIXED_SIZE);
|
||||
BIND_ENUM_CONSTANT(FLAG_MAX);
|
||||
|
||||
BIND_ENUM_CONSTANT(ALPHA_CUT_DISABLED);
|
||||
BIND_ENUM_CONSTANT(ALPHA_CUT_DISCARD);
|
||||
BIND_ENUM_CONSTANT(ALPHA_CUT_OPAQUE_PREPASS);
|
||||
}
|
||||
|
||||
bool Label3D::_set(const StringName &p_name, const Variant &p_value) {
|
||||
String str = p_name;
|
||||
if (str.begins_with("opentype_features/")) {
|
||||
String name = str.get_slicec('/', 1);
|
||||
int32_t tag = TS->name_to_tag(name);
|
||||
int value = p_value;
|
||||
if (value == -1) {
|
||||
if (opentype_features.has(tag)) {
|
||||
opentype_features.erase(tag);
|
||||
dirty_font = true;
|
||||
_queue_update();
|
||||
}
|
||||
} else {
|
||||
if (!opentype_features.has(tag) || (int)opentype_features[tag] != value) {
|
||||
opentype_features[tag] = value;
|
||||
dirty_font = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
notify_property_list_changed();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Label3D::_get(const StringName &p_name, Variant &r_ret) const {
|
||||
String str = p_name;
|
||||
if (str.begins_with("opentype_features/")) {
|
||||
String name = str.get_slicec('/', 1);
|
||||
int32_t tag = TS->name_to_tag(name);
|
||||
if (opentype_features.has(tag)) {
|
||||
r_ret = opentype_features[tag];
|
||||
return true;
|
||||
} else {
|
||||
r_ret = -1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Label3D::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
for (const Variant *ftr = opentype_features.next(nullptr); ftr != nullptr; ftr = opentype_features.next(ftr)) {
|
||||
String name = TS->tag_to_name(*ftr);
|
||||
p_list->push_back(PropertyInfo(Variant::INT, "opentype_features/" + name));
|
||||
}
|
||||
p_list->push_back(PropertyInfo(Variant::NIL, "opentype_features/_new", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
|
||||
}
|
||||
|
||||
void Label3D::_validate_property(PropertyInfo &property) const {
|
||||
if (property.name == "material_override" || property.name == "material_overlay") {
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
}
|
||||
|
||||
void Label3D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
if (!pending_update) {
|
||||
_im_update();
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_TRANSLATION_CHANGED: {
|
||||
String new_text = tr(text);
|
||||
if (new_text == xl_text) {
|
||||
return; // Nothing new.
|
||||
}
|
||||
xl_text = new_text;
|
||||
dirty_text = true;
|
||||
_queue_update();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void Label3D::_im_update() {
|
||||
_shape();
|
||||
|
||||
triangle_mesh.unref();
|
||||
update_gizmos();
|
||||
|
||||
pending_update = false;
|
||||
}
|
||||
|
||||
void Label3D::_queue_update() {
|
||||
if (pending_update) {
|
||||
return;
|
||||
}
|
||||
|
||||
pending_update = true;
|
||||
call_deferred(SceneStringNames::get_singleton()->_im_update);
|
||||
}
|
||||
|
||||
AABB Label3D::get_aabb() const {
|
||||
return aabb;
|
||||
}
|
||||
|
||||
Ref<TriangleMesh> Label3D::generate_triangle_mesh() const {
|
||||
if (triangle_mesh.is_valid()) {
|
||||
return triangle_mesh;
|
||||
}
|
||||
|
||||
Ref<Font> font = _get_font_or_default();
|
||||
if (font.is_null()) {
|
||||
return Ref<TriangleMesh>();
|
||||
}
|
||||
|
||||
Vector<Vector3> faces;
|
||||
faces.resize(6);
|
||||
Vector3 *facesw = faces.ptrw();
|
||||
|
||||
float total_h = 0.0;
|
||||
float max_line_w = 0.0;
|
||||
for (int i = 0; i < lines_rid.size(); i++) {
|
||||
total_h += TS->shaped_text_get_size(lines_rid[i]).y + font->get_spacing(TextServer::SPACING_TOP) + font->get_spacing(TextServer::SPACING_BOTTOM) + line_spacing;
|
||||
max_line_w = MAX(max_line_w, TS->shaped_text_get_width(lines_rid[i]));
|
||||
}
|
||||
|
||||
float vbegin = 0;
|
||||
switch (vertical_alignment) {
|
||||
case VERTICAL_ALIGNMENT_FILL:
|
||||
case VERTICAL_ALIGNMENT_TOP: {
|
||||
// Nothing.
|
||||
} break;
|
||||
case VERTICAL_ALIGNMENT_CENTER: {
|
||||
vbegin = (total_h - line_spacing) / 2.0;
|
||||
} break;
|
||||
case VERTICAL_ALIGNMENT_BOTTOM: {
|
||||
vbegin = (total_h - line_spacing);
|
||||
} break;
|
||||
}
|
||||
|
||||
Vector2 offset = Vector2(0, vbegin);
|
||||
switch (horizontal_alignment) {
|
||||
case HORIZONTAL_ALIGNMENT_LEFT:
|
||||
break;
|
||||
case HORIZONTAL_ALIGNMENT_FILL:
|
||||
case HORIZONTAL_ALIGNMENT_CENTER: {
|
||||
offset.x = -max_line_w / 2.0;
|
||||
} break;
|
||||
case HORIZONTAL_ALIGNMENT_RIGHT: {
|
||||
offset.x = -max_line_w;
|
||||
} break;
|
||||
}
|
||||
|
||||
Rect2 final_rect = Rect2(offset, Size2(max_line_w, total_h));
|
||||
|
||||
if (final_rect.size.x == 0 || final_rect.size.y == 0) {
|
||||
return Ref<TriangleMesh>();
|
||||
}
|
||||
|
||||
real_t pixel_size = get_pixel_size();
|
||||
|
||||
Vector2 vertices[4] = {
|
||||
|
||||
(final_rect.position + Vector2(0, -final_rect.size.y)) * pixel_size,
|
||||
(final_rect.position + Vector2(final_rect.size.x, -final_rect.size.y)) * pixel_size,
|
||||
(final_rect.position + Vector2(final_rect.size.x, 0)) * pixel_size,
|
||||
final_rect.position * pixel_size,
|
||||
|
||||
};
|
||||
|
||||
static const int indices[6] = {
|
||||
0, 1, 2,
|
||||
0, 2, 3
|
||||
};
|
||||
|
||||
for (int j = 0; j < 6; j++) {
|
||||
int i = indices[j];
|
||||
Vector3 vtx;
|
||||
vtx[0] = vertices[i][0];
|
||||
vtx[1] = vertices[i][1];
|
||||
facesw[j] = vtx;
|
||||
}
|
||||
|
||||
triangle_mesh = Ref<TriangleMesh>(memnew(TriangleMesh));
|
||||
triangle_mesh->create(faces);
|
||||
|
||||
return triangle_mesh;
|
||||
}
|
||||
|
||||
void Label3D::_generate_glyph_surfaces(const Glyph &p_glyph, Vector2 &r_offset, const Color &p_modulate, int p_priority, int p_outline_size) {
|
||||
for (int j = 0; j < p_glyph.repeat; j++) {
|
||||
Vector2 gl_of;
|
||||
Vector2 gl_sz;
|
||||
Rect2 gl_uv;
|
||||
Size2 texs;
|
||||
RID tex;
|
||||
|
||||
if (p_glyph.font_rid != RID()) {
|
||||
tex = TS->font_get_glyph_texture_rid(p_glyph.font_rid, Vector2i(p_glyph.font_size, p_outline_size), p_glyph.index);
|
||||
if (tex != RID()) {
|
||||
gl_of = (TS->font_get_glyph_offset(p_glyph.font_rid, Vector2i(p_glyph.font_size, p_outline_size), p_glyph.index) + Vector2(p_glyph.x_off, p_glyph.y_off)) * pixel_size;
|
||||
gl_sz = TS->font_get_glyph_size(p_glyph.font_rid, Vector2i(p_glyph.font_size, p_outline_size), p_glyph.index) * pixel_size;
|
||||
gl_uv = TS->font_get_glyph_uv_rect(p_glyph.font_rid, Vector2i(p_glyph.font_size, p_outline_size), p_glyph.index);
|
||||
texs = TS->font_get_glyph_texture_size(p_glyph.font_rid, Vector2i(p_glyph.font_size, p_outline_size), p_glyph.index);
|
||||
}
|
||||
} else {
|
||||
gl_sz = TS->get_hex_code_box_size(p_glyph.font_size, p_glyph.index) * pixel_size;
|
||||
gl_of = Vector2(0, -gl_sz.y);
|
||||
}
|
||||
|
||||
bool msdf = TS->font_is_multichannel_signed_distance_field(p_glyph.font_rid);
|
||||
|
||||
uint64_t mat_hash;
|
||||
if (tex != RID()) {
|
||||
mat_hash = hash_one_uint64(tex.get_id());
|
||||
} else {
|
||||
mat_hash = hash_one_uint64(0);
|
||||
}
|
||||
mat_hash = hash_djb2_one_64(p_priority | (p_outline_size << 31), mat_hash);
|
||||
|
||||
if (!surfaces.has(mat_hash)) {
|
||||
SurfaceData surf;
|
||||
surf.material = RenderingServer::get_singleton()->material_create();
|
||||
// Set defaults for material, names need to match up those in StandardMaterial3D
|
||||
RS::get_singleton()->material_set_param(surf.material, "albedo", Color(1, 1, 1, 1));
|
||||
RS::get_singleton()->material_set_param(surf.material, "specular", 0.5);
|
||||
RS::get_singleton()->material_set_param(surf.material, "metallic", 0.0);
|
||||
RS::get_singleton()->material_set_param(surf.material, "roughness", 1.0);
|
||||
RS::get_singleton()->material_set_param(surf.material, "uv1_offset", Vector3(0, 0, 0));
|
||||
RS::get_singleton()->material_set_param(surf.material, "uv1_scale", Vector3(1, 1, 1));
|
||||
RS::get_singleton()->material_set_param(surf.material, "uv2_offset", Vector3(0, 0, 0));
|
||||
RS::get_singleton()->material_set_param(surf.material, "uv2_scale", Vector3(1, 1, 1));
|
||||
RS::get_singleton()->material_set_param(surf.material, "alpha_scissor_threshold", alpha_scissor_threshold);
|
||||
if (msdf) {
|
||||
RS::get_singleton()->material_set_param(surf.material, "msdf_pixel_range", TS->font_get_msdf_pixel_range(p_glyph.font_rid));
|
||||
RS::get_singleton()->material_set_param(surf.material, "msdf_outline_size", p_outline_size);
|
||||
}
|
||||
|
||||
RID shader_rid;
|
||||
StandardMaterial3D::get_material_for_2d(get_draw_flag(FLAG_SHADED), true, get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y, msdf, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE), texture_filter, &shader_rid);
|
||||
|
||||
RS::get_singleton()->material_set_shader(surf.material, shader_rid);
|
||||
RS::get_singleton()->material_set_param(surf.material, "texture_albedo", tex);
|
||||
if (get_alpha_cut_mode() == ALPHA_CUT_DISABLED) {
|
||||
RS::get_singleton()->material_set_render_priority(surf.material, p_priority);
|
||||
} else {
|
||||
surf.z_shift = p_priority * pixel_size;
|
||||
}
|
||||
|
||||
surfaces[mat_hash] = surf;
|
||||
}
|
||||
SurfaceData &s = surfaces[mat_hash];
|
||||
|
||||
s.mesh_vertices.resize((s.offset + 1) * 4);
|
||||
s.mesh_normals.resize((s.offset + 1) * 4);
|
||||
s.mesh_tangents.resize((s.offset + 1) * 16);
|
||||
s.mesh_colors.resize((s.offset + 1) * 4);
|
||||
s.mesh_uvs.resize((s.offset + 1) * 4);
|
||||
|
||||
s.mesh_vertices.write[(s.offset * 4) + 3] = Vector3(r_offset.x + gl_of.x, r_offset.y - gl_of.y - gl_sz.y, s.z_shift);
|
||||
s.mesh_vertices.write[(s.offset * 4) + 2] = Vector3(r_offset.x + gl_of.x + gl_sz.x, r_offset.y - gl_of.y - gl_sz.y, s.z_shift);
|
||||
s.mesh_vertices.write[(s.offset * 4) + 1] = Vector3(r_offset.x + gl_of.x + gl_sz.x, r_offset.y - gl_of.y, s.z_shift);
|
||||
s.mesh_vertices.write[(s.offset * 4) + 0] = Vector3(r_offset.x + gl_of.x, r_offset.y - gl_of.y, s.z_shift);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
s.mesh_normals.write[(s.offset * 4) + i] = Vector3(0.0, 0.0, 1.0);
|
||||
s.mesh_tangents.write[(s.offset * 16) + (i * 4) + 0] = 1.0;
|
||||
s.mesh_tangents.write[(s.offset * 16) + (i * 4) + 1] = 0.0;
|
||||
s.mesh_tangents.write[(s.offset * 16) + (i * 4) + 2] = 0.0;
|
||||
s.mesh_tangents.write[(s.offset * 16) + (i * 4) + 3] = 1.0;
|
||||
s.mesh_colors.write[(s.offset * 4) + i] = p_modulate;
|
||||
s.mesh_uvs.write[(s.offset * 4) + i] = Vector2();
|
||||
|
||||
if (aabb == AABB()) {
|
||||
aabb.position = s.mesh_vertices[(s.offset * 4) + i];
|
||||
} else {
|
||||
aabb.expand_to(s.mesh_vertices[(s.offset * 4) + i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (tex != RID()) {
|
||||
s.mesh_uvs.write[(s.offset * 4) + 3] = Vector2(gl_uv.position.x / texs.x, (gl_uv.position.y + gl_uv.size.y) / texs.y);
|
||||
s.mesh_uvs.write[(s.offset * 4) + 2] = Vector2((gl_uv.position.x + gl_uv.size.x) / texs.x, (gl_uv.position.y + gl_uv.size.y) / texs.y);
|
||||
s.mesh_uvs.write[(s.offset * 4) + 1] = Vector2((gl_uv.position.x + gl_uv.size.x) / texs.x, gl_uv.position.y / texs.y);
|
||||
s.mesh_uvs.write[(s.offset * 4) + 0] = Vector2(gl_uv.position.x / texs.x, gl_uv.position.y / texs.y);
|
||||
}
|
||||
|
||||
s.indices.resize((s.offset + 1) * 6);
|
||||
s.indices.write[(s.offset * 6) + 0] = (s.offset * 4) + 0;
|
||||
s.indices.write[(s.offset * 6) + 1] = (s.offset * 4) + 1;
|
||||
s.indices.write[(s.offset * 6) + 2] = (s.offset * 4) + 2;
|
||||
s.indices.write[(s.offset * 6) + 3] = (s.offset * 4) + 0;
|
||||
s.indices.write[(s.offset * 6) + 4] = (s.offset * 4) + 2;
|
||||
s.indices.write[(s.offset * 6) + 5] = (s.offset * 4) + 3;
|
||||
|
||||
s.offset++;
|
||||
r_offset.x += p_glyph.advance * pixel_size;
|
||||
}
|
||||
}
|
||||
|
||||
void Label3D::_shape() {
|
||||
// Clear mesh.
|
||||
RS::get_singleton()->mesh_clear(mesh);
|
||||
aabb = AABB();
|
||||
|
||||
// Clear materials.
|
||||
for (Map<uint64_t, SurfaceData>::Element *E = surfaces.front(); E; E = E->next()) {
|
||||
RenderingServer::get_singleton()->free(E->get().material);
|
||||
}
|
||||
surfaces.clear();
|
||||
|
||||
Ref<Font> font = _get_font_or_default();
|
||||
ERR_FAIL_COND(font.is_null());
|
||||
|
||||
// Update text buffer.
|
||||
if (dirty_text) {
|
||||
TS->shaped_text_clear(text_rid);
|
||||
TS->shaped_text_set_direction(text_rid, text_direction);
|
||||
|
||||
String text = (uppercase) ? TS->string_to_upper(xl_text, language) : xl_text;
|
||||
TS->shaped_text_add_string(text_rid, text, font->get_rids(), font_size, opentype_features, language);
|
||||
|
||||
Array stt;
|
||||
if (st_parser == TextServer::STRUCTURED_TEXT_CUSTOM) {
|
||||
GDVIRTUAL_CALL(_structured_text_parser, st_args, text, stt);
|
||||
} else {
|
||||
stt = TS->parse_structured_text(st_parser, st_args, text);
|
||||
}
|
||||
TS->shaped_text_set_bidi_override(text_rid, stt);
|
||||
|
||||
dirty_text = false;
|
||||
dirty_font = false;
|
||||
dirty_lines = true;
|
||||
} else if (dirty_font) {
|
||||
int spans = TS->shaped_get_span_count(text_rid);
|
||||
for (int i = 0; i < spans; i++) {
|
||||
TS->shaped_set_span_update_font(text_rid, i, font->get_rids(), font_size, opentype_features);
|
||||
}
|
||||
|
||||
dirty_font = false;
|
||||
dirty_lines = true;
|
||||
}
|
||||
|
||||
if (dirty_lines) {
|
||||
for (int i = 0; i < lines_rid.size(); i++) {
|
||||
TS->free_rid(lines_rid[i]);
|
||||
}
|
||||
lines_rid.clear();
|
||||
|
||||
uint16_t autowrap_flags = TextServer::BREAK_MANDATORY;
|
||||
switch (autowrap_mode) {
|
||||
case AUTOWRAP_WORD_SMART:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY;
|
||||
break;
|
||||
case AUTOWRAP_WORD:
|
||||
autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY;
|
||||
break;
|
||||
case AUTOWRAP_ARBITRARY:
|
||||
autowrap_flags = TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_MANDATORY;
|
||||
break;
|
||||
case AUTOWRAP_OFF:
|
||||
break;
|
||||
}
|
||||
PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags);
|
||||
|
||||
float max_line_w = 0.0;
|
||||
for (int i = 0; i < line_breaks.size(); i = i + 2) {
|
||||
RID line = TS->shaped_text_substr(text_rid, line_breaks[i], line_breaks[i + 1] - line_breaks[i]);
|
||||
max_line_w = MAX(max_line_w, TS->shaped_text_get_width(line));
|
||||
lines_rid.push_back(line);
|
||||
}
|
||||
|
||||
if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
for (int i = 0; i < lines_rid.size() - 1; i++) {
|
||||
TS->shaped_text_fit_to_width(lines_rid[i], (width > 0) ? width : max_line_w, TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA);
|
||||
}
|
||||
}
|
||||
dirty_lines = false;
|
||||
}
|
||||
|
||||
// Generate surfaces and materials.
|
||||
float total_h = 0.0;
|
||||
for (int i = 0; i < lines_rid.size(); i++) {
|
||||
total_h += (TS->shaped_text_get_size(lines_rid[i]).y + font->get_spacing(TextServer::SPACING_TOP) + font->get_spacing(TextServer::SPACING_BOTTOM) + line_spacing) * pixel_size;
|
||||
}
|
||||
|
||||
float vbegin = 0.0;
|
||||
switch (vertical_alignment) {
|
||||
case VERTICAL_ALIGNMENT_FILL:
|
||||
case VERTICAL_ALIGNMENT_TOP: {
|
||||
// Nothing.
|
||||
} break;
|
||||
case VERTICAL_ALIGNMENT_CENTER: {
|
||||
vbegin = (total_h - line_spacing * pixel_size) / 2.0;
|
||||
} break;
|
||||
case VERTICAL_ALIGNMENT_BOTTOM: {
|
||||
vbegin = (total_h - line_spacing * pixel_size);
|
||||
} break;
|
||||
}
|
||||
|
||||
Vector2 offset = Vector2(0, vbegin);
|
||||
for (int i = 0; i < lines_rid.size(); i++) {
|
||||
const Glyph *glyphs = TS->shaped_text_get_glyphs(lines_rid[i]);
|
||||
int gl_size = TS->shaped_text_get_glyph_count(lines_rid[i]);
|
||||
float line_width = TS->shaped_text_get_width(lines_rid[i]) * pixel_size;
|
||||
|
||||
switch (horizontal_alignment) {
|
||||
case HORIZONTAL_ALIGNMENT_LEFT:
|
||||
offset.x = 0.0;
|
||||
break;
|
||||
case HORIZONTAL_ALIGNMENT_FILL:
|
||||
case HORIZONTAL_ALIGNMENT_CENTER: {
|
||||
offset.x = -line_width / 2.0;
|
||||
} break;
|
||||
case HORIZONTAL_ALIGNMENT_RIGHT: {
|
||||
offset.x = -line_width;
|
||||
} break;
|
||||
}
|
||||
offset.y -= (TS->shaped_text_get_ascent(lines_rid[i]) + font->get_spacing(TextServer::SPACING_TOP)) * pixel_size;
|
||||
|
||||
if (outline_modulate.a != 0.0 && outline_size > 0) {
|
||||
// Outline surfaces.
|
||||
Vector2 ol_offset = offset;
|
||||
for (int j = 0; j < gl_size; j++) {
|
||||
_generate_glyph_surfaces(glyphs[j], ol_offset, outline_modulate, -1, outline_size);
|
||||
}
|
||||
}
|
||||
|
||||
// Main text surfaces.
|
||||
for (int j = 0; j < gl_size; j++) {
|
||||
_generate_glyph_surfaces(glyphs[j], offset, modulate, 0);
|
||||
}
|
||||
offset.y -= (TS->shaped_text_get_descent(lines_rid[i]) + line_spacing + font->get_spacing(TextServer::SPACING_BOTTOM)) * pixel_size;
|
||||
}
|
||||
|
||||
for (Map<uint64_t, SurfaceData>::Element *E = surfaces.front(); E; E = E->next()) {
|
||||
Array mesh_array;
|
||||
mesh_array.resize(RS::ARRAY_MAX);
|
||||
mesh_array[RS::ARRAY_VERTEX] = E->get().mesh_vertices;
|
||||
mesh_array[RS::ARRAY_NORMAL] = E->get().mesh_normals;
|
||||
mesh_array[RS::ARRAY_TANGENT] = E->get().mesh_tangents;
|
||||
mesh_array[RS::ARRAY_COLOR] = E->get().mesh_colors;
|
||||
mesh_array[RS::ARRAY_TEX_UV] = E->get().mesh_uvs;
|
||||
mesh_array[RS::ARRAY_INDEX] = E->get().indices;
|
||||
|
||||
RS::SurfaceData sd;
|
||||
RS::get_singleton()->mesh_create_surface_data_from_arrays(&sd, RS::PRIMITIVE_TRIANGLES, mesh_array);
|
||||
|
||||
sd.material = E->get().material;
|
||||
|
||||
RS::get_singleton()->mesh_add_surface(mesh, sd);
|
||||
}
|
||||
}
|
||||
|
||||
void Label3D::set_text(const String &p_string) {
|
||||
text = p_string;
|
||||
xl_text = tr(p_string);
|
||||
dirty_text = true;
|
||||
_queue_update();
|
||||
}
|
||||
|
||||
String Label3D::get_text() const {
|
||||
return text;
|
||||
}
|
||||
|
||||
void Label3D::set_horizontal_alignment(HorizontalAlignment p_alignment) {
|
||||
ERR_FAIL_INDEX((int)p_alignment, 4);
|
||||
if (horizontal_alignment != p_alignment) {
|
||||
if (horizontal_alignment == HORIZONTAL_ALIGNMENT_FILL || p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||
dirty_lines = true; // Reshape lines.
|
||||
}
|
||||
horizontal_alignment = p_alignment;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalAlignment Label3D::get_horizontal_alignment() const {
|
||||
return horizontal_alignment;
|
||||
}
|
||||
|
||||
void Label3D::set_vertical_alignment(VerticalAlignment p_alignment) {
|
||||
ERR_FAIL_INDEX((int)p_alignment, 4);
|
||||
if (vertical_alignment != p_alignment) {
|
||||
vertical_alignment = p_alignment;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
VerticalAlignment Label3D::get_vertical_alignment() const {
|
||||
return vertical_alignment;
|
||||
}
|
||||
|
||||
void Label3D::set_text_direction(TextServer::Direction p_text_direction) {
|
||||
ERR_FAIL_COND((int)p_text_direction < -1 || (int)p_text_direction > 3);
|
||||
if (text_direction != p_text_direction) {
|
||||
text_direction = p_text_direction;
|
||||
dirty_text = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
TextServer::Direction Label3D::get_text_direction() const {
|
||||
return text_direction;
|
||||
}
|
||||
|
||||
void Label3D::clear_opentype_features() {
|
||||
opentype_features.clear();
|
||||
dirty_font = true;
|
||||
_queue_update();
|
||||
}
|
||||
|
||||
void Label3D::set_opentype_feature(const String &p_name, int p_value) {
|
||||
int32_t tag = TS->name_to_tag(p_name);
|
||||
if (!opentype_features.has(tag) || (int)opentype_features[tag] != p_value) {
|
||||
opentype_features[tag] = p_value;
|
||||
dirty_font = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
int Label3D::get_opentype_feature(const String &p_name) const {
|
||||
int32_t tag = TS->name_to_tag(p_name);
|
||||
if (!opentype_features.has(tag)) {
|
||||
return -1;
|
||||
}
|
||||
return opentype_features[tag];
|
||||
}
|
||||
|
||||
void Label3D::set_language(const String &p_language) {
|
||||
if (language != p_language) {
|
||||
language = p_language;
|
||||
dirty_text = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
String Label3D::get_language() const {
|
||||
return language;
|
||||
}
|
||||
|
||||
void Label3D::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
||||
if (st_parser != p_parser) {
|
||||
st_parser = p_parser;
|
||||
dirty_text = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
TextServer::StructuredTextParser Label3D::get_structured_text_bidi_override() const {
|
||||
return st_parser;
|
||||
}
|
||||
|
||||
void Label3D::set_structured_text_bidi_override_options(Array p_args) {
|
||||
if (st_args != p_args) {
|
||||
st_args = p_args;
|
||||
dirty_text = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
Array Label3D::get_structured_text_bidi_override_options() const {
|
||||
return st_args;
|
||||
}
|
||||
|
||||
void Label3D::set_uppercase(bool p_uppercase) {
|
||||
if (uppercase != p_uppercase) {
|
||||
uppercase = p_uppercase;
|
||||
dirty_text = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
bool Label3D::is_uppercase() const {
|
||||
return uppercase;
|
||||
}
|
||||
|
||||
void Label3D::_font_changed() {
|
||||
dirty_font = true;
|
||||
_queue_update();
|
||||
}
|
||||
|
||||
void Label3D::set_font(const Ref<Font> &p_font) {
|
||||
if (font_override != p_font) {
|
||||
if (font_override.is_valid()) {
|
||||
font_override->disconnect(CoreStringNames::get_singleton()->changed, Callable(this, "_font_changed"));
|
||||
}
|
||||
font_override = p_font;
|
||||
dirty_font = true;
|
||||
if (font_override.is_valid()) {
|
||||
font_override->connect(CoreStringNames::get_singleton()->changed, Callable(this, "_font_changed"));
|
||||
}
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Font> Label3D::get_font() const {
|
||||
return font_override;
|
||||
}
|
||||
|
||||
Ref<Font> Label3D::_get_font_or_default() const {
|
||||
if (font_override.is_valid() && font_override->get_data_count() > 0) {
|
||||
return font_override;
|
||||
}
|
||||
|
||||
// Check the project-defined Theme resource.
|
||||
if (Theme::get_project_default().is_valid()) {
|
||||
List<StringName> theme_types;
|
||||
Theme::get_project_default()->get_type_dependencies(get_class_name(), StringName(), &theme_types);
|
||||
|
||||
for (const StringName &E : theme_types) {
|
||||
if (Theme::get_project_default()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
|
||||
return Theme::get_project_default()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lastly, fall back on the items defined in the default Theme, if they exist.
|
||||
{
|
||||
List<StringName> theme_types;
|
||||
Theme::get_default()->get_type_dependencies(get_class_name(), StringName(), &theme_types);
|
||||
|
||||
for (const StringName &E : theme_types) {
|
||||
if (Theme::get_default()->has_theme_item(Theme::DATA_TYPE_FONT, "font", E)) {
|
||||
return Theme::get_default()->get_theme_item(Theme::DATA_TYPE_FONT, "font", E);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If they don't exist, use any type to return the default/empty value.
|
||||
return Theme::get_default()->get_theme_item(Theme::DATA_TYPE_FONT, "font", StringName());
|
||||
}
|
||||
|
||||
void Label3D::set_font_size(int p_size) {
|
||||
if (font_size != p_size) {
|
||||
font_size = p_size;
|
||||
dirty_font = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
int Label3D::get_font_size() const {
|
||||
return font_size;
|
||||
}
|
||||
|
||||
void Label3D::set_outline_size(int p_size) {
|
||||
if (outline_size != p_size) {
|
||||
outline_size = p_size;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
int Label3D::get_outline_size() const {
|
||||
return outline_size;
|
||||
}
|
||||
|
||||
void Label3D::set_modulate(const Color &p_color) {
|
||||
if (modulate != p_color) {
|
||||
modulate = p_color;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
Color Label3D::get_modulate() const {
|
||||
return modulate;
|
||||
}
|
||||
|
||||
void Label3D::set_outline_modulate(const Color &p_color) {
|
||||
if (outline_modulate != p_color) {
|
||||
outline_modulate = p_color;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
Color Label3D::get_outline_modulate() const {
|
||||
return outline_modulate;
|
||||
}
|
||||
|
||||
void Label3D::set_autowrap_mode(Label3D::AutowrapMode p_mode) {
|
||||
if (autowrap_mode != p_mode) {
|
||||
autowrap_mode = p_mode;
|
||||
dirty_lines = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
Label3D::AutowrapMode Label3D::get_autowrap_mode() const {
|
||||
return autowrap_mode;
|
||||
}
|
||||
|
||||
void Label3D::set_width(float p_width) {
|
||||
if (width != p_width) {
|
||||
width = p_width;
|
||||
dirty_lines = true;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
float Label3D::get_width() const {
|
||||
return width;
|
||||
}
|
||||
|
||||
void Label3D::set_pixel_size(real_t p_amount) {
|
||||
if (pixel_size != p_amount) {
|
||||
pixel_size = p_amount;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
real_t Label3D::get_pixel_size() const {
|
||||
return pixel_size;
|
||||
}
|
||||
|
||||
void Label3D::set_line_spacing(float p_line_spacing) {
|
||||
if (line_spacing != p_line_spacing) {
|
||||
line_spacing = p_line_spacing;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
float Label3D::get_line_spacing() const {
|
||||
return line_spacing;
|
||||
}
|
||||
|
||||
void Label3D::set_draw_flag(DrawFlags p_flag, bool p_enable) {
|
||||
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
|
||||
if (flags[p_flag] != p_enable) {
|
||||
flags[p_flag] = p_enable;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
bool Label3D::get_draw_flag(DrawFlags p_flag) const {
|
||||
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
|
||||
return flags[p_flag];
|
||||
}
|
||||
|
||||
void Label3D::set_billboard_mode(StandardMaterial3D::BillboardMode p_mode) {
|
||||
ERR_FAIL_INDEX(p_mode, 3);
|
||||
if (billboard_mode != p_mode) {
|
||||
billboard_mode = p_mode;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
StandardMaterial3D::BillboardMode Label3D::get_billboard_mode() const {
|
||||
return billboard_mode;
|
||||
}
|
||||
|
||||
void Label3D::set_alpha_cut_mode(AlphaCutMode p_mode) {
|
||||
ERR_FAIL_INDEX(p_mode, 3);
|
||||
if (alpha_cut != p_mode) {
|
||||
alpha_cut = p_mode;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
void Label3D::set_texture_filter(StandardMaterial3D::TextureFilter p_filter) {
|
||||
if (texture_filter != p_filter) {
|
||||
texture_filter = p_filter;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
StandardMaterial3D::TextureFilter Label3D::get_texture_filter() const {
|
||||
return texture_filter;
|
||||
}
|
||||
|
||||
Label3D::AlphaCutMode Label3D::get_alpha_cut_mode() const {
|
||||
return alpha_cut;
|
||||
}
|
||||
|
||||
void Label3D::set_alpha_scissor_threshold(float p_threshold) {
|
||||
if (alpha_scissor_threshold != p_threshold) {
|
||||
alpha_scissor_threshold = p_threshold;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
float Label3D::get_alpha_scissor_threshold() const {
|
||||
return alpha_scissor_threshold;
|
||||
}
|
||||
|
||||
Label3D::Label3D() {
|
||||
for (int i = 0; i < FLAG_MAX; i++) {
|
||||
flags[i] = (i == FLAG_DOUBLE_SIDED);
|
||||
}
|
||||
|
||||
text_rid = TS->create_shaped_text();
|
||||
|
||||
mesh = RenderingServer::get_singleton()->mesh_create();
|
||||
|
||||
set_cast_shadows_setting(SHADOW_CASTING_SETTING_OFF);
|
||||
set_base(mesh);
|
||||
}
|
||||
|
||||
Label3D::~Label3D() {
|
||||
for (int i = 0; i < lines_rid.size(); i++) {
|
||||
TS->free_rid(lines_rid[i]);
|
||||
}
|
||||
lines_rid.clear();
|
||||
|
||||
TS->free_rid(text_rid);
|
||||
|
||||
RenderingServer::get_singleton()->free(mesh);
|
||||
for (Map<uint64_t, SurfaceData>::Element *E = surfaces.front(); E; E = E->next()) {
|
||||
RenderingServer::get_singleton()->free(E->get().material);
|
||||
}
|
||||
surfaces.clear();
|
||||
}
|
228
scene/3d/label_3d.h
Normal file
228
scene/3d/label_3d.h
Normal file
|
@ -0,0 +1,228 @@
|
|||
/*************************************************************************/
|
||||
/* label_3d.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef LABEL_3D_H
|
||||
#define LABEL_3D_H
|
||||
|
||||
#include "scene/3d/visual_instance_3d.h"
|
||||
#include "scene/resources/font.h"
|
||||
|
||||
#include "servers/text_server.h"
|
||||
|
||||
class Label3D : public GeometryInstance3D {
|
||||
GDCLASS(Label3D, GeometryInstance3D);
|
||||
|
||||
public:
|
||||
enum DrawFlags {
|
||||
FLAG_SHADED,
|
||||
FLAG_DOUBLE_SIDED,
|
||||
FLAG_DISABLE_DEPTH_TEST,
|
||||
FLAG_FIXED_SIZE,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
enum AlphaCutMode {
|
||||
ALPHA_CUT_DISABLED,
|
||||
ALPHA_CUT_DISCARD,
|
||||
ALPHA_CUT_OPAQUE_PREPASS
|
||||
};
|
||||
|
||||
enum AutowrapMode {
|
||||
AUTOWRAP_OFF,
|
||||
AUTOWRAP_ARBITRARY,
|
||||
AUTOWRAP_WORD,
|
||||
AUTOWRAP_WORD_SMART
|
||||
};
|
||||
|
||||
private:
|
||||
real_t pixel_size = 0.01;
|
||||
bool flags[FLAG_MAX] = {};
|
||||
AlphaCutMode alpha_cut = ALPHA_CUT_DISABLED;
|
||||
float alpha_scissor_threshold = 0.5;
|
||||
|
||||
AABB aabb;
|
||||
|
||||
mutable Ref<TriangleMesh> triangle_mesh;
|
||||
RID mesh;
|
||||
struct SurfaceData {
|
||||
PackedVector3Array mesh_vertices;
|
||||
PackedVector3Array mesh_normals;
|
||||
PackedFloat32Array mesh_tangents;
|
||||
PackedColorArray mesh_colors;
|
||||
PackedVector2Array mesh_uvs;
|
||||
PackedInt32Array indices;
|
||||
int offset = 0;
|
||||
float z_shift = 0.0;
|
||||
RID material;
|
||||
};
|
||||
|
||||
Map<uint64_t, SurfaceData> surfaces;
|
||||
|
||||
HorizontalAlignment horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER;
|
||||
VerticalAlignment vertical_alignment = VERTICAL_ALIGNMENT_CENTER;
|
||||
String text;
|
||||
String xl_text;
|
||||
bool uppercase = false;
|
||||
|
||||
AutowrapMode autowrap_mode = AUTOWRAP_OFF;
|
||||
float width = 500.0;
|
||||
|
||||
int font_size = 16;
|
||||
Ref<Font> font_override;
|
||||
Color modulate = Color(1, 1, 1, 1);
|
||||
|
||||
int outline_size = 0;
|
||||
Color outline_modulate = Color(0, 0, 0, 1);
|
||||
|
||||
float line_spacing = 0.f;
|
||||
|
||||
Dictionary opentype_features;
|
||||
String language;
|
||||
TextServer::Direction text_direction = TextServer::DIRECTION_AUTO;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
Array st_args;
|
||||
|
||||
RID text_rid;
|
||||
Vector<RID> lines_rid;
|
||||
|
||||
RID base_material;
|
||||
StandardMaterial3D::BillboardMode billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED;
|
||||
StandardMaterial3D::TextureFilter texture_filter = StandardMaterial3D::TEXTURE_FILTER_LINEAR_WITH_MIPMAPS;
|
||||
|
||||
bool pending_update = false;
|
||||
|
||||
bool dirty_lines = true;
|
||||
bool dirty_font = true;
|
||||
bool dirty_text = true;
|
||||
|
||||
void _generate_glyph_surfaces(const Glyph &p_glyph, Vector2 &r_offset, const Color &p_modulate, int p_priority = 0, int p_outline_size = 0);
|
||||
|
||||
protected:
|
||||
GDVIRTUAL2RC(Array, _structured_text_parser, Array, String)
|
||||
|
||||
void _notification(int p_what);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
void _validate_property(PropertyInfo &property) const override;
|
||||
|
||||
void _im_update();
|
||||
void _font_changed();
|
||||
void _queue_update();
|
||||
|
||||
void _shape();
|
||||
|
||||
public:
|
||||
void set_horizontal_alignment(HorizontalAlignment p_alignment);
|
||||
HorizontalAlignment get_horizontal_alignment() const;
|
||||
|
||||
void set_vertical_alignment(VerticalAlignment p_alignment);
|
||||
VerticalAlignment get_vertical_alignment() const;
|
||||
|
||||
void set_text(const String &p_string);
|
||||
String get_text() const;
|
||||
|
||||
void set_text_direction(TextServer::Direction p_text_direction);
|
||||
TextServer::Direction get_text_direction() const;
|
||||
|
||||
void set_opentype_feature(const String &p_name, int p_value);
|
||||
int get_opentype_feature(const String &p_name) const;
|
||||
void clear_opentype_features();
|
||||
|
||||
void set_language(const String &p_language);
|
||||
String get_language() const;
|
||||
|
||||
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser);
|
||||
TextServer::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
|
||||
void set_structured_text_bidi_override_options(Array p_args);
|
||||
Array get_structured_text_bidi_override_options() const;
|
||||
|
||||
void set_uppercase(bool p_uppercase);
|
||||
bool is_uppercase() const;
|
||||
|
||||
void set_font(const Ref<Font> &p_font);
|
||||
Ref<Font> get_font() const;
|
||||
Ref<Font> _get_font_or_default() const;
|
||||
|
||||
void set_font_size(int p_size);
|
||||
int get_font_size() const;
|
||||
|
||||
void set_outline_size(int p_size);
|
||||
int get_outline_size() const;
|
||||
|
||||
void set_line_spacing(float p_size);
|
||||
float get_line_spacing() const;
|
||||
|
||||
void set_modulate(const Color &p_color);
|
||||
Color get_modulate() const;
|
||||
|
||||
void set_outline_modulate(const Color &p_color);
|
||||
Color get_outline_modulate() const;
|
||||
|
||||
void set_autowrap_mode(AutowrapMode p_mode);
|
||||
AutowrapMode get_autowrap_mode() const;
|
||||
|
||||
void set_width(float p_width);
|
||||
float get_width() const;
|
||||
|
||||
void set_pixel_size(real_t p_amount);
|
||||
real_t get_pixel_size() const;
|
||||
|
||||
void set_draw_flag(DrawFlags p_flag, bool p_enable);
|
||||
bool get_draw_flag(DrawFlags p_flag) const;
|
||||
|
||||
void set_alpha_cut_mode(AlphaCutMode p_mode);
|
||||
AlphaCutMode get_alpha_cut_mode() const;
|
||||
|
||||
void set_alpha_scissor_threshold(float p_threshold);
|
||||
float get_alpha_scissor_threshold() const;
|
||||
|
||||
void set_billboard_mode(StandardMaterial3D::BillboardMode p_mode);
|
||||
StandardMaterial3D::BillboardMode get_billboard_mode() const;
|
||||
|
||||
void set_texture_filter(StandardMaterial3D::TextureFilter p_filter);
|
||||
StandardMaterial3D::TextureFilter get_texture_filter() const;
|
||||
|
||||
virtual AABB get_aabb() const override;
|
||||
Ref<TriangleMesh> generate_triangle_mesh() const;
|
||||
|
||||
Label3D();
|
||||
~Label3D();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Label3D::AutowrapMode);
|
||||
VARIANT_ENUM_CAST(Label3D::DrawFlags);
|
||||
VARIANT_ENUM_CAST(Label3D::AlphaCutMode);
|
||||
|
||||
#endif // LABEL_3D_H
|
|
@ -268,6 +268,17 @@ StandardMaterial3D::BillboardMode SpriteBase3D::get_billboard_mode() const {
|
|||
return billboard_mode;
|
||||
}
|
||||
|
||||
void SpriteBase3D::set_texture_filter(StandardMaterial3D::TextureFilter p_filter) {
|
||||
if (texture_filter != p_filter) {
|
||||
texture_filter = p_filter;
|
||||
_queue_update();
|
||||
}
|
||||
}
|
||||
|
||||
StandardMaterial3D::TextureFilter SpriteBase3D::get_texture_filter() const {
|
||||
return texture_filter;
|
||||
}
|
||||
|
||||
void SpriteBase3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_centered", "centered"), &SpriteBase3D::set_centered);
|
||||
ClassDB::bind_method(D_METHOD("is_centered"), &SpriteBase3D::is_centered);
|
||||
|
@ -299,6 +310,9 @@ void SpriteBase3D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &SpriteBase3D::set_billboard_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_billboard_mode"), &SpriteBase3D::get_billboard_mode);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_texture_filter", "mode"), &SpriteBase3D::set_texture_filter);
|
||||
ClassDB::bind_method(D_METHOD("get_texture_filter"), &SpriteBase3D::get_texture_filter);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_rect"), &SpriteBase3D::get_item_rect);
|
||||
ClassDB::bind_method(D_METHOD("generate_triangle_mesh"), &SpriteBase3D::generate_triangle_mesh);
|
||||
|
||||
|
@ -317,11 +331,16 @@ void SpriteBase3D::_bind_methods() {
|
|||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transparent"), "set_draw_flag", "get_draw_flag", FLAG_TRANSPARENT);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "shaded"), "set_draw_flag", "get_draw_flag", FLAG_SHADED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "double_sided"), "set_draw_flag", "get_draw_flag", FLAG_DOUBLE_SIDED);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "no_depth_test"), "set_draw_flag", "get_draw_flag", FLAG_DISABLE_DEPTH_TEST);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_size"), "set_draw_flag", "get_draw_flag", FLAG_FIXED_SIZE);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "alpha_cut", PROPERTY_HINT_ENUM, "Disabled,Discard,Opaque Pre-Pass"), "set_alpha_cut_mode", "get_alpha_cut_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,Nearest Mipmap,Linear Mipmap,Nearest Mipmap Anisotropic,Linear Mipmap Anisotropic"), "set_texture_filter", "get_texture_filter");
|
||||
|
||||
BIND_ENUM_CONSTANT(FLAG_TRANSPARENT);
|
||||
BIND_ENUM_CONSTANT(FLAG_SHADED);
|
||||
BIND_ENUM_CONSTANT(FLAG_DOUBLE_SIDED);
|
||||
BIND_ENUM_CONSTANT(FLAG_DISABLE_DEPTH_TEST);
|
||||
BIND_ENUM_CONSTANT(FLAG_FIXED_SIZE);
|
||||
BIND_ENUM_CONSTANT(FLAG_MAX);
|
||||
|
||||
BIND_ENUM_CONSTANT(ALPHA_CUT_DISABLED);
|
||||
|
@ -586,7 +605,7 @@ void Sprite3D::_draw() {
|
|||
set_aabb(aabb);
|
||||
|
||||
RID shader_rid;
|
||||
StandardMaterial3D::get_material_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y, &shader_rid);
|
||||
StandardMaterial3D::get_material_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y, false, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE), get_texture_filter(), &shader_rid);
|
||||
if (last_shader != shader_rid) {
|
||||
RS::get_singleton()->material_set_shader(get_material(), shader_rid);
|
||||
last_shader = shader_rid;
|
||||
|
@ -948,7 +967,7 @@ void AnimatedSprite3D::_draw() {
|
|||
set_aabb(aabb);
|
||||
|
||||
RID shader_rid;
|
||||
StandardMaterial3D::get_material_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y, &shader_rid);
|
||||
StandardMaterial3D::get_material_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y, false, get_draw_flag(FLAG_DISABLE_DEPTH_TEST), get_draw_flag(FLAG_FIXED_SIZE), get_texture_filter(), &shader_rid);
|
||||
if (last_shader != shader_rid) {
|
||||
RS::get_singleton()->material_set_shader(get_material(), shader_rid);
|
||||
last_shader = shader_rid;
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
FLAG_TRANSPARENT,
|
||||
FLAG_SHADED,
|
||||
FLAG_DOUBLE_SIDED,
|
||||
FLAG_DISABLE_DEPTH_TEST,
|
||||
FLAG_FIXED_SIZE,
|
||||
FLAG_MAX
|
||||
|
||||
};
|
||||
|
@ -80,6 +82,7 @@ private:
|
|||
bool flags[FLAG_MAX] = {};
|
||||
AlphaCutMode alpha_cut = ALPHA_CUT_DISABLED;
|
||||
StandardMaterial3D::BillboardMode billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED;
|
||||
StandardMaterial3D::TextureFilter texture_filter = StandardMaterial3D::TEXTURE_FILTER_LINEAR_WITH_MIPMAPS;
|
||||
bool pending_update = false;
|
||||
void _im_update();
|
||||
|
||||
|
@ -131,9 +134,13 @@ public:
|
|||
|
||||
void set_alpha_cut_mode(AlphaCutMode p_mode);
|
||||
AlphaCutMode get_alpha_cut_mode() const;
|
||||
|
||||
void set_billboard_mode(StandardMaterial3D::BillboardMode p_mode);
|
||||
StandardMaterial3D::BillboardMode get_billboard_mode() const;
|
||||
|
||||
void set_texture_filter(StandardMaterial3D::TextureFilter p_filter);
|
||||
StandardMaterial3D::TextureFilter get_texture_filter() const;
|
||||
|
||||
virtual Rect2 get_item_rect() const = 0;
|
||||
|
||||
virtual AABB get_aabb() const override;
|
||||
|
|
|
@ -2946,90 +2946,17 @@ bool Control::is_text_field() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
Array Control::structured_text_parser(StructuredTextParser p_theme_type, const Array &p_args, const String &p_text) const {
|
||||
Array ret;
|
||||
switch (p_theme_type) {
|
||||
case STRUCTURED_TEXT_URI: {
|
||||
int prev = 0;
|
||||
for (int i = 0; i < p_text.length(); i++) {
|
||||
if ((p_text[i] == '\\') || (p_text[i] == '/') || (p_text[i] == '.') || (p_text[i] == ':') || (p_text[i] == '&') || (p_text[i] == '=') || (p_text[i] == '@') || (p_text[i] == '?') || (p_text[i] == '#')) {
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
}
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
}
|
||||
}
|
||||
if (prev != p_text.length()) {
|
||||
ret.push_back(Vector2i(prev, p_text.length()));
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_FILE: {
|
||||
int prev = 0;
|
||||
for (int i = 0; i < p_text.length(); i++) {
|
||||
if ((p_text[i] == '\\') || (p_text[i] == '/') || (p_text[i] == ':')) {
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
}
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
}
|
||||
}
|
||||
if (prev != p_text.length()) {
|
||||
ret.push_back(Vector2i(prev, p_text.length()));
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_EMAIL: {
|
||||
bool local = true;
|
||||
int prev = 0;
|
||||
for (int i = 0; i < p_text.length(); i++) {
|
||||
if ((p_text[i] == '@') && local) { // Add full "local" as single context.
|
||||
local = false;
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
} else if (!local & (p_text[i] == '.')) { // Add each dot separated "domain" part as context.
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
}
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
}
|
||||
}
|
||||
if (prev != p_text.length()) {
|
||||
ret.push_back(Vector2i(prev, p_text.length()));
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_LIST: {
|
||||
if (p_args.size() == 1 && p_args[0].get_type() == Variant::STRING) {
|
||||
Vector<String> tags = p_text.split(String(p_args[0]));
|
||||
int prev = 0;
|
||||
for (int i = 0; i < tags.size(); i++) {
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, prev + tags[i].length()));
|
||||
}
|
||||
ret.push_back(Vector2i(prev + tags[i].length(), prev + tags[i].length() + 1));
|
||||
prev = prev + tags[i].length() + 1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_CUSTOM: {
|
||||
Array r;
|
||||
if (GDVIRTUAL_CALL(_structured_text_parser, p_args, p_text, r)) {
|
||||
for (int i = 0; i < r.size(); i++) {
|
||||
if (r[i].get_type() == Variant::VECTOR2I) {
|
||||
ret.push_back(Vector2i(r[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_NONE:
|
||||
case STRUCTURED_TEXT_DEFAULT:
|
||||
default: {
|
||||
ret.push_back(Vector2i(0, p_text.length()));
|
||||
Array Control::structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {
|
||||
if (p_parser_type == TextServer::STRUCTURED_TEXT_CUSTOM) {
|
||||
Array ret;
|
||||
if (GDVIRTUAL_CALL(_structured_text_parser, p_args, p_text, ret)) {
|
||||
return ret;
|
||||
} else {
|
||||
return Array();
|
||||
}
|
||||
} else {
|
||||
return TS->parse_structured_text(p_parser_type, p_args, p_text);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Control::set_rotation(real_t p_radians) {
|
||||
|
@ -3491,14 +3418,6 @@ void Control::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(TEXT_DIRECTION_LTR);
|
||||
BIND_ENUM_CONSTANT(TEXT_DIRECTION_RTL);
|
||||
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_DEFAULT);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_URI);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_FILE);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_EMAIL);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_LIST);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_NONE);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_CUSTOM);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("resized"));
|
||||
ADD_SIGNAL(MethodInfo("gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
|
||||
ADD_SIGNAL(MethodInfo("mouse_entered"));
|
||||
|
|
|
@ -147,16 +147,6 @@ public:
|
|||
TEXT_DIRECTION_INHERITED,
|
||||
};
|
||||
|
||||
enum StructuredTextParser {
|
||||
STRUCTURED_TEXT_DEFAULT,
|
||||
STRUCTURED_TEXT_URI,
|
||||
STRUCTURED_TEXT_FILE,
|
||||
STRUCTURED_TEXT_EMAIL,
|
||||
STRUCTURED_TEXT_LIST,
|
||||
STRUCTURED_TEXT_NONE,
|
||||
STRUCTURED_TEXT_CUSTOM
|
||||
};
|
||||
|
||||
private:
|
||||
struct CComparator {
|
||||
bool operator()(const Control *p_a, const Control *p_b) const {
|
||||
|
@ -290,7 +280,7 @@ protected:
|
|||
|
||||
//virtual void _window_gui_input(InputEvent p_event);
|
||||
|
||||
virtual Array structured_text_parser(StructuredTextParser p_theme_type, const Array &p_args, const String &p_text) const;
|
||||
virtual Array structured_text_parser(TextServer::StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
|
||||
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
|
@ -579,6 +569,5 @@ VARIANT_ENUM_CAST(Control::Anchor);
|
|||
VARIANT_ENUM_CAST(Control::LayoutMode);
|
||||
VARIANT_ENUM_CAST(Control::LayoutDirection);
|
||||
VARIANT_ENUM_CAST(Control::TextDirection);
|
||||
VARIANT_ENUM_CAST(Control::StructuredTextParser);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -988,7 +988,7 @@ FileDialog::FileDialog() {
|
|||
hbc->add_child(drives);
|
||||
|
||||
dir = memnew(LineEdit);
|
||||
dir->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
dir->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
hbc->add_child(dir);
|
||||
dir->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
||||
|
@ -1029,7 +1029,7 @@ FileDialog::FileDialog() {
|
|||
file_box = memnew(HBoxContainer);
|
||||
file_box->add_child(memnew(Label(TTRC("File:"))));
|
||||
file = memnew(LineEdit);
|
||||
file->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
file->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
file->set_stretch_ratio(4);
|
||||
file->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
file_box->add_child(file);
|
||||
|
@ -1063,7 +1063,7 @@ FileDialog::FileDialog() {
|
|||
makedialog->add_child(makevb);
|
||||
|
||||
makedirname = memnew(LineEdit);
|
||||
makedirname->set_structured_text_bidi_override(Control::STRUCTURED_TEXT_FILE);
|
||||
makedirname->set_structured_text_bidi_override(TextServer::STRUCTURED_TEXT_FILE);
|
||||
makevb->add_margin_child(TTRC("Name:"), makedirname);
|
||||
add_child(makedialog, false, INTERNAL_MODE_FRONT);
|
||||
makedialog->register_text_enter(makedirname);
|
||||
|
|
|
@ -648,21 +648,21 @@ void Label::set_text_direction(Control::TextDirection p_text_direction) {
|
|||
}
|
||||
}
|
||||
|
||||
void Label::set_structured_text_bidi_override(Control::StructuredTextParser p_parser) {
|
||||
void Label::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
||||
if (st_parser != p_parser) {
|
||||
st_parser = p_parser;
|
||||
font_dirty = true;
|
||||
dirty = true;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
Control::StructuredTextParser Label::get_structured_text_bidi_override() const {
|
||||
TextServer::StructuredTextParser Label::get_structured_text_bidi_override() const {
|
||||
return st_parser;
|
||||
}
|
||||
|
||||
void Label::set_structured_text_bidi_override_options(Array p_args) {
|
||||
st_args = p_args;
|
||||
font_dirty = true;
|
||||
dirty = true;
|
||||
update();
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ private:
|
|||
Dictionary opentype_features;
|
||||
String language;
|
||||
TextDirection text_direction = TEXT_DIRECTION_AUTO;
|
||||
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
Array st_args;
|
||||
|
||||
float percent_visible = 1.0;
|
||||
|
@ -124,8 +124,8 @@ public:
|
|||
void set_language(const String &p_language);
|
||||
String get_language() const;
|
||||
|
||||
void set_structured_text_bidi_override(Control::StructuredTextParser p_parser);
|
||||
Control::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser);
|
||||
TextServer::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
|
||||
void set_structured_text_bidi_override_options(Array p_args);
|
||||
Array get_structured_text_bidi_override_options() const;
|
||||
|
|
|
@ -1452,7 +1452,7 @@ bool LineEdit::get_draw_control_chars() const {
|
|||
return draw_control_chars;
|
||||
}
|
||||
|
||||
void LineEdit::set_structured_text_bidi_override(Control::StructuredTextParser p_parser) {
|
||||
void LineEdit::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
||||
if (st_parser != p_parser) {
|
||||
st_parser = p_parser;
|
||||
_shape();
|
||||
|
@ -1460,7 +1460,7 @@ void LineEdit::set_structured_text_bidi_override(Control::StructuredTextParser p
|
|||
}
|
||||
}
|
||||
|
||||
Control::StructuredTextParser LineEdit::get_structured_text_bidi_override() const {
|
||||
TextServer::StructuredTextParser LineEdit::get_structured_text_bidi_override() const {
|
||||
return st_parser;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ private:
|
|||
String language;
|
||||
TextDirection text_direction = TEXT_DIRECTION_AUTO;
|
||||
TextDirection input_direction = TEXT_DIRECTION_LTR;
|
||||
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
Array st_args;
|
||||
bool draw_control_chars = false;
|
||||
|
||||
|
@ -253,8 +253,8 @@ public:
|
|||
void set_draw_control_chars(bool p_draw_control_chars);
|
||||
bool get_draw_control_chars() const;
|
||||
|
||||
void set_structured_text_bidi_override(Control::StructuredTextParser p_parser);
|
||||
Control::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser);
|
||||
TextServer::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
|
||||
void set_structured_text_bidi_override_options(Array p_args);
|
||||
Array get_structured_text_bidi_override_options() const;
|
||||
|
|
|
@ -61,7 +61,7 @@ String LinkButton::get_text() const {
|
|||
return text;
|
||||
}
|
||||
|
||||
void LinkButton::set_structured_text_bidi_override(Control::StructuredTextParser p_parser) {
|
||||
void LinkButton::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
||||
if (st_parser != p_parser) {
|
||||
st_parser = p_parser;
|
||||
_shape();
|
||||
|
@ -69,7 +69,7 @@ void LinkButton::set_structured_text_bidi_override(Control::StructuredTextParser
|
|||
}
|
||||
}
|
||||
|
||||
Control::StructuredTextParser LinkButton::get_structured_text_bidi_override() const {
|
||||
TextServer::StructuredTextParser LinkButton::get_structured_text_bidi_override() const {
|
||||
return st_parser;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ private:
|
|||
Dictionary opentype_features;
|
||||
String language;
|
||||
TextDirection text_direction = TEXT_DIRECTION_AUTO;
|
||||
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
Array st_args;
|
||||
|
||||
void _shape();
|
||||
|
@ -71,8 +71,8 @@ public:
|
|||
void set_text(const String &p_text);
|
||||
String get_text() const;
|
||||
|
||||
void set_structured_text_bidi_override(Control::StructuredTextParser p_parser);
|
||||
Control::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser);
|
||||
TextServer::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
|
||||
void set_structured_text_bidi_override_options(Array p_args);
|
||||
Array get_structured_text_bidi_override_options() const;
|
||||
|
|
|
@ -2248,7 +2248,7 @@ TextServer::Direction RichTextLabel::_find_direction(Item *p_item) {
|
|||
}
|
||||
}
|
||||
|
||||
Control::StructuredTextParser RichTextLabel::_find_stt(Item *p_item) {
|
||||
TextServer::StructuredTextParser RichTextLabel::_find_stt(Item *p_item) {
|
||||
Item *item = p_item;
|
||||
|
||||
while (item) {
|
||||
|
@ -2838,7 +2838,7 @@ void RichTextLabel::push_strikethrough() {
|
|||
_add_item(item, true);
|
||||
}
|
||||
|
||||
void RichTextLabel::push_paragraph(HorizontalAlignment p_alignment, Control::TextDirection p_direction, const String &p_language, Control::StructuredTextParser p_st_parser) {
|
||||
void RichTextLabel::push_paragraph(HorizontalAlignment p_alignment, Control::TextDirection p_direction, const String &p_language, TextServer::StructuredTextParser p_st_parser) {
|
||||
ERR_FAIL_COND(current->type == ITEM_TABLE);
|
||||
|
||||
ItemParagraph *item = memnew(ItemParagraph);
|
||||
|
@ -3463,7 +3463,7 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|||
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
||||
Control::TextDirection dir = Control::TEXT_DIRECTION_INHERITED;
|
||||
String lang;
|
||||
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
for (int i = 0; i < subtag.size(); i++) {
|
||||
Vector<String> subtag_a = subtag[i].split("=");
|
||||
if (subtag_a.size() == 2) {
|
||||
|
@ -3489,19 +3489,19 @@ void RichTextLabel::append_text(const String &p_bbcode) {
|
|||
lang = subtag_a[1];
|
||||
} else if (subtag_a[0] == "st" || subtag_a[0] == "bidi_override") {
|
||||
if (subtag_a[1] == "d" || subtag_a[1] == "default") {
|
||||
st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
} else if (subtag_a[1] == "u" || subtag_a[1] == "uri") {
|
||||
st_parser = STRUCTURED_TEXT_URI;
|
||||
st_parser = TextServer::STRUCTURED_TEXT_URI;
|
||||
} else if (subtag_a[1] == "f" || subtag_a[1] == "file") {
|
||||
st_parser = STRUCTURED_TEXT_FILE;
|
||||
st_parser = TextServer::STRUCTURED_TEXT_FILE;
|
||||
} else if (subtag_a[1] == "e" || subtag_a[1] == "email") {
|
||||
st_parser = STRUCTURED_TEXT_EMAIL;
|
||||
st_parser = TextServer::STRUCTURED_TEXT_EMAIL;
|
||||
} else if (subtag_a[1] == "l" || subtag_a[1] == "list") {
|
||||
st_parser = STRUCTURED_TEXT_LIST;
|
||||
st_parser = TextServer::STRUCTURED_TEXT_LIST;
|
||||
} else if (subtag_a[1] == "n" || subtag_a[1] == "none") {
|
||||
st_parser = STRUCTURED_TEXT_NONE;
|
||||
st_parser = TextServer::STRUCTURED_TEXT_NONE;
|
||||
} else if (subtag_a[1] == "c" || subtag_a[1] == "custom") {
|
||||
st_parser = STRUCTURED_TEXT_CUSTOM;
|
||||
st_parser = TextServer::STRUCTURED_TEXT_CUSTOM;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4376,7 +4376,7 @@ void RichTextLabel::set_text_direction(Control::TextDirection p_text_direction)
|
|||
}
|
||||
}
|
||||
|
||||
void RichTextLabel::set_structured_text_bidi_override(Control::StructuredTextParser p_parser) {
|
||||
void RichTextLabel::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
||||
if (st_parser != p_parser) {
|
||||
st_parser = p_parser;
|
||||
main->first_invalid_line = 0; //invalidate ALL
|
||||
|
@ -4385,7 +4385,7 @@ void RichTextLabel::set_structured_text_bidi_override(Control::StructuredTextPar
|
|||
}
|
||||
}
|
||||
|
||||
Control::StructuredTextParser RichTextLabel::get_structured_text_bidi_override() const {
|
||||
TextServer::StructuredTextParser RichTextLabel::get_structured_text_bidi_override() const {
|
||||
return st_parser;
|
||||
}
|
||||
|
||||
|
@ -4520,7 +4520,7 @@ void RichTextLabel::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("push_color", "color"), &RichTextLabel::push_color);
|
||||
ClassDB::bind_method(D_METHOD("push_outline_size", "outline_size"), &RichTextLabel::push_outline_size);
|
||||
ClassDB::bind_method(D_METHOD("push_outline_color", "color"), &RichTextLabel::push_outline_color);
|
||||
ClassDB::bind_method(D_METHOD("push_paragraph", "alignment", "base_direction", "language", "st_parser"), &RichTextLabel::push_paragraph, DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(""), DEFVAL(STRUCTURED_TEXT_DEFAULT));
|
||||
ClassDB::bind_method(D_METHOD("push_paragraph", "alignment", "base_direction", "language", "st_parser"), &RichTextLabel::push_paragraph, DEFVAL(TextServer::DIRECTION_AUTO), DEFVAL(""), DEFVAL(TextServer::STRUCTURED_TEXT_DEFAULT));
|
||||
ClassDB::bind_method(D_METHOD("push_indent", "level"), &RichTextLabel::push_indent);
|
||||
ClassDB::bind_method(D_METHOD("push_list", "level", "type", "capitalize"), &RichTextLabel::push_list);
|
||||
ClassDB::bind_method(D_METHOD("push_meta", "data"), &RichTextLabel::push_meta);
|
||||
|
|
|
@ -234,7 +234,7 @@ private:
|
|||
HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT;
|
||||
String language;
|
||||
Control::TextDirection direction = Control::TEXT_DIRECTION_AUTO;
|
||||
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
ItemParagraph() { type = ITEM_PARAGRAPH; }
|
||||
};
|
||||
|
||||
|
@ -399,7 +399,7 @@ private:
|
|||
|
||||
String language;
|
||||
TextDirection text_direction = TEXT_DIRECTION_AUTO;
|
||||
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
Array st_args;
|
||||
|
||||
struct Selection {
|
||||
|
@ -467,7 +467,7 @@ private:
|
|||
int _find_margin(Item *p_item, const Ref<Font> &p_base_font, int p_base_font_size);
|
||||
HorizontalAlignment _find_alignment(Item *p_item);
|
||||
TextServer::Direction _find_direction(Item *p_item);
|
||||
Control::StructuredTextParser _find_stt(Item *p_item);
|
||||
TextServer::StructuredTextParser _find_stt(Item *p_item);
|
||||
String _find_language(Item *p_item);
|
||||
Color _find_color(Item *p_item, const Color &p_default_color);
|
||||
Color _find_outline_color(Item *p_item, const Color &p_default_color);
|
||||
|
@ -525,7 +525,7 @@ public:
|
|||
void push_outline_color(const Color &p_color);
|
||||
void push_underline();
|
||||
void push_strikethrough();
|
||||
void push_paragraph(HorizontalAlignment p_alignment, Control::TextDirection p_direction = Control::TEXT_DIRECTION_INHERITED, const String &p_language = "", Control::StructuredTextParser p_st_parser = STRUCTURED_TEXT_DEFAULT);
|
||||
void push_paragraph(HorizontalAlignment p_alignment, Control::TextDirection p_direction = Control::TEXT_DIRECTION_INHERITED, const String &p_language = "", TextServer::StructuredTextParser p_st_parser = TextServer::STRUCTURED_TEXT_DEFAULT);
|
||||
void push_indent(int p_level);
|
||||
void push_list(int p_level, ListType p_list, bool p_capitalize);
|
||||
void push_meta(const Variant &p_meta);
|
||||
|
@ -633,8 +633,8 @@ public:
|
|||
void set_autowrap_mode(AutowrapMode p_mode);
|
||||
AutowrapMode get_autowrap_mode() const;
|
||||
|
||||
void set_structured_text_bidi_override(Control::StructuredTextParser p_parser);
|
||||
Control::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser);
|
||||
TextServer::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
|
||||
void set_structured_text_bidi_override_options(Array p_args);
|
||||
Array get_structured_text_bidi_override_options() const;
|
||||
|
|
|
@ -2859,7 +2859,7 @@ String TextEdit::get_language() const {
|
|||
return language;
|
||||
}
|
||||
|
||||
void TextEdit::set_structured_text_bidi_override(Control::StructuredTextParser p_parser) {
|
||||
void TextEdit::set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser) {
|
||||
if (st_parser != p_parser) {
|
||||
st_parser = p_parser;
|
||||
for (int i = 0; i < text.size(); i++) {
|
||||
|
@ -2869,7 +2869,7 @@ void TextEdit::set_structured_text_bidi_override(Control::StructuredTextParser p
|
|||
}
|
||||
}
|
||||
|
||||
Control::StructuredTextParser TextEdit::get_structured_text_bidi_override() const {
|
||||
TextServer::StructuredTextParser TextEdit::get_structured_text_bidi_override() const {
|
||||
return st_parser;
|
||||
}
|
||||
|
||||
|
|
|
@ -271,7 +271,7 @@ private:
|
|||
Dictionary opentype_features;
|
||||
String language = "";
|
||||
|
||||
Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
Array st_args;
|
||||
|
||||
void _clear();
|
||||
|
@ -651,8 +651,8 @@ public:
|
|||
void set_language(const String &p_language);
|
||||
String get_language() const;
|
||||
|
||||
void set_structured_text_bidi_override(Control::StructuredTextParser p_parser);
|
||||
Control::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser);
|
||||
TextServer::StructuredTextParser get_structured_text_bidi_override() const;
|
||||
void set_structured_text_bidi_override_options(Array p_args);
|
||||
Array get_structured_text_bidi_override_options() const;
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ int TreeItem::get_opentype_feature(int p_column, const String &p_name) const {
|
|||
return cells[p_column].opentype_features[tag];
|
||||
}
|
||||
|
||||
void TreeItem::set_structured_text_bidi_override(int p_column, Control::StructuredTextParser p_parser) {
|
||||
void TreeItem::set_structured_text_bidi_override(int p_column, TextServer::StructuredTextParser p_parser) {
|
||||
ERR_FAIL_INDEX(p_column, cells.size());
|
||||
|
||||
if (cells[p_column].st_parser != p_parser) {
|
||||
|
@ -346,8 +346,8 @@ void TreeItem::set_structured_text_bidi_override(int p_column, Control::Structur
|
|||
}
|
||||
}
|
||||
|
||||
Control::StructuredTextParser TreeItem::get_structured_text_bidi_override(int p_column) const {
|
||||
ERR_FAIL_INDEX_V(p_column, cells.size(), Control::STRUCTURED_TEXT_NONE);
|
||||
TextServer::StructuredTextParser TreeItem::get_structured_text_bidi_override(int p_column) const {
|
||||
ERR_FAIL_INDEX_V(p_column, cells.size(), TextServer::STRUCTURED_TEXT_NONE);
|
||||
return cells[p_column].st_parser;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ private:
|
|||
Ref<TextLine> text_buf;
|
||||
Dictionary opentype_features;
|
||||
String language;
|
||||
Control::StructuredTextParser st_parser = Control::STRUCTURED_TEXT_DEFAULT;
|
||||
TextServer::StructuredTextParser st_parser = TextServer::STRUCTURED_TEXT_DEFAULT;
|
||||
Array st_args;
|
||||
Control::TextDirection text_direction = Control::TEXT_DIRECTION_INHERITED;
|
||||
bool dirty = true;
|
||||
|
@ -220,8 +220,8 @@ public:
|
|||
int get_opentype_feature(int p_column, const String &p_name) const;
|
||||
void clear_opentype_features(int p_column);
|
||||
|
||||
void set_structured_text_bidi_override(int p_column, Control::StructuredTextParser p_parser);
|
||||
Control::StructuredTextParser get_structured_text_bidi_override(int p_column) const;
|
||||
void set_structured_text_bidi_override(int p_column, TextServer::StructuredTextParser p_parser);
|
||||
TextServer::StructuredTextParser get_structured_text_bidi_override(int p_column) const;
|
||||
|
||||
void set_structured_text_bidi_override_options(int p_column, Array p_args);
|
||||
Array get_structured_text_bidi_override_options(int p_column) const;
|
||||
|
|
|
@ -226,6 +226,7 @@
|
|||
#include "scene/3d/gpu_particles_collision_3d.h"
|
||||
#include "scene/3d/importer_mesh_instance_3d.h"
|
||||
#include "scene/3d/joint_3d.h"
|
||||
#include "scene/3d/label_3d.h"
|
||||
#include "scene/3d/light_3d.h"
|
||||
#include "scene/3d/lightmap_gi.h"
|
||||
#include "scene/3d/lightmap_probe.h"
|
||||
|
@ -480,6 +481,7 @@ void register_scene_types() {
|
|||
GDREGISTER_ABSTRACT_CLASS(SpriteBase3D);
|
||||
GDREGISTER_CLASS(Sprite3D);
|
||||
GDREGISTER_CLASS(AnimatedSprite3D);
|
||||
GDREGISTER_CLASS(Label3D);
|
||||
GDREGISTER_ABSTRACT_CLASS(Light3D);
|
||||
GDREGISTER_CLASS(DirectionalLight3D);
|
||||
GDREGISTER_CLASS(OmniLight3D);
|
||||
|
|
|
@ -54,6 +54,7 @@ _FORCE_INLINE_ void FontData::_ensure_rid(int p_cache_index) const {
|
|||
cache.write[p_cache_index] = TS->create_font();
|
||||
TS->font_set_data_ptr(cache[p_cache_index], data_ptr, data_size);
|
||||
TS->font_set_antialiased(cache[p_cache_index], antialiased);
|
||||
TS->font_set_generate_mipmaps(cache[p_cache_index], mipmaps);
|
||||
TS->font_set_multichannel_signed_distance_field(cache[p_cache_index], msdf);
|
||||
TS->font_set_msdf_pixel_range(cache[p_cache_index], msdf_pixel_range);
|
||||
TS->font_set_msdf_size(cache[p_cache_index], msdf_size);
|
||||
|
@ -77,6 +78,9 @@ void FontData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &FontData::set_antialiased);
|
||||
ClassDB::bind_method(D_METHOD("is_antialiased"), &FontData::is_antialiased);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_generate_mipmaps", "generate_mipmaps"), &FontData::set_generate_mipmaps);
|
||||
ClassDB::bind_method(D_METHOD("get_generate_mipmaps"), &FontData::get_generate_mipmaps);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_font_name", "name"), &FontData::set_font_name);
|
||||
ClassDB::bind_method(D_METHOD("get_font_name"), &FontData::get_font_name);
|
||||
|
||||
|
@ -212,6 +216,7 @@ void FontData::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_supported_variation_list"), &FontData::get_supported_variation_list);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_data", "get_data");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "generate_mipmaps", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_generate_mipmaps", "get_generate_mipmaps");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_antialiased", "is_antialiased");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "font_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_name", "get_font_name");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "style_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "set_font_style_name", "get_font_style_name");
|
||||
|
@ -442,6 +447,7 @@ void FontData::reset_state() {
|
|||
cache.clear();
|
||||
|
||||
antialiased = true;
|
||||
mipmaps = false;
|
||||
msdf = false;
|
||||
force_autohinter = false;
|
||||
hinting = TextServer::HINTING_LIGHT;
|
||||
|
@ -735,6 +741,7 @@ Error FontData::load_bitmap_font(const String &p_path) {
|
|||
reset_state();
|
||||
|
||||
antialiased = false;
|
||||
mipmaps = false;
|
||||
msdf = false;
|
||||
force_autohinter = false;
|
||||
hinting = TextServer::HINTING_NONE;
|
||||
|
@ -1290,6 +1297,21 @@ bool FontData::is_antialiased() const {
|
|||
return antialiased;
|
||||
}
|
||||
|
||||
void FontData::set_generate_mipmaps(bool p_generate_mipmaps) {
|
||||
if (mipmaps != p_generate_mipmaps) {
|
||||
mipmaps = p_generate_mipmaps;
|
||||
for (int i = 0; i < cache.size(); i++) {
|
||||
_ensure_rid(i);
|
||||
TS->font_set_generate_mipmaps(cache[i], mipmaps);
|
||||
}
|
||||
emit_changed();
|
||||
}
|
||||
}
|
||||
|
||||
bool FontData::get_generate_mipmaps() const {
|
||||
return mipmaps;
|
||||
}
|
||||
|
||||
void FontData::set_multichannel_signed_distance_field(bool p_msdf) {
|
||||
if (msdf != p_msdf) {
|
||||
msdf = p_msdf;
|
||||
|
|
|
@ -49,6 +49,7 @@ class FontData : public Resource {
|
|||
PackedByteArray data;
|
||||
|
||||
bool antialiased = true;
|
||||
bool mipmaps = false;
|
||||
bool msdf = false;
|
||||
int msdf_pixel_range = 16;
|
||||
int msdf_size = 48;
|
||||
|
@ -103,6 +104,9 @@ public:
|
|||
virtual void set_antialiased(bool p_antialiased);
|
||||
virtual bool is_antialiased() const;
|
||||
|
||||
virtual void set_generate_mipmaps(bool p_generate_mipmaps);
|
||||
virtual bool get_generate_mipmaps() const;
|
||||
|
||||
virtual void set_multichannel_signed_distance_field(bool p_msdf);
|
||||
virtual bool is_multichannel_signed_distance_field() const;
|
||||
|
||||
|
|
|
@ -395,6 +395,9 @@ void BaseMaterial3D::init_shaders() {
|
|||
shader_names->distance_fade_min = "distance_fade_min";
|
||||
shader_names->distance_fade_max = "distance_fade_max";
|
||||
|
||||
shader_names->msdf_pixel_range = "msdf_pixel_range";
|
||||
shader_names->msdf_outline_size = "msdf_outline_size";
|
||||
|
||||
shader_names->metallic_texture_channel = "metallic_texture_channel";
|
||||
shader_names->ao_texture_channel = "ao_texture_channel";
|
||||
shader_names->clearcoat_texture_channel = "clearcoat_texture_channel";
|
||||
|
@ -432,12 +435,10 @@ void BaseMaterial3D::init_shaders() {
|
|||
shader_names->albedo_texture_size = "albedo_texture_size";
|
||||
}
|
||||
|
||||
Ref<StandardMaterial3D> BaseMaterial3D::materials_for_2d[BaseMaterial3D::MAX_MATERIALS_FOR_2D];
|
||||
HashMap<uint64_t, Ref<StandardMaterial3D>> BaseMaterial3D::materials_for_2d;
|
||||
|
||||
void BaseMaterial3D::finish_shaders() {
|
||||
for (int i = 0; i < MAX_MATERIALS_FOR_2D; i++) {
|
||||
materials_for_2d[i].unref();
|
||||
}
|
||||
materials_for_2d.clear();
|
||||
|
||||
memdelete(dirty_materials);
|
||||
dirty_materials = nullptr;
|
||||
|
@ -644,6 +645,11 @@ void BaseMaterial3D::_update_shader() {
|
|||
code += "uniform float distance_fade_max;\n";
|
||||
}
|
||||
|
||||
if (flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
||||
code += "uniform float msdf_pixel_range;\n";
|
||||
code += "uniform float msdf_outline_size;\n";
|
||||
}
|
||||
|
||||
// alpha scissor is only valid if there is not antialiasing edge
|
||||
// alpha hash is valid whenever, but not with alpha scissor
|
||||
if (transparency == TRANSPARENCY_ALPHA_SCISSOR) {
|
||||
|
@ -911,6 +917,12 @@ void BaseMaterial3D::_update_shader() {
|
|||
|
||||
code += "}\n";
|
||||
code += "\n\n";
|
||||
if (flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
||||
code += "float msdf_median(float r, float g, float b, float a) {\n";
|
||||
code += " return min(max(min(r, g), min(max(r, g), b)), a);\n";
|
||||
code += "}\n";
|
||||
}
|
||||
code += "\n\n";
|
||||
if (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR]) {
|
||||
code += "vec4 triplanar_texture(sampler2D p_sampler,vec3 p_weights,vec3 p_triplanar_pos) {\n";
|
||||
code += " vec4 samp=vec4(0.0);\n";
|
||||
|
@ -1010,7 +1022,30 @@ void BaseMaterial3D::_update_shader() {
|
|||
}
|
||||
}
|
||||
|
||||
if (flags[FLAG_ALBEDO_TEXTURE_FORCE_SRGB]) {
|
||||
if (flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
||||
code += " {\n";
|
||||
code += " albedo_tex.rgb = mix(vec3(1.0 + 0.055) * pow(albedo_tex.rgb, vec3(1.0 / 2.4)) - vec3(0.055), vec3(12.92) * albedo_tex.rgb.rgb, lessThan(albedo_tex.rgb, vec3(0.0031308)));\n";
|
||||
code += " vec2 msdf_size = vec2(msdf_pixel_range) / vec2(textureSize(texture_albedo, 0));\n";
|
||||
if (flags[FLAG_USE_POINT_SIZE]) {
|
||||
code += " vec2 dest_size = vec2(1.0) / fwidth(POINT_COORD);\n";
|
||||
} else {
|
||||
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
|
||||
code += " vec2 dest_size = vec2(1.0) / fwidth(uv1_triplanar_pos);\n";
|
||||
} else {
|
||||
code += " vec2 dest_size = vec2(1.0) / fwidth(base_uv);\n";
|
||||
}
|
||||
}
|
||||
code += " float px_size = max(0.5 * dot(msdf_size, dest_size), 1.0);\n";
|
||||
code += " float d = msdf_median(albedo_tex.r, albedo_tex.g, albedo_tex.b, albedo_tex.a) - 0.5;\n";
|
||||
code += " if (msdf_outline_size > 0.0) {\n";
|
||||
code += " float cr = clamp(msdf_outline_size, 0.0, msdf_pixel_range / 2.0) / msdf_pixel_range;\n";
|
||||
code += " albedo_tex.a = clamp((d + cr) * px_size, 0.0, 1.0);\n";
|
||||
code += " } else {\n";
|
||||
code += " albedo_tex.a = clamp(d * px_size + 0.5, 0.0, 1.0);\n";
|
||||
code += " }\n";
|
||||
code += " albedo_tex.rgb = vec3(1.0);\n";
|
||||
code += " }\n";
|
||||
} else if (flags[FLAG_ALBEDO_TEXTURE_FORCE_SRGB]) {
|
||||
code += " albedo_tex.rgb = mix(pow((albedo_tex.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex.rgb.rgb * (1.0 / 12.92),lessThan(albedo_tex.rgb,vec3(0.04045)));\n";
|
||||
}
|
||||
|
||||
|
@ -1777,6 +1812,14 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const {
|
|||
property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
if (property.name == "msdf_pixel_range" && !flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
if (property.name == "msdf_outline_size" && !flags[FLAG_ALBEDO_TEXTURE_MSDF]) {
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
||||
if ((property.name == "distance_fade_max_distance" || property.name == "distance_fade_min_distance") && distance_fade == DISTANCE_FADE_DISABLED) {
|
||||
property.usage = PROPERTY_USAGE_NO_EDITOR;
|
||||
}
|
||||
|
@ -2125,35 +2168,45 @@ BaseMaterial3D::TextureChannel BaseMaterial3D::get_refraction_texture_channel()
|
|||
return refraction_texture_channel;
|
||||
}
|
||||
|
||||
Ref<Material> BaseMaterial3D::get_material_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard, bool p_billboard_y, RID *r_shader_rid) {
|
||||
int version = 0;
|
||||
Ref<Material> BaseMaterial3D::get_material_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard, bool p_billboard_y, bool p_msdf, bool p_no_depth, bool p_fixed_size, TextureFilter p_filter, RID *r_shader_rid) {
|
||||
int64_t hash = 0;
|
||||
if (p_shaded) {
|
||||
version = 1;
|
||||
hash |= 1 << 0;
|
||||
}
|
||||
if (p_transparent) {
|
||||
version |= 2;
|
||||
hash |= 1 << 1;
|
||||
}
|
||||
if (p_cut_alpha) {
|
||||
version |= 4;
|
||||
hash |= 1 << 2;
|
||||
}
|
||||
if (p_opaque_prepass) {
|
||||
version |= 8;
|
||||
hash |= 1 << 3;
|
||||
}
|
||||
if (p_double_sided) {
|
||||
version |= 16;
|
||||
hash |= 1 << 4;
|
||||
}
|
||||
if (p_billboard) {
|
||||
version |= 32;
|
||||
hash |= 1 << 5;
|
||||
}
|
||||
if (p_billboard_y) {
|
||||
version |= 64;
|
||||
hash |= 1 << 6;
|
||||
}
|
||||
if (p_msdf) {
|
||||
hash |= 1 << 7;
|
||||
}
|
||||
if (p_no_depth) {
|
||||
hash |= 1 << 8;
|
||||
}
|
||||
if (p_fixed_size) {
|
||||
hash |= 1 << 9;
|
||||
}
|
||||
hash = hash_djb2_one_64(p_filter, hash);
|
||||
|
||||
if (materials_for_2d[version].is_valid()) {
|
||||
if (materials_for_2d.has(hash)) {
|
||||
if (r_shader_rid) {
|
||||
*r_shader_rid = materials_for_2d[version]->get_shader_rid();
|
||||
*r_shader_rid = materials_for_2d[hash]->get_shader_rid();
|
||||
}
|
||||
return materials_for_2d[version];
|
||||
return materials_for_2d[hash];
|
||||
}
|
||||
|
||||
Ref<StandardMaterial3D> material;
|
||||
|
@ -2164,18 +2217,22 @@ Ref<Material> BaseMaterial3D::get_material_for_2d(bool p_shaded, bool p_transpar
|
|||
material->set_cull_mode(p_double_sided ? CULL_DISABLED : CULL_BACK);
|
||||
material->set_flag(FLAG_SRGB_VERTEX_COLOR, true);
|
||||
material->set_flag(FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
|
||||
material->set_flag(FLAG_ALBEDO_TEXTURE_MSDF, p_msdf);
|
||||
material->set_flag(FLAG_DISABLE_DEPTH_TEST, p_no_depth);
|
||||
material->set_flag(FLAG_FIXED_SIZE, p_fixed_size);
|
||||
material->set_texture_filter(p_filter);
|
||||
if (p_billboard || p_billboard_y) {
|
||||
material->set_flag(FLAG_BILLBOARD_KEEP_SCALE, true);
|
||||
material->set_billboard_mode(p_billboard_y ? BILLBOARD_FIXED_Y : BILLBOARD_ENABLED);
|
||||
}
|
||||
|
||||
materials_for_2d[version] = material;
|
||||
materials_for_2d[hash] = material;
|
||||
|
||||
if (r_shader_rid) {
|
||||
*r_shader_rid = materials_for_2d[version]->get_shader_rid();
|
||||
*r_shader_rid = materials_for_2d[hash]->get_shader_rid();
|
||||
}
|
||||
|
||||
return materials_for_2d[version];
|
||||
return materials_for_2d[hash];
|
||||
}
|
||||
|
||||
void BaseMaterial3D::set_on_top_of_alpha() {
|
||||
|
@ -2203,6 +2260,24 @@ float BaseMaterial3D::get_proximity_fade_distance() const {
|
|||
return proximity_fade_distance;
|
||||
}
|
||||
|
||||
void BaseMaterial3D::set_msdf_pixel_range(float p_range) {
|
||||
msdf_pixel_range = p_range;
|
||||
RS::get_singleton()->material_set_param(_get_material(), shader_names->msdf_pixel_range, p_range);
|
||||
}
|
||||
|
||||
float BaseMaterial3D::get_msdf_pixel_range() const {
|
||||
return msdf_pixel_range;
|
||||
}
|
||||
|
||||
void BaseMaterial3D::set_msdf_outline_size(float p_size) {
|
||||
msdf_outline_size = p_size;
|
||||
RS::get_singleton()->material_set_param(_get_material(), shader_names->msdf_outline_size, p_size);
|
||||
}
|
||||
|
||||
float BaseMaterial3D::get_msdf_outline_size() const {
|
||||
return msdf_outline_size;
|
||||
}
|
||||
|
||||
void BaseMaterial3D::set_distance_fade(DistanceFadeMode p_mode) {
|
||||
distance_fade = p_mode;
|
||||
_queue_shader_change();
|
||||
|
@ -2445,6 +2520,12 @@ void BaseMaterial3D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_proximity_fade_distance", "distance"), &BaseMaterial3D::set_proximity_fade_distance);
|
||||
ClassDB::bind_method(D_METHOD("get_proximity_fade_distance"), &BaseMaterial3D::get_proximity_fade_distance);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_msdf_pixel_range", "range"), &BaseMaterial3D::set_msdf_pixel_range);
|
||||
ClassDB::bind_method(D_METHOD("get_msdf_pixel_range"), &BaseMaterial3D::get_msdf_pixel_range);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_msdf_outline_size", "size"), &BaseMaterial3D::set_msdf_outline_size);
|
||||
ClassDB::bind_method(D_METHOD("get_msdf_outline_size"), &BaseMaterial3D::get_msdf_outline_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_distance_fade", "mode"), &BaseMaterial3D::set_distance_fade);
|
||||
ClassDB::bind_method(D_METHOD("get_distance_fade"), &BaseMaterial3D::get_distance_fade);
|
||||
|
||||
|
@ -2479,6 +2560,7 @@ void BaseMaterial3D::_bind_methods() {
|
|||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "albedo_color"), "set_albedo", "get_albedo");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ALBEDO);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "albedo_tex_force_srgb"), "set_flag", "get_flag", FLAG_ALBEDO_TEXTURE_FORCE_SRGB);
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "albedo_tex_msdf"), "set_flag", "get_flag", FLAG_ALBEDO_TEXTURE_MSDF);
|
||||
|
||||
ADD_GROUP("ORM", "orm_");
|
||||
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orm_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ORM);
|
||||
|
@ -2616,6 +2698,9 @@ void BaseMaterial3D::_bind_methods() {
|
|||
ADD_GROUP("Proximity Fade", "proximity_fade_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "proximity_fade_enable"), "set_proximity_fade", "is_proximity_fade_enabled");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "proximity_fade_distance", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_proximity_fade_distance", "get_proximity_fade_distance");
|
||||
ADD_GROUP("MSDF", "msdf_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "msdf_pixel_range", PROPERTY_HINT_RANGE, "1,100,1"), "set_msdf_pixel_range", "get_msdf_pixel_range");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "msdf_outline_size", PROPERTY_HINT_RANGE, "1,250,1"), "set_msdf_outline_size", "get_msdf_outline_size");
|
||||
ADD_GROUP("Distance Fade", "distance_fade_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "distance_fade_mode", PROPERTY_HINT_ENUM, "Disabled,PixelAlpha,PixelDither,ObjectDither"), "set_distance_fade", "get_distance_fade");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "distance_fade_min_distance", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_distance_fade_min_distance", "get_distance_fade_min_distance");
|
||||
|
@ -2715,6 +2800,7 @@ void BaseMaterial3D::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(FLAG_INVERT_HEIGHTMAP);
|
||||
BIND_ENUM_CONSTANT(FLAG_SUBSURFACE_MODE_SKIN);
|
||||
BIND_ENUM_CONSTANT(FLAG_PARTICLE_TRAILS_MODE);
|
||||
BIND_ENUM_CONSTANT(FLAG_ALBEDO_TEXTURE_MSDF);
|
||||
BIND_ENUM_CONSTANT(FLAG_MAX);
|
||||
|
||||
BIND_ENUM_CONSTANT(DIFFUSE_BURLEY);
|
||||
|
@ -2804,6 +2890,7 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
|
|||
set_heightmap_deep_parallax_max_layers(32);
|
||||
set_heightmap_deep_parallax_flip_tangent(false); //also sets binormal
|
||||
|
||||
flags[FLAG_ALBEDO_TEXTURE_MSDF] = false;
|
||||
flags[FLAG_USE_TEXTURE_REPEAT] = true;
|
||||
|
||||
is_initialized = true;
|
||||
|
|
|
@ -242,6 +242,7 @@ public:
|
|||
FLAG_INVERT_HEIGHTMAP,
|
||||
FLAG_SUBSURFACE_MODE_SKIN,
|
||||
FLAG_PARTICLE_TRAILS_MODE,
|
||||
FLAG_ALBEDO_TEXTURE_MSDF,
|
||||
FLAG_MAX
|
||||
};
|
||||
|
||||
|
@ -412,6 +413,8 @@ private:
|
|||
StringName uv2_blend_sharpness;
|
||||
StringName grow;
|
||||
StringName proximity_fade_distance;
|
||||
StringName msdf_pixel_range;
|
||||
StringName msdf_outline_size;
|
||||
StringName distance_fade_min;
|
||||
StringName distance_fade_max;
|
||||
StringName ao_light_affect;
|
||||
|
@ -500,6 +503,9 @@ private:
|
|||
bool proximity_fade_enabled = false;
|
||||
float proximity_fade_distance;
|
||||
|
||||
float msdf_pixel_range = 4.f;
|
||||
float msdf_outline_size = 0.f;
|
||||
|
||||
DistanceFadeMode distance_fade = DISTANCE_FADE_DISABLED;
|
||||
float distance_fade_max_distance;
|
||||
float distance_fade_min_distance;
|
||||
|
@ -527,9 +533,7 @@ private:
|
|||
|
||||
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
|
||||
|
||||
static const int MAX_MATERIALS_FOR_2D = 128;
|
||||
|
||||
static Ref<StandardMaterial3D> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff
|
||||
static HashMap<uint64_t, Ref<StandardMaterial3D>> materials_for_2d; //used by Sprite3D, Label3D and other stuff
|
||||
|
||||
void _validate_high_end(const String &text, PropertyInfo &property) const;
|
||||
|
||||
|
@ -714,6 +718,12 @@ public:
|
|||
void set_proximity_fade_distance(float p_distance);
|
||||
float get_proximity_fade_distance() const;
|
||||
|
||||
void set_msdf_pixel_range(float p_range);
|
||||
float get_msdf_pixel_range() const;
|
||||
|
||||
void set_msdf_outline_size(float p_size);
|
||||
float get_msdf_outline_size() const;
|
||||
|
||||
void set_distance_fade(DistanceFadeMode p_mode);
|
||||
DistanceFadeMode get_distance_fade() const;
|
||||
|
||||
|
@ -739,7 +749,7 @@ public:
|
|||
static void finish_shaders();
|
||||
static void flush_changes();
|
||||
|
||||
static Ref<Material> get_material_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard = false, bool p_billboard_y = false, RID *r_shader_rid = nullptr);
|
||||
static Ref<Material> get_material_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard = false, bool p_billboard_y = false, bool p_msdf = false, bool p_no_depth = false, bool p_fixed_size = false, TextureFilter p_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RID *r_shader_rid = nullptr);
|
||||
|
||||
virtual RID get_shader_rid() const override;
|
||||
|
||||
|
|
|
@ -461,10 +461,6 @@ float msdf_median(float r, float g, float b, float a) {
|
|||
return min(max(min(r, g), min(max(r, g), b)), a);
|
||||
}
|
||||
|
||||
vec2 msdf_map(vec2 value, vec2 in_min, vec2 in_max, vec2 out_min, vec2 out_max) {
|
||||
return out_min + (out_max - out_min) * (value - in_min) / (in_max - in_min);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 color = color_interp;
|
||||
vec2 uv = uv_interp;
|
||||
|
|
|
@ -67,6 +67,9 @@ void TextServerExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(font_set_antialiased, "font_rid", "antialiased");
|
||||
GDVIRTUAL_BIND(font_is_antialiased, "font_rid");
|
||||
|
||||
GDVIRTUAL_BIND(font_set_generate_mipmaps, "font_rid", "generate_mipmaps");
|
||||
GDVIRTUAL_BIND(font_get_generate_mipmaps, "font_rid");
|
||||
|
||||
GDVIRTUAL_BIND(font_set_multichannel_signed_distance_field, "font_rid", "msdf");
|
||||
GDVIRTUAL_BIND(font_is_multichannel_signed_distance_field, "font_rid");
|
||||
|
||||
|
@ -151,6 +154,9 @@ void TextServerExtension::_bind_methods() {
|
|||
GDVIRTUAL_BIND(font_get_glyph_texture_idx, "font_rid", "size", "glyph");
|
||||
GDVIRTUAL_BIND(font_set_glyph_texture_idx, "font_rid", "size", "glyph", "texture_idx");
|
||||
|
||||
GDVIRTUAL_BIND(font_get_glyph_texture_rid, "font_rid", "size", "glyph");
|
||||
GDVIRTUAL_BIND(font_get_glyph_texture_size, "font_rid", "size", "glyph");
|
||||
|
||||
GDVIRTUAL_BIND(font_get_glyph_contours, "font_rid", "size", "index");
|
||||
|
||||
GDVIRTUAL_BIND(font_get_kerning_list, "font_rid", "size");
|
||||
|
@ -289,6 +295,8 @@ void TextServerExtension::_bind_methods() {
|
|||
|
||||
GDVIRTUAL_BIND(string_to_upper, "string", "language");
|
||||
GDVIRTUAL_BIND(string_to_lower, "string", "language");
|
||||
|
||||
GDVIRTUAL_BIND(parse_structured_text, "parser_type", "args", "text");
|
||||
}
|
||||
|
||||
bool TextServerExtension::has_feature(Feature p_feature) const {
|
||||
|
@ -451,6 +459,18 @@ bool TextServerExtension::font_is_antialiased(const RID &p_font_rid) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
void TextServerExtension::font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) {
|
||||
GDVIRTUAL_CALL(font_set_generate_mipmaps, p_font_rid, p_generate_mipmaps);
|
||||
}
|
||||
|
||||
bool TextServerExtension::font_get_generate_mipmaps(const RID &p_font_rid) const {
|
||||
bool ret;
|
||||
if (GDVIRTUAL_CALL(font_get_generate_mipmaps, p_font_rid, ret)) {
|
||||
return ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TextServerExtension::font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) {
|
||||
GDVIRTUAL_CALL(font_set_multichannel_signed_distance_field, p_font_rid, p_msdf);
|
||||
}
|
||||
|
@ -787,6 +807,22 @@ void TextServerExtension::font_set_glyph_texture_idx(const RID &p_font_rid, cons
|
|||
GDVIRTUAL_CALL(font_set_glyph_texture_idx, p_font_rid, p_size, p_glyph, p_texture_idx);
|
||||
}
|
||||
|
||||
RID TextServerExtension::font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const {
|
||||
RID ret;
|
||||
if (GDVIRTUAL_CALL(font_get_glyph_texture_rid, p_font_rid, p_size, p_glyph, ret)) {
|
||||
return ret;
|
||||
}
|
||||
return RID();
|
||||
}
|
||||
|
||||
Size2 TextServerExtension::font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const {
|
||||
Size2 ret;
|
||||
if (GDVIRTUAL_CALL(font_get_glyph_texture_size, p_font_rid, p_size, p_glyph, ret)) {
|
||||
return ret;
|
||||
}
|
||||
return Size2();
|
||||
}
|
||||
|
||||
Dictionary TextServerExtension::font_get_glyph_contours(const RID &p_font_rid, int64_t p_size, int64_t p_index) const {
|
||||
Dictionary ret;
|
||||
if (GDVIRTUAL_CALL(font_get_glyph_contours, p_font_rid, p_size, p_index, ret)) {
|
||||
|
@ -1459,6 +1495,14 @@ String TextServerExtension::string_to_lower(const String &p_string, const String
|
|||
return p_string;
|
||||
}
|
||||
|
||||
Array TextServerExtension::parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {
|
||||
Array ret;
|
||||
if (GDVIRTUAL_CALL(parse_structured_text, p_parser_type, p_args, p_text, ret)) {
|
||||
return ret;
|
||||
}
|
||||
return Array();
|
||||
}
|
||||
|
||||
TextServerExtension::TextServerExtension() {
|
||||
//NOP
|
||||
}
|
||||
|
|
|
@ -104,6 +104,11 @@ public:
|
|||
GDVIRTUAL2(font_set_antialiased, RID, bool);
|
||||
GDVIRTUAL1RC(bool, font_is_antialiased, RID);
|
||||
|
||||
virtual void font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) override;
|
||||
virtual bool font_get_generate_mipmaps(const RID &p_font_rid) const override;
|
||||
GDVIRTUAL2(font_set_generate_mipmaps, RID, bool);
|
||||
GDVIRTUAL1RC(bool, font_get_generate_mipmaps, RID);
|
||||
|
||||
virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) override;
|
||||
virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const override;
|
||||
GDVIRTUAL2(font_set_multichannel_signed_distance_field, RID, bool);
|
||||
|
@ -245,6 +250,12 @@ public:
|
|||
GDVIRTUAL3RC(int64_t, font_get_glyph_texture_idx, RID, const Vector2i &, int64_t);
|
||||
GDVIRTUAL4(font_set_glyph_texture_idx, RID, const Vector2i &, int64_t, int64_t);
|
||||
|
||||
virtual RID font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
GDVIRTUAL3RC(RID, font_get_glyph_texture_rid, RID, const Vector2i &, int64_t);
|
||||
|
||||
virtual Size2 font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const override;
|
||||
GDVIRTUAL3RC(Size2, font_get_glyph_texture_size, RID, const Vector2i &, int64_t);
|
||||
|
||||
virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const override;
|
||||
GDVIRTUAL3RC(Dictionary, font_get_glyph_contours, RID, int64_t, int64_t);
|
||||
|
||||
|
@ -479,6 +490,9 @@ public:
|
|||
GDVIRTUAL2RC(String, string_to_upper, const String &, const String &);
|
||||
GDVIRTUAL2RC(String, string_to_lower, const String &, const String &);
|
||||
|
||||
Array parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
|
||||
GDVIRTUAL3RC(Array, parse_structured_text, StructuredTextParser, const Array &, const String &);
|
||||
|
||||
TextServerExtension();
|
||||
~TextServerExtension();
|
||||
};
|
||||
|
|
|
@ -220,6 +220,9 @@ void TextServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("font_set_antialiased", "font_rid", "antialiased"), &TextServer::font_set_antialiased);
|
||||
ClassDB::bind_method(D_METHOD("font_is_antialiased", "font_rid"), &TextServer::font_is_antialiased);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("font_set_generate_mipmaps", "font_rid", "generate_mipmaps"), &TextServer::font_set_generate_mipmaps);
|
||||
ClassDB::bind_method(D_METHOD("font_get_generate_mipmaps", "font_rid"), &TextServer::font_get_generate_mipmaps);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("font_set_multichannel_signed_distance_field", "font_rid", "msdf"), &TextServer::font_set_multichannel_signed_distance_field);
|
||||
ClassDB::bind_method(D_METHOD("font_is_multichannel_signed_distance_field", "font_rid"), &TextServer::font_is_multichannel_signed_distance_field);
|
||||
|
||||
|
@ -304,6 +307,9 @@ void TextServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("font_get_glyph_texture_idx", "font_rid", "size", "glyph"), &TextServer::font_get_glyph_texture_idx);
|
||||
ClassDB::bind_method(D_METHOD("font_set_glyph_texture_idx", "font_rid", "size", "glyph", "texture_idx"), &TextServer::font_set_glyph_texture_idx);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("font_get_glyph_texture_rid", "font_rid", "size", "glyph"), &TextServer::font_get_glyph_texture_rid);
|
||||
ClassDB::bind_method(D_METHOD("font_get_glyph_texture_size", "font_rid", "size", "glyph"), &TextServer::font_get_glyph_texture_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("font_get_glyph_contours", "font", "size", "index"), &TextServer::font_get_glyph_contours);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("font_get_kerning_list", "font_rid", "size"), &TextServer::font_get_kerning_list);
|
||||
|
@ -438,6 +444,8 @@ void TextServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("string_to_upper", "string", "language"), &TextServer::string_to_upper, DEFVAL(""));
|
||||
ClassDB::bind_method(D_METHOD("string_to_lower", "string", "language"), &TextServer::string_to_lower, DEFVAL(""));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("parse_structured_text", "parser_type", "args", "text"), &TextServer::parse_structured_text);
|
||||
|
||||
/* Direction */
|
||||
BIND_ENUM_CONSTANT(DIRECTION_AUTO);
|
||||
BIND_ENUM_CONSTANT(DIRECTION_LTR);
|
||||
|
@ -526,6 +534,15 @@ void TextServer::_bind_methods() {
|
|||
BIND_ENUM_CONSTANT(FONT_BOLD);
|
||||
BIND_ENUM_CONSTANT(FONT_ITALIC);
|
||||
BIND_ENUM_CONSTANT(FONT_FIXED_WIDTH);
|
||||
|
||||
/* Structured text parser */
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_DEFAULT);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_URI);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_FILE);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_EMAIL);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_LIST);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_NONE);
|
||||
BIND_ENUM_CONSTANT(STRUCTURED_TEXT_CUSTOM);
|
||||
}
|
||||
|
||||
Vector2 TextServer::get_hex_code_box_size(int64_t p_size, int64_t p_index) const {
|
||||
|
@ -1533,6 +1550,83 @@ String TextServer::strip_diacritics(const String &p_string) const {
|
|||
return result;
|
||||
}
|
||||
|
||||
Array TextServer::parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const {
|
||||
Array ret;
|
||||
switch (p_parser_type) {
|
||||
case STRUCTURED_TEXT_URI: {
|
||||
int prev = 0;
|
||||
for (int i = 0; i < p_text.length(); i++) {
|
||||
if ((p_text[i] == '\\') || (p_text[i] == '/') || (p_text[i] == '.') || (p_text[i] == ':') || (p_text[i] == '&') || (p_text[i] == '=') || (p_text[i] == '@') || (p_text[i] == '?') || (p_text[i] == '#')) {
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
}
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
}
|
||||
}
|
||||
if (prev != p_text.length()) {
|
||||
ret.push_back(Vector2i(prev, p_text.length()));
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_FILE: {
|
||||
int prev = 0;
|
||||
for (int i = 0; i < p_text.length(); i++) {
|
||||
if ((p_text[i] == '\\') || (p_text[i] == '/') || (p_text[i] == ':')) {
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
}
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
}
|
||||
}
|
||||
if (prev != p_text.length()) {
|
||||
ret.push_back(Vector2i(prev, p_text.length()));
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_EMAIL: {
|
||||
bool local = true;
|
||||
int prev = 0;
|
||||
for (int i = 0; i < p_text.length(); i++) {
|
||||
if ((p_text[i] == '@') && local) { // Add full "local" as single context.
|
||||
local = false;
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
} else if (!local & (p_text[i] == '.')) { // Add each dot separated "domain" part as context.
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, i));
|
||||
}
|
||||
ret.push_back(Vector2i(i, i + 1));
|
||||
prev = i + 1;
|
||||
}
|
||||
}
|
||||
if (prev != p_text.length()) {
|
||||
ret.push_back(Vector2i(prev, p_text.length()));
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_LIST: {
|
||||
if (p_args.size() == 1 && p_args[0].get_type() == Variant::STRING) {
|
||||
Vector<String> tags = p_text.split(String(p_args[0]));
|
||||
int prev = 0;
|
||||
for (int i = 0; i < tags.size(); i++) {
|
||||
if (prev != i) {
|
||||
ret.push_back(Vector2i(prev, prev + tags[i].length()));
|
||||
}
|
||||
ret.push_back(Vector2i(prev + tags[i].length(), prev + tags[i].length() + 1));
|
||||
prev = prev + tags[i].length() + 1;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case STRUCTURED_TEXT_CUSTOM:
|
||||
case STRUCTURED_TEXT_NONE:
|
||||
case STRUCTURED_TEXT_DEFAULT:
|
||||
default: {
|
||||
ret.push_back(Vector2i(0, p_text.length()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Array TextServer::_shaped_text_get_glyphs_wrapper(const RID &p_shaped) const {
|
||||
Array ret;
|
||||
|
||||
|
|
|
@ -146,6 +146,16 @@ public:
|
|||
FONT_FIXED_WIDTH = 1 << 2,
|
||||
};
|
||||
|
||||
enum StructuredTextParser {
|
||||
STRUCTURED_TEXT_DEFAULT,
|
||||
STRUCTURED_TEXT_URI,
|
||||
STRUCTURED_TEXT_FILE,
|
||||
STRUCTURED_TEXT_EMAIL,
|
||||
STRUCTURED_TEXT_LIST,
|
||||
STRUCTURED_TEXT_NONE,
|
||||
STRUCTURED_TEXT_CUSTOM
|
||||
};
|
||||
|
||||
void _draw_hex_code_box_number(const RID &p_canvas, int64_t p_size, const Vector2 &p_pos, uint8_t p_index, const Color &p_color) const;
|
||||
|
||||
protected:
|
||||
|
@ -191,6 +201,9 @@ public:
|
|||
virtual void font_set_antialiased(const RID &p_font_rid, bool p_antialiased) = 0;
|
||||
virtual bool font_is_antialiased(const RID &p_font_rid) const = 0;
|
||||
|
||||
virtual void font_set_generate_mipmaps(const RID &p_font_rid, bool p_generate_mipmaps) = 0;
|
||||
virtual bool font_get_generate_mipmaps(const RID &p_font_rid) const = 0;
|
||||
|
||||
virtual void font_set_multichannel_signed_distance_field(const RID &p_font_rid, bool p_msdf) = 0;
|
||||
virtual bool font_is_multichannel_signed_distance_field(const RID &p_font_rid) const = 0;
|
||||
|
||||
|
@ -274,6 +287,8 @@ public:
|
|||
|
||||
virtual int64_t font_get_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const = 0;
|
||||
virtual void font_set_glyph_texture_idx(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph, int64_t p_texture_idx) = 0;
|
||||
virtual RID font_get_glyph_texture_rid(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const = 0;
|
||||
virtual Size2 font_get_glyph_texture_size(const RID &p_font_rid, const Vector2i &p_size, int64_t p_glyph) const = 0;
|
||||
|
||||
virtual Dictionary font_get_glyph_contours(const RID &p_font, int64_t p_size, int64_t p_index) const = 0;
|
||||
|
||||
|
@ -422,6 +437,8 @@ public:
|
|||
virtual String string_to_upper(const String &p_string, const String &p_language = "") const = 0;
|
||||
virtual String string_to_lower(const String &p_string, const String &p_language = "") const = 0;
|
||||
|
||||
Array parse_structured_text(StructuredTextParser p_parser_type, const Array &p_args, const String &p_text) const;
|
||||
|
||||
TextServer();
|
||||
~TextServer();
|
||||
};
|
||||
|
@ -509,6 +526,7 @@ VARIANT_ENUM_CAST(TextServer::Feature);
|
|||
VARIANT_ENUM_CAST(TextServer::ContourPointTag);
|
||||
VARIANT_ENUM_CAST(TextServer::SpacingType);
|
||||
VARIANT_ENUM_CAST(TextServer::FontStyle);
|
||||
VARIANT_ENUM_CAST(TextServer::StructuredTextParser);
|
||||
|
||||
GDVIRTUAL_NATIVE_PTR(Glyph);
|
||||
GDVIRTUAL_NATIVE_PTR(CaretInfo);
|
||||
|
|
Loading…
Reference in a new issue