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

Deprecate ImmediateGeometry #57345

Closed
wants to merge 1 commit into from
Closed
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
26 changes: 21 additions & 5 deletions doc/classes/ArrayMesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,27 @@
arr_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays)
var m = MeshInstance.new()
m.mesh = arr_mesh
[/codeblock]
The [MeshInstance] is ready to be added to the [SceneTree] to be shown.
See also [ImmediateGeometry], [MeshDataTool] and [SurfaceTool] for procedural geometry generation.
[/gdscript]
[csharp]
var vertices = new Godot.Collections.Array<Vector3>();
vertices.Add(new Vector3(0, 1, 0));
vertices.Add(new Vector3(1, 0, 0));
vertices.Add(new Vector3(0, 0, 1));

// Initialize the ArrayMesh.
var arrMesh = new ArrayMesh();
var arrays = new Godot.Collections.Array();
arrays.Resize((int)Mesh.ArrayType.Max);
arrays[(int)Mesh.ArrayType.Vertex] = vertices;

// Create the Mesh.
arrMesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, arrays);
var m = new MeshInstance();
m.Mesh = arrMesh;
[/csharp]
[/codeblocks]
The [MeshInstance3D] is ready to be added to the [SceneTree] to be shown.
See also [ImmediateMesh], [MeshDataTool] and [SurfaceTool] 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>
Expand Down Expand Up @@ -144,8 +162,6 @@
<argument index="1" name="offset" type="int" />
<argument index="2" name="data" type="PoolByteArray" />
<description>
Updates a specified region of mesh arrays on the GPU.
[b]Warning:[/b] Only use if you know what you are doing. You can easily cause crashes by calling this function with improper arguments.
</description>
</method>
</methods>
Expand Down
92 changes: 0 additions & 92 deletions doc/classes/ImmediateGeometry.xml

This file was deleted.

103 changes: 103 additions & 0 deletions doc/classes/ImmediateMesh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ImmediateMesh" inherits="Mesh" version="4.0">
<brief_description>
Mesh optimized for creating geometry manually.
</brief_description>
<description>
Mesh optimized for creating geometry manually, similar to OpenGL1.x immediate mode.
</description>
<tutorials>
</tutorials>
<methods>
<method name="clear_surfaces">
<return type="void">
</return>
<description>
Clear all surfaces.
</description>
</method>
<method name="surface_add_vertex">
<return type="void">
</return>
<argument index="0" name="vertex" type="Vector3">
</argument>
<description>
Add a 3D vertex using the current attributes previously set.
</description>
</method>
<method name="surface_add_vertex_2d">
<return type="void">
</return>
<argument index="0" name="vertex" type="Vector2">
</argument>
<description>
Add a 2D vertex using the current attributes previously set.
</description>
</method>
<method name="surface_begin">
<return type="void">
</return>
<argument index="0" name="primitive" type="int" enum="Mesh.PrimitiveType">
</argument>
<argument index="1" name="material" type="Material" default="null">
</argument>
<description>
Begin a new surface.
</description>
</method>
<method name="surface_end">
<return type="void">
</return>
<description>
End and commit current surface. Note that surface being created will not be visible until this function is called.
</description>
</method>
<method name="surface_set_color">
<return type="void">
</return>
<argument index="0" name="color" type="Color">
</argument>
<description>
Set the color attribute that will be pushed with the next vertex.
</description>
</method>
<method name="surface_set_normal">
<return type="void">
</return>
<argument index="0" name="normal" type="Vector3">
</argument>
<description>
Set the normal attribute that will be pushed with the next vertex.
</description>
</method>
<method name="surface_set_tangent">
<return type="void">
</return>
<argument index="0" name="tangent" type="Plane">
</argument>
<description>
Set the tangent attribute that will be pushed with the next vertex.
</description>
</method>
<method name="surface_set_uv">
<return type="void">
</return>
<argument index="0" name="uv" type="Vector2">
</argument>
<description>
Set the UV attribute that will be pushed with the next vertex.
</description>
</method>
<method name="surface_set_uv2">
<return type="void">
</return>
<argument index="0" name="uv2" type="Vector2">
</argument>
<description>
Set the UV2 attribute that will be pushed with the next vertex.
</description>
</method>
</methods>
<constants>
</constants>
</class>
24 changes: 22 additions & 2 deletions doc/classes/MeshDataTool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,28 @@
var mi = MeshInstance.new()
mi.mesh = mesh
add_child(mi)
[/codeblock]
See also [ArrayMesh], [ImmediateGeometry] and [SurfaceTool] for procedural geometry generation.
[/gdscript]
[csharp]
var mesh = new ArrayMesh();
mesh.AddSurfaceFromArrays(Mesh.PrimitiveType.Triangles, new BoxMesh().GetMeshArrays());
var mdt = new MeshDataTool();
mdt.CreateFromSurface(mesh, 0);
for (var i = 0; i &lt; mdt.GetVertexCount(); i++)
{
Vector3 vertex = mdt.GetVertex(i);
// In this example we extend the mesh by one unit, which results in separated faces as it is flat shaded.
vertex += mdt.GetVertexNormal(i);
// Save your change.
mdt.SetVertex(i, vertex);
}
mesh.SurfaceRemove(0);
mdt.CommitToSurface(mesh);
var mi = new MeshInstance();
mi.Mesh = mesh;
AddChild(mi);
[/csharp]
[/codeblocks]
See also [ArrayMesh], [ImmediateMesh] and [SurfaceTool] 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>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/SurfaceTool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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.
See also [ArrayMesh], [ImmediateMesh] 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>
Expand Down
Loading