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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
pub mod particle_color;
pub mod particle_group;
pub mod particle_system;
use libc::size_t;
use self::particle_color::*;
use self::particle_group::*;
use std::ptr;
use super::common::math::*;
use super::common::settings::*;
bitflags! {
flags ParticleFlags: UInt32 {
const WATER_PARTICLE = 0,
const ZOMBIE_PARTICLE = 1 << 1,
const WALL_PARTICLE = 1 << 2,
const SPRING_PARTICLE = 1 << 3,
const ELASTIC_PARTICLE = 1 << 4,
const VISCOUS_PARTICLE = 1 << 5,
const POWDER_PARTICLE = 1 << 6,
const TENSILE_PARTICLE = 1 << 7,
const COLOR_MIXING_PARTICLE = 1 << 8,
const DESTRUCTION_LISTENER_PARTICLE = 1 << 9,
const BARRIER_PARTICLE = 1 << 10,
const STATIC_PRESSURE_PARTICLE = 1 << 11,
const REACTIVE_PARTICLE = 1 << 12,
const REPULSIVE_PARTICLE = 1 << 13,
const FIXTURE_CONTACT_LISTENER_PARTICLE = 1 << 14,
const PARTICLE_CONTACT_LISTENER_PARTICLE = 1 << 15,
const FIXTURE_CONTACT_FILTER_PARTICLE = 1 << 16,
const PARTICLE_CONTACT_FILTER_PARTICLE = 1 << 17,
}
}
#[repr(C)]
#[derive(Debug)]
pub struct B2ParticleDef {
flags: UInt32,
position: Vec2,
velocity: Vec2,
color: *mut B2ParticleColor,
lifetime: Float32,
user_data: size_t,
group: *mut B2ParticleGroup,
}
pub struct ParticleDef {
pub flags: ParticleFlags,
pub position: Vec2,
pub velocity: Vec2,
pub color: ParticleColor,
pub lifetime: Float32,
pub user_data: size_t,
pub group: Option<ParticleGroup>,
}
impl Default for ParticleDef {
fn default () -> ParticleDef {
ParticleDef {
flags: ParticleFlags::empty(),
position: Vec2::zero(),
velocity: Vec2::zero(),
color: ParticleColor::zero(),
lifetime: 0.0,
user_data: 0,
group: None,
}
}
}
impl B2ParticleDef {
fn from(pd: &ParticleDef) -> B2ParticleDef {
B2ParticleDef {
flags: pd.flags.bits(),
position: pd.position.clone(),
velocity: pd.velocity.clone(),
color: pd.color.ptr(),
lifetime: pd.lifetime,
user_data: pd.user_data,
group: match pd.group {
Some(ref g) => g.ptr(),
None => ptr::null_mut()
}
}
}
}