1
This commit is contained in:
parent
27ecd5c940
commit
cc57f69109
@ -85,6 +85,104 @@ namespace a8
|
|||||||
return u1 > 0.000001f && u2 > 0.000001;
|
return u1 > 0.000001f && u2 > 0.000001;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IntersectAabbObb(a8::Vec2 a_min, a8::Vec2 a_max, a8::Vec2 b_pos, float rotate)
|
||||||
|
{
|
||||||
|
struct Segment
|
||||||
|
{
|
||||||
|
a8::Vec2 point1;
|
||||||
|
a8::Vec2 point2;
|
||||||
|
a8::Vec2 dir;
|
||||||
|
};
|
||||||
|
std::vector<Segment> a_edges;
|
||||||
|
std::vector<Segment> b_edges;
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
Segment seg;
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
seg.point1 = a_min;
|
||||||
|
seg.point2 = a_min + a8::Vec2(a_max.x - a_min.x, 0);
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
seg.point1 = a_min + a8::Vec2(a_max.x - a_min.x, 0);
|
||||||
|
seg.point2 = a_max;
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
seg.point1 = a_max;
|
||||||
|
seg.point2 = a_min + a8::Vec2(0, a_max.y - a_min.y);
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
seg.point1 = a_min + a8::Vec2(0, a_max.y - a_min.y);
|
||||||
|
seg.point2 = a_min;
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a_edges.push_back(seg);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
Segment seg;
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
seg.point1 = a_min;
|
||||||
|
seg.point2 = a_min + a8::Vec2(a_max.x - a_min.x, 0);
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
seg.point1 = a_min + a8::Vec2(a_max.x - a_min.x, 0);
|
||||||
|
seg.point2 = a_max;
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
seg.point1 = a_max;
|
||||||
|
seg.point2 = a_min + a8::Vec2(0, a_max.y - a_min.y);
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
seg.point1 = a_min + a8::Vec2(0, a_max.y - a_min.y);
|
||||||
|
seg.point2 = a_min;
|
||||||
|
seg.dir = seg.point2 - seg.point1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
b_edges.push_back(seg);
|
||||||
|
}
|
||||||
|
auto GetProjectionWithAxis =
|
||||||
|
[] (std::vector<a8::Vec2> vertices, a8::Vec2 axis) -> a8::Vec2 {
|
||||||
|
axis.Normalize();
|
||||||
|
float _min = vertices[0].Dot(axis);
|
||||||
|
float _max = _min;
|
||||||
|
for (a8::Vec2& v : vertices) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool IntersectCircleCircle(a8::Vec2 a_pos, float a_rad, a8::Vec2 b_pos, float b_rad)
|
bool IntersectCircleCircle(a8::Vec2 a_pos, float a_rad, a8::Vec2 b_pos, float b_rad)
|
||||||
{
|
{
|
||||||
float t = a_rad + b_rad;
|
float t = a_rad + b_rad;
|
||||||
|
@ -9,6 +9,7 @@ namespace a8
|
|||||||
bool IntersectSegmentAabb(a8::Vec2 p0, a8::Vec2 p1, a8::Vec2 _min, a8::Vec2 _max);
|
bool IntersectSegmentAabb(a8::Vec2 p0, a8::Vec2 p1, a8::Vec2 _min, a8::Vec2 _max);
|
||||||
bool IntersectAabbCircle(a8::Vec2 a_min, a8::Vec2 a_max, a8::Vec2 b_pos, float b_rad);
|
bool IntersectAabbCircle(a8::Vec2 a_min, a8::Vec2 a_max, a8::Vec2 b_pos, float b_rad);
|
||||||
bool IntersectAabbAabb(a8::Vec2 a_min, a8::Vec2 a_max, a8::Vec2 b_min, a8::Vec2 b_max);
|
bool IntersectAabbAabb(a8::Vec2 a_min, a8::Vec2 a_max, a8::Vec2 b_min, a8::Vec2 b_max);
|
||||||
|
bool IntersectAabbObb(a8::Vec2 a_min, a8::Vec2 a_max, a8::Vec2 b_pos, float rotate);
|
||||||
bool IntersectCircleCircle(a8::Vec2 a_pos, float a_rad, a8::Vec2 b_pos, float b_rad);
|
bool IntersectCircleCircle(a8::Vec2 a_pos, float a_rad, a8::Vec2 b_pos, float b_rad);
|
||||||
bool IntersectSectorCircle(a8::Vec2 a_pos, float angle, float a_rad, a8::Vec2 b_pos, float b_rad);
|
bool IntersectSectorCircle(a8::Vec2 a_pos, float angle, float a_rad, a8::Vec2 b_pos, float b_rad);
|
||||||
bool IntersectSectorAabb(a8::Vec2 a_pos, float angle, float a_rad, a8::Vec2 b_min, a8::Vec2 b_max);
|
bool IntersectSectorAabb(a8::Vec2 a_pos, float angle, float a_rad, a8::Vec2 b_min, a8::Vec2 b_max);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user