diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-25 11:44:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-25 11:44:11 +0200 |
commit | e9bff84ce3faf843f1c2af7625a04adad162a545 (patch) | |
tree | 6666072cd3d687fe2aadc6fa9270f13cb142beaf | |
parent | 1481d299ea97fa1311a75a9ee39eb97d624a8619 (diff) | |
parent | ff7c37927a7eac929e1518915dbeac259f63398f (diff) |
Merge pull request #23820 from clayjohn/pointmesh
Added PointMesh primitive
-rw-r--r-- | doc/classes/PointMesh.xml | 17 | ||||
-rw-r--r-- | editor/icons/icon_point_mesh.svg | 7 | ||||
-rw-r--r-- | scene/register_scene_types.cpp | 1 | ||||
-rw-r--r-- | scene/resources/primitive_meshes.cpp | 16 | ||||
-rw-r--r-- | scene/resources/primitive_meshes.h | 15 |
5 files changed, 56 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="PointMesh" inherits="PrimitiveMesh" category="Core" version="3.2"> + <brief_description> + Mesh with a single Point primitive. + </brief_description> + <description> + 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. + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <constants> + </constants> +</class> 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 @@ +<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"> +<g fill="#ffd684" stroke="#000" stroke-dasharray="null" stroke-linecap="null" stroke-linejoin="null" stroke-opacity="0" stroke-width="0"> +<ellipse cx="3.7237" cy="3.0268" rx="2.0114" ry="1.9956"/> +<ellipse cx="11.717" cy="6.1734" rx="2.0114" ry="1.9956"/> +<ellipse cx="6.5219" cy="12.477" rx="2.0114" ry="1.9956"/> +</g> +</svg> 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<PrismMesh>(); ClassDB::register_class<QuadMesh>(); ClassDB::register_class<SphereMesh>(); + ClassDB::register_class<PointMesh>(); ClassDB::register_virtual_class<Material>(); ClassDB::register_class<SpatialMaterial>(); 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<Vector3> 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 |