From ff7c37927a7eac929e1518915dbeac259f63398f Mon Sep 17 00:00:00 2001 From: clayjohn Date: Sun, 18 Nov 2018 21:13:09 -0800 Subject: added pointMesh primitive --- doc/classes/PointMesh.xml | 17 +++++++++++++++++ editor/icons/icon_point_mesh.svg | 7 +++++++ scene/register_scene_types.cpp | 1 + scene/resources/primitive_meshes.cpp | 16 ++++++++++++++++ scene/resources/primitive_meshes.h | 15 +++++++++++++++ 5 files changed, 56 insertions(+) create mode 100644 doc/classes/PointMesh.xml create mode 100644 editor/icons/icon_point_mesh.svg diff --git a/doc/classes/PointMesh.xml b/doc/classes/PointMesh.xml new file mode 100644 index 0000000000..dc7dd065cf --- /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 0000000000..8da7759daf --- /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 2533d91156..245fe3856a 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 74a493d3b5..24fdaafbe1 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 312899c028..fad49f9642 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 -- cgit v1.2.3