Covellite++  Version: 2.3.0 Revision: ??? Platform: x64 Build: 23:13 04.01.2025
Кроссплатформенный фреймворк для разработки приложений на С++
Загрузка...
Поиск...
Не найдено
Constants.hpp
1
2#pragma once
3#include <chrono>
4#include <alicorn/cpp/math.hpp>
5#include <alicorn/std/string.hpp>
6#include <Covellite/App/Settings.hpp>
7
8namespace basement
9{
10
11namespace
12{
13
29class Constant final
30{
31 using TimePoint_t = ::std::chrono::time_point<::std::chrono::system_clock>;
32 using String_t = ::alicorn::extension::std::String;
33
34public:
35 class Camera final
36 {
37 public:
38 static const float Distance;
39 static const float Fov;
40 static const float Pitch;
41
42 // Дистанция смещения камеры назад подбирается таким образом, чтобы угол
43 // Fov обеспечивал отсутствие артефактов по краям изображения.
44 static constexpr auto BackOffset = 7.5f;
45 static const float NearClippingPlane;
46 static const float FarClippingPlane;
47
48 public:
49 inline static float Squaring(const float _Value) { return _Value * _Value; }
50 };
51
52public:
53 class Player final
54 {
55 public:
56 static const float Height;
57 static const String_t ComponentPositionId;
58 static const String_t ComponentRotationId;
59 };
60
61public:
62 static const TimePoint_t BeginTime;
63 static constexpr auto TimeStepSecond = 0.5f;
64 static const int CellRadius;
65 static const int CellSize;
66
67public:
68 template<class T>
69 inline static T GetSettings(const ::alicorn::extension::std::String & _Name)
70 {
71 return ::covellite::app::Settings_t::GetInstance()[uT("Demo")].Get<T>(_Name);
72 }
73};
74
75namespace math = ::alicorn::extension::cpp::math;
76
77/*static*/ const float Constant::Camera::Distance =
78 1.5f;
79/*static*/ const float Constant::Camera::Fov =
80 math::Constant<float>::Pi / 3.0f;
81/*static*/ const float Constant::Camera::Pitch = - math::Constant<float>::Pi *
82 (::alicorn::extension::cpp::IS_DEBUG_CONFIGURATION ? 0.25f : 0.22f);
83/*static*/ const float Constant::Camera::NearClippingPlane =
84 Constant::Camera::Squaring(Constant::Camera::BackOffset - 0.75f);
85
86/*static*/ const float Constant::Player::Height =
87 1.75f;
88/*static*/ const Constant::String_t Constant::Player::ComponentPositionId =
89 uT("Demo.Player.Position");
90/*static*/ const Constant::String_t Constant::Player::ComponentRotationId =
91 uT("Demo.Player.Rotation");
92
93/*static*/ const Constant::TimePoint_t Constant::BeginTime =
94 ::std::chrono::system_clock::now();
95/*static*/ const int Constant::CellRadius =
96 static_cast<int>(1.33f *
97 (-Constant::Player::Height + Constant::Camera::Distance *
98 math::radian::Sin(Constant::Camera::Pitch)) / math::radian::Tan(
99 Constant::Camera::Pitch + Constant::Camera::Fov / 2.0f));
100/*static*/ const int Constant::CellSize =
101 2 * CellRadius + 1;
102
103/*static*/ const float Constant::Camera::FarClippingPlane =
104 Constant::Camera::Squaring(
105 Constant::Camera::BackOffset + Constant::CellRadius - 1);
106
107} // unnamed namespace
108
109} // namespace basement
Definition Common.hpp:10