From 00364ad476f86692934ba2c9e5fc7516ee6517ae Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Thu, 26 May 2022 17:43:22 -0700 Subject: [PATCH] Client: add helper function drawpic3d. Which instead of a screen position takes a 3d-world position as an argument. --- src/client/defs.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/client/defs.h b/src/client/defs.h index f68319b3..275fc056 100644 --- a/src/client/defs.h +++ b/src/client/defs.h @@ -110,6 +110,35 @@ void drawrect(vector pos, vector sz, float thickness, vector rgb, float al, opti drawfill(pos + [sz[0] - thickness, thickness], [thickness, sz[1] - (thickness * 2)], rgb, al, dfl); } +void +drawpic3d(vector worldpos, string mat, vector sz, vector rgb, float alpha) +{ + static bool + drawpic3d_visible(vector p1) { + vector delta; + float fov; + vector p2 = getproperty(VF_ORIGIN); + vector ang = getproperty(VF_CL_VIEWANGLES); + + makevectors(ang); + delta = normalize (p1 - p2); + fov = delta * v_forward; + + if (fov > (getproperty(VF_AFOV)/180)) { + traceline(p2, p1, MOVE_WORLDONLY, self); + if (trace_fraction == 1.0) { + return (1); + } + } + return (0); + } + + if (drawpic3d_visible(worldpos) == true) { + vector vecProj = project(worldpos) - (sz/2); + drawpic(vecProj, mat, sz, rgb, alpha); + } +} + void precache_cubemap(string path) {