From 87710517fae21aa23390055ec3e64564b9d0f93e Mon Sep 17 00:00:00 2001 From: clayjohn Date: Fri, 16 Sep 2022 09:54:42 -0700 Subject: [PATCH] Add QuadMesh back as a subclass of PlaneMesh. This simplifies the creation of billboarded meshes without any code overhead. --- doc/classes/PlaneMesh.xml | 4 ++-- doc/classes/QuadMesh.xml | 16 ++++++++++++++++ scene/register_scene_types.cpp | 2 +- scene/resources/primitive_meshes.h | 12 ++++++++++++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 doc/classes/QuadMesh.xml diff --git a/doc/classes/PlaneMesh.xml b/doc/classes/PlaneMesh.xml index 564b6fe7435..1dceac70b02 100644 --- a/doc/classes/PlaneMesh.xml +++ b/doc/classes/PlaneMesh.xml @@ -31,10 +31,10 @@ [PlaneMesh] will face the positive X-axis. - [PlaneMesh] will face the positive Y-axis. This matches the behaviour of the [PlaneMesh] in Godot 3.x. + [PlaneMesh] will face the positive Y-axis. This matches the behavior of the [PlaneMesh] in Godot 3.x. - [PlaneMesh] will face the positive Z-axis. This matches the behvaiour of the QuadMesh in Godot 3.x. + [PlaneMesh] will face the positive Z-axis. This matches the behavior of the QuadMesh in Godot 3.x. diff --git a/doc/classes/QuadMesh.xml b/doc/classes/QuadMesh.xml new file mode 100644 index 00000000000..7469338ef96 --- /dev/null +++ b/doc/classes/QuadMesh.xml @@ -0,0 +1,16 @@ + + + + Class representing a square mesh facing the camera. + + + Class representing a square [PrimitiveMesh]. This flat mesh does not have a thickness. By default, this mesh is aligned on the X and Y axes; this rotation is more suited for use with billboarded materials. A [QuadMesh] is equivalent to a [PlaneMesh] except its default [member PlaneMesh.orientation] is [constant PlaneMesh.FACE_Z]. + + + https://godotengine.org/asset-library/asset/127 + https://godotengine.org/asset-library/asset/129 + + + + + diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 72c57f1bfce..e536aeee512 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -794,6 +794,7 @@ void register_scene_types() { GDREGISTER_CLASS(CylinderMesh); GDREGISTER_CLASS(PlaneMesh); GDREGISTER_CLASS(PrismMesh); + GDREGISTER_CLASS(QuadMesh); GDREGISTER_CLASS(SphereMesh); GDREGISTER_CLASS(TextMesh); GDREGISTER_CLASS(TorusMesh); @@ -959,7 +960,6 @@ void register_scene_types() { ClassDB::add_compatibility_class("Navigation3D", "Node3D"); ClassDB::add_compatibility_class("Navigation2D", "Node2D"); ClassDB::add_compatibility_class("OpenSimplexNoise", "FastNoiseLite"); - ClassDB::add_compatibility_class("QuadMesh", "PlaneMesh"); ClassDB::add_compatibility_class("ToolButton", "Button"); ClassDB::add_compatibility_class("YSort", "Node2D"); // Portal and room occlusion was replaced by raster occlusion (OccluderInstance3D node). diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index 280477ebfa3..65823a8f7f8 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -262,6 +262,18 @@ public: VARIANT_ENUM_CAST(PlaneMesh::Orientation) +/* + A flat rectangle, inherits from PlaneMesh but defaults to facing the Z-plane. +*/ +class QuadMesh : public PlaneMesh { + GDCLASS(QuadMesh, PlaneMesh); + +public: + QuadMesh() { + set_orientation(FACE_Z); + } +}; + /** A prism shapen, handy for ramps, triangles, etc. */