v0.1.0: 初始工程骨架 — 7模块 40头文件 32源文件 17文档 Apache-2.0

This commit is contained in:
ViewDesignEngine
2026-07-23 05:27:51 +00:00
commit 02d0520aa5
133 changed files with 5350 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
#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
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#include "vde/core/point.h"
#include "vde/core/line.h"
#include "vde/core/triangle.h"
#include <optional>
namespace vde::collision {
struct RayTriResult {
double t; // parameter along ray
double u, v; // barycentric
Point3D point;
};
/// MöllerTrumbore ray-triangle intersection
std::optional<RayTriResult> ray_triangle_intersect(
const Point3D& origin, const Vector3D& dir, const Triangle3D& tri);
inline std::optional<RayTriResult> ray_triangle_intersect(
const Ray3Dd& ray, const Triangle3D& tri) {
return ray_triangle_intersect(ray.origin(), ray.direction(), tri);
}
} // namespace vde::collision
+14
View File
@@ -0,0 +1,14 @@
#pragma once
#include "vde/core/point.h"
#include <vector>
#include <array>
namespace vde::collision {
/// SAT (Separating Axis Theorem) for convex polyhedra
bool sat_intersect(const std::vector<Point3D>& verts_a,
const std::vector<std::array<int,3>>& faces_a,
const std::vector<Point3D>& verts_b,
const std::vector<std::array<int,3>>& faces_b);
} // namespace vde::collision
+9
View File
@@ -0,0 +1,9 @@
#pragma once
#include "vde/core/triangle.h"
namespace vde::collision {
/// Triangle-triangle intersection test (Möller)
bool tri_tri_intersect(const Triangle3D& t1, const Triangle3D& t2);
} // namespace vde::collision