21 lines
560 B
C++
21 lines
560 B
C++
|
|
#include <gtest/gtest.h>
|
||
|
|
#include "vde/collision/gjk.h"
|
||
|
|
|
||
|
|
using namespace vde::collision;
|
||
|
|
|
||
|
|
static SupportFunc make_sphere(const Point3D& center, double radius) {
|
||
|
|
return [=](const Vector3D& dir) { return center + dir.normalized() * radius; };
|
||
|
|
}
|
||
|
|
|
||
|
|
TEST(GJKTest, SeparatedSpheres) {
|
||
|
|
auto a = make_sphere({0,0,0}, 1.0);
|
||
|
|
auto b = make_sphere({5,0,0}, 1.0);
|
||
|
|
EXPECT_FALSE(gjk_intersect(a, b));
|
||
|
|
}
|
||
|
|
|
||
|
|
TEST(GJKTest, OverlappingSpheres) {
|
||
|
|
auto a = make_sphere({0,0,0}, 1.0);
|
||
|
|
auto b = make_sphere({1,0,0}, 1.0);
|
||
|
|
EXPECT_TRUE(gjk_intersect(a, b));
|
||
|
|
}
|