Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of static typing from the documentation #99925

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions doc/classes/CompositorEffect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
If [code]true[/code] and MSAA is enabled, this will trigger a color buffer resolve before the effect is run.
[b]Note:[/b] In [method _render_callback], to access the resolved buffer use:
[codeblock]
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
var render_scene_buffers = render_data.get_render_scene_buffers()
var color_buffer = render_scene_buffers.get_texture("render_buffers", "color")
[/codeblock]
</member>
<member name="access_resolved_depth" type="bool" setter="set_access_resolved_depth" getter="get_access_resolved_depth">
If [code]true[/code] and MSAA is enabled, this will trigger a depth buffer resolve before the effect is run.
[b]Note:[/b] In [method _render_callback], to access the resolved buffer use:
[codeblock]
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
var render_scene_buffers = render_data.get_render_scene_buffers()
var depth_buffer = render_scene_buffers.get_texture("render_buffers", "depth")
[/codeblock]
</member>
Expand All @@ -46,15 +46,15 @@
If [code]true[/code] this triggers motion vectors being calculated during the opaque render state.
[b]Note:[/b] In [method _render_callback], to access the motion vector buffer use:
[codeblock]
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
var render_scene_buffers = render_data.get_render_scene_buffers()
var motion_buffer = render_scene_buffers.get_velocity_texture()
[/codeblock]
</member>
<member name="needs_normal_roughness" type="bool" setter="set_needs_normal_roughness" getter="get_needs_normal_roughness">
If [code]true[/code] this triggers normal and roughness data to be output during our depth pre-pass, only applicable for the Forward+ renderer.
[b]Note:[/b] In [method _render_callback], to access the roughness buffer use:
[codeblock]
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
var render_scene_buffers = render_data.get_render_scene_buffers()
var roughness_buffer = render_scene_buffers.get_texture("forward_clustered", "normal_roughness")
[/codeblock]
The raw normal and roughness buffer is stored in an optimized format, different than the one available in Spatial shaders. When sampling the buffer, a conversion function must be applied. Use this function, copied from [url=https://github.com/godotengine/godot/blob/da5f39889f155658cef7f7ec3cc1abb94e17d815/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl#L334-L341]here[/url]:
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/DTLSServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

func _process(delta):
while server.is_connection_available():
var peer: PacketPeerUDP = server.take_connection()
var dtls_peer: PacketPeerDTLS = dtls.take_connection(peer)
var peer = server.take_connection()
var dtls_peer = dtls.take_connection(peer)
if dtls_peer.get_status() != PacketPeerDTLS.STATUS_HANDSHAKING:
continue # It is normal that 50% of the connections fails due to cookie exchange.
print("Peer connected!")
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/GraphEdit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
Below is a sample code to help get started:
[codeblock]
func _is_in_input_hotzone(in_node, in_port, mouse_position):
var port_size: Vector2 = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
var port_pos: Vector2 = in_node.get_position() + in_node.get_input_port_position(in_port) - port_size / 2
var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
var port_pos = in_node.get_position() + in_node.get_input_port_position(in_port) - port_size / 2
var rect = Rect2(port_pos, port_size)

return rect.has_point(mouse_position)
Expand All @@ -49,8 +49,8 @@
Below is a sample code to help get started:
[codeblock]
func _is_in_output_hotzone(in_node, in_port, mouse_position):
var port_size: Vector2 = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
var port_pos: Vector2 = in_node.get_position() + in_node.get_output_port_position(in_port) - port_size / 2
var port_size = Vector2(get_theme_constant("port_grab_distance_horizontal"), get_theme_constant("port_grab_distance_vertical"))
var port_pos = in_node.get_position() + in_node.get_output_port_position(in_port) - port_size / 2
var rect = Rect2(port_pos, port_size)

return rect.has_point(mouse_position)
Expand Down
8 changes: 4 additions & 4 deletions doc/classes/HeightMapShape3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
A heightmap collision shape can also be build by using an [Image] reference:
[codeblocks]
[gdscript]
var heightmap_texture: Texture = ResourceLoader.load("res://heightmap_image.exr")
var heightmap_image: Image = heightmap_texture.get_image()
var heightmap_texture = ResourceLoader.load("res://heightmap_image.exr")
var heightmap_image = heightmap_texture.get_image()
Comment on lines -12 to +13
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is type narrowing again.

heightmap_image.convert(Image.FORMAT_RF)

var height_min: float = 0.0
var height_max: float = 10.0
var height_min = 0.0
var height_max = 10.0

update_map_data_from_image(heightmap_image, height_min, height_max)
[/gdscript]
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/ImageTexture.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[b]Note:[/b] The image can be retrieved from an imported texture using the [method Texture2D.get_image] method, which returns a copy of the image:
[codeblock]
var texture = load("res://icon.svg")
var image: Image = texture.get_image()
var image = texture.get_image()
Comment on lines 22 to +23
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no guarantee that texture is a Texture, and that it has the get_image() method, so this is another example of type narrowing.

[/codeblock]
An [ImageTexture] is not meant to be operated from within the editor interface directly, and is mostly useful for rendering images on screen dynamically via code. If you need to generate images procedurally from within the editor, consider saving and importing images as custom texture resources implementing a new [EditorImportPlugin].
[b]Note:[/b] The maximum texture size is 16384×16384 pixels due to graphics hardware limitations.
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/UDPServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
func _process(delta):
server.poll() # Important!
if server.is_connection_available():
var peer: PacketPeerUDP = server.take_connection()
var peer = server.take_connection()
var packet = peer.get_packet()
print("Accepted peer: %s:%s" % [peer.get_packet_ip(), peer.get_packet_port()])
print("Received data: %s" % [packet.get_string_from_utf8()])
Expand Down
4 changes: 2 additions & 2 deletions doc/classes/XRInterface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
[b]Note:[/b] Not all runtimes support all environment blend modes, so it is important to check this at startup. For example:
[codeblock]
func _ready():
var xr_interface: XRInterface = XRServer.find_interface("OpenXR")
var xr_interface = XRServer.find_interface("OpenXR")
if xr_interface and xr_interface.is_initialized():
var vp: Viewport = get_viewport()
var vp = get_viewport()
vp.use_xr = true
var acceptable_modes = [XRInterface.XR_ENV_BLEND_MODE_OPAQUE, XRInterface.XR_ENV_BLEND_MODE_ADDITIVE]
var modes = xr_interface.get_supported_environment_blend_modes()
Expand Down
2 changes: 1 addition & 1 deletion modules/gdscript/doc_classes/@GDScript.xml
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@
<description>
Mark the following property as assigned when the [Node] is ready. Values for these properties are not assigned immediately when the node is initialized ([method Object._init]), and instead are computed and stored right before [method Node._ready].
[codeblock]
@onready var character_name: Label = $Label
@onready var character_name = $Label
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Narrowing down the type of an @onready variable is good practice but by hard-following the general rule this should be removed.

[/codeblock]
</description>
</annotation>
Expand Down