Files
ViewDesignEngine/include/vde/collision/gjk.h
T

28 lines
770 B
C++

#pragma once
#include "vde/core/point.h"
#include <functional>
#include <optional>
namespace vde::collision {
/// Support function type: given direction, return farthest point on shape
using SupportFunc = std::function<Point3D(const Vector3D&)>;
struct GJKResult {
bool intersect;
double distance;
Point3D point_a;
Point3D point_b;
};
/// GJK intersection test for convex shapes
bool gjk_intersect(const SupportFunc& shape_a, const SupportFunc& shape_b);
/// GJK distance between convex shapes
double gjk_distance(const SupportFunc& shape_a, const SupportFunc& shape_b);
/// Full GJK: intersection + closest points + penetration (with EPA)
GJKResult gjk_full(const SupportFunc& shape_a, const SupportFunc& shape_b);
} // namespace vde::collision