Toggle navigation
PlayRho
0.9.0
GitHub
Main Page
Modules
Classes
Files
Examples
File List
File Members
Collision
Distance.hpp
Go to the documentation of this file.
1
/*
2
* Original work Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
3
* Modified work Copyright (c) 2017 Louis Langholtz https://github.com/louis-langholtz/PlayRho
4
*
5
* This software is provided 'as-is', without any express or implied
6
* warranty. In no event will the authors be held liable for any damages
7
* arising from the use of this software.
8
* Permission is granted to anyone to use this software for any purpose,
9
* including commercial applications, and to alter it and redistribute it
10
* freely, subject to the following restrictions:
11
* 1. The origin of this software must not be misrepresented; you must not
12
* claim that you wrote the original software. If you use this software
13
* in a product, an acknowledgment in the product documentation would be
14
* appreciated but is not required.
15
* 2. Altered source versions must be plainly marked as such, and must not be
16
* misrepresented as being the original software.
17
* 3. This notice may not be removed or altered from any source distribution.
18
*/
19
20
#ifndef PLAYRHO_COLLISION_DISTANCE_HPP
21
#define PLAYRHO_COLLISION_DISTANCE_HPP
22
23
#include <
PlayRho/Common/Math.hpp
>
24
#include <
PlayRho/Collision/Simplex.hpp
>
25
26
namespace
playrho
{
27
31
using
PairLength2
= std::pair<Length2, Length2>;
32
33
struct
ToiConf
;
34
35
namespace
d2 {
36
37
class
DistanceProxy;
38
40
PairLength2
GetWitnessPoints
(
const
Simplex& simplex) noexcept;
41
43
PLAYRHO_CONSTEXPR
inline
Length2
GetDelta
(
PairLength2
arg) noexcept
44
{
45
return
std::get<1>
(arg) -
std::get<0>
(arg);
46
}
47
50
struct
DistanceConf
51
{
53
using
iteration_type
= std::remove_const<decltype(
DefaultMaxDistanceIters
)>::type;
54
55
Simplex::Cache
cache
;
56
iteration_type
maxIterations
=
DefaultMaxDistanceIters
;
57
};
58
60
DistanceConf
GetDistanceConf
(
const
ToiConf
& conf) noexcept;
61
63
struct
DistanceOutput
64
{
66
enum
State
: std::uint8_t
67
{
68
Unknown
,
69
MaxPoints
,
70
UnfitSearchDir
,
71
DuplicateIndexPair
,
72
HitMaxIters
73
};
74
76
using
iteration_type
= std::remove_const<decltype(
DefaultMaxDistanceIters
)>::type;
77
78
Simplex
simplex
;
79
iteration_type
iterations
= 0;
80
State
state
=
Unknown
;
81
};
82
96
DistanceOutput
Distance
(
const
DistanceProxy
& proxyA,
const
Transformation
& transformA,
97
const
DistanceProxy
& proxyB,
const
Transformation
& transformB,
98
DistanceConf
conf =
DistanceConf
{});
99
106
Area
TestOverlap
(
const
DistanceProxy& proxyA,
const
Transformation& xfA,
107
const
DistanceProxy& proxyB,
const
Transformation& xfB,
108
DistanceConf conf = DistanceConf{});
109
110
}
// namespace d2
111
}
// namespace playrho
112
113
#endif // PLAYRHO_COLLISION_DISTANCE_HPP