-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.h
80 lines (63 loc) · 1.45 KB
/
Player.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include "typedefs.h"
#include "WorldObject.h"
#include "ScreenLogger.h"
namespace engine
{
class Player : public WorldObject
{
private:
Player() :
WorldObject(),
move_speed(20.0),
cam_dir{ 0.0, 0.0, -1.0 },
cam_pos{ 0.0, 1.7, 0.0 },
torso_dir{ 0.0, 0.0, -1.0 },
left_dir{ -1.0, 0.0, 0.0 }
{}
public:
Player(const Player&) = delete;
~Player() = default;
Player& operator = (const Player&) = delete;
public:
double move_speed;
volatile vector3d cam_dir;
volatile vector3d cam_pos;
volatile vector3d torso_dir;
volatile vector3d left_dir;
public:
static Player& getInstance()
{
static Player instance;
return instance;
}
void createCollisionBox(float x, float y, float z) override
{
auto* AABB = new CollisionBox;
AABB->x1 = -0.5f;
AABB->x2 = +0.5f;
AABB->y1 = 0.05f;
AABB->y2 = 2.0f;
AABB->z1 = -0.5f;
AABB->z2 = +0.5f;
CBlist.push_back(AABB);
}
void updateCollisionBox()
{
for (auto bb : CBlist)
{
bb->x1 = (float)cam_pos[0] - 0.5f;
bb->x2 = (float)cam_pos[0] + 0.5f;
bb->y1 = (float)cam_pos[1] - 1.65f;
bb->y2 = (float)cam_pos[1] + 0.3f;
bb->z1 = (float)cam_pos[2] - 0.5f;
bb->z2 = (float)cam_pos[2] + 0.5f;
if constexpr (LOG_COLLISIONS)
ScreenLogger::getInstance().logMessage(
"AABB: from (%.3lf, %.3lf, %.3lf) to (%.3lf, %.3lf, %.3lf)",
bb->x1, bb->y1, bb->z1, bb->x2, bb->y2, bb->z2
);
}
}
};
}