diff options
Diffstat (limited to 'Spear/Physics/Rigid.hs')
-rw-r--r-- | Spear/Physics/Rigid.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Spear/Physics/Rigid.hs b/Spear/Physics/Rigid.hs index 9147553..99a9d5a 100644 --- a/Spear/Physics/Rigid.hs +++ b/Spear/Physics/Rigid.hs | |||
@@ -12,7 +12,7 @@ where | |||
12 | 12 | ||
13 | import qualified Spear.Math.Matrix3 as M3 | 13 | import qualified Spear.Math.Matrix3 as M3 |
14 | import Spear.Math.Spatial2 | 14 | import Spear.Math.Spatial2 |
15 | import Spear.Math.Vector2 | 15 | import Spear.Math.Vector |
16 | import Spear.Physics.Types | 16 | import Spear.Physics.Types |
17 | 17 | ||
18 | import Data.List (foldl') | 18 | import Data.List (foldl') |
@@ -31,13 +31,13 @@ instance Spatial2 RigidBody where | |||
31 | 31 | ||
32 | move v body = body { position = v + position body } | 32 | move v body = body { position = v + position body } |
33 | 33 | ||
34 | moveFwd speed body = body { position = position body + scale speed unity } | 34 | moveFwd speed body = body { position = position body + scale speed unity2 } |
35 | 35 | ||
36 | moveBack speed body = body { position = position body + scale (-speed) unity } | 36 | moveBack speed body = body { position = position body + scale (-speed) unity2 } |
37 | 37 | ||
38 | strafeLeft speed body = body { position = position body + scale (-speed) unitx } | 38 | strafeLeft speed body = body { position = position body + scale (-speed) unitx2 } |
39 | 39 | ||
40 | strafeRight speed body = body { position = position body + scale speed unitx } | 40 | strafeRight speed body = body { position = position body + scale speed unitx2 } |
41 | 41 | ||
42 | rotate angle = id | 42 | rotate angle = id |
43 | 43 | ||
@@ -45,13 +45,13 @@ instance Spatial2 RigidBody where | |||
45 | 45 | ||
46 | pos = position | 46 | pos = position |
47 | 47 | ||
48 | fwd _ = unity | 48 | fwd _ = unity2 |
49 | 49 | ||
50 | up _ = unity | 50 | up _ = unity2 |
51 | 51 | ||
52 | right _ = unitx | 52 | right _ = unitx2 |
53 | 53 | ||
54 | transform body = M3.transform unitx unity $ position body | 54 | transform body = M3.transform unitx2 unity2 $ position body |
55 | 55 | ||
56 | setTransform transf body = body { position = M3.position transf } | 56 | setTransform transf body = body { position = M3.position transf } |
57 | 57 | ||
@@ -60,13 +60,13 @@ instance Spatial2 RigidBody where | |||
60 | 60 | ||
61 | -- | Build a 'RigidBody'. | 61 | -- | Build a 'RigidBody'. |
62 | rigidBody :: Mass -> Position -> RigidBody | 62 | rigidBody :: Mass -> Position -> RigidBody |
63 | rigidBody m x = RigidBody m x zero zero | 63 | rigidBody m x = RigidBody m x zero2 zero2 |
64 | 64 | ||
65 | 65 | ||
66 | -- | Update the given 'RigidBody'. | 66 | -- | Update the given 'RigidBody'. |
67 | update :: [Force] -> Dt -> RigidBody -> RigidBody | 67 | update :: [Force] -> Dt -> RigidBody -> RigidBody |
68 | update forces dt body = | 68 | update forces dt body = |
69 | let netforce = foldl' (+) zero forces | 69 | let netforce = foldl' (+) zero2 forces |
70 | m = mass body | 70 | m = mass body |
71 | r1 = position body | 71 | r1 = position body |
72 | v1 = velocity body | 72 | v1 = velocity body |