summaryrefslogtreecommitdiffstats
path: root/src/render/Occlusion.h
blob: 9b7ba34f3a2eddea96b40e3b710b49f2c4abb796 (plain) (blame)
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
#pragma once

struct ActiveOccluderLine {
	CVector2D origin;
	CVector2D direction;
	float length; 
};

class CActiveOccluder {

public:
	ActiveOccluderLine lines[6];
	int32 linesCount;
	float radius; 

	bool IsPointWithinOcclusionArea(float x, float y, float area);
};

class COccluder
{
public:
	int16 width, length, height;
	int16 x, y, z;
	uint16 angle;
	int16 listIndex;

	bool NearCamera();
	bool ProcessOneOccluder(CActiveOccluder *occl);
	bool ProcessLineSegment(int corner1, int corner2, CActiveOccluder* occl);
};

class COcclusion
{
public:
	static int32 NumOccludersOnMap;
	static int16 FarAwayList;
	static int16 NearbyList;
	static int16 ListWalkThroughFA;
	static int16 PreviousListWalkThroughFA;
	static int16 NumActiveOccluders;

	static COccluder aOccluders[NUMOCCLUSIONVOLUMES];
	static CActiveOccluder aActiveOccluders[NUMACTIVEOCCLUDERS];

	static void Init(void);
	static void AddOne(float x, float y, float z, float width, float length, float height, float angle);
	static void ProcessBeforeRendering(void); 
	static bool OccluderHidesBehind(CActiveOccluder *occl1, CActiveOccluder *occl2);
	static bool IsAABoxOccluded(CVector pos, float width, float length, float height);
	static bool IsPositionOccluded(CVector pos, float side);
	static void Render();
};

bool CalcScreenCoors(CVector const &in, CVector *out, float *outw, float *outh);
bool CalcScreenCoors(CVector const &in, CVector *out);