Skip to content

Commit

Permalink
Add primitive 2D meshes
Browse files Browse the repository at this point in the history
Allows drawing (anti-aliased) 2D shapes using MeshInstance2D.
Based on the code for primitive 3D meshes.
  • Loading branch information
rburing committed Dec 26, 2024
1 parent 4364ed6 commit 34b0ed6
Show file tree
Hide file tree
Showing 13 changed files with 1,604 additions and 0 deletions.
22 changes: 22 additions & 0 deletions doc/classes/CapsuleMesh2D.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CapsuleMesh2D" inherits="PrimitiveMesh2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A capsule-shaped [PrimitiveMesh2D].
</brief_description>
<description>
A capsule-shaped [PrimitiveMesh2D].
</description>
<tutorials>
</tutorials>
<members>
<member name="height" type="float" setter="set_height" getter="get_height" default="30.0">
Total height of the capsule mesh (including the semicircular ends).
</member>
<member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" default="32">
Number of radial segments on each semicircle of the capsule mesh.
</member>
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="10.0">
Radius of the semicircles on the ends of the capsule mesh.
</member>
</members>
</class>
19 changes: 19 additions & 0 deletions doc/classes/CircleMesh2D.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="CircleMesh2D" inherits="PrimitiveMesh2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A circular [PrimitiveMesh2D].
</brief_description>
<description>
A circular [PrimitiveMesh2D].
</description>
<tutorials>
</tutorials>
<members>
<member name="radial_segments" type="int" setter="set_radial_segments" getter="get_radial_segments" default="64">
Number of radial segments on the circle.
</member>
<member name="radius" type="float" setter="set_radius" getter="get_radius" default="10.0">
Radius of the circle.
</member>
</members>
</class>
39 changes: 39 additions & 0 deletions doc/classes/PrimitiveMesh2D.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PrimitiveMesh2D" inherits="Mesh" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Base class for all primitive 2D meshes.
</brief_description>
<description>
Base class for all primitive 2D meshes. Examples include [RectangleMesh2D], [CircleMesh2D], and [CapsuleMesh2D].
</description>
<tutorials>
</tutorials>
<methods>
<method name="_create_mesh_array" qualifiers="virtual const">
<return type="Array" />
<description>
Override this method to customize how this primitive mesh should be generated. Should return an [Array] where each element is another Array of values required for the mesh (see the [enum Mesh.ArrayType] constants).
</description>
</method>
<method name="get_mesh_arrays" qualifiers="const">
<return type="Array" />
<description>
Returns the mesh arrays used to make up the surface of this primitive mesh.
</description>
</method>
<method name="request_update">
<return type="void" />
<description>
Request an update of this primitive mesh based on its properties.
</description>
</method>
</methods>
<members>
<member name="antialiased" type="bool" setter="set_antialiased" getter="is_antialiased" default="false">
If [code]true[/code], a half transparent "skirt" will be attached to the boundary, making outlines smooth.
</member>
<member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb" default="AABB(0, 0, 0, 0, 0, 0)">
Overrides the [AABB] with one defined by user for use with frustum culling. Especially useful to avoid unexpected culling when using a shader to offset vertices.
</member>
</members>
</class>
22 changes: 22 additions & 0 deletions doc/classes/RectangleMesh2D.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="RectangleMesh2D" inherits="PrimitiveMesh2D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
A rectangular [PrimitiveMesh2D].
</brief_description>
<description>
A rectangular [PrimitiveMesh2D].
</description>
<tutorials>
</tutorials>
<members>
<member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2(20, 20)">
The rectangle's width and height.
</member>
<member name="subdivide_height" type="int" setter="set_subdivide_height" getter="get_subdivide_height" default="0">
Number of extra edge loops inserted along the Y axis.
</member>
<member name="subdivide_width" type="int" setter="set_subdivide_width" getter="get_subdivide_width" default="0">
Number of extra edge loops inserted along the X axis.
</member>
</members>
</class>
1 change: 1 addition & 0 deletions editor/icons/CapsuleMesh2D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions editor/icons/CircleMesh2D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions editor/icons/RectangleMesh2D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 34b0ed6

Please sign in to comment.