Dandelion
2.0.0
A light-weight 3D builder for educational usage
Toggle main menu visibility
载入中...
搜索中...
未找到
aabb.h
浏览该文件的文档.
1
#pragma once
2
3
#include <array>
4
5
#include <Eigen/Core>
6
#include <spdlog/spdlog.h>
7
8
#include "
../geometry/mesh.hpp
"
9
#include "
ray.h
"
10
11
/*!
12
* \file utils/aabb.h
13
*/
14
15
/*!
16
* \ingroup utils
17
* \~chinese
18
* \brief BVH中的Aligned-axis bounding box
19
*/
20
class
AABB
21
{
22
public
:
23
24
/*! \~chinese x,y,z最小的点以及最大的点,两个点即能确定一个AABB */
25
Eigen::Vector3f
p_min
, p_max;
26
27
AABB();
28
29
AABB(
const
Eigen::Vector3f& p) :
p_min
(p), p_max(p) {}
30
31
AABB
(
const
Eigen::Vector3f& p1,
const
Eigen::Vector3f& p2);
32
33
/*! \~chinese 返回p_max和p_min的距离,即AABB對角线的长度 */
34
Eigen::Vector3f
diagonal
()
const
;
35
/*! \~chinese 返回AABB的x,y,z中最长的一维 */
36
int
max_extent
()
const
;
37
/*! \~chinese 返回AABB的中心坐标 */
38
Eigen::Vector3f
centroid
();
39
40
/*
41
AABB intersect(const AABB& b);
42
bool inside(const Eigen::Vector3f& p, const AABB& b);
43
inline const Eigen::Vector3f& operator[](int i) const{
44
return (i==0) ? p_min : p_max;
45
}
46
*/
47
48
/*!
49
* \~chinese
50
* \brief BVH加速求交的函数调用接口
51
*
52
* \param ray 求交的射线
53
* \param inv_dir (1/dir.x, 1/dir.y, 1/dir.z),乘法比除法快
54
* \param dir_is_neg 判断x,y,z方向是否为负,为负则交换t_min和t_max
55
*/
56
bool
57
intersect
(
const
Ray
& ray,
const
Eigen::Vector3f& inv_dir,
const
std::array<int, 3>& dir_is_neg);
58
};
59
60
/*! \~chinese
61
* 将两个AABB融合,融合之后的AABB的p_min各维度取二者最小值,p_max各维度取二者最大值,返回融合之后的AABB
62
*/
63
AABB
union_AABB(
const
AABB
& b1,
const
AABB
& b2);
64
65
/*! \~chinese
66
* 将一个AABB和一个点融合,融合之后的AABB的p_min各维度取二者最小值,p_max各维度取二者最大值,返回融合之后的AABB
67
*/
68
AABB
union_AABB(
const
AABB
& b,
const
Eigen::Vector3f& p);
69
70
/*!
71
* \~chinese
72
* \brief BVH加速求交的函数调用接口
73
*
74
* \param mesh 当前AABB所在的mesh
75
* \param face_idx 当前的面片所对应的index
76
*/
77
AABB
get_aabb(
const
Mesh
& mesh,
size_t
face_idx);
78
AABB
BVH中的Aligned-axis bounding box
定义
aabb.h:21
AABB::max_extent
int max_extent() const
定义
aabb.cpp:30
AABB::intersect
bool intersect(const Ray &ray, const Eigen::Vector3f &inv_dir, const std::array< int, 3 > &dir_is_neg)
BVH加速求交的函数调用接口
定义
aabb.cpp:48
AABB::p_min
Eigen::Vector3f p_min
定义
aabb.h:25
AABB::diagonal
Eigen::Vector3f diagonal() const
定义
aabb.cpp:24
AABB::centroid
Eigen::Vector3f centroid()
定义
aabb.cpp:42
mesh.hpp
ray.h
提供生成射线、判定相交的工具函数。
Mesh
用于同步渲染数据的三角形 Mesh 。
定义
mesh.hpp:28
Ray
定义
ray.h:24
src
utils
aabb.h
制作者
1.18.0