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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use {cgmath};
use {collision, force, math, object};
#[derive(Debug, PartialEq)]
pub enum Input {
Step,
CreateObject (object::Variant, object::Key),
ModifyObject (ObjectModify),
DestroyObject (object::Identifier),
SetGravity (force::Gravity),
ClearGravity
}
#[derive(Debug, PartialEq)]
pub enum ObjectModify {
Dynamic (object::Key, ObjectModifyDynamic),
Static (object::Key, ObjectModifyStatic)
}
#[derive(Debug, PartialEq)]
pub enum ObjectModifyDynamic {
ApplyImpulse (cgmath::Vector3 <f64>)
}
#[derive(Debug, PartialEq)]
pub enum ObjectModifyStatic {
Move (cgmath::Vector3 <f64>)
}
#[derive(FromVariants, Debug, PartialEq)]
pub enum Output {
CollisionResolve (CollisionResolve),
CreateObjectResult (CreateObjectResult)
}
#[cfg_attr(feature = "derive_serdes", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct CollisionResolve {
pub toi : math::Normalized <f64>,
pub object_id_a : object::Identifier,
pub object_id_b : object::Identifier,
pub contact : collision::contact::Colliding,
pub impulse_normal_a : cgmath::Vector3 <f64>,
pub impulse_normal_b : cgmath::Vector3 <f64>,
pub impulse_tangent_a : cgmath::Vector3 <f64>,
pub impulse_tangent_b : cgmath::Vector3 <f64>,
pub pseudo_impulse_a : cgmath::Vector3 <f64>,
pub pseudo_impulse_b : cgmath::Vector3 <f64>
}
#[derive(Debug, PartialEq)]
pub enum CreateObjectResult {
Intersection (
object::Identifier,
Vec <(object::Identifier, collision::Intersection)>),
}