3void xcal::camera::PerspectiveCamera::update_projection_matrix()
const {
7 const float tan_half = std::tan(fov_rad * 0.5f);
8 const float n = near_.
value();
9 const float f = far_.
value();
10 const float a = aspect_.
value();
12 auto& P = projection_matrix_cache_;
16 P[0][0] = 1.0f / (a * tan_half);
17 P[1][1] = 1.0f / tan_half;
18 P[2][2] = -(f + n) / (f - n);
19 P[2][3] = -2.0f * f * n / (f - n);
30 return fov_.is_changed() || aspect_.is_changed() || near_.is_changed() ||
35 update_projection_matrix();
36 return projection_matrix_cache_;
void projection_has_changed() const
标记投影矩阵已改变
bool_t projection_should_update() const override
检查投影矩阵是否需要更新
const xcmath::mat< float_t, 4, 4 > & projection_matrix() const override
获取投影矩阵
void reset_changed() const
const data_t & value() const
constexpr long double PI
Pi constant