Skip to content

Commit

Permalink
remove empty mmi
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtarsia committed Oct 13, 2024
1 parent 583d889 commit ed06faf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/terrain_3d_instancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ void Terrain3DInstancer::_update_vertex_spacing(const real_t p_vertex_spacing) {
region->set_vertex_spacing(p_vertex_spacing);
region->set_modified(true);
}
destroy();
_update_mmis();
}

Expand Down Expand Up @@ -564,6 +565,15 @@ void Terrain3DInstancer::remove_instances(const Vector3 &p_global_position, cons
triple[2] = true;
cells_dict[cell] = triple;
} else {
// free the mmi for this cell
// _mmi_nodes{region_loc} -> mesh{v2i(mesh_id,lod)} -> cell{v2i} -> MultiMeshInstance3D
Dictionary region_mmis = _mmi_nodes[region_loc];
Dictionary mesh_mmis = region_mmis[Vector2i(m, 0)];
if (mesh_mmis.has(cell)) {
MultiMeshInstance3D *mmi = cast_to<MultiMeshInstance3D>(mesh_mmis[cell]);
remove_from_tree(mmi);
memdelete_safely(mmi);
}
cells_dict.erase(cell);
}
}
Expand Down

0 comments on commit ed06faf

Please sign in to comment.