-
Notifications
You must be signed in to change notification settings - Fork 47
/
Geometry.h
73 lines (54 loc) · 1.58 KB
/
Geometry.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
#ifndef CM_GEOMETRY_H_
#define CM_GEOMETRY_H_
#include <map>
#include <vector>
#include "math/Vector3.h"
#include "math/Plane3.h"
/** greebo: This contains all the geometry subtypes of a Doom3 CollisionModel.
**/
namespace cmutil {
// A list of indexed ("named") vertices
typedef std::vector<std::size_t> VertexList;
// The indexed vertices of the collisionmodel
typedef std::map<std::size_t, Vector3> VertexMap;
struct Edge {
std::size_t from; // The starting vertex index
std::size_t to; // The end vertex index
std::size_t numVertices; // At least I think it's numVertices
Edge(std::size_t num = 2) :
from(0),
to(0),
numVertices(num)
{}
};
// The indexed Edges (each consisting of a start/end vertex)
typedef std::map<std::size_t, Edge> EdgeMap;
// A vector of Edges defining a polygon (the sign indicates the direction)
typedef std::vector<int> EdgeList;
struct Polygon {
// The number of edges of this polygon
std::size_t numEdges;
// The indices of the edges forming this polygon
EdgeList edges;
// The plane (normal + distance)
Plane3 plane;
// Two vertices defining the AABB
Vector3 min;
Vector3 max;
// The shadername (this is textures/common/collision for
// proper Doom3 hulls, but it can be different as well).
std::string shader;
};
// The unsorted list of Polygons
typedef std::vector<Polygon> PolygonList;
typedef std::vector<Plane3> PlaneList;
struct BrushStruc {
std::size_t numFaces;
PlaneList planes;
// Two points defining the AABB
Vector3 min;
Vector3 max;
};
typedef std::vector<BrushStruc> BrushList;
} // namespace cmutil
#endif /*CM_GEOMETRY_H_*/