]> git.lizzy.rs Git - minetest.git/blobdiff - src/client/clientmap.h
Add depth sorting for node faces (#11696)
[minetest.git] / src / client / clientmap.h
index b4dc423950c697e628c837060e2e03abf4e5d35b..d8554313d1cddf6fb56361c344a00165713a5287 100644 (file)
@@ -56,6 +56,7 @@ struct MeshBufListList
 
 class Client;
 class ITextureSource;
+class PartialMeshBuffer;
 
 /*
        ClientMap
@@ -85,21 +86,7 @@ class ClientMap : public Map, public scene::ISceneNode
                ISceneNode::drop();
        }
 
-       void updateCamera(const v3f &pos, const v3f &dir, f32 fov, const v3s16 &offset)
-       {
-               v3s16 previous_block = getContainerPos(floatToInt(m_camera_position, BS) + m_camera_offset, MAP_BLOCKSIZE);
-
-               m_camera_position = pos;
-               m_camera_direction = dir;
-               m_camera_fov = fov;
-               m_camera_offset = offset;
-
-               v3s16 current_block = getContainerPos(floatToInt(m_camera_position, BS) + m_camera_offset, MAP_BLOCKSIZE);
-
-               // reorder the blocks when camera crosses block boundary
-               if (previous_block != current_block)
-                       m_needs_update_drawlist = true;
-       }
+       void updateCamera(v3f pos, v3f dir, f32 fov, v3s16 offset);
 
        /*
                Forcefully get a sector from somewhere
@@ -150,6 +137,10 @@ class ClientMap : public Map, public scene::ISceneNode
        f32 getCameraFov() const { return m_camera_fov; }
 
 private:
+
+       // update the vertex order in transparent mesh buffers
+       void updateTransparentMeshBuffers();
+
        // Orders blocks by distance to the camera
        class MapBlockComparer
        {
@@ -167,6 +158,26 @@ class ClientMap : public Map, public scene::ISceneNode
                v3s16 m_camera_block;
        };
 
+
+       // reference to a mesh buffer used when rendering the map.
+       struct DrawDescriptor {
+               v3s16 m_pos;
+               union {
+                       scene::IMeshBuffer *m_buffer;
+                       const PartialMeshBuffer *m_partial_buffer;
+               };
+               bool m_reuse_material:1;
+               bool m_use_partial_buffer:1;
+
+               DrawDescriptor(v3s16 pos, scene::IMeshBuffer *buffer, bool reuse_material) :
+                       m_pos(pos), m_buffer(buffer), m_reuse_material(reuse_material), m_use_partial_buffer(false)
+               {}
+
+               DrawDescriptor(v3s16 pos, const PartialMeshBuffer *buffer) :
+                       m_pos(pos), m_partial_buffer(buffer), m_reuse_material(false), m_use_partial_buffer(true)
+               {}
+       };
+
        Client *m_client;
        RenderingEngine *m_rendering_engine;
 
@@ -179,6 +190,7 @@ class ClientMap : public Map, public scene::ISceneNode
        v3f m_camera_direction = v3f(0,0,1);
        f32 m_camera_fov = M_PI;
        v3s16 m_camera_offset;
+       bool m_needs_update_transparent_meshes = true;
 
        std::map<v3s16, MapBlock*, MapBlockComparer> m_drawlist;
        std::map<v3s16, MapBlock*> m_drawlist_shadow;
@@ -190,4 +202,5 @@ class ClientMap : public Map, public scene::ISceneNode
        bool m_cache_bilinear_filter;
        bool m_cache_anistropic_filter;
        bool m_added_to_shadow_renderer{false};
+       u16 m_cache_transparency_sorting_distance;
 };