From ee2d9d973a0397ce244f05d49083250956578780 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 4 Sep 2012 09:48:26 +0300 Subject: Reorganize ClientMap rendering code for a bit more performance - Don't select blocks for drawing in every frame - Sort meshbuffers by material before drawing --- src/game.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index 7d93e3db2..a1a197219 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1235,6 +1235,9 @@ void the_game( float object_hit_delay_timer = 0.0; float time_from_last_punch = 10; + float update_draw_list_timer = 0.0; + v3f update_draw_list_last_cam_dir; + bool invert_mouse = g_settings->getBool("invert_mouse"); bool respawn_menu_active = false; @@ -2697,7 +2700,19 @@ void the_game( item = mlist->getItem(client.getPlayerItem()); camera.wield(item); } - + + /* + Update block draw list every 200ms or when camera direction has + changed much + */ + update_draw_list_timer += dtime; + if(update_draw_list_timer >= 0.2 || + update_draw_list_last_cam_dir.getDistanceFrom(camera_direction) > 0.2){ + update_draw_list_timer = 0; + client.getEnv().getClientMap().updateDrawList(driver); + update_draw_list_last_cam_dir = camera_direction; + } + /* Drawing begins */ -- cgit v1.2.3