blob: 7b1c3e33c7b57a69486bf1fd5b6dd0d4f2707b2c (
plain)
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
|
#include "Body.h"
#include "Constants.h"
using namespace Phy2D;
Body::Body()
{
position.Set(_0, _0);
rotation = _0;
velocity.Set(_0, _0);
angularVelocity = _0;
force.Set(_0, _0);
torque = _0;
friction = _0_2;
width.Set(_1, _1);
mass = NUMBER_MAX;
invMass = _0;
I = NUMBER_MAX;
invI = _0;
}
void Body::Set(const Vec2& w, fixed m)
{
position.Set(_0, _0);
rotation = _0;
velocity.Set(_0, _0);
angularVelocity = _0;
force.Set(_0, _0);
torque = _0;
friction = _0_2;
width = w;
mass = m;
if (mass < NUMBER_MAX)
{
invMass = (fixed)_1 / mass;
I = mass * (width.x * width.x + width.y * width.y) / _12;
invI = (fixed)_1 / I;
}
else
{
invMass = _0;
I = NUMBER_MAX;
invI = _0;
}
}
|