32 |
using enigma::GridLayer; |
using enigma::GridLayer; |
33 |
using enigma::Direction; |
using enigma::Direction; |
34 |
using enigma::DirectionBits; |
using enigma::DirectionBits; |
35 |
using px::V3; |
using px::V2; |
36 |
|
|
37 |
using std::string; |
using std::string; |
38 |
} |
} |
45 |
*/ |
*/ |
46 |
class ActorInfo { |
class ActorInfo { |
47 |
public: |
public: |
48 |
ActorInfo(V3 p, V3 v) |
ActorInfo(V2 p, V2 v) |
49 |
: pos(p), oldpos(p), vel(v), oldvel(v), |
: pos(p), oldpos(p), vel(v), oldvel(v), |
50 |
forceacc(), |
forceacc(), |
51 |
charge(0), mass(1), radius(1), |
charge(0), mass(1), radius(1), |
52 |
grabbed(false) |
grabbed(false) |
53 |
{} |
{} |
54 |
|
|
55 |
V3 pos, oldpos; // Absolute position |
V2 pos, oldpos; // Absolute position |
56 |
V3 vel, oldvel; // Velocity |
V2 vel, oldvel; // Velocity |
57 |
V3 forceacc; // Force accumulator |
V2 forceacc; // Force accumulator |
58 |
V3 forceacc2; |
V2 forceacc2; |
59 |
double charge; // Electric charge |
double charge; // Electric charge |
60 |
double mass; // Mass |
double mass; // Mass |
61 |
double radius; // Radius of the sphere |
double radius; // Radius of the sphere |
78 |
{ |
{ |
79 |
// Constructor. |
// Constructor. |
80 |
StoneContact(Actor *a, GridPos p, |
StoneContact(Actor *a, GridPos p, |
81 |
const V3 &cp, const V3 &n); |
const V2 &cp, const V2 &n); |
82 |
StoneContact(); |
StoneContact(); |
83 |
|
|
84 |
// Variables. |
// Variables. |
87 |
GridPos stonepos; |
GridPos stonepos; |
88 |
StoneResponse response; |
StoneResponse response; |
89 |
|
|
90 |
V3 contact_point; // where do the shapes meet? (world coords) |
V2 contact_point; // where do the shapes meet? (world coords) |
91 |
V3 normal; // the surface normal at the contact point |
V2 normal; // the surface normal at the contact point |
92 |
bool is_collision; // actor moves towards the stone, not away |
bool is_collision; // actor moves towards the stone, not away |
93 |
bool fake_collision; |
bool fake_collision; |
94 |
bool is_contact; |
bool is_contact; |
105 |
class ForceField { |
class ForceField { |
106 |
public: |
public: |
107 |
virtual ~ForceField() {} |
virtual ~ForceField() {} |
108 |
virtual V3 get_force(Actor *a, V3 x, V3 v, double time)=0; |
virtual V2 get_force(Actor *a, V2 x, V2 v, double time)=0; |
109 |
virtual void tick(double dtime) {} |
virtual void tick(double dtime) {} |
110 |
}; |
}; |
111 |
|
|
112 |
class ConstantForce : public ForceField { |
class ConstantForce : public ForceField { |
113 |
public: |
public: |
114 |
ConstantForce(V3 f) : force(f) |
ConstantForce(V2 f) : force(f) |
115 |
{} |
{} |
116 |
V3 get_force(Actor *a,V3 x, V3 v, double time) { |
V2 get_force(Actor *a,V2 x, V2 v, double time) { |
117 |
return force; |
return force; |
118 |
} |
} |
119 |
private: |
private: |
120 |
V3 force; |
V2 force; |
121 |
}; |
}; |
122 |
} |
} |
123 |
|
|
152 |
//---------------------------------------- |
//---------------------------------------- |
153 |
void AddForceField(ForceField *ff); |
void AddForceField(ForceField *ff); |
154 |
void RemoveForceField(ForceField *ff); |
void RemoveForceField(ForceField *ff); |
155 |
void SetMouseForce(V3 f); |
void SetMouseForce(V2 f); |
156 |
|
|
157 |
|
|
158 |
//---------------------------------------- |
//---------------------------------------- |