mirror of
https://github.com/Relintai/godot_voxel.git
synced 2024-11-19 02:47:18 +01:00
Fix dual grid debug mesh not making cubes properly; check for emptyness
This commit is contained in:
parent
1181cfa59f
commit
a12435266f
@ -311,6 +311,10 @@ Ref<ArrayMesh> generate_debug_octree_mesh(OctreeNode *root) {
|
||||
add_cube.max_depth = get_max_depth.max_depth;
|
||||
foreach_node(root, add_cube);
|
||||
|
||||
if (arrays.positions.size() == 0) {
|
||||
return Ref<ArrayMesh>();
|
||||
}
|
||||
|
||||
Array surface;
|
||||
surface.resize(Mesh::ARRAY_MAX);
|
||||
surface[Mesh::ARRAY_VERTEX] = arrays.positions;
|
||||
@ -373,14 +377,20 @@ Ref<ArrayMesh> generate_debug_dual_grid_mesh(const DualGrid &grid) {
|
||||
|
||||
const DualCell &cell = grid.cells[i];
|
||||
|
||||
int vi = positions.size();
|
||||
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
positions.push_back(cell.corners[j]);
|
||||
}
|
||||
|
||||
for (int j = 0; j < Cube::EDGE_COUNT; ++j) {
|
||||
indices.push_back(vi + Cube::g_edge_corners[j][0]);
|
||||
indices.push_back(vi + Cube::g_edge_corners[j][1]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < positions.size(); ++i) {
|
||||
indices.push_back(i);
|
||||
indices.push_back(i + 1);
|
||||
if (positions.size() == 0) {
|
||||
return Ref<ArrayMesh>();
|
||||
}
|
||||
|
||||
Array surface;
|
||||
|
Loading…
Reference in New Issue
Block a user