btManifoldPoint and its members

Post Reply
KayJ
Posts: 4
Joined: Mon Oct 12, 2009 2:11 pm

btManifoldPoint and its members

Post by KayJ »

Hi,

does someone know what exactly is stored in
m_localPointA resp. m_localPointB. Is this a world or local position?

I've got a collision sphere. When a collision is detected, I'm interesed in where the collision point on this sphere is. So I think I need spherical coordinates. Does someone know how to get this information from the btManifoldPoint class?

It's really hard to get to know what exactly is done in bullet without a documentation....

*hoping for answers

Thanks in advance!

KayJ
User avatar
teravus
Posts: 12
Joined: Sat Sep 19, 2009 12:44 pm

Re: btManifoldPoint and its members

Post by teravus »

It would be nice to know a 'life cycle' of a btPersistentManifold and btManifoldPoint... like.. which part of the simulation creates it, changes it, and releases it.

A couple things that I do know... the btConstraintSolver (this is your btSequentialImpulseConstraintSolver) modifies it and uses it to apply impulses to the bodies.

inside btManifoldResult is a method called addContact, it seems to be the only thing that initializes btManifoldPoint.

It's initialized like the following:

Code: Select all

bool isSwapped = m_manifoldPtr->getBody0() != m_body0;

btVector3 pointA = pointInWorld + normalOnBInWorld * depth;

btVector3 localA;
btVector3 localB;
	
if (isSwapped)
{
	localA = m_rootTransB.invXform(pointA );
	localB = m_rootTransA.invXform(pointInWorld);
} else
{
	localA = m_rootTransA.invXform(pointA );
	localB = m_rootTransB.invXform(pointInWorld);
}

btManifoldPoint newPt(localA,localB,normalOnBInWorld,depth);
newPt.m_positionWorldOnA = pointA;
newPt.m_positionWorldOnB = pointInWorld;
	
int insertIndex = m_manifoldPtr->getCacheEntry(newPt);
Additionally, the properties that you are referring to are set in the constructor of btManifoldPoint.

Code: Select all

btManifoldPoint( const btVector3 &pointA, const btVector3 &pointB, 
					const btVector3 &normal, 
					btScalar distance ) :
					m_localPointA( pointA ), 
					m_localPointB( pointB ), 
					m_normalWorldOnB( normal ), 
					m_distance1( distance ),
					m_combinedFriction(btScalar(0.)),
					m_combinedRestitution(btScalar(0.)),
					m_userPersistentData(0),
					m_appliedImpulse(0.f),
					m_lateralFrictionInitialized(false),
					m_appliedImpulseLateral1(0.f),
					m_appliedImpulseLateral2(0.f),
					m_lifeTime(0)
			{
So, it seems that
when swapped;

Code: Select all

m_localPointA = m_rootTransB.invXform(pointInWorld + normalOnBInWorld * depth)
when not swapped;

Code: Select all

m_localPointA = m_rootTransA.invXform(pointInWorld + normalOnBInWorld * depth)
additioanlly, the code for invXform looks like:

Code: Select all

btVector3 v = inVec - m_origin;
return (m_basis.transpose() * v);
which means it's taking the transposed basis of the btTransform(btMatrix3x3) and multiplying by the vector supplied minus the origin(btVector3) of the transform

There's another place in the code that references the btManifoldPoint where cp was passed in via the manifold and

Code: Select all

btManifoldPoint& cp = manifold->getContactPoint(j);
that's in
btSequentialImpulseConstraintSolver::convertContact

Code: Select all

btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expand();
btRigidBody* rb0 = btRigidBody::upcast(colObj0);
btRigidBody* rb1 = btRigidBody::upcast(colObj1);

solverConstraint.m_solverBodyIdA = solverBodyIdA;
solverConstraint.m_solverBodyIdB = solverBodyIdB;

solverConstraint.m_originalContactPoint = &cp;
btSequentialImpulseConstraintSolver::solveGroup

Code: Select all

btManifoldPoint* pt = (btManifoldPoint*) solveManifold.m_originalContactPoint;
One more thing to note.. the Collision Algorithms call the constructor for btManifoldResult.. so ultimately, these all source from the collision algorithm that's being used.
Post Reply