improved performance by adding constructors to btTransform/btMatrix3x3 to avoid conversions, compoundshape returns const references (instead of duplicate objects)
Thanks Marten Svanfeldt, Starbreeze Studios
This commit is contained in:
@@ -302,41 +302,6 @@ void CcdPhysicsDemo::clientMoveAndDisplay()
|
||||
updateCamera();
|
||||
|
||||
|
||||
#ifdef CENTER_OF_MASS_SHIFT
|
||||
btScalar m[16];
|
||||
|
||||
if (m_dynamicsWorld)
|
||||
{
|
||||
int numObjects = m_dynamicsWorld->getNumCollisionObjects();
|
||||
btVector3 wireColor(1,0,0);
|
||||
for (int i=0;i<numObjects;i++)
|
||||
{
|
||||
btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
|
||||
btRigidBody* body = btRigidBody::upcast(colObj);
|
||||
|
||||
if (body && body->getMotionState())
|
||||
{
|
||||
btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
|
||||
btTransform offsetTrans = myMotionState->m_graphicsWorldTrans;
|
||||
|
||||
|
||||
btVector3 worldShift = offsetTrans.getBasis() * comOffsetVec;
|
||||
offsetTrans.setOrigin(offsetTrans.getOrigin() + worldShift);
|
||||
|
||||
|
||||
offsetTrans.getOpenGLMatrix(m);
|
||||
|
||||
btVector3 wireColor(1.f,1.0f,1.f); //wants deactivation
|
||||
|
||||
btSphereShape sphereTmp(CUBE_HALF_EXTENTS);
|
||||
|
||||
GL_ShapeDrawer::drawOpenGL(m,&sphereTmp,wireColor,0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif //CENTER_OF_MASS_SHIFT
|
||||
|
||||
|
||||
#ifdef USE_QUICKPROF
|
||||
btProfiler::endBlock("render");
|
||||
|
||||
@@ -77,9 +77,9 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
|
||||
btTransform orgTrans = colObj->getWorldTransform();
|
||||
btCollisionShape* orgShape = colObj->getCollisionShape();
|
||||
|
||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||
btTransform newChildWorldTrans = orgTrans*childTrans ;
|
||||
colObj->setWorldTransform( newChildWorldTrans );
|
||||
const btTransform& childTrans = compoundShape->getChildTransform(i);
|
||||
//btTransform newChildWorldTrans = orgTrans*childTrans ;
|
||||
colObj->setWorldTransform( orgTrans*childTrans );
|
||||
//the contactpoint is still projected back using the original inverted worldtrans
|
||||
colObj->setCollisionShape( childShape );
|
||||
m_childCollisionAlgorithms[i]->processCollision(colObj,otherObj,dispatchInfo,resultOut);
|
||||
@@ -119,9 +119,9 @@ btScalar btCompoundCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject*
|
||||
btTransform orgTrans = colObj->getWorldTransform();
|
||||
btCollisionShape* orgShape = colObj->getCollisionShape();
|
||||
|
||||
btTransform childTrans = compoundShape->getChildTransform(i);
|
||||
btTransform newChildWorldTrans = orgTrans*childTrans ;
|
||||
colObj->setWorldTransform( newChildWorldTrans );
|
||||
const btTransform& childTrans = compoundShape->getChildTransform(i);
|
||||
//btTransform newChildWorldTrans = orgTrans*childTrans ;
|
||||
colObj->setWorldTransform( orgTrans*childTrans );
|
||||
|
||||
colObj->setCollisionShape( childShape );
|
||||
btScalar frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(colObj,otherObj,dispatchInfo,resultOut);
|
||||
|
||||
@@ -58,11 +58,11 @@ public:
|
||||
return m_childShapes[index];
|
||||
}
|
||||
|
||||
btTransform getChildTransform(int index)
|
||||
btTransform& getChildTransform(int index)
|
||||
{
|
||||
return m_childTransforms[index];
|
||||
}
|
||||
const btTransform getChildTransform(int index) const
|
||||
const btTransform& getChildTransform(int index) const
|
||||
{
|
||||
return m_childTransforms[index];
|
||||
}
|
||||
|
||||
@@ -45,6 +45,21 @@ class btMatrix3x3 {
|
||||
zx, zy, zz);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btMatrix3x3 (const btMatrix3x3& other)
|
||||
{
|
||||
m_el[0] = other.m_el[0];
|
||||
m_el[1] = other.m_el[1];
|
||||
m_el[2] = other.m_el[2];
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btMatrix3x3& operator=(const btMatrix3x3& other)
|
||||
{
|
||||
m_el[0] = other.m_el[0];
|
||||
m_el[1] = other.m_el[1];
|
||||
m_el[2] = other.m_el[2];
|
||||
return *this;
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btVector3 getColumn(int i) const
|
||||
{
|
||||
return btVector3(m_el[0][i],m_el[1][i],m_el[2][i]);
|
||||
|
||||
@@ -42,6 +42,19 @@ public:
|
||||
m_origin(c)
|
||||
{}
|
||||
|
||||
SIMD_FORCE_INLINE btTransform (const btTransform& other)
|
||||
: m_basis(other.m_basis),
|
||||
m_origin(other.m_origin)
|
||||
{
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btTransform& operator=(const btTransform& other)
|
||||
{
|
||||
m_basis = other.m_basis;
|
||||
m_origin = other.m_origin;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
SIMD_FORCE_INLINE void mult(const btTransform& t1, const btTransform& t2) {
|
||||
m_basis = t1.m_basis * t2.m_basis;
|
||||
|
||||
Reference in New Issue
Block a user