If a convex has called 'initializePolyhedralFeatures', use those features also to create debug visualizer mesh, to avoid showing penetration.
Avoid crash in InvertedPendulumPDControl, due to recent change in m_jointFeedbackInWorldSpace
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "btBulletCollisionCommon.h"
|
#include "btBulletCollisionCommon.h"
|
||||||
#include "BulletCollision/CollisionShapes/btShapeHull.h" //to create a tesselation of a generic btConvexShape
|
#include "BulletCollision/CollisionShapes/btShapeHull.h" //to create a tesselation of a generic btConvexShape
|
||||||
|
#include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
|
||||||
|
|
||||||
void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTransform& parentTransform, btAlignedObjectArray<btVector3>& vertexPositions, btAlignedObjectArray<btVector3>& vertexNormals, btAlignedObjectArray<int>& indicesOut)
|
void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTransform& parentTransform, btAlignedObjectArray<btVector3>& vertexPositions, btAlignedObjectArray<btVector3>& vertexNormals, btAlignedObjectArray<int>& indicesOut)
|
||||||
|
|
||||||
@@ -131,6 +132,38 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans
|
|||||||
{
|
{
|
||||||
btConvexShape* convex = (btConvexShape*)collisionShape;
|
btConvexShape* convex = (btConvexShape*)collisionShape;
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const btConvexPolyhedron* pol = 0;
|
||||||
|
if (convex->isPolyhedral())
|
||||||
|
{
|
||||||
|
btPolyhedralConvexShape* poly = (btPolyhedralConvexShape*)convex;
|
||||||
|
pol = poly->getConvexPolyhedron();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pol)
|
||||||
|
{
|
||||||
|
for (int v = 0; v < pol->m_vertices.size(); v++)
|
||||||
|
{
|
||||||
|
vertexPositions.push_back(pol->m_vertices[v]);
|
||||||
|
btVector3 norm = pol->m_vertices[v];
|
||||||
|
norm.safeNormalize();
|
||||||
|
vertexNormals.push_back(norm);
|
||||||
|
}
|
||||||
|
for (int f = 0; f < pol->m_faces.size(); f++)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int ii = 2; ii < pol->m_faces[f].m_indices.size(); ii++)
|
||||||
|
{
|
||||||
|
indicesOut.push_back(pol->m_faces[f].m_indices[0]);
|
||||||
|
indicesOut.push_back(pol->m_faces[f].m_indices[ii-1]);
|
||||||
|
indicesOut.push_back(pol->m_faces[f].m_indices[ii]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
btShapeHull* hull = new btShapeHull(convex);
|
btShapeHull* hull = new btShapeHull(convex);
|
||||||
hull->buildHull(0.0, 1);
|
hull->buildHull(0.0, 1);
|
||||||
|
|
||||||
@@ -165,6 +198,7 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans
|
|||||||
delete hull;
|
delete hull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (collisionShape->isCompound())
|
if (collisionShape->isCompound())
|
||||||
|
|||||||
@@ -313,13 +313,15 @@ void InvertedPendulumPDControl::initPhysics()
|
|||||||
|
|
||||||
int upAxis = 1;
|
int upAxis = 1;
|
||||||
|
|
||||||
m_dynamicsWorld->getSolverInfo().m_jointFeedbackInWorldSpace = true;
|
|
||||||
m_dynamicsWorld->getSolverInfo().m_jointFeedbackInJointFrame = true;
|
|
||||||
|
|
||||||
|
|
||||||
m_guiHelper->setUpAxis(upAxis);
|
m_guiHelper->setUpAxis(upAxis);
|
||||||
|
|
||||||
this->createEmptyDynamicsWorld();
|
this->createEmptyDynamicsWorld();
|
||||||
|
|
||||||
|
m_dynamicsWorld->getSolverInfo().m_jointFeedbackInWorldSpace = true;
|
||||||
|
m_dynamicsWorld->getSolverInfo().m_jointFeedbackInJointFrame = true;
|
||||||
|
|
||||||
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
|
||||||
m_dynamicsWorld->getDebugDrawer()->setDebugMode(
|
m_dynamicsWorld->getDebugDrawer()->setDebugMode(
|
||||||
//btIDebugDraw::DBG_DrawConstraints
|
//btIDebugDraw::DBG_DrawConstraints
|
||||||
|
|||||||
Reference in New Issue
Block a user