How to compute BoxBox contact point ?

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
Jack2016
Posts: 10
Joined: Fri Aug 12, 2016 5:46 am

How to compute BoxBox contact point ?

Post by Jack2016 »

when I read the btBoxBoxCollisionAlgorithm source code to compute BoxBox contact points ,I find it's hard to understand.
so which book or paper should I refer to,I want to know the principle first
jheanley
Posts: 1
Joined: Fri Aug 12, 2016 2:10 pm

Re: How to compute BoxBox contact point ?

Post by jheanley »

This should be a reasonable start, this is OBB vs OBB collisions. (OBB is Oriented Bounding Box, the other type is AABB or axis aligned bounding box which is somewhat cheaper to compute)

http://www.randygaul.net/2014/05/22/der ... ction-sat/
Jack2016
Posts: 10
Joined: Fri Aug 12, 2016 5:46 am

Re: How to compute BoxBox contact point ?

Post by Jack2016 »

jheanley wrote:This should be a reasonable start, this is OBB vs OBB collisions. (OBB is Oriented Bounding Box, the other type is AABB or axis aligned bounding box which is somewhat cheaper to compute)

http://www.randygaul.net/2014/05/22/der ... ction-sat/
this article is very helpful , Thanks
Jack2016
Posts: 10
Joined: Fri Aug 12, 2016 5:46 am

Re: How to compute BoxBox contact point ?

Post by Jack2016 »

http://gamedev.stackexchange.com/questi ... -with-sat/

SAT in 3D / compute contact point implementation detail
Jack2016
Posts: 10
Joined: Fri Aug 12, 2016 5:46 am

Re: How to compute BoxBox contact point ?

Post by Jack2016 »

In the func dBoxBox2 ,after SAT it's clear to get the collision type which store in the variable "code" -> 1,2,3 / 4,5,6 /9-15
But then I find it's still not clear about the implementation detail of contact point computing,I read the paper of Erwin GDC10_Contact.pdf
The paper just give us some description about Box Box Clipping,introduce the concepts of incident face ,reference face,clipping planes,
still not clear about the implementation detail

Code: Select all

  // find the normal and non-normal axis numbers of the reference box
  int codeN,code1,code2;
  if (code <= 3) codeN = code-1; else codeN = code-4;
  if (codeN==0) {
    code1 = 1;
    code2 = 2;
  }
  else if (codeN==1) {
    code1 = 0;
    code2 = 2;
  }
  else {
    code1 = 0;
    code2 = 1;
  }

  // find the four corners of the incident face, in reference-face coordinates
  btScalar quad[8];	// 2D coordinate of incident face (x,y pairs)
  btScalar c1,c2,m11,m12,m21,m22;
  c1 = dDOT14 (center,Ra+code1);
  c2 = dDOT14 (center,Ra+code2);
  // optimize this? - we have already computed this data above, but it is not
  // stored in an easy-to-index format. for now it's quicker just to recompute
  // the four dot products.
  m11 = dDOT44 (Ra+code1,Rb+a1);
  m12 = dDOT44 (Ra+code1,Rb+a2);
  m21 = dDOT44 (Ra+code2,Rb+a1);
  m22 = dDOT44 (Ra+code2,Rb+a2);
  {
    btScalar k1 = m11*Sb[a1];
    btScalar k2 = m21*Sb[a1];
    btScalar k3 = m12*Sb[a2];
    btScalar k4 = m22*Sb[a2];
    quad[0] = c1 - k1 - k3;
    quad[1] = c2 - k2 - k4;
    quad[2] = c1 - k1 + k3;
    quad[3] = c2 - k2 + k4;
    quad[4] = c1 + k1 + k3;
    quad[5] = c2 + k2 + k4;
    quad[6] = c1 + k1 - k3;
    quad[7] = c2 + k2 - k4;
  }

  // find the size of the reference face
  btScalar rect[2];
  rect[0] = Sa[code1];
  rect[1] = Sa[code2];

  // intersect the incident and reference faces
  btScalar ret[16];
  int n = intersectRectQuad2 (rect,quad,ret);
  if (n < 1) return 0;		// this should never happen
what's the reason to compute 4 cornors, and why quat[0] = c1 - k1 -k3 compute like this
In order to make it clear about the code above,which paper should I read or refer to ?

after two days to read the src code above, I'm clear now.So I'll share my experience and give a brief description about the algorithm
1 -> incident face(world coordinate) projected to reference face local coordinate, the local coordinate is 2D
2 -> compute the contact in reference face local coordinate points which is implemented in func intersectRectQuat2
3 -> convert the contact points from the local coordinate to world coordinate
4 -> compute the penetration of each contact point,only the depth <= 0. is contact point
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: How to compute BoxBox contact point ?

Post by RandyGaul »

They wrote dBoxBox like that because it made sense to them at the time to write it like that. They probably derive a lot of the math on paper and then translated it into code. If you want to know what c1 - k1 - k3 is then you need to go through the math and draw pictures of what everything is. You can do the math by hand and follow it along. The four points you outline look correct. If you want to read more about contact point computing try searching this forum for posts by Dirk Gregorius, also look up his GDC lecture about generating contacts.

"In order to make it clear about the code above,which paper should I read or refer to ?"
I suggest to stop looking into ODE and look at the link jheanley gave you if you are stuck. The code there should be easier to understand. You did read the code, right?
Jack2016
Posts: 10
Joined: Fri Aug 12, 2016 5:46 am

Re: How to compute BoxBox contact point ?

Post by Jack2016 »

RandyGaul wrote:They wrote dBoxBox like that because it made sense to them at the time to write it like that. They probably derive a lot of the math on paper and then translated it into code. If you want to know what c1 - k1 - k3 is then you need to go through the math and draw pictures of what everything is. You can do the math by hand and follow it along. The four points you outline look correct. If you want to read more about contact point computing try searching this forum for posts by Dirk Gregorius, also look up his GDC lecture about generating contacts.

"In order to make it clear about the code above,which paper should I read or refer to ?"
I suggest to stop looking into ODE and look at the link jheanley gave you if you are stuck. The code there should be easier to understand. You did read the code, right?
Thanks a lot.
I have read jHeanley's link,and understand the SAT in 3D .Also read the lecture of Drik TheSperatingAxisTest.pdf .
The meaning of "c1 - k1 -k3" is the cornor of the quad which is projected to the reference face,I think I have understood.
Post Reply