From baf7da9d4a7fc0566840b159903999d76d99a228 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Thu, 8 Sep 2011 01:08:47 +0200 Subject: Collected and moved existing camera infrastructure from game.cpp to camera.cpp and camera.h. Introduced configuration settings 'fov' which chooses the camera's (vertical) field of view and 'view_bobbing' which currently does nothing. Other code refactored to not expect the FOV to be a build time constant. --- src/server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index 14d8942cb..fd93d7523 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -584,7 +584,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime, Don't generate or send if not in sight */ - if(isBlockInSight(p, camera_pos, camera_dir, 10000*BS) == false) + if(isBlockInSight(p, camera_pos, camera_dir, M_PI, 10000*BS) == false) { continue; } -- cgit v1.2.3 From e4cb0044602f2dc5eb92c8955797b628c158a0d9 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Thu, 8 Sep 2011 16:10:44 +0200 Subject: trying something else... also replaced M_PI by PI everywhere --- src/camera.cpp | 6 +++--- src/game.cpp | 9 +++++---- src/map.cpp | 2 +- src/server.cpp | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/server.cpp') diff --git a/src/camera.cpp b/src/camera.cpp index 7c3dfda3c..8dc1af02b 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -105,10 +105,10 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize) if ((m_view_bobbing_anim & (BOBFRAMES/2-1)) != 0) { - f32 bobamount = cos(player->getPitch() * M_PI / 180); + f32 bobamount = cos(player->getPitch() * PI / 180); bobamount = 2 * MYMIN(bobamount, 0.5); - f32 bobangle = m_view_bobbing_anim * 2 * M_PI / BOBFRAMES; + f32 bobangle = m_view_bobbing_anim * 2 * PI / BOBFRAMES; f32 bobangle_s = sin(bobangle); f32 bobangle_c = cos(bobangle); f32 bobwidth = 0.02 * bobamount / (bobangle_c * bobangle_c + 1); @@ -282,7 +282,7 @@ void Camera::updateSettings() f32 fov_degrees = g_settings.getFloat("fov"); fov_degrees = MYMAX(fov_degrees, 10.0); fov_degrees = MYMIN(fov_degrees, 170.0); - m_fov_y = fov_degrees * M_PI / 180.0; + m_fov_y = fov_degrees * PI / 180.0; f32 wanted_fps = g_settings.getFloat("wanted_fps"); wanted_fps = MYMAX(wanted_fps, 1.0); diff --git a/src/game.cpp b/src/game.cpp index af4886137..cb7594c30 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -831,7 +831,7 @@ void the_game( Tool */ - v3f tool_wield_position(0.06*BS, 1.619*BS, 0.1*BS); + v3f tool_wield_position(0.06*BS, -0.06*BS, 0.1*BS); v3f tool_wield_rotation(-25, 180, -25); float tool_wield_animation = 0.0; scene::IMeshSceneNode *tool_wield; @@ -856,7 +856,7 @@ void the_game( mesh->addMeshBuffer(buf); buf->drop(); - tool_wield = smgr->addMeshSceneNode(mesh, camera.getPlayerNode()); + tool_wield = smgr->addMeshSceneNode(mesh, camera.getCameraNode()); mesh->drop(); } tool_wield->setVisible(false); @@ -1997,8 +1997,9 @@ void the_game( Animate tool */ { - tool_wield->setRotation(tool_wield_rotation - sin(tool_wield_animation * PI) * 40.0); - tool_wield->setPosition(tool_wield_position - sin(tool_wield_animation * PI) / 3.0); + f32 tool_wield_sin = sin(tool_wield_animation * PI); + tool_wield->setRotation(tool_wield_rotation - tool_wield_sin * 40.0); + tool_wield->setPosition(tool_wield_position - tool_wield_sin * BS / 30.0); } diff --git a/src/map.cpp b/src/map.cpp index b1908fe2e..ecd12bddb 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3605,7 +3605,7 @@ ClientMap::ClientMap( m_control(control), m_camera_position(0,0,0), m_camera_direction(0,0,1), - m_camera_fov(M_PI) + m_camera_fov(PI) { m_camera_mutex.Init(); assert(m_camera_mutex.IsInitialized()); diff --git a/src/server.cpp b/src/server.cpp index fd93d7523..c89e4113b 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -584,7 +584,7 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime, Don't generate or send if not in sight */ - if(isBlockInSight(p, camera_pos, camera_dir, M_PI, 10000*BS) == false) + if(isBlockInSight(p, camera_pos, camera_dir, PI, 10000*BS) == false) { continue; } -- cgit v1.2.3 From acfb2bb8bced286626fa1fc04d56c9ba9ff82d48 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Fri, 16 Sep 2011 18:03:58 +0200 Subject: Revert some changes that could lead to slower map transfer and increaed network load. --- src/server.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index c89e4113b..46993913f 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -582,9 +582,12 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime, /* Don't generate or send if not in sight + FIXME This only works if the client uses a small enough + FOV setting. The default of 72 degrees is fine. */ - if(isBlockInSight(p, camera_pos, camera_dir, PI, 10000*BS) == false) + float camera_fov = (72.0*PI/180) * 4./3.; + if(isBlockInSight(p, camera_pos, camera_dir, camera_fov, 10000*BS) == false) { continue; } -- cgit v1.2.3