rename _mmi_nodes to _mmi_rids
This commit is contained in:
parent
114352f4fe
commit
3a50b8e3f1
|
|
@ -170,7 +170,7 @@ void Terrain3DInstancer::_update_mmi_by_region(const Terrain3DRegion *p_region,
|
||||||
// Setup MMIs for each LOD + shadows
|
// Setup MMIs for each LOD + shadows
|
||||||
|
|
||||||
// Get or create mesh dict (defined here as cleanup above might invalidate it)
|
// Get or create mesh dict (defined here as cleanup above might invalidate it)
|
||||||
MeshMMIDict &mesh_mmi_dict = _region_mmis[region_loc];
|
MeshMMIDict &mesh_mmi_dict = _mmi_rids[region_loc];
|
||||||
RID shadow_impostor_source_mm;
|
RID shadow_impostor_source_mm;
|
||||||
|
|
||||||
for (int lod = ma->get_last_lod(); lod >= Terrain3DMeshAsset::SHADOW_LOD_ID; lod--) {
|
for (int lod = ma->get_last_lod(); lod >= Terrain3DMeshAsset::SHADOW_LOD_ID; lod--) {
|
||||||
|
|
@ -373,8 +373,8 @@ void Terrain3DInstancer::_destroy_mmi_by_mesh(const int p_mesh_id) {
|
||||||
void Terrain3DInstancer::_destroy_mmi_by_location(const Vector2i &p_region_loc, const int p_mesh_id) {
|
void Terrain3DInstancer::_destroy_mmi_by_location(const Vector2i &p_region_loc, const int p_mesh_id) {
|
||||||
LOG(DEBUG, "Deleting all MMIs in region: ", p_region_loc, " for mesh_id: ", p_mesh_id);
|
LOG(DEBUG, "Deleting all MMIs in region: ", p_region_loc, " for mesh_id: ", p_mesh_id);
|
||||||
std::unordered_set<Vector2i, Vector2iHash> cells;
|
std::unordered_set<Vector2i, Vector2iHash> cells;
|
||||||
if (_region_mmis.count(p_region_loc) > 0) {
|
if (_mmi_rids.count(p_region_loc) > 0) {
|
||||||
MeshMMIDict &mesh_mmi_dict = _region_mmis[p_region_loc];
|
MeshMMIDict &mesh_mmi_dict = _mmi_rids[p_region_loc];
|
||||||
for (const auto &mesh_entry : mesh_mmi_dict) {
|
for (const auto &mesh_entry : mesh_mmi_dict) {
|
||||||
const Vector2i &mesh_key = mesh_entry.first;
|
const Vector2i &mesh_key = mesh_entry.first;
|
||||||
if (mesh_key.x != p_mesh_id) {
|
if (mesh_key.x != p_mesh_id) {
|
||||||
|
|
@ -393,10 +393,10 @@ void Terrain3DInstancer::_destroy_mmi_by_location(const Vector2i &p_region_loc,
|
||||||
}
|
}
|
||||||
|
|
||||||
void Terrain3DInstancer::_destroy_mmi_by_cell(const Vector2i &p_region_loc, const int p_mesh_id, const Vector2i p_cell, const int p_lod) {
|
void Terrain3DInstancer::_destroy_mmi_by_cell(const Vector2i &p_region_loc, const int p_mesh_id, const Vector2i p_cell, const int p_lod) {
|
||||||
if (_region_mmis.count(p_region_loc) == 0) {
|
if (_mmi_rids.count(p_region_loc) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MeshMMIDict &mesh_mmi_dict = _region_mmis[p_region_loc];
|
MeshMMIDict &mesh_mmi_dict = _mmi_rids[p_region_loc];
|
||||||
Ref<Terrain3DMeshAsset> ma = _terrain->get_assets()->get_mesh_asset(p_mesh_id);
|
Ref<Terrain3DMeshAsset> ma = _terrain->get_assets()->get_mesh_asset(p_mesh_id);
|
||||||
|
|
||||||
for (int lod = Terrain3DMeshAsset::SHADOW_LOD_ID; lod < Terrain3DMeshAsset::MAX_LOD_COUNT; lod++) {
|
for (int lod = Terrain3DMeshAsset::SHADOW_LOD_ID; lod < Terrain3DMeshAsset::MAX_LOD_COUNT; lod++) {
|
||||||
|
|
@ -431,7 +431,7 @@ void Terrain3DInstancer::_destroy_mmi_by_cell(const Vector2i &p_region_loc, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
// This invalidates mesh_mmi_dict here and for calling functions
|
// This invalidates mesh_mmi_dict here and for calling functions
|
||||||
_region_mmis.erase(p_region_loc);
|
_mmi_rids.erase(p_region_loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,11 @@ private:
|
||||||
// Region::_instances{mesh_id:int} -> cell{v2i} -> [ TypedArray<Transform3D>, PackedColorArray, modified:bool ]
|
// Region::_instances{mesh_id:int} -> cell{v2i} -> [ TypedArray<Transform3D>, PackedColorArray, modified:bool ]
|
||||||
|
|
||||||
// A pair of MMI and MM RIDs, freed in destructor, stored as
|
// A pair of MMI and MM RIDs, freed in destructor, stored as
|
||||||
// _region_mmis{region_loc} -> mesh{v2i(mesh_id,lod)} -> cell{v2i} -> std::pair<mmi.RID, mm.RID>
|
// _mmi_rids{region_loc} -> mesh{v2i(mesh_id,lod)} -> cell{v2i} -> std::pair<mmi_RID, mm_RID>
|
||||||
|
|
||||||
using CellMMIDict = std::unordered_map<Vector2i, std::pair<RID, RID>, Vector2iHash>;
|
using CellMMIDict = std::unordered_map<Vector2i, std::pair<RID, RID>, Vector2iHash>;
|
||||||
using MeshMMIDict = std::unordered_map<Vector2i, CellMMIDict, Vector2iHash>;
|
using MeshMMIDict = std::unordered_map<Vector2i, CellMMIDict, Vector2iHash>;
|
||||||
std::unordered_map<Vector2i, MeshMMIDict, Vector2iHash> _region_mmis;
|
std::unordered_map<Vector2i, MeshMMIDict, Vector2iHash> _mmi_rids;
|
||||||
|
|
||||||
// MMI Updates tracked in a unique Set of <region_location, mesh_id>
|
// MMI Updates tracked in a unique Set of <region_location, mesh_id>
|
||||||
// <V2I_MAX, -2> means destroy first, then update everything
|
// <V2I_MAX, -2> means destroy first, then update everything
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue