MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / discEmitter

Method discEmitter

cpp/5_Domain_Specific/smokeParticles/ParticleSystem.cpp:295–328  ·  view source on GitHub ↗

particle emitters

Source from the content-addressed store, hash-verified

293
294// particle emitters
295void ParticleSystem::discEmitter(uint &index,
296 vec3f pos,
297 vec3f vel,
298 vec3f vx,
299 vec3f vy,
300 float r,
301 int n,
302 float lifetime,
303 float lifetimeVariance)
304{
305 float4 *posPtr = m_pos.getHostPtr();
306 float4 *velPtr = m_vel.getHostPtr();
307
308 uint start = index;
309 uint count = 0;
310
311 for (int i = 0; i < n; i++) {
312 vec2f delta = randCircle() * r;
313
314 if (index < m_numParticles) {
315 vec3f p = pos + delta.x * vx + delta.y * vy;
316 float lt = lifetime + frand() * lifetimeVariance;
317
318 posPtr[index] = make_float4(p.x, p.y, p.z, 0.0f);
319 velPtr[index] = make_float4(vel.x, vel.y, vel.z, lt);
320
321 index++;
322 count++;
323 }
324 }
325
326 m_pos.copy(GpuArray<float4>::HOST_TO_DEVICE, start, count);
327 m_vel.copy(GpuArray<float4>::HOST_TO_DEVICE, start, count);
328}
329
330void ParticleSystem::sphereEmitter(uint &index,
331 vec3f pos,

Callers

nothing calls this directly

Calls 5

randCircleFunction · 0.85
make_float4Function · 0.85
getHostPtrMethod · 0.80
copyMethod · 0.80
frandFunction · 0.70

Tested by

no test coverage detected