particle emitters
| 293 | |
| 294 | // particle emitters |
| 295 | void 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 | |
| 330 | void ParticleSystem::sphereEmitter(uint &index, |
| 331 | vec3f pos, |
nothing calls this directly
no test coverage detected