diff --git a/doc/classes/PointMesh.xml b/doc/classes/PointMesh.xml new file mode 100644 index 00000000000..dc7dd065cf7 --- /dev/null +++ b/doc/classes/PointMesh.xml @@ -0,0 +1,17 @@ + + + + Mesh with a single Point primitive. + + + The PointMesh is made from a single point. Instead of relying on triangles, points are rendered as a single rectangle on the screen with a constant size. They are intended to be used with Particle systems, but can be used as a cheap way to render constant size billboarded sprites (for example in a point cloud). + PointMeshes, must be used with a material that has a point size. Point size can be accessed in a shader with [code]POINT_SIZE[/code], or in a [SpatialMaterial] by setting [member SpatialMaterial.flags_use_point_size] and the variable [member SpatialMaterial.params_point_size]. + When using PointMeshes, properties that normally alter vertices will be ignored, including billboard mode, grow, and cull face. + + + + + + + + diff --git a/editor/icons/icon_point_mesh.svg b/editor/icons/icon_point_mesh.svg new file mode 100644 index 00000000000..8da7759daf4 --- /dev/null +++ b/editor/icons/icon_point_mesh.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 2533d911562..245fe3856a0 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -607,6 +607,7 @@ void register_scene_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_virtual_class(); ClassDB::register_class(); SceneTree::add_idle_callback(SpatialMaterial::flush_changes); diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 74a493d3b55..24fdaafbe1e 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -1572,3 +1572,19 @@ SphereMesh::SphereMesh() { rings = 32; is_hemisphere = false; } + +/** + PointMesh +*/ + +void PointMesh::_create_mesh_array(Array &p_arr) const { + PoolVector faces; + faces.resize(1); + faces.set(0, Vector3(0.0, 0.0, 0.0)); + + p_arr[VS::ARRAY_VERTEX] = faces; +} + +PointMesh::PointMesh() { + primitive_type = PRIMITIVE_POINTS; +} diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index 312899c0282..fad49f96428 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -322,4 +322,19 @@ public: SphereMesh(); }; +/** + A single point for use in particle systems +*/ + +class PointMesh : public PrimitiveMesh { + + GDCLASS(PointMesh, PrimitiveMesh) + +protected: + virtual void _create_mesh_array(Array &p_arr) const; + +public: + PointMesh(); +}; + #endif