]> git.lizzy.rs Git - minetest.git/commitdiff
Fix rounding errors when slicing the shadow draw list (#13226)
authorx2048 <codeforsmile@gmail.com>
Mon, 20 Feb 2023 20:01:05 +0000 (21:01 +0100)
committerGitHub <noreply@github.com>
Mon, 20 Feb 2023 20:01:05 +0000 (21:01 +0100)
src/client/clientmap.cpp

index 39c811b85f7a15acdd6c862b975176e7dcb09fc8..d987a2ee35f3408268ea24ffa628c44785ee46da 100644 (file)
@@ -978,9 +978,10 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
        std::vector<DrawDescriptor> draw_order;
 
 
-       int count = 0;
-       int low_bound = is_transparent_pass ? 0 : m_drawlist_shadow.size() / total_frames * frame;
-       int high_bound = is_transparent_pass ? m_drawlist_shadow.size() : m_drawlist_shadow.size() / total_frames * (frame + 1);
+       std::size_t count = 0;
+       std::size_t meshes_per_frame = m_drawlist_shadow.size() / total_frames + 1;
+       std::size_t low_bound = is_transparent_pass ? 0 : meshes_per_frame * frame;
+       std::size_t high_bound = is_transparent_pass ? m_drawlist_shadow.size() : meshes_per_frame * (frame + 1);
 
        // transparent pass should be rendered in one go
        if (is_transparent_pass && frame != total_frames - 1) {