Bullet Collision Detection & Physics Library
boxBoxDistance.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006, 2008 Sony Computer Entertainment Inc.
3  All rights reserved.
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 
15 */
16 
17 
18 #ifndef __BOXBOXDISTANCE_H__
19 #define __BOXBOXDISTANCE_H__
20 
21 
22 #include "Box.h"
23 
24 
25 //---------------------------------------------------------------------------
26 // boxBoxDistance:
27 //
28 // description:
29 // this computes info that can be used for the collision response of two boxes. when the boxes
30 // do not overlap, the points are set to the closest points of the boxes, and a positive
31 // distance between them is returned. if the boxes do overlap, a negative distance is returned
32 // and the points are set to two points that would touch after the boxes are translated apart.
33 // the contact normal gives the direction to repel or separate the boxes when they touch or
34 // overlap (it's being approximated here as one of the 15 "separating axis" directions).
35 //
36 // returns:
37 // positive or negative distance between two boxes.
38 //
39 // args:
40 // vmVector3& normal: set to a unit contact normal pointing from box A to box B.
41 //
42 // BoxPoint& boxPointA, BoxPoint& boxPointB:
43 // set to a closest point or point of penetration on each box.
44 //
45 // Box boxA, Box boxB:
46 // boxes, represented as 3 half-widths
47 //
48 // const vmTransform3& transformA, const vmTransform3& transformB:
49 // box transformations, in world coordinates
50 //
51 // float distanceThreshold:
52 // the algorithm will exit early if it finds that the boxes are more distant than this
53 // threshold, and not compute a contact normal or points. if this distance returned
54 // exceeds the threshold, all the other output data may not have been computed. by
55 // default, this is set to MAX_FLOAT so it will have no effect.
56 //
57 //---------------------------------------------------------------------------
58 
59 float
60 boxBoxDistance(vmVector3& normal, BoxPoint& boxPointA, BoxPoint& boxPointB,
61  PE_REF(Box) boxA, const vmTransform3 & transformA, PE_REF(Box) boxB,
62  const vmTransform3 & transformB,
63  float distanceThreshold = FLT_MAX );
64 
65 #endif /* __BOXBOXDISTANCE_H__ */
float boxBoxDistance(vmVector3 &normal, BoxPoint &boxPointA, BoxPoint &boxPointB, PE_REF(Box) boxA, const vmTransform3 &transformA, PE_REF(Box) boxB, const vmTransform3 &transformB, float distanceThreshold=FLT_MAX)
#define PE_REF(a)
Definition: Box.h:22
The Box is an internal class used by the boxBoxDistance calculation.
Definition: Box.h:39
The BoxPoint class is an internally used class to contain feature information for boxBoxDistance calc...
Definition: Box.h:93