MCPcopy Create free account
hub / github.com/PerroEngine/Perro / eval_ops_particle

Function eval_ops_particle

perro_source/core/perro_particle_math/src/lib.rs:128–260  ·  view source on GitHub ↗
(
    ops: &[Op],
    input: &ParticleEvalInput<'_>,
    stack: &mut Vec<f32>,
)

Source from the content-addressed store, hash-verified

126 };
127 eval_ops_particle(ops, &input, stack)
128}
129
130pub fn eval_ops_particle(
131 ops: &[Op],
132 input: &ParticleEvalInput<'_>,
133 stack: &mut Vec<f32>,
134) -> Option<f32> {
135 stack.clear();
136 for op in ops {
137 match *op {
138 Op::Const(v) => stack.push(v),
139 Op::T | Op::Age01 => stack.push(input.t),
140 Op::Life => stack.push(input.life),
141 Op::Lifetime => stack.push(input.lifetime),
142 Op::AgeLeft => stack.push((input.lifetime - input.life).max(0.0)),
143 Op::SpawnTime => stack.push(input.spawn_time),
144 Op::EmitterTime => stack.push(input.emitter_time),
145 Op::Speed => stack.push(input.speed),
146 Op::Id => stack.push(input.particle_id),
147 Op::DirX => stack.push(input.dir[0]),
148 Op::DirY => stack.push(input.dir[1]),
149 Op::DirZ => stack.push(input.dir[2]),
150 Op::VelX => stack.push(input.vel[0]),
151 Op::VelY => stack.push(input.vel[1]),
152 Op::VelZ => stack.push(input.vel[2]),
153 Op::Rand => stack.push(input.rand[0]),
154 Op::Rand2 => stack.push(input.rand[1]),
155 Op::Rand3 => stack.push(input.rand[2]),
156 Op::Seed => stack.push(input.seed),
157 Op::RingU => stack.push(input.ring_u),
158 Op::Index01 => stack.push(input.index01),
159 Op::EmitterX => stack.push(input.emitter_pos[0]),
160 Op::EmitterY => stack.push(input.emitter_pos[1]),
161 Op::EmitterZ => stack.push(input.emitter_pos[2]),
162 Op::PrevX => stack.push(input.prev_pos[0]),
163 Op::PrevY => stack.push(input.prev_pos[1]),
164 Op::PrevZ => stack.push(input.prev_pos[2]),
165 Op::Param => {
166 let idx = stack.pop()?.floor() as isize;
167 let value = usize::try_from(idx)
168 .ok()
169 .and_then(|idx| input.params.get(idx))
170 .copied()
171 .unwrap_or_default();
172 stack.push(value);
173 }
174 Op::Add => eval_binary(stack, |a, b| a + b)?,
175 Op::Sub => eval_binary(stack, |a, b| a - b)?,
176 Op::Mul => eval_binary(stack, |a, b| a * b)?,
177 Op::Div => eval_binary(stack, |a, b| a / b)?,
178 Op::Pow => eval_binary(stack, f32::powf)?,
179 Op::Neg => eval_unary(stack, |value| -value)?,
180 Op::Sin => eval_unary(stack, f32::sin)?,
181 Op::Cos => eval_unary(stack, f32::cos)?,
182 Op::Tan => eval_unary(stack, f32::tan)?,
183 Op::Abs => eval_unary(stack, f32::abs)?,
184 Op::Sqrt => eval_unary(stack, |value| value.max(0.0).sqrt())?,
185 Op::Min => eval_binary(stack, f32::min)?,

Callers 4

eval_particleMethod · 0.85
eval_opsFunction · 0.85
eval_particle_pos_2dFunction · 0.85

Calls 11

hash01fFunction · 0.85
sinMethod · 0.80
clearMethod · 0.45
pushMethod · 0.45
maxMethod · 0.45
popMethod · 0.45
getMethod · 0.45
absMethod · 0.45
minMethod · 0.45
clampMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected