| 942 | } |
| 943 | |
| 944 | void BindlessDeferred::Update(const Timer& timer) |
| 945 | { |
| 946 | CPUProfileBlock profileBlock("Update"); |
| 947 | |
| 948 | AppSettings::UpdateUI(); |
| 949 | |
| 950 | MouseState mouseState = MouseState::GetMouseState(window); |
| 951 | KeyboardState kbState = KeyboardState::GetKeyboardState(window); |
| 952 | |
| 953 | currMouseState = mouseState; |
| 954 | |
| 955 | if(kbState.IsKeyDown(KeyboardState::Escape)) |
| 956 | window.Destroy(); |
| 957 | |
| 958 | float CamMoveSpeed = 5.0f * timer.DeltaSecondsF(); |
| 959 | const float CamRotSpeed = 0.180f * timer.DeltaSecondsF(); |
| 960 | |
| 961 | // Move the camera with keyboard input |
| 962 | if(kbState.IsKeyDown(KeyboardState::LeftShift)) |
| 963 | CamMoveSpeed *= 0.25f; |
| 964 | |
| 965 | Float3 camPos = camera.Position(); |
| 966 | if(kbState.IsKeyDown(KeyboardState::W)) |
| 967 | camPos += camera.Forward() * CamMoveSpeed; |
| 968 | else if (kbState.IsKeyDown(KeyboardState::S)) |
| 969 | camPos += camera.Back() * CamMoveSpeed; |
| 970 | if(kbState.IsKeyDown(KeyboardState::A)) |
| 971 | camPos += camera.Left() * CamMoveSpeed; |
| 972 | else if (kbState.IsKeyDown(KeyboardState::D)) |
| 973 | camPos += camera.Right() * CamMoveSpeed; |
| 974 | if(kbState.IsKeyDown(KeyboardState::Q)) |
| 975 | camPos += camera.Up() * CamMoveSpeed; |
| 976 | else if (kbState.IsKeyDown(KeyboardState::E)) |
| 977 | camPos += camera.Down() * CamMoveSpeed; |
| 978 | camera.SetPosition(camPos); |
| 979 | |
| 980 | // Rotate the camera with the mouse |
| 981 | if(mouseState.RButton.Pressed && mouseState.IsOverWindow) |
| 982 | { |
| 983 | float xRot = camera.XRotation(); |
| 984 | float yRot = camera.YRotation(); |
| 985 | xRot += mouseState.DY * CamRotSpeed; |
| 986 | yRot += mouseState.DX * CamRotSpeed; |
| 987 | camera.SetXRotation(xRot); |
| 988 | camera.SetYRotation(yRot); |
| 989 | } |
| 990 | |
| 991 | UpdateDecals(timer); |
| 992 | UpdateLights(); |
| 993 | |
| 994 | appViewMatrix = camera.ViewMatrix(); |
| 995 | |
| 996 | // Toggle VSYNC |
| 997 | swapChain.SetVSYNCEnabled(AppSettings::EnableVSync ? true : false); |
| 998 | |
| 999 | skyCache.Init(AppSettings::SunDirection, AppSettings::SunSize, AppSettings::GroundAlbedo, AppSettings::Turbidity, true); |
| 1000 | |
| 1001 | if(AppSettings::MSAAMode.Changed() || AppSettings::ClusterRasterizationMode.Changed()) |
no test coverage detected