From ca2b7a87a5af6c6086266c2db048a8c50d445b54 Mon Sep 17 00:00:00 2001 From: Silc 'Tokage' Renew Date: Sun, 28 Nov 2021 09:12:10 +0900 Subject: Fixed minimum size of aabb in ImmediateMesh to draw only one vertex --- scene/resources/immediate_mesh.cpp | 3 ++- scene/resources/immediate_mesh.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'scene/resources') diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp index fe7124de9e..4f9a055bfb 100644 --- a/scene/resources/immediate_mesh.cpp +++ b/scene/resources/immediate_mesh.cpp @@ -144,6 +144,7 @@ void ImmediateMesh::surface_add_vertex_2d(const Vector2 &p_vertex) { active_surface_data.vertex_2d = true; } + void ImmediateMesh::surface_end() { ERR_FAIL_COND_MSG(!surface_active, "Not creating any surface. Use surface_begin() to do it."); ERR_FAIL_COND_MSG(!vertices.size(), "No vertices were added, surface can't be created."); @@ -185,7 +186,7 @@ void ImmediateMesh::surface_end() { vtx[2] = vertices[i].z; } if (i == 0) { - aabb.position = vertices[i]; + aabb = AABB(vertices[i], SMALL_VEC3); // Must have a bit of size. } else { aabb.expand_to(vertices[i]); } diff --git a/scene/resources/immediate_mesh.h b/scene/resources/immediate_mesh.h index 6673ee6f3d..92bf91441d 100644 --- a/scene/resources/immediate_mesh.h +++ b/scene/resources/immediate_mesh.h @@ -75,6 +75,8 @@ class ImmediateMesh : public Mesh { Vector surface_vertex_create_cache; Vector surface_attribute_create_cache; + const Vector3 SMALL_VEC3 = Vector3(CMP_EPSILON, CMP_EPSILON, CMP_EPSILON); + protected: static void _bind_methods(); -- cgit v1.2.3