TDME2 1.9.121
CollisionResponse_Entity.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include <tdme/tdme.h>
8#include <tdme/math/Vector3.h>
11
12using std::vector;
13
17
18/**
19 * Collision response entity
20 * @author Andreas Drewke
21 * @version $Id$
22 */
24{
25 friend class CollisionResponse;
26
27private:
28 float distance;
30 vector<Vector3> hitPoints;
31
32public:
33 /**
34 * Public constructor
35 */
37 }
38
39 /**
40 * @return distance
41 */
42 inline float getDistance() {
43 return distance;
44 }
45
46 /**
47 * Set distance
48 * @param distance distance
49 */
50 inline void setDistance(float distance) {
51 this->distance = distance;
52 }
53
54 /**
55 * @return penetration
56 */
57 inline float getPenetration() {
58 return -distance;
59 }
60
61 /**
62 * @return normal
63 */
64 inline const Vector3& getNormal() {
65 return normal;
66 }
67
68 /**
69 * Set normal
70 * @param normal normal
71 */
72 inline void setNormal(const Vector3& normal) {
73 this->normal = normal;
74 }
75
76 /**
77 * Adds a hit point
78 * @param hitPoint hit point
79 */
80 inline void addHitPoint(const Vector3& hitPoint) {
81 // check if we already have this hit point
82 for (auto i = 0; i < hitPoints.size(); i++) {
83 if (hitPoints[i].equals(hitPoint, 0.1f)) return;
84 }
85 hitPoints.push_back(hitPoint);
86 }
87
88 /**
89 * @return hit point count
90 */
91 inline int32_t getHitPointCount() {
92 return hitPoints.size();
93 }
94
95 /**
96 * Get hit point of given index
97 * @param idx index
98 * @return hit point for given hit points index
99 */
100 inline Vector3& getHitPoint(int32_t idx) {
101 return hitPoints[idx];
102 }
103
104};
void setNormal(const Vector3 &normal)
Set normal.
void addHitPoint(const Vector3 &hitPoint)
Adds a hit point.
Vector3 & getHitPoint(int32_t idx)
Get hit point of given index.
3D vector 3 class
Definition: Vector3.h:22
Console class.
Definition: Console.h:26