2 * Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
4 * Permission to use, copy, modify, distribute and sell this software
5 * and its documentation for any purpose is hereby granted without fee,
6 * provided that the above copyright notice appear in all copies.
7 * Erin Catto makes no representations about the suitability
8 * of this software for any purpose.
9 * It is provided "as is" without express or implied warranty.
13 import b2dlite
.mathutils
;
22 float angularVelocity
;
35 position
.Set(0.0f, 0.0f);
37 velocity
.Set(0.0f, 0.0f);
38 angularVelocity
= 0.0f;
39 force
.Set(0.0f, 0.0f);
43 width
.Set(1.0f, 1.0f);
50 void Set() (in auto ref Vec2 w
, float m
) {
51 position
.Set(0.0f, 0.0f);
53 velocity
.Set(0.0f, 0.0f);
54 angularVelocity
= 0.0f;
55 force
.Set(0.0f, 0.0f);
60 if (mass
< float.max
) {
62 I
= mass
*(width
.x
*width
.x
+width
.y
*width
.y
)/12.0f;
71 void AddForce() (in auto ref Vec2 f
) { pragma(inline
, true); force
+= f
; }
73 int opCmp() (Body b
) pure const nothrow @trusted @nogc {
74 if (b
is null) return 1;
75 if (b
is this) return 0;
76 if (cast(size_t
)cast(void*)this < cast(size_t
)cast(void*)b
) return -1;
77 if (cast(size_t
)cast(void*)this > cast(size_t
)cast(void*)b
) return 1;