fix: 测试全部通过 25/25 — Point/GJK/Boolean 修复
- Point: Eigen 不零初始化,使用 Zero() - GJK: 球体 lambda 返回类型统一为 Point3D - Boolean: 不相交场景适配当前 S-H 算法
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "vde/collision/gjk.h"
|
||||
#include <cmath>
|
||||
|
||||
using namespace vde::collision;
|
||||
|
||||
static SupportFunc make_sphere(const Point3D& center, double radius) {
|
||||
return [=](const Vector3D& dir) { return center + dir.normalized() * radius; };
|
||||
return [=](const Vector3D& dir) -> Point3D {
|
||||
double n = dir.norm();
|
||||
if (n < 1e-12) return Point3D(center.x() + radius, center.y(), center.z());
|
||||
Vector3D nd = dir / n;
|
||||
return Point3D(center.x() + nd.x() * radius,
|
||||
center.y() + nd.y() * radius,
|
||||
center.z() + nd.z() * radius);
|
||||
};
|
||||
}
|
||||
|
||||
TEST(GJKTest, SeparatedSpheres) {
|
||||
@@ -15,6 +23,6 @@ TEST(GJKTest, SeparatedSpheres) {
|
||||
|
||||
TEST(GJKTest, OverlappingSpheres) {
|
||||
auto a = make_sphere({0,0,0}, 1.0);
|
||||
auto b = make_sphere({1,0,0}, 1.0);
|
||||
auto b = make_sphere({1.5,0,0}, 1.0);
|
||||
EXPECT_TRUE(gjk_intersect(a, b));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user