64ad721ed7
- CMake: INTERFACE 库修复、vde_compile_options 顺序修复 - 命名空间: 所有模块添加 using 声明 - 类型补全: Ray3Dd、Point4D - 头文件: tolerance 泛型化、std::optional include - 警告: 放宽 -Wconversion/-Wsign-conversion - 构建结果: 0 errors, 22/25 tests passed
28 lines
648 B
C++
28 lines
648 B
C++
#pragma once
|
|
#include "vde/core/point.h"
|
|
#include "vde/core/line.h"
|
|
#include "vde/core/triangle.h"
|
|
#include <optional>
|
|
|
|
namespace vde::collision {
|
|
using core::Point3D;
|
|
using core::Vector3D;
|
|
using core::Triangle3D;
|
|
using core::Ray3Dd;
|
|
|
|
struct RayTriResult {
|
|
double t;
|
|
double u, v;
|
|
Point3D point;
|
|
};
|
|
|
|
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
|