mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 12:39:17 +02:00
reformat: set variables to constexpr where possible
This commit is contained in:
@@ -51,8 +51,8 @@ enum stream {
|
||||
texture = 0x8
|
||||
};
|
||||
|
||||
unsigned int const basic_streams { position | normal | texture };
|
||||
unsigned int const color_streams { position | color | texture };
|
||||
constexpr unsigned int basic_streams { position | normal | texture };
|
||||
constexpr unsigned int color_streams { position | color | texture };
|
||||
|
||||
struct stream_units {
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ opengl33_precipitation::create( int const Tesselation ) {
|
||||
m_uvs.clear();
|
||||
m_indices.clear();
|
||||
|
||||
auto const heightfactor { 10.f }; // height-to-radius factor
|
||||
auto const verticaltexturestretchfactor { 1.5f }; // crude motion blur
|
||||
constexpr auto heightfactor { 10.f }; // height-to-radius factor
|
||||
constexpr auto verticaltexturestretchfactor { 1.5f }; // crude motion blur
|
||||
|
||||
// create geometry chunk
|
||||
auto const latitudes { 3 }; // just a cylinder with end cones
|
||||
constexpr auto latitudes { 3 }; // just a cylinder with end cones
|
||||
auto const longitudes { Tesselation };
|
||||
auto const longitudehalfstep { 0.5f * static_cast<float>( 2.0 * M_PI * 1.f / longitudes ) }; // for crude uv correction
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ bool opengl33_renderer::Init(GLFWwindow *Window)
|
||||
WriteLog("...gfx data pre-loading done");
|
||||
|
||||
// prepare basic geometry chunks
|
||||
float const size = 2.5f / 2.0f;
|
||||
constexpr float size = 2.5f / 2.0f;
|
||||
auto const geometrybank = Create_Bank();
|
||||
|
||||
gfx::vertex_array billboard_array{
|
||||
@@ -571,7 +571,7 @@ bool opengl33_renderer::Render()
|
||||
{
|
||||
m_sunlight = Global.DayLight;
|
||||
// quantize sun angle to reduce shadow crawl
|
||||
auto const quantizationstep{0.004f};
|
||||
constexpr auto quantizationstep{0.004f};
|
||||
m_sunlight.direction = glm::normalize(quantizationstep * glm::roundEven(m_sunlight.direction * (1.f / quantizationstep)));
|
||||
}
|
||||
// generate new frame
|
||||
@@ -4134,7 +4134,7 @@ void opengl33_renderer::Render_vr_models()
|
||||
tmpmat = glm::dmat3(tmpmat);
|
||||
glMultMatrixd(glm::value_ptr(glm::inverse(tmpmat)));
|
||||
const std::vector<TModel3d*> list = vr->get_render_models();
|
||||
const material_data data;
|
||||
constexpr material_data data;
|
||||
for (TModel3d *mdl : list)
|
||||
Render(mdl, &data, 0.0);
|
||||
::glPopMatrix();
|
||||
@@ -5219,7 +5219,7 @@ void opengl33_renderer::Update_Lights(light_array &Lights)
|
||||
auto const &ownerdimensions{ scenelight.owner->MoverParameters->Dim };
|
||||
auto const up{ static_cast<glm::dvec3>( scenelight.owner->VectorUp() ) };
|
||||
auto const size{ static_cast<float>( std::max( ownerdimensions.W, ownerdimensions.H ) * 1.0 ) }; // ensure square ratio
|
||||
auto const cone{ 5.f };
|
||||
constexpr auto cone{ 5.f };
|
||||
auto const offset{ 75.f * ( 5.f / cone ) };
|
||||
headlights.position() =
|
||||
scenelight.owner->GetPosition()
|
||||
|
||||
@@ -140,7 +140,7 @@ class opengl33_renderer : public gfx_renderer {
|
||||
void Update_AnimModel(TAnimModel *model);
|
||||
|
||||
// members
|
||||
GLenum static const sunlight{0};
|
||||
constexpr GLenum static sunlight{0};
|
||||
|
||||
static std::unique_ptr<gfx_renderer> create_func();
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ opengl_precipitation::create( int const Tesselation ) {
|
||||
m_uvs.clear();
|
||||
m_indices.clear();
|
||||
|
||||
auto const heightfactor { 10.f }; // height-to-radius factor
|
||||
auto const verticaltexturestretchfactor { 1.5f }; // crude motion blur
|
||||
constexpr auto heightfactor { 10.f }; // height-to-radius factor
|
||||
constexpr auto verticaltexturestretchfactor { 1.5f }; // crude motion blur
|
||||
|
||||
// create geometry chunk
|
||||
auto const latitudes { 3 }; // just a cylinder with end cones
|
||||
constexpr auto latitudes { 3 }; // just a cylinder with end cones
|
||||
auto const longitudes { Tesselation };
|
||||
auto const longitudehalfstep { 0.5f * static_cast<float>( 2.0 * M_PI * 1.f / longitudes ) }; // for crude uv correction
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ int constexpr EU07_PICKBUFFERSIZE { 1024 }; // size of (square) textures bound w
|
||||
int constexpr EU07_ENVIRONMENTBUFFERSIZE { 256 }; // size of (square) environmental cube map texture
|
||||
int constexpr EU07_REFLECTIONFIDELITYOFFSET { 250 }; // artificial increase of range for reflection pass detail reduction
|
||||
|
||||
float const EU07_OPACITYDEFAULT { 0.5f };
|
||||
constexpr float EU07_OPACITYDEFAULT { 0.5f };
|
||||
|
||||
bool
|
||||
opengl_renderer::Init( GLFWwindow *Window ) {
|
||||
@@ -301,7 +301,7 @@ opengl_renderer::Init( GLFWwindow *Window ) {
|
||||
}
|
||||
// prepare basic geometry chunks
|
||||
auto const geometrybank = Create_Bank();
|
||||
float const size = 2.5f;
|
||||
constexpr float size = 2.5f;
|
||||
gfx::vertex_array billboard_array{
|
||||
{ { -size, size, 0.f }, glm::vec3(), { 1.f, 1.f } },
|
||||
{ { size, size, 0.f }, glm::vec3(), { 0.f, 1.f } },
|
||||
@@ -328,7 +328,7 @@ opengl_renderer::Render() {
|
||||
if( simulation::is_ready ) {
|
||||
m_sunlight = Global.DayLight;
|
||||
// quantize sun angle to reduce shadow crawl
|
||||
auto const quantizationstep { 0.004f };
|
||||
constexpr auto quantizationstep { 0.004f };
|
||||
m_sunlight.direction = glm::normalize( quantizationstep * glm::roundEven( m_sunlight.direction * ( 1.f / quantizationstep ) ) );
|
||||
}
|
||||
// generate new frame
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
opengl_material const & Material( TSubModel const * Submodel ) const;
|
||||
|
||||
// members
|
||||
GLenum static const sunlight { GL_LIGHT0 };
|
||||
constexpr GLenum static sunlight { GL_LIGHT0 };
|
||||
|
||||
static std::unique_ptr<gfx_renderer> create_func();
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ smoke_source::initialize( smoke_particle &Particle ) {
|
||||
|
||||
if( m_ownertype == owner_type::vehicle ) {
|
||||
Particle.opacity *= m_owner.vehicle->MoverParameters->dizel_fill;
|
||||
auto const enginerevolutionsfactor { 1.5f }; // high engine revolutions increase initial particle velocity
|
||||
constexpr auto enginerevolutionsfactor { 1.5f }; // high engine revolutions increase initial particle velocity
|
||||
switch( m_owner.vehicle->MoverParameters->EngineType ) {
|
||||
case TEngineType::DieselElectric: {
|
||||
if (m_owner.vehicle->MoverParameters->dizel_spinup == true)
|
||||
|
||||
@@ -22,7 +22,7 @@ basic_precipitation::~basic_precipitation() {
|
||||
bool
|
||||
basic_precipitation::init() {
|
||||
|
||||
auto const heightfactor { 10.f }; // height-to-radius factor
|
||||
constexpr auto heightfactor { 10.f }; // height-to-radius factor
|
||||
m_moverate *= heightfactor;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user