mirror of
https://github.com/phoboslab/wipeout-rewrite
synced 2024-12-27 09:59:24 +01:00
Prevent int overflow when projecting target reticle on screen; close #48
This commit is contained in:
parent
41399234f6
commit
da4d3b5c0c
1 changed files with 9 additions and 0 deletions
|
@ -170,6 +170,15 @@ static void hud_draw_target_icon(vec3_t position) {
|
|||
vec2i_t size = ui_scaled(render_texture_size(target_reticle));
|
||||
vec3_t projected = render_transform(position);
|
||||
|
||||
// Not on screen?
|
||||
if (
|
||||
projected.x < -1 || projected.x > 1 ||
|
||||
projected.y < -1 || projected.y > 1 ||
|
||||
projected.z >= 1
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
vec2i_t pos = vec2i(
|
||||
(( projected.x + 1.0) / 2.0) * screen_size.x - size.x / 2,
|
||||
((-projected.y + 1.0) / 2.0) * screen_size.y - size.y / 2
|
||||
|
|
Loading…
Reference in a new issue