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

#include "../Common/Math.h"

namespace Phy2D
{

    struct Body;

    struct Joint
    {
        Joint() :
            body1(0), body2(0),
            P(0.0f, 0.0f),
            biasFactor(0.2f), softness(0.0f)
        {}

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

        void PreStep(number inv_dt);
        void ApplyImpulse();

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

}