aboutsummaryrefslogtreecommitdiff
path: root/Client/Source/Phy2DLite/Joint.h
blob: c65bf0b52d1fe2c52abd8dff979ea9a9327646e0 (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
#pragma once

#include "Math.h"
#include "Constants.h"

namespace Phy2D
{

    struct Body;

    struct Joint
    {
        Joint() :
            body1(0), body2(0),
            P(_0, _0),
            biasFactor(_0_2), softness(_0)
        {}

        void Set(Body* body1, Body* body2, const Vec2& anchor);

        void PreStep(fixed inv_dt);
        void ApplyImpulse();

        Mat22 M;
        Vec2 localAnchor1, localAnchor2;
        Vec2 r1, r2;
        Vec2 bias;
        Vec2 P;		// accumulated impulse
        Body* body1;
        Body* body2;
        fixed biasFactor;
        fixed softness;
    };

}