Skip to content

Commit

Permalink
Merge pull request #47345 from nekomatata/heightmap-draw-triangles
Browse files Browse the repository at this point in the history
Draw triangles for HeightMapShape debug collision
  • Loading branch information
akien-mga authored Apr 20, 2021
2 parents fdf041a + 806a1a6 commit c368079
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scene/resources/height_map_shape_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit c368079

Please sign in to comment.