summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-04-20 17:41:11 +0200
committerGitHub <noreply@github.com>2021-04-20 17:41:11 +0200
commitc36807994d06d812053f469c4189c81439f69231 (patch)
tree1cc49bdc02b513d2006eb52d53313159564ff683 /scene
parentfdf041a466b5ecbdd2294ecfeab598fcc3dc5cda (diff)
parent806a1a6646d194493dc2eb283a2e4e9a59083bc0 (diff)
Merge pull request #47345 from nekomatata/heightmap-draw-triangles
Draw triangles for HeightMapShape debug collision
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/height_map_shape_3d.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/scene/resources/height_map_shape_3d.cpp b/scene/resources/height_map_shape_3d.cpp
index 6bb0faf098..de5da944bc 100644
--- a/scene/resources/height_map_shape_3d.cpp
+++ b/scene/resources/height_map_shape_3d.cpp
@@ -44,7 +44,7 @@ Vector<Vector3> HeightMapShape3D::get_debug_mesh_lines() const {
const float *r = map_data.ptr();
// reserve some memory for our points..
- points.resize(((map_width - 1) * map_depth * 2) + (map_width * (map_depth - 1) * 2));
+ points.resize(((map_width - 1) * map_depth * 2) + (map_width * (map_depth - 1) * 2) + ((map_width - 1) * (map_depth - 1) * 2));
// now set our points
int r_offset = 0;
@@ -65,6 +65,11 @@ Vector<Vector3> HeightMapShape3D::get_debug_mesh_lines() const {
points.write[w_offset++] = Vector3(height.x, r[r_offset + map_width - 1], height.z + 1.0);
}
+ if ((w != map_width - 1) && (d != map_depth - 1)) {
+ points.write[w_offset++] = Vector3(height.x + 1.0, r[r_offset], height.z);
+ points.write[w_offset++] = Vector3(height.x, r[r_offset + map_width - 1], height.z + 1.0);
+ }
+
height.x += 1.0;
}