Confused about Manifold Points

AshMcConnell
Posts: 29
Joined: Sat Sep 23, 2006 1:35 pm
Location: Northern Ireland

Confused about Manifold Points

Post by AshMcConnell »

Hi Folks,

I have set up a simple test that add 2 boxes to the collisionWorld.

boxA - position(0 ,0 ,0) size (1,1,1)
boxB - position(0.1 ,0 ,0) size (1,1,1)

the position is set by setOrigin (is that correct?). Is the size specified in half lengths (if I create a box shape with 1,1,1 will it be a 2x2x2 cube?)

I get 1 contactManifold contacts.

mp.GetPositionWorldOnA() = (0.05, 0.96, 1.0)
mp.GetPositionWorldOnB() = (0.05, 0.96, -1.0)
mp.GetDistance() = 2.0

I'm confused, does GetPositionWorldOnA mean the world position mapped to model A's local co-ordinate system?

Shouldnt the contact point be -0.9, 0, 0 on object A and -1.0, 0, 0 on object B? (assuming halflengths).

Sorry for such a basic question, but it just hasnt quite clicked yet for me.

Thanks!
All the best,
Ash
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Confused about Manifold Points

Post by Erwin Coumans »

AshMcConnell wrote:Hi Folks,

I have set up a simple test that add 2 boxes to the collisionWorld.

boxA - position(0 ,0 ,0) size (1,1,1)
boxB - position(0.1 ,0 ,0) size (1,1,1)

the position is set by setOrigin (is that correct?). Is the size specified in half lengths (if I create a box shape with 1,1,1 will it be a 2x2x2 cube?)

I get 1 contactManifold contacts.

mp.GetPositionWorldOnA() = (0.05, 0.96, 1.0)
mp.GetPositionWorldOnB() = (0.05, 0.96, -1.0)
mp.GetDistance() = 2.0

I'm confused, does GetPositionWorldOnA mean the world position mapped to model A's local co-ordinate system?

Shouldnt the contact point be -0.9, 0, 0 on object A and -1.0, 0, 0 on object B? (assuming halflengths).

Sorry for such a basic question, but it just hasnt quite clicked yet for me.

Thanks!
All the best,
Ash
Boxes are defined by half extents.

It is not really a basic question. The contact point management is fairly complex due to its persistency (poins are gathered, and contact manifold reduction takes place), hence it's not an 'easy' question.
Also, notice that moving objects after the query will invalidate the results. It looks like they start almost entirely overlapping/in a deep penetration.

Can you make a simple Bullet demo (in the DemoApplication) that shows your results? Have you played with the Bullet demos itself (including the dynamics)? Pressing 'c' will visualize contact points.

Thanks,
Erwin
Last edited by Erwin Coumans on Sun Sep 24, 2006 3:09 pm, edited 2 times in total.
AshMcConnell
Posts: 29
Joined: Sat Sep 23, 2006 1:35 pm
Location: Northern Ireland

Post by AshMcConnell »

Hi Erwin,

Thanks for the quick reply. I am adding the box with the following code (I set the position before I add it)

Code: Select all

	unsigned BulletCollisionDetection::addBox(void* userObject, float x, float y, float z, float posx, float posy, float posz )
	{
		BoxShape *bs = new BoxShape(SimdVector3(x,y,z));
		CollisionObject *colObj = new CollisionObject();

		SimdMatrix3x3 basisA;
		basisA.setIdentity();
		colObj->m_worldTransform.setIdentity();
		colObj->m_worldTransform.setOrigin(SimdVector3(posx,posy,posz));
		colObj->m_collisionShape = bs;
		colObj->m_userObjectPointer = userObject;

		Logger::LOGD("Adding Collision Object (%p) to the Collision World (%p)", colObj, _collisionWorld);
		_collisionWorld->AddCollisionObject(colObj);
		Logger::LOGD("Adding Complete");

		_collisionObjectList.push_back(colObj);

		return _collisionWorld->GetNumCollisionObjects()-1;
	}
I am just playing about with it until I understand how everything works (hence the lack of orientation in the interface)

In my test code I call this function twice to add the boxes to the collisionWorld then

- performCollisionDetection
- get the contactManifold (a single manifold is returned)
- refresh the contact points (I am not sure what this does but i didnt get any results at all if I didnt do this when I was using meshes).
- get the manifold point (contactManifold->GetContactPoint(0);)

Do you mean extending the DemoApplication? Sorry I haven't been around here very long.

Thanks again.

All the best,
Ash
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Can you make sure you use the most recent Bullet library (2.0f at the moment), and check out CollisionInterfaceDemo.

Are you doing things different that in that demo? Can you try to use that setup to show a case that doesn't work for you?

Thanks,
Erwin
AshMcConnell
Posts: 29
Joined: Sat Sep 23, 2006 1:35 pm
Location: Northern Ireland

Post by AshMcConnell »

Hi Erwin,

Yup, I've got 2.0f. I've just done a couple more tests.

Two Cubes (2 x 2 x 2)

CubeA - Position( 0, 0, 0 )
CubeB - Position (1.9, 1.9, 1.9)

Expected: -0.173205 (The diagonal of a 0.1,0.1,0.1 cube if my maths are correct)
Actual: -0.1

Two Cubes (2 x 2 x 2)

CubeA - Position ( 0, 0, 0 )
CubeB - Position (1.9, 0, 0 )

Expected Distance: -0.1
Actual Distance: -0.133884

I guess i'm looking for the ideal distance (which may not be completely necessary) - I guess bullet is taking the 2 nearest corner points of the cube?

All the best,
Ash
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

AshMcConnell wrote:Hi Erwin,

Yup, I've got 2.0f. I've just done a couple more tests.

Two Cubes (2 x 2 x 2)

CubeA - Position( 0, 0, 0 )
CubeB - Position (1.9, 1.9, 1.9)

Expected: -0.173205 (The diagonal of a 0.1,0.1,0.1 cube if my maths are correct)
Actual: -0.1

Two Cubes (2 x 2 x 2)

CubeA - Position ( 0, 0, 0 )
CubeB - Position (1.9, 0, 0 )

Expected Distance: -0.1
Actual Distance: -0.133884

I guess i'm looking for the ideal distance (which may not be completely necessary) - I guess bullet is taking the 2 nearest corner points of the cube?

All the best,
Ash
You must take the collision margin into account. Basically a cube is spherically extruded, or 'rounded' with this margin. This has an effect on the penetration depth. Also, penetrations deeper then the added margins are estimated (not accurate). For most situations, like resting contact, deep penetrations should not happen (and should be covered by the collision margins. This concept of hybrid penetration depth computation is nicely explained in Gino van den Bergens book on GJK collision detection.

Try varying the margins and see the effect. One of the demos (CollisionInterfaceDemo.cpp I think) shows the calculated distance and penetration dept vector in red. For penetrations less then the added margins (so if each margin is 0.05, the added is 0.1, penetrations between -0.1 and 0.0 are very accurate, although using the rounded corners. Penetrations deeper then the added margins (<-.1 in this example) are approximated.

I should provide some documentation explaining the collision margins and hybrid penetration depth computation, that should make things clear.

Does this help?
Thanks,
Erwin
AshMcConnell
Posts: 29
Joined: Sat Sep 23, 2006 1:35 pm
Location: Northern Ireland

Post by AshMcConnell »

Hi Erwin,

I thought it may have been something like that, I think I remember you talking about margins on another thread.

I think it should be more than sufficient for my purposes, I just wanted to write some tests to see how it worked.

It'd be great if you could brain-dump some more of this stuff to the help files, it would save noobies like me bothering you so often! :). I know that documentation is a terrible terrible burden (I hate doing it myself too!). It would be very useful to have a little more detail in the docs.

Perhaps it would be more sensible to update it after the refactoring exercise though.

Thanks again for the help! Much Appreciated! :)

All the best,
Ash