MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / emitParticlesCircle

Method emitParticlesCircle

SPlisHSPlasH/Emitter.cpp:231–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229
230
231void Emitter::emitParticlesCircle(std::vector <unsigned int> &reusedParticles, unsigned int &indexReuse, unsigned int &numEmittedParticles)
232{
233 TimeManager *tm = TimeManager::getCurrent();
234 const Real t = tm->getTime();
235 const Real timeStepSize = tm->getTimeStepSize();
236 const Vector3r & emitDir = m_rotation.col(0);
237 Simulation *sim = Simulation::getCurrent();
238 const Real particleRadius = sim->getParticleRadius();
239 const Real diam = static_cast<Real>(2.0)*particleRadius;
240 Vector3r emitVel = m_velocity * emitDir;
241
242 // shortly before the emitter starts, cleanup the emitter from particles
243 if (t < m_emitStartTime || t > m_emitEndTime)
244 emitVel = emitDir * particleRadius * 10 / 0.25;
245
246 if (t >= m_emitStartTime - 0.25 && t <= m_emitEndTime)
247 {
248 // animate emitted particles
249 const Vector3r & x0 = m_x;
250
251 const Real animationMarginAhead = sim->getSupportRadius();
252 const Vector3r size = getSize(static_cast<Real>(m_width), static_cast<Real>(m_height), m_type);
253 const Real h = size[0];
254 const Real r = 0.5f * size[1];
255 const Real r2 = r * r;
256 const Vector3r pos = x0 + 0.5f * animationMarginAhead * emitDir;
257
258
259 const unsigned int nModels = sim->numberOfFluidModels();
260 for (unsigned int m = 0; m < nModels; m++)
261 {
262 FluidModel *fm = sim->getFluidModel(m);
263 const unsigned int numParticles = fm->numActiveParticles();
264 #pragma omp parallel for schedule(static) default(shared)
265 for (int i = 0; i < (int)numParticles; i++)
266 {
267 Vector3r &xi = fm->getPosition(i);
268 if (inCylinder(xi, pos, m_rotation, h, r2))
269 {
270 fm->getVelocity(i) = emitVel;
271 fm->getPosition(i) += timeStepSize * emitVel;
272 fm->setParticleState(i, ParticleState::AnimatedByEmitter);
273 fm->setObjectId(i, m_objectId);
274 }
275 }
276 }
277 }
278 if (t < m_nextEmitTime || t > m_emitEndTime)
279 {
280 return;
281 }
282
283 Vector3r axisHeight = m_rotation.col(1);
284 Vector3r axisWidth = m_rotation.col(2);
285
286 const Real radius = (static_cast<Real>(0.5) * (Real)m_width * diam);
287 const Real radius2 = radius*radius;
288

Callers

nothing calls this directly

Calls 15

getTimeMethod · 0.80
getSupportRadiusMethod · 0.80
numberOfFluidModelsMethod · 0.80
getFluidModelMethod · 0.80
numActiveParticlesMethod · 0.80
getVelocityMethod · 0.80
setParticleStateMethod · 0.80
numParticlesMethod · 0.80
setNumActiveParticlesMethod · 0.80
getNeighborhoodSearchMethod · 0.80
getTimeStepSizeMethod · 0.45
colMethod · 0.45

Tested by

no test coverage detected