17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-03 12:00:22 +01:00

Cull the scenery models drawn on their own on the GPU with the instances

This commit is contained in:
2026-10-19 10:54:04 +02:00
parent ffe77be754
commit b1f880b5a7
10 changed files with 185 additions and 15 deletions

View File

@@ -221,9 +221,12 @@ public:
struct instance_bucket_key {
TModel3d *pModel { nullptr };
std::array<material_handle, 5> skins {};
// an instance drawn on its own (not instanceable) culled on the gpu as a bucket of its own: it isn't drawn
// together with other instances of the model, as its submodel tree is prepared and walked for it alone
TAnimModel const *instance { nullptr };
bool operator==( instance_bucket_key const &other ) const {
return pModel == other.pModel && skins == other.skins;
return pModel == other.pModel && skins == other.skins && instance == other.instance;
}
};
struct instance_bucket_key_hash {
@@ -233,6 +236,7 @@ public:
// boost-style hash combine
h ^= std::hash<int>()( s ) + 0x9e3779b9 + ( h << 6 ) + ( h >> 2 );
}
h ^= std::hash<TAnimModel const *>()( k.instance ) + 0x9e3779b9 + ( h << 6 ) + ( h >> 2 );
return h;
}
};