MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/FleX / RenderDebug

Function RenderDebug

demo/main.cpp:1419–1544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1417}
1418
1419void RenderDebug()
1420{
1421 if (g_mouseParticle != -1)
1422 {
1423 // draw mouse spring
1424 BeginLines();
1425 DrawLine(g_mousePos, Vec3(g_buffers->positions[g_mouseParticle]), Vec4(1.0f));
1426 EndLines();
1427 }
1428
1429 // springs
1430 if (g_drawSprings)
1431 {
1432 Vec4 color;
1433
1434 if (g_drawSprings == 1)
1435 {
1436 // stretch
1437 color = Vec4(0.0f, 0.0f, 1.0f, 0.8f);
1438 }
1439 if (g_drawSprings == 2)
1440 {
1441 // tether
1442 color = Vec4(0.0f, 1.0f, 0.0f, 0.8f);
1443 }
1444
1445 BeginLines();
1446
1447 int start = 0;
1448
1449 for (int i = start; i < g_buffers->springLengths.size(); ++i)
1450 {
1451 if (g_drawSprings == 1 && g_buffers->springStiffness[i] < 0.0f)
1452 continue;
1453 if (g_drawSprings == 2 && g_buffers->springStiffness[i] > 0.0f)
1454 continue;
1455
1456 int a = g_buffers->springIndices[i * 2];
1457 int b = g_buffers->springIndices[i * 2 + 1];
1458
1459 DrawLine(Vec3(g_buffers->positions[a]), Vec3(g_buffers->positions[b]), color);
1460 }
1461
1462 EndLines();
1463 }
1464
1465 // visualize contacts against the environment
1466 if (g_drawContacts)
1467 {
1468 const int maxContactsPerParticle = 6;
1469
1470 NvFlexVector<Vec4> contactPlanes(g_flexLib, g_buffers->positions.size()*maxContactsPerParticle);
1471 NvFlexVector<Vec4> contactVelocities(g_flexLib, g_buffers->positions.size()*maxContactsPerParticle);
1472 NvFlexVector<int> contactIndices(g_flexLib, g_buffers->positions.size());
1473 NvFlexVector<unsigned int> contactCounts(g_flexLib, g_buffers->positions.size());
1474
1475 NvFlexGetContacts(g_flex, contactPlanes.buffer, contactVelocities.buffer, contactIndices.buffer, contactCounts.buffer);
1476

Callers 1

UpdateFrameFunction · 0.85

Calls 5

sizeMethod · 0.80
mapMethod · 0.80
BeginLinesFunction · 0.50
DrawLineFunction · 0.50
EndLinesFunction · 0.50

Tested by

no test coverage detected