-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCollisionComponent.h
57 lines (44 loc) · 1.17 KB
/
CollisionComponent.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
#ifndef COLLISIONCOMPONENT_H
#define COLLISIONCOMPONENT_H
#include "../CommonTypes.h"
#include "../math/Vector3.h"
#include "../math/Matrix.h"
class Object;
class Sector;
struct CollisionPacket
{
Vector3 eRadius; //ellipsoid radius
Vector3 R3Velocity;
Vector3 R3VelocityNorm;
Vector3 R3Position;
Vector3 velocity;
Vector3 normalizedVelocity;
Vector3 basePoint;
Vector3 intNormal;
bool bFoundCollision;
bool bOnGround;
bool bEmbedded;
float nearestDist;
Vector3 intersectionPoint;
Vector3 pushVec;
};
struct RaycastPacket
{
Vector3 rayOrigin;
Vector3 rayDir;
bool bFoundIntersection;
float nearestDist;
Vector3 intersectionPoint;
Object *pCollisionObj;
Sector *pCollisionSector;
Vector3 bounds[2];
};
class CollisionComponent
{
public:
CollisionComponent() = default;
virtual ~CollisionComponent() = default;
virtual bool Collide(CollisionPacket *packet, Matrix *pWorldMtx, const Vector3& vOffset) {return false; }
virtual bool Raycast(RaycastPacket *packet, Matrix *pWorldMtx, Object *parent, Sector *pSector, const Vector3& vOffset) {return false;}
};
#endif //COLLISIONCOMPONENT_H