home *** CD-ROM | disk | FTP | other *** search
- #ifndef __collision_h__
- #define __collision_h__
-
- #include "vectormath.h"
- #include "Face.h"
- //#include "Vehicle.h"
- class Vehicle;
-
- #include <vector>
- using namespace std;
-
- class SpacePartitioningTreeNode;
-
- typedef struct AABB_s{
- vec3_t min, max;
- }AABB_t;
-
-
- #define COLLISION_FLAG_NONE 0x0000
- #define COLLISION_FLAG_SHOOT_THROUGH 0x0001
- #define COLLISION_FLAG_WALK_THROUGH 0x0002
- #define COLLISION_FLAG_ARENA 0x0004
- #define COLLISION_FLAG_VEHICLES 0x0008
- #define COLLISION_FLAG_BACKFACES 0x0010
- #define COLLISION_FLAG_SUBSEQUENT_HITS 0x0020
-
- enum traceTypes_e{
- TRACE_TYPE_RAY=0,
- TRACE_TYPE_LINE_SEGMENT,
- TRACE_TYPE_AABB,
-
- NUM_TRACE_TYPES
- };
-
- typedef struct hit_s{
- vec3_t pos;
- float distance;
- SpacePartitioningTreeNode* node;
- Face* face;
- Vehicle* vehicle;
- }hit_t;
-
- typedef struct trace_s{
- int traceType;
- vec3_t startPos;
- vec3_t dir;
- vec3_t endPos;
- vec3_t min, max;
- unsigned int ignoreFlags;
-
- vector<hit_t> hits;
- }trace_t;
-
-
-
- bool rayIntersectsFace(vec3_t pos, vec3_t dir, Face* face, float* distance, vec3_t hitpoint);
- bool linesegmentIntersectsFace(vec3_t pos1, vec3_t pos2, Face* face, float* distance, vec3_t hitpoint);
-
-
- void traceRay(vec3_t startPos, vec3_t dir, trace_t* trace);
- void traceLinesegment(vec3_t pos1, vec3_t pos2, trace_t* trace);
- void traceAABB(vec3_t pos1, vec3_t pos2, AABB_t, trace_t* trace);
-
- //void castRay();
- //void renderDebugStuff();
-
- //void collisionDetection(Mech* mech, int deltaT);
- //void collisionDetection(Camera* cam, int deltaT); // als member
-
- #endif /* __collision_h__ */
-