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

Method update

cpp/2_Concepts_and_Techniques/particles/particleSystem.cpp:255–307  ·  view source on GitHub ↗

step the simulation

Source from the content-addressed store, hash-verified

253
254// step the simulation
255void 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
309void ParticleSystem::dumpGrid()
310{

Callers 3

runBenchmarkFunction · 0.45
displayFunction · 0.45
keyFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected