forked from hitmen047/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmodel.h
129 lines (100 loc) · 2.79 KB
/
cmodel.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//=============================================================================//
#ifndef CMODEL_H
#define CMODEL_H
#ifdef _WIN32
#pragma once
#endif
#include "trace.h"
#include "tier0/dbg.h"
#include "basehandle.h"
struct edict_t;
struct model_t;
/*
==============================================================
COLLISION DETECTION
==============================================================
*/
#include "bspflags.h"
//#include "mathlib/vector.h"
// gi.BoxEdicts() can return a list of either solid or trigger entities
// FIXME: eliminate AREA_ distinction?
#define AREA_SOLID 1
#define AREA_TRIGGERS 2
#include "vcollide.h"
struct cmodel_t
{
Vector mins, maxs;
Vector origin; // for sounds or lights
int headnode;
vcollide_t vcollisionData;
};
struct csurface_t
{
const char *name;
short surfaceProps;
unsigned short flags; // BUGBUG: These are declared per surface, not per material, but this database is per-material now
};
//-----------------------------------------------------------------------------
// A ray...
//-----------------------------------------------------------------------------
struct Ray_t
{
VectorAligned m_Start; // starting point, centered within the extents
VectorAligned m_Delta; // direction + length of the ray
VectorAligned m_StartOffset; // Add this to m_Start to get the actual ray start
VectorAligned m_Extents; // Describes an axis aligned box extruded along a ray
bool m_IsRay; // are the extents zero?
bool m_IsSwept; // is delta != 0?
void Init( Vector const& start, Vector const& end )
{
Assert( &end );
VectorSubtract( end, start, m_Delta );
m_IsSwept = (m_Delta.LengthSqr() != 0);
VectorClear( m_Extents );
m_IsRay = true;
// Offset m_Start to be in the center of the box...
VectorClear( m_StartOffset );
VectorCopy( start, m_Start );
}
void Init( Vector const& start, Vector const& end, Vector const& mins, Vector const& maxs )
{
Assert( &end );
VectorSubtract( end, start, m_Delta );
m_IsSwept = (m_Delta.LengthSqr() != 0);
VectorSubtract( maxs, mins, m_Extents );
m_Extents *= 0.5f;
m_IsRay = (m_Extents.LengthSqr() < 1e-6);
// Offset m_Start to be in the center of the box...
VectorAdd( mins, maxs, m_StartOffset );
m_StartOffset *= 0.5f;
VectorAdd( start, m_StartOffset, m_Start );
m_StartOffset *= -1.0f;
}
// compute inverse delta
Vector InvDelta() const
{
Vector vecInvDelta;
for ( int iAxis = 0; iAxis < 3; ++iAxis )
{
if ( m_Delta[iAxis] != 0.0f )
{
vecInvDelta[iAxis] = 1.0f / m_Delta[iAxis];
}
else
{
vecInvDelta[iAxis] = FLT_MAX;
}
}
return vecInvDelta;
}
private:
};
#endif // CMODEL_H
#include "gametrace.h"