Skip to content

Commit

Permalink
Fixed the background blur behavior when the menu is opened on a syste…
Browse files Browse the repository at this point in the history
…m with over 24 days of uptime, and a few related type-casts.

In case of such uptime, Sys_Milliseconds() returns a value over 2^31, which is cast to a negative int.
  • Loading branch information
apanteleev committed Oct 18, 2021
1 parent f5a7dbf commit cd9c5c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/refresh/vkpt/bloom.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ void vkpt_bloom_update(QVKUniformBuffer_t * ubo, float frame_time, qboolean unde
bloom_sigma = mix(cvar_bloom_sigma->value, cvar_bloom_sigma_water->value, under_water_animation);
}

static int menu_start_ms = -1;
static uint32_t menu_start_ms = 0;

if (menu_mode)
{
if (menu_start_ms < 0)
if (menu_start_ms == 0)
menu_start_ms = Sys_Milliseconds();
int current_ms = Sys_Milliseconds();
uint32_t current_ms = Sys_Milliseconds();

float phase = max(0.f, min(1.f, (float)(current_ms - menu_start_ms) / 150.f));
phase = powf(phase, 0.25f);
Expand All @@ -118,7 +118,7 @@ void vkpt_bloom_update(QVKUniformBuffer_t * ubo, float frame_time, qboolean unde
}
else
{
menu_start_ms = -1;
menu_start_ms = 0;

ubo->bloom_intensity = bloom_intensity;
}
Expand Down
14 changes: 7 additions & 7 deletions src/refresh/vkpt/physical_sky.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,15 @@ static void change_image_layouts(VkImage image, const VkImageSubresourceRange* s
static void
process_gamepad_input()
{
static int prev_milliseconds = 0;
int curr_milliseconds = Sys_Milliseconds();
static uint32_t prev_milliseconds = 0;
uint32_t curr_milliseconds = Sys_Milliseconds();
if (!prev_milliseconds)
{
prev_milliseconds = curr_milliseconds;
return;
}

int frame_time = curr_milliseconds - prev_milliseconds;
uint32_t frame_time = curr_milliseconds - prev_milliseconds;
prev_milliseconds = curr_milliseconds;

if (frame_time > 1000)
Expand All @@ -575,10 +575,10 @@ process_gamepad_input()
dx = powf(max(fabsf(dx) - deadzone, 0.f) / limit, 2.f) * (dx < 0 ? -1.f : 1.f);
dy = powf(max(fabsf(dy) - deadzone, 0.f) / limit, 2.f) * (dy < 0 ? -1.f : 1.f);

dx *= frame_time * 0.05f;
dy *= frame_time * 0.05f;
dx *= (float)frame_time * 0.05f;
dy *= (float)frame_time * 0.05f;

if (dx)
if (dx != 0.f)
{
float azimuth = sun_azimuth->value;
azimuth -= dx;
Expand All @@ -588,7 +588,7 @@ process_gamepad_input()
sun_azimuth->changed(sun_azimuth);
}

if (dy)
if (dy != 0.f)
{
float elevation = sun_elevation->value;
elevation -= dy;
Expand Down

0 comments on commit cd9c5c7

Please sign in to comment.