-
Notifications
You must be signed in to change notification settings - Fork 30
/
bsp.h
executable file
·96 lines (75 loc) · 1.52 KB
/
bsp.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef BSP_INCLUDED
#define BSP_INCLUDED
#include "main.h"
/*
* Defines
*/
#define TOLER (0.03125) //0.0000076F
#define INSIDE 1
#define OUTSIDE -1
#define ONPLANE 0
#define MAX_BSP_MODELS (2)
/*
* Structures
*/
typedef struct BSP_RAWNODE
{
VECTOR Normal;
float Offset;
int Front;
int Back;
int Colour;
}BSP_RAWNODE;
typedef struct BSP_NODE
{
VECTOR Normal;
float Offset;
int Colour;
struct BSP_NODE * Parent;
struct BSP_NODE * Front;
struct BSP_NODE * Back;
}BSP_NODE;
typedef struct BSP_TREE
{
int NumNodes;
BSP_NODE * Root;
}BSP_TREE;
typedef struct BSP_HEADER
{
bool State;
int NumGroups;
BSP_TREE Bsp_Tree[MAXGROUPS];
}BSP_HEADER;
typedef struct _BSP_PORTAL
{
u_int16_t group;
VECTOR normal;
float offset;
BSP_TREE bsp;
} BSP_PORTAL;
typedef struct _BSP_PORTAL_GROUP
{
int portals;
BSP_PORTAL *portal;
} BSP_PORTAL_GROUP;
typedef struct _BSP_PORTAL_HEADER
{
bool state;
int groups;
BSP_PORTAL_GROUP group[ MAXGROUPS ];
} BSP_PORTAL_HEADER;
/*
* global vars
*/
extern BSP_HEADER Bsp_Header[];
extern BSP_PORTAL_HEADER Bsp_Portal_Header;
/*
* fn prototypes
*/
void Bspfree( void );
bool Bspload( char * Filename, BSP_HEADER *Bsp_Header );
bool InBSPGroup( u_int16_t group, VECTOR *pos );
bool RayCollide( BSP_HEADER *Bsp_Header, VECTOR *StartPos, VECTOR *Dir, VECTOR *ImpactPoint, VECTOR *ImpactNormal, float *ImpactOffset ,u_int16_t group );
bool PointInSpaceRecursive( VECTOR *Pos );
bool PointInsideSkin( VECTOR *Pos, u_int16_t Group );
#endif // BSP_INCLUDED