<commit_before><?xml version="1.0" encoding="UTF-8" ?>
<class name="SurfaceTool" inherits="Reference" version="3.5">
	<brief_description>
		Helper tool to create geometry.
	</brief_description>
	<description>
		The [SurfaceTool] is used to construct a [Mesh] by specifying vertex attributes individually. It can be used to construct a [Mesh] from a script. All properties except indices need to be added before calling [method add_vertex]. For example, to add vertex colors and UVs:
		[codeblock]
		var st = SurfaceTool.new()
		st.begin(Mesh.PRIMITIVE_TRIANGLES)
		st.add_color(Color(1, 0, 0))
		st.add_uv(Vector2(0, 0))
		st.add_vertex(Vector3(0, 0, 0))
		[/codeblock]
		The above [SurfaceTool] now contains one vertex of a triangle which has a UV coordinate and a specified [Color]. If another vertex were added without calling [method add_uv] or [method add_color], then the last values would be used.
		Vertex attributes must be passed [b]before[/b] calling [method add_vertex]. Failure to do so will result in an error when committing the vertex information to a mesh.
		Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example, if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices.
		See also [ArrayMesh], [ImmediateGeometry] and [MeshDataTool] for procedural geometry generation.
		[b]Note:[/b] Godot uses clockwise [url=https://learnopengl.com/Advanced-OpenGL/Face-culling]winding order[/url] for front faces of triangle primitive modes.
	</description>
	<tutorials>
		<link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/676</link>
	</tutorials>
	<methods>
		<method name="add_bones">
			<return type="void" />
			<argument index="0" name="bones" type="PoolIntArray" />
			<description>
				Specifies an array of bones to use for the [i]next[/i] vertex. [code]bones[/code] must contain 4 integers.
			</description>
		</method>
		<method name="add_color">
			<return type="void" />
			<argument index="0" name="color" type="Color" />
			<description>
				Specifies a [Color] to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
				[b]Note:[/b] The material must have [member SpatialMaterial.vertex_color_use_as_albedo] enabled for the vertex color to be visible.
			</description>
		</method>
		<method name="add_index">
			<return type="void" />
			<argument index="0" name="index" type="int" />
			<description>
				Adds an index to index array if you are using indexed vertices. Does not need to be called before adding vertices.
			</description>
		</method>
		<method name="add_normal">
			<return type="void" />
			<argument index="0" name="normal" type="Vector3" />
			<description>
				Specifies a normal to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_smooth_group">
			<return type="void" />
			<argument index="0" name="smooth" type="bool" />
			<description>
				Specifies whether the current vertex (if using only vertex arrays) or current index (if also using index arrays) should use smooth normals for normal calculation.
			</description>
		</method>
		<method name="add_tangent">
			<return type="void" />
			<argument index="0" name="tangent" type="Plane" />
			<description>
				Specifies a tangent to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_triangle_fan">
			<return type="void" />
			<argument index="0" name="vertices" type="PoolVector3Array" />
			<argument index="1" name="uvs" type="PoolVector2Array" default="PoolVector2Array(  )" />
			<argument index="2" name="colors" type="PoolColorArray" default="PoolColorArray(  )" />
			<argument index="3" name="uv2s" type="PoolVector2Array" default="PoolVector2Array(  )" />
			<argument index="4" name="normals" type="PoolVector3Array" default="PoolVector3Array(  )" />
			<argument index="5" name="tangents" type="Array" default="[  ]" />
			<description>
				Inserts a triangle fan made of array data into [Mesh] being constructed.
				Requires the primitive type be set to [constant Mesh.PRIMITIVE_TRIANGLES].
			</description>
		</method>
		<method name="add_uv">
			<return type="void" />
			<argument index="0" name="uv" type="Vector2" />
			<description>
				Specifies a set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_uv2">
			<return type="void" />
			<argument index="0" name="uv2" type="Vector2" />
			<description>
				Specifies an optional second set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_vertex">
			<return type="void" />
			<argument index="0" name="vertex" type="Vector3" />
			<description>
				Specifies the position of current vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
			</description>
		</method>
		<method name="add_weights">
			<return type="void" />
			<argument index="0" name="weights" type="PoolRealArray" />
			<description>
				Specifies weight values to use for the [i]next[/i] vertex. [code]weights[/code] must contain 4 values. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="append_from">
			<return type="void" />
			<argument index="0" name="existing" type="Mesh" />
			<argument index="1" name="surface" type="int" />
			<argument index="2" name="transform" type="Transform" />
			<description>
				Append vertices from a given [Mesh] surface onto the current vertex array with specified [Transform].
			</description>
		</method>
		<method name="begin">
			<return type="void" />
			<argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType" />
			<description>
				Called before adding any vertices. Takes the primitive type as an argument (e.g. [constant Mesh.PRIMITIVE_TRIANGLES]).
			</description>
		</method>
		<method name="clear">
			<return type="void" />
			<description>
				Clear all information passed into the surface tool so far.
			</description>
		</method>
		<method name="commit">
			<return type="ArrayMesh" />
			<argument index="0" name="existing" type="ArrayMesh" default="null" />
			<argument index="1" name="flags" type="int" default="2194432" />
			<description>
				Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh].
				Default flag is [constant Mesh.ARRAY_COMPRESS_DEFAULT] if compression is enabled. If compression is disabled the default flag is [constant Mesh.ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION]. See [code]ARRAY_COMPRESS_*[/code] constants in [enum Mesh.ArrayFormat] for other flags.
			</description>
		</method>
		<method name="commit_to_arrays">
			<return type="Array" />
			<description>
				Commits the data to the same format used by [method ArrayMesh.add_surface_from_arrays]. This way you can further process the mesh data using the [ArrayMesh] API.
			</description>
		</method>
		<method name="create_from"><commit_msg>Document low performance when using `SurfaceTool.append_from()` in thread<commit_after><?xml version="1.0" encoding="UTF-8" ?>
<class name="SurfaceTool" inherits="Reference" version="3.5">
	<brief_description>
		Helper tool to create geometry.
	</brief_description>
	<description>
		The [SurfaceTool] is used to construct a [Mesh] by specifying vertex attributes individually. It can be used to construct a [Mesh] from a script. All properties except indices need to be added before calling [method add_vertex]. For example, to add vertex colors and UVs:
		[codeblock]
		var st = SurfaceTool.new()
		st.begin(Mesh.PRIMITIVE_TRIANGLES)
		st.add_color(Color(1, 0, 0))
		st.add_uv(Vector2(0, 0))
		st.add_vertex(Vector3(0, 0, 0))
		[/codeblock]
		The above [SurfaceTool] now contains one vertex of a triangle which has a UV coordinate and a specified [Color]. If another vertex were added without calling [method add_uv] or [method add_color], then the last values would be used.
		Vertex attributes must be passed [b]before[/b] calling [method add_vertex]. Failure to do so will result in an error when committing the vertex information to a mesh.
		Additionally, the attributes used before the first vertex is added determine the format of the mesh. For example, if you only add UVs to the first vertex, you cannot add color to any of the subsequent vertices.
		See also [ArrayMesh], [ImmediateGeometry] and [MeshDataTool] for procedural geometry generation.
		[b]Note:[/b] Godot uses clockwise [url=https://learnopengl.com/Advanced-OpenGL/Face-culling]winding order[/url] for front faces of triangle primitive modes.
	</description>
	<tutorials>
		<link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/676</link>
	</tutorials>
	<methods>
		<method name="add_bones">
			<return type="void" />
			<argument index="0" name="bones" type="PoolIntArray" />
			<description>
				Specifies an array of bones to use for the [i]next[/i] vertex. [code]bones[/code] must contain 4 integers.
			</description>
		</method>
		<method name="add_color">
			<return type="void" />
			<argument index="0" name="color" type="Color" />
			<description>
				Specifies a [Color] to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
				[b]Note:[/b] The material must have [member SpatialMaterial.vertex_color_use_as_albedo] enabled for the vertex color to be visible.
			</description>
		</method>
		<method name="add_index">
			<return type="void" />
			<argument index="0" name="index" type="int" />
			<description>
				Adds an index to index array if you are using indexed vertices. Does not need to be called before adding vertices.
			</description>
		</method>
		<method name="add_normal">
			<return type="void" />
			<argument index="0" name="normal" type="Vector3" />
			<description>
				Specifies a normal to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_smooth_group">
			<return type="void" />
			<argument index="0" name="smooth" type="bool" />
			<description>
				Specifies whether the current vertex (if using only vertex arrays) or current index (if also using index arrays) should use smooth normals for normal calculation.
			</description>
		</method>
		<method name="add_tangent">
			<return type="void" />
			<argument index="0" name="tangent" type="Plane" />
			<description>
				Specifies a tangent to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_triangle_fan">
			<return type="void" />
			<argument index="0" name="vertices" type="PoolVector3Array" />
			<argument index="1" name="uvs" type="PoolVector2Array" default="PoolVector2Array(  )" />
			<argument index="2" name="colors" type="PoolColorArray" default="PoolColorArray(  )" />
			<argument index="3" name="uv2s" type="PoolVector2Array" default="PoolVector2Array(  )" />
			<argument index="4" name="normals" type="PoolVector3Array" default="PoolVector3Array(  )" />
			<argument index="5" name="tangents" type="Array" default="[  ]" />
			<description>
				Inserts a triangle fan made of array data into [Mesh] being constructed.
				Requires the primitive type be set to [constant Mesh.PRIMITIVE_TRIANGLES].
			</description>
		</method>
		<method name="add_uv">
			<return type="void" />
			<argument index="0" name="uv" type="Vector2" />
			<description>
				Specifies a set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_uv2">
			<return type="void" />
			<argument index="0" name="uv2" type="Vector2" />
			<description>
				Specifies an optional second set of UV coordinates to use for the [i]next[/i] vertex. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="add_vertex">
			<return type="void" />
			<argument index="0" name="vertex" type="Vector3" />
			<description>
				Specifies the position of current vertex. Should be called after specifying other vertex properties (e.g. Color, UV).
			</description>
		</method>
		<method name="add_weights">
			<return type="void" />
			<argument index="0" name="weights" type="PoolRealArray" />
			<description>
				Specifies weight values to use for the [i]next[/i] vertex. [code]weights[/code] must contain 4 values. If every vertex needs to have this information set and you fail to submit it for the first vertex, this information may not be used at all.
			</description>
		</method>
		<method name="append_from">
			<return type="void" />
			<argument index="0" name="existing" type="Mesh" />
			<argument index="1" name="surface" type="int" />
			<argument index="2" name="transform" type="Transform" />
			<description>
				Append vertices from a given [Mesh] surface onto the current vertex array with specified [Transform].
				[b]Note:[/b] Using [method append_from] on a [Thread] is much slower as the GPU must communicate data back to the CPU, while also causing the main thread to stall (as OpenGL is not thread-safe). Consider requesting a copy of the mesh, converting it to an [ArrayMesh] and adding vertices manually instead.
			</description>
		</method>
		<method name="begin">
			<return type="void" />
			<argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType" />
			<description>
				Called before adding any vertices. Takes the primitive type as an argument (e.g. [constant Mesh.PRIMITIVE_TRIANGLES]).
			</description>
		</method>
		<method name="clear">
			<return type="void" />
			<description>
				Clear all information passed into the surface tool so far.
			</description>
		</method>
		<method name="commit">
			<return type="ArrayMesh" />
			<argument index="0" name="existing" type="ArrayMesh" default="null" />
			<argument index="1" name="flags" type="int" default="2194432" />
			<description>
				Returns a constructed [ArrayMesh] from current information passed in. If an existing [ArrayMesh] is passed in as an argument, will add an extra surface to the existing [ArrayMesh].
				Default flag is [constant Mesh.ARRAY_COMPRESS_DEFAULT] if compression is enabled. If compression is disabled the default flag is [constant Mesh.ARRAY_FLAG_USE_OCTAHEDRAL_COMPRESSION]. See [code]ARRAY_COMPRESS_*[/code] constants in [enum Mesh.ArrayFormat] for other flags.
			</description>
		</method>
		<method name="commit_to_arrays">
			<return type="Array" />
			<description>
				Commits the data to the same format used by [method ArrayMesh.add_surface_from_arrays]. This way you can further process the mesh data using the [ArrayMesh] API.
			</description>
		</method>
		<method name="create_from">
{'fraction_non_alphanumeric': 0.11614677752078514, 'fraction_numerical': 0.008001500281302745, 'mean_word_length': 4.26076948372246, 'pattern_counts': {'":': 0, '<': 231, '<?xml version=': 2, '>': 231, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6315070', 'n_tokens_mistral': 5206, 'n_tokens_neox': 4607, 'n_words': 1816}