1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Scale culler steps proportionally to the mesh sizes (#13250)

This commit is contained in:
x2048 2023-03-11 14:10:26 +01:00 committed by GitHub
parent 1de8a1e962
commit 705195b43e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 129 additions and 63 deletions

View file

@ -151,10 +151,22 @@ struct MeshGrid {
u32 getCellVolume() const { return cell_size * cell_size * cell_size; }
/// @brief returns coordinate of mesh cell given coordinate of a map block
s16 getCellPos(s16 p) const
{
return (p - (p < 0) * (cell_size - 1)) / cell_size;
}
/// @brief returns position of mesh cell in the grid given position of a map block
v3s16 getCellPos(v3s16 block_pos) const
{
return v3s16(getCellPos(block_pos.X), getCellPos(block_pos.Y), getCellPos(block_pos.Z));
}
/// @brief returns closest step of the grid smaller than p
s16 getMeshPos(s16 p) const
{
return ((p - (p < 0) * (cell_size - 1)) / cell_size * cell_size);
return getCellPos(p) * cell_size;
}
/// @brief Returns coordinates of the origin of the grid cell containing p