step the simulation
| 253 | |
| 254 | // step the simulation |
| 255 | void ParticleSystem::update(float deltaTime) |
| 256 | { |
| 257 | assert(m_bInitialized); |
| 258 | |
| 259 | float *dPos; |
| 260 | |
| 261 | if (m_bUseOpenGL) { |
| 262 | dPos = (float *)mapGLBufferObject(&m_cuda_posvbo_resource); |
| 263 | } |
| 264 | else { |
| 265 | dPos = (float *)m_cudaPosVBO; |
| 266 | } |
| 267 | |
| 268 | // update constants |
| 269 | setParameters(&m_params); |
| 270 | |
| 271 | // integrate |
| 272 | integrateSystem(dPos, m_dVel, deltaTime, m_numParticles); |
| 273 | |
| 274 | // calculate grid hash |
| 275 | calcHash(m_dGridParticleHash, m_dGridParticleIndex, dPos, m_numParticles); |
| 276 | |
| 277 | // sort particles based on hash |
| 278 | sortParticles(m_dGridParticleHash, m_dGridParticleIndex, m_numParticles); |
| 279 | |
| 280 | // reorder particle arrays into sorted order and |
| 281 | // find start and end of each cell |
| 282 | reorderDataAndFindCellStart(m_dCellStart, |
| 283 | m_dCellEnd, |
| 284 | m_dSortedPos, |
| 285 | m_dSortedVel, |
| 286 | m_dGridParticleHash, |
| 287 | m_dGridParticleIndex, |
| 288 | dPos, |
| 289 | m_dVel, |
| 290 | m_numParticles, |
| 291 | m_numGridCells); |
| 292 | |
| 293 | // process collisions |
| 294 | collide(m_dVel, |
| 295 | m_dSortedPos, |
| 296 | m_dSortedVel, |
| 297 | m_dGridParticleIndex, |
| 298 | m_dCellStart, |
| 299 | m_dCellEnd, |
| 300 | m_numParticles, |
| 301 | m_numGridCells); |
| 302 | |
| 303 | // note: do unmap at end here to avoid unnecessary graphics/CUDA context switch |
| 304 | if (m_bUseOpenGL) { |
| 305 | unmapGLBufferObject(m_cuda_posvbo_resource); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | void ParticleSystem::dumpGrid() |
| 310 | { |
no outgoing calls
no test coverage detected