Merge pull request #23820 from clayjohn/pointmesh

Added PointMesh primitive
This commit is contained in:
Rémi Verschelde 2019-07-25 11:44:11 +02:00 committed by GitHub
commit e9bff84ce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 0 deletions

17
doc/classes/PointMesh.xml Normal file
View File

@ -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>

View File

@ -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>

After

Width:  |  Height:  |  Size: 391 B

View File

@ -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);

View File

@ -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;
}

View File

@ -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