-
Notifications
You must be signed in to change notification settings - Fork 4
/
context.h
56 lines (44 loc) · 1.35 KB
/
context.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include "settings.h"
#include "gui.h"
#include "l4d2.h"
#define anti_rin( items )\
static bool init = true; \
if ( init ) \
{ \
items; \
init = false;\
} \
class c_context
{
public:
bool panic{ };
HMODULE instance{ };
c_gui m_gui;
c_render m_render;
c_settings m_settings;
std::vector< std::string > m_cfg_list;
int m_current_cfg;
bool m_menu_open;
int m_screen_w;
int m_screen_h;
int m_local_index{ };
CBaseEntity* m_local{ };
CUserCmd* m_cmd{ };
vec3 m_angles{ };
__forceinline bool w2s( const vec3& world, vec2& screen )
{
vec3 transform;
auto& matrix = g_l4d2.engine->WorldToScreenMatrix( );
transform.z = matrix[3][0] * world.x + matrix[3][1] * world.y + matrix[3][2] * world.z + matrix[3][3];
if ( transform.z < 0.001f )
return false;
transform.x = matrix[0][0] * world.x + matrix[0][1] * world.y + matrix[0][2] * world.z + matrix[0][3];
transform.y = matrix[1][0] * world.x + matrix[1][1] * world.y + matrix[1][2] * world.z + matrix[1][3];
transform.x /= transform.z;
transform.y /= transform.z;
screen.x = ( m_screen_w * 0.5f ) + ( transform.x * m_screen_w ) * 0.5f;
screen.y = ( m_screen_h * 0.5f ) - ( transform.y * m_screen_h ) * 0.5f;
return true;
}
}; extern c_context g_ctx;