I am able to render a softbody mesh and do collision detection without any problems.
But recently I moved the physics to a separate new thread and step it at very high rate when compared to the graphics.
All physics forces and movement , rogid bodies seems ok to me but the vertex normals of soft bodies are not rendered properly. It looks like the artifact is because of physics been stepped at a very high rate (1000 Hz) when compared to the graphics loop which is stepped at 33Hz because when I step the physics at the same rate as the graphics, the vertex normals are rendered properly but the simulation is really slow.
I draw the soft body in the graphics loop as follows.
Code: Select all
void ViewManager::renderSoftbodyMeshes(btSoftBody* sBody)
{
btTransform meshTransform = sBody->getWorldTransform();
GLfloat tempForm[16];
meshTransform.getOpenGLMatrix(tempForm);
glPushMatrix();
glMultMatrixf(tempForm);
glBegin(GL_TRIANGLES);
int numFaces = sBody->m_faces.size();
for (int i=0; i< numFaces; i++)
{
glNormal3fv(sBody->m_faces[i].m_n[0]->m_n);
glVertex3fv(sBody->m_faces[i].m_n[0]->m_x);
glNormal3fv(sBody->m_faces[i].m_n[1]->m_n);
glVertex3fv(sBody->m_faces[i].m_n[1]->m_x);
glNormal3fv(sBody->m_faces[i].m_n[2]->m_n);
glVertex3fv(sBody->m_faces[i].m_n[2]->m_x);
}
glEnd();
glPopMatrix();
}
Pls see attached video for demo of the problem.
Thanks
V