Modernize client code (#6250)
[oweals/minetest.git] / src / clientmap.cpp
index 73d600a7a89973e431c38163f9c500f15bd9f7a5..c443773b66461beaf7391066193001e97c295e1f 100644 (file)
@@ -31,16 +31,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "camera.h"               // CameraModes
 #include "util/basic_macros.h"
 #include <algorithm>
+#include "client/renderingengine.h"
 
 ClientMap::ClientMap(
                Client *client,
                MapDrawControl &control,
-               scene::ISceneNode* parent,
-               scene::ISceneManager* mgr,
                s32 id
 ):
        Map(dout_client, client),
-       scene::ISceneNode(parent, mgr, id),
+       scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(),
+               RenderingEngine::get_scene_manager(), id),
        m_client(client),
        m_control(control),
        m_camera_position(0,0,0),
@@ -596,11 +596,12 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
        };
        if(z_directions[0].X < -99){
                for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
+                       // Assumes FOV of 72 and 16/9 aspect ratio
                        z_directions[i] = v3f(
-                               0.01 * myrand_range(-100, 100),
+                               0.02 * myrand_range(-100, 100),
                                1.0,
                                0.01 * myrand_range(-100, 100)
-                       );
+                       ).normalize();
                        z_offsets[i] = 0.01 * myrand_range(0,100);
                }
        }
@@ -613,7 +614,6 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
        std::vector<int> values;
        for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
                v3f z_dir = z_directions[i];
-               z_dir.normalize();
                core::CMatrix4<f32> a;
                a.buildRotateFromTo(v3f(0,1,0), z_dir);
                v3f dir = m_camera_direction;