mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-31 13:29:07 +01:00
perf(gl46): leave out instance buckets before the culling, lod bounds once per model, shared walks of the shadow cascades
This commit is contained in:
@@ -1616,6 +1616,7 @@ void TModel3d::AddTo(TSubModel *tmp, TSubModel *SubModel)
|
||||
}
|
||||
++iSubModelsCount; // teraz jest o 1 submodel więcej
|
||||
iFlags |= 0x0200; // submodele są oddzielne
|
||||
m_lodboundsfound = false; // the new submodel may have its own range
|
||||
};
|
||||
|
||||
TSubModel *TModel3d::GetFromName(std::string const &Name) const
|
||||
@@ -1643,6 +1644,33 @@ TModel3d::instance_submodels const &TModel3d::instance_parts()
|
||||
return m_instancesubmodels;
|
||||
}
|
||||
|
||||
// returns the distinct bounds of the visibility ranges of the submodels, sorted, finding them on first use
|
||||
std::vector<float> const &TModel3d::lod_bounds()
|
||||
{
|
||||
if (false == m_lodboundsfound)
|
||||
{
|
||||
m_lodbounds.clear();
|
||||
std::vector<TSubModel const *> pending{Root};
|
||||
while (false == pending.empty())
|
||||
{
|
||||
auto const *submodel{pending.back()};
|
||||
pending.pop_back();
|
||||
if (submodel == nullptr)
|
||||
continue;
|
||||
if (submodel->fSquareMinDist > 0.f)
|
||||
m_lodbounds.emplace_back(submodel->fSquareMinDist);
|
||||
if (submodel->fSquareMaxDist < std::numeric_limits<float>::max())
|
||||
m_lodbounds.emplace_back(submodel->fSquareMaxDist);
|
||||
pending.push_back(submodel->Child);
|
||||
pending.push_back(submodel->Next);
|
||||
}
|
||||
std::sort(m_lodbounds.begin(), m_lodbounds.end());
|
||||
m_lodbounds.erase(std::unique(m_lodbounds.begin(), m_lodbounds.end()), m_lodbounds.end());
|
||||
m_lodboundsfound = true;
|
||||
}
|
||||
return m_lodbounds;
|
||||
}
|
||||
|
||||
// locates particle source submodels and stores them on internal list
|
||||
nameoffset_sequence const &TModel3d::find_smoke_sources()
|
||||
{
|
||||
|
||||
@@ -292,6 +292,8 @@ private:
|
||||
nameoffset_sequence m_smokesources; // list of particle sources defined in the model
|
||||
instance_submodels m_instancesubmodels; // filled on first use, see instance_parts()
|
||||
bool m_instancesubmodelslocated { false };
|
||||
std::vector<float> m_lodbounds; // filled on first use, see lod_bounds()
|
||||
bool m_lodboundsfound { false };
|
||||
|
||||
public:
|
||||
TModel3d() = default;
|
||||
@@ -303,6 +305,9 @@ public:
|
||||
// returns submodels which scenery instances of the model refer to by name. the search for a name goes through the whole
|
||||
// submodel tree, so it's done once for the model instead of once for each of its instances
|
||||
instance_submodels const & instance_parts();
|
||||
// returns the distinct bounds of the visibility ranges of the submodels (fSquareMinDist and fSquareMaxDist, squared), sorted:
|
||||
// they split the distance into bands in which the same submodels are drawn. found once for the model, like instance_parts()
|
||||
std::vector<float> const & lod_bounds();
|
||||
TSubModel * AddToNamed(const char *Name, TSubModel *SubModel);
|
||||
nameoffset_sequence const & find_smoke_sources();
|
||||
void AddTo(TSubModel *tmp, TSubModel *SubModel);
|
||||
|
||||
Reference in New Issue
Block a user