MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / computeSoftBodyVertices

Method computeSoftBodyVertices

examples/ExampleBrowser/OpenGLGuiHelper.cpp:1520–1550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1518}
1519
1520void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape,
1521 btAlignedObjectArray<GLInstanceVertex>& gfxVertices,
1522 btAlignedObjectArray<int>& indices)
1523{
1524 if (collisionShape->getUserPointer() == 0)
1525 return;
1526 b3Assert(collisionShape->getUserPointer());
1527 btSoftBody* psb = (btSoftBody*)collisionShape->getUserPointer();
1528 gfxVertices.resize(psb->m_faces.size() * 3);
1529
1530 for (int i = 0; i < psb->m_faces.size(); i++) // Foreach face
1531 {
1532 for (int k = 0; k < 3; k++) // Foreach vertex on a face
1533 {
1534 int currentIndex = i * 3 + k;
1535 for (int j = 0; j < 3; j++)
1536 {
1537 gfxVertices[currentIndex].xyzw[j] = psb->m_faces[i].m_n[k]->m_x[j];
1538 }
1539 for (int j = 0; j < 3; j++)
1540 {
1541 gfxVertices[currentIndex].normal[j] = psb->m_faces[i].m_n[k]->m_n[j];
1542 }
1543 for (int j = 0; j < 2; j++)
1544 {
1545 gfxVertices[currentIndex].uv[j] = psb->m_faces[i].m_n[k]->m_x[j];
1546 }
1547 indices.push_back(currentIndex);
1548 }
1549 }
1550}
1551
1552void OpenGLGuiHelper::updateShape(int shapeIndex, float* vertices, int numVertices)
1553{

Callers

nothing calls this directly

Calls 3

resizeMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected