Skip to content
0.2.0-dev Download ZIP
69 lines ·1.4 KB Raw
1using EvilEngine.Formats;
2using EvilEngine.Formats.Collision;
3using EvilEngine.Formats.Maps;
4
5namespace EvilEngine.Api.Physics;
6
7public enum BodyMotion
8{
9 Static,
10 Kinematic,
11 Dynamic
12}
13
14public sealed record BodySpec(CollisionContent Collision)
15{
16 public const string DefaultGroup = "default";
17
18 public BodyMotion Motion { get; init; } = BodyMotion.Dynamic;
19
20 public MapVector Position { get; init; } = MapVector.Zero;
21
22 public Orientation Orientation { get; init; } = Orientation.Identity;
23
24 public double? Mass { get; init; }
25
26 public ContentId? Surface { get; init; }
27
28 public MapVector Velocity { get; init; } = MapVector.Zero;
29
30 public MapVector Spin { get; init; } = MapVector.Zero;
31
32 public string Group { get; init; } = DefaultGroup;
33}
34
35public interface IPhysicsBody
36{
37 BodyMotion Motion { get; }
38
39 double Mass { get; }
40
41 double Volume { get; }
42
43 MapVector Position { get; set; }
44
45 Orientation Orientation { get; set; }
46
47 MapVector Velocity { get; set; }
48
49 MapVector Spin { get; set; }
50
51 bool Asleep { get; }
52
53 (MapVector Min, MapVector Max) Bounds { get; }
54
55 void Push(MapVector impulse, MapVector at);
56
57 void Force(MapVector force, MapVector at);
58}
59
60public interface IPhysicsWorld
61{
62 MapVector Gravity { get; set; }
63
64 IReadOnlyCollection<IPhysicsBody> Bodies { get; }
65
66 IPhysicsBody Add(BodySpec body);
67
68 bool Remove(IPhysicsBody body);
69}