| 1189 | } |
| 1190 | |
| 1191 | void RenderScene() |
| 1192 | { |
| 1193 | const int numParticles = NvFlexGetActiveCount(g_flex); |
| 1194 | const int numDiffuse = NvFlexGetDiffuseParticles(g_flex, NULL, NULL, NULL); |
| 1195 | |
| 1196 | //--------------------------------------------------- |
| 1197 | // use VBO buffer wrappers to allow Flex to write directly to the OpenGL buffers |
| 1198 | // Flex will take care of any CUDA interop mapping/unmapping during the get() operations |
| 1199 | |
| 1200 | if (numParticles) |
| 1201 | { |
| 1202 | |
| 1203 | if (g_interop) |
| 1204 | { |
| 1205 | // copy data directly from solver to the renderer buffers |
| 1206 | UpdateFluidRenderBuffers(g_fluidRenderBuffers, g_flex, g_drawEllipsoids, g_drawDensity); |
| 1207 | } |
| 1208 | else |
| 1209 | { |
| 1210 | // copy particle data to GPU render device |
| 1211 | |
| 1212 | if (g_drawEllipsoids) |
| 1213 | { |
| 1214 | // if fluid surface rendering then update with smooth positions and anisotropy |
| 1215 | UpdateFluidRenderBuffers(g_fluidRenderBuffers, |
| 1216 | &g_buffers->smoothPositions[0], |
| 1217 | (g_drawDensity) ? &g_buffers->densities[0] : (float*)&g_buffers->phases[0], |
| 1218 | &g_buffers->anisotropy1[0], |
| 1219 | &g_buffers->anisotropy2[0], |
| 1220 | &g_buffers->anisotropy3[0], |
| 1221 | g_buffers->positions.size(), |
| 1222 | &g_buffers->activeIndices[0], |
| 1223 | numParticles); |
| 1224 | } |
| 1225 | else |
| 1226 | { |
| 1227 | // otherwise just send regular positions and no anisotropy |
| 1228 | UpdateFluidRenderBuffers(g_fluidRenderBuffers, |
| 1229 | &g_buffers->positions[0], |
| 1230 | (float*)&g_buffers->phases[0], |
| 1231 | NULL, NULL, NULL, |
| 1232 | g_buffers->positions.size(), |
| 1233 | &g_buffers->activeIndices[0], |
| 1234 | numParticles); |
| 1235 | } |
| 1236 | } |
| 1237 | } |
| 1238 | |
| 1239 | if (numDiffuse) |
| 1240 | { |
| 1241 | if (g_interop) |
| 1242 | { |
| 1243 | // copy data directly from solver to the renderer buffers |
| 1244 | UpdateDiffuseRenderBuffers(g_diffuseRenderBuffers, g_flex); |
| 1245 | } |
| 1246 | else |
| 1247 | { |
| 1248 | // copy diffuse particle data from host to GPU render device |
no test coverage detected