1use super::streams::{REACTION_WORDS, SoftDemand, SoftStreams};
2use dynamis_domain::{MIN_SLOTS, STREAM_FLOOR, settled};
3
4#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
5pub struct SoftCapacity {
6 pub particles: u32,
7 pub elements: u32,
8 pub attachments: u32,
9 pub adjacency: u32,
10 pub bodies: u32,
11}
12
13#[derive(Clone, Copy, Debug)]
14pub struct SoftInputs {
15 pub particles: u32,
16 pub elements: u32,
17 pub attachments: u32,
18 pub adjacency: u32,
19 pub bodies: u32,
20 pub material: bool,
21}
22
23pub fn capacity(streams: &SoftStreams) -> SoftCapacity {
24 SoftCapacity {
25 particles: streams.particles.slots(),
26 elements: streams.elements.slots(),
27 attachments: streams.attachments.slots(),
28 adjacency: streams.adjacency.slots(),
29 bodies: streams.bodies.slots(),
30 }
31}
32
33pub fn plan(
34 inputs: &SoftInputs,
35 idle: bool,
36 rigid_bodies: u32,
37 current: &SoftStreams,
38) -> SoftDemand {
39 SoftDemand {
40 particles: settled(idle, current.particles.slots(), inputs.particles, MIN_SLOTS),
41 elements: settled(idle, current.elements.slots(), inputs.elements, MIN_SLOTS),
42 attachments: settled(
43 idle,
44 current.attachments.slots(),
45 inputs.attachments,
46 MIN_SLOTS,
47 ),
48 adjacency: settled(
49 idle,
50 current.adjacency.slots(),
51 inputs.adjacency,
52 STREAM_FLOOR,
53 ),
54 soft_bodies: settled(idle, current.bodies.slots(), inputs.bodies, MIN_SLOTS),
55 rigid_bodies: settled(
56 idle,
57 current.reactions.slots() / REACTION_WORDS,
58 rigid_bodies,
59 MIN_SLOTS,
60 ),
61 }
62}
63
64pub const fn floor() -> SoftDemand {
65 SoftDemand {
66 particles: MIN_SLOTS,
67 elements: MIN_SLOTS,
68 attachments: MIN_SLOTS,
69 adjacency: STREAM_FLOOR,
70 soft_bodies: MIN_SLOTS,
71 rigid_bodies: MIN_SLOTS,
72 }
73}