16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 20:39:18 +02:00

reformat: use auto on certain types

This commit is contained in:
jerrrrycho
2026-07-04 05:22:52 +02:00
parent f61068ff89
commit 20e7a99516
118 changed files with 2118 additions and 2063 deletions

View File

@@ -125,7 +125,7 @@ void flip_dxt1_image(void *data, int width, int height)
{
int x, y;
struct dxt1_block temp1, temp2;
auto blocks = (struct dxt1_block *)data;
const auto blocks = (struct dxt1_block *)data;
width = (width + 3) / 4;
height = (height + 3) / 4;
@@ -154,7 +154,7 @@ void flip_dxt23_image(void *data, int width, int height)
{
int x, y;
struct dxt23_block temp1, temp2;
auto blocks = (struct dxt23_block *)data;
const auto blocks = (struct dxt23_block *)data;
width = (width + 3) / 4;
height = (height + 3) / 4;
@@ -183,7 +183,7 @@ void flip_dxt45_image(void *data, int width, int height)
{
int x, y;
struct dxt45_block temp1, temp2;
auto blocks = (struct dxt45_block *)data;
const auto blocks = (struct dxt45_block *)data;
width = (width + 3) / 4;
height = (height + 3) / 4;

View File

@@ -171,7 +171,7 @@ cFrustum::cube_inside( float const X, float const Y, float const Z, float const
void cFrustum::normalize_plane( cFrustum::side const Side ) {
float magnitude =
const float magnitude =
std::sqrt(
m_frustum[ Side ][ plane_A ] * m_frustum[ Side ][ plane_A ]
+ m_frustum[ Side ][ plane_B ] * m_frustum[ Side ][ plane_B ]

View File

@@ -212,7 +212,7 @@ void calculate_indices( index_array &Indices, vertex_array &Vertices, userdata_a
vertex_array indexedvertices{};
userdata_array indexeduserdata{};
indexedvertices.reserve( std::max<size_t>( 100, Vertices.size() / 3 ) ); // optimistic guesstimate, but should reduce re-allocation somewhat
bool has_userdata = !Userdata.empty();
const bool has_userdata = !Userdata.empty();
if (has_userdata)
indexeduserdata.reserve(std::max<size_t>(100, Userdata.size() / 3));
auto const matchtolerance { 1e-5f * tolerancescale };
@@ -258,7 +258,7 @@ geometry_bank::create( gfx::vertex_array &Vertices, userdata_array &Userdata, un
m_chunks.emplace_back( Vertices, Userdata, Type );
// NOTE: handle is effectively (index into chunk array + 1) this leaves value of 0 to serve as error/empty handle indication
gfx::geometry_handle chunkhandle { 0, static_cast<std::uint32_t>(m_chunks.size()) };
const gfx::geometry_handle chunkhandle { 0, static_cast<std::uint32_t>(m_chunks.size()) };
// template method implementation
create_( chunkhandle );
// all done
@@ -273,7 +273,7 @@ geometry_bank::create( gfx::index_array &Indices, gfx::vertex_array &Vertices, u
m_chunks.emplace_back( Indices, Vertices, Userdata, Type );
// NOTE: handle is effectively (index into chunk array + 1) this leaves value of 0 to serve as error/empty handle indication
gfx::geometry_handle chunkhandle { 0, static_cast<std::uint32_t>(m_chunks.size()) };
const gfx::geometry_handle chunkhandle { 0, static_cast<std::uint32_t>(m_chunks.size()) };
// template method implementation
create_( chunkhandle );
// all done

View File

@@ -71,7 +71,7 @@ light_array::update() {
// set intensity
if( light.count > 0 ) {
bool isEnabled = light.index == end::front ? !light.owner->HeadlightsAoff : !light.owner->HeadlightsBoff;
const bool isEnabled = light.index == end::front ? !light.owner->HeadlightsAoff : !light.owner->HeadlightsBoff;
light.intensity = std::max(0.0f, std::log((float)light.count + 1.0f));
if (light.owner->DimHeadlights && !light.owner->HighBeamLights && isEnabled) // tylko przyciemnione

View File

@@ -120,7 +120,7 @@ opengl33_particles::render() {
if (!m_shader) {
gl::shader vert("smoke.vert");
gl::shader frag("smoke.frag");
auto prog = new gl::program({vert, frag});
const auto prog = new gl::program({vert, frag});
m_shader = std::unique_ptr<gl::program>(prog);
}

View File

@@ -36,8 +36,8 @@ opengl33_precipitation::create( int const Tesselation ) {
std::uint16_t index = 0;
// auto const radius { 25.f }; // cylinder radius
std::vector<float> radii { 25.f, 10.f, 5.f, 1.f };
for( auto radius : radii ) {
const std::vector<float> radii { 25.f, 10.f, 5.f, 1.f };
for (const auto radius : radii ) {
for( int i = 0; i <= latitudes; ++i ) {
@@ -54,7 +54,7 @@ opengl33_precipitation::create( int const Tesselation ) {
m_vertices.emplace_back( glm::vec3( -x * zr, -z * heightfactor, -y * zr ) * radius );
// uvs
// NOTE: first and last row receives modified u values to deal with limitation of mapping onto triangles
auto u = (
const auto u = (
i == 0 ? longitude + longitudehalfstep :
i == latitudes ? longitude - longitudehalfstep :
longitude );

View File

@@ -393,7 +393,7 @@ bool opengl33_renderer::AddViewport(const global_settings::extraviewport_config
vp->proj_type = viewport_config::custom;
vp->draw_range = conf.draw_range;
bool ret = init_viewport(*vp);
const bool ret = init_viewport(*vp);
glfwMakeContextCurrent(m_window);
return ret;
@@ -445,7 +445,7 @@ bool opengl33_renderer::init_viewport(viewport_config &vp)
glBindVertexArray(v);
}
int samples = 1 << Global.iMultisampling;
const int samples = 1 << Global.iMultisampling;
model_ubo->bind_uniform();
scene_ubo->bind_uniform();
@@ -510,8 +510,8 @@ bool opengl33_renderer::init_viewport(viewport_config &vp)
if (Global.gfx_postfx_ssao_enabled)
{
int ssao_w = std::max(1, vp.width / 2);
int ssao_h = std::max(1, vp.height / 2);
const int ssao_w = std::max(1, vp.width / 2);
const int ssao_h = std::max(1, vp.height / 2);
vp.ssao_tex = std::make_unique<opengl_texture>();
vp.ssao_tex->alloc_rendertarget(GL_R8, GL_RED, ssao_w, ssao_h, 1, 1, GL_CLAMP_TO_EDGE);
@@ -559,7 +559,7 @@ bool opengl33_renderer::Render()
if (!Global.gfx_usegles)
{
std::optional<int64_t> result = m_timequery->result();
const std::optional<int64_t> result = m_timequery->result();
if (result) {
m_gllasttime = *result;
m_timequery->begin();
@@ -622,7 +622,7 @@ void opengl33_renderer::SwapBuffers()
{
Timer::subsystem.gfx_swap.start();
for (auto &viewport : m_viewports) {
for (const auto &viewport : m_viewports) {
if (viewport->window && viewport->real_window)
glfwSwapBuffers(viewport->window);
}
@@ -1489,7 +1489,7 @@ glm::mat4 opengl33_renderer::perspective_projection_raw(float fovy, float aspect
glm::mat4 opengl33_renderer::ortho_projection(float l, float r, float b, float t, float znear, float zfar)
{
glm::mat4 proj = glm::ortho(l, r, b, t, znear, zfar);
const glm::mat4 proj = glm::ortho(l, r, b, t, znear, zfar);
if (GLAD_GL_ARB_clip_control || GLAD_GL_EXT_clip_control)
// when clip_control available, use projection matrix with 1..0 Z range
return glm::mat4( //
@@ -2141,11 +2141,11 @@ material_handle opengl33_renderer::Fetch_Material(std::string const &Filename, b
std::shared_ptr<gl::program> opengl33_renderer::Fetch_Shader(const std::string &name)
{
auto it = m_shaders.find(name);
const auto it = m_shaders.find(name);
if (it == m_shaders.end())
{
gl::shader fragment("mat_" + name + ".frag");
auto program = new gl::program({fragment, *m_vertex_shader.get()});
const auto program = new gl::program({fragment, *m_vertex_shader.get()});
m_shaders.insert({name, std::shared_ptr<gl::program>(program)});
}
@@ -2305,7 +2305,7 @@ void opengl33_renderer::Bind_Material_Shadow(material_handle const Material)
{
if (Material != null_handle)
{
auto &material = m_materials.material(Material);
const auto &material = m_materials.material(Material);
if (material.textures[0] != null_handle)
{
@@ -3653,7 +3653,7 @@ void opengl33_renderer::Render(TSubModel *Submodel)
if ((Submodel->iVisible) && (TSubModel::fSquareDist >= Submodel->fSquareMinDist) && (TSubModel::fSquareDist < Submodel->fSquareMaxDist))
{
glm::mat4 future_stack = model_ubs.future;
const glm::mat4 future_stack = model_ubs.future;
if (Submodel->iFlags & 0xC000)
{
@@ -3664,7 +3664,7 @@ void opengl33_renderer::Render(TSubModel *Submodel)
{
Submodel->RaAnimation(Submodel->b_aAnim);
glm::mat4 mv = OpenGLMatrices.data(GL_MODELVIEW);
const glm::mat4 mv = OpenGLMatrices.data(GL_MODELVIEW);
model_ubs.future *= (mv * Submodel->future_transform) * glm::inverse(mv);
}
}
@@ -4133,8 +4133,8 @@ void opengl33_renderer::Render_vr_models()
Global.pCamera.SetMatrix(tmpmat);
tmpmat = glm::dmat3(tmpmat);
glMultMatrixd(glm::value_ptr(glm::inverse(tmpmat)));
std::vector<TModel3d*> list = vr->get_render_models();
material_data data;
const std::vector<TModel3d*> list = vr->get_render_models();
const material_data data;
for (TModel3d *mdl : list)
Render(mdl, &data, 0.0);
::glPopMatrix();
@@ -4516,7 +4516,7 @@ bool opengl33_renderer::Render_Alpha(TDynamicObject *Dynamic)
bool opengl33_renderer::Render_Alpha(TModel3d *Model, material_data const *Material, float const Squaredistance)
{
auto alpha = (Material != nullptr ? Material->textures_alpha : 0x30300030);
const auto alpha = (Material != nullptr ? Material->textures_alpha : 0x30300030);
if (0 == (alpha & Model->iFlags & 0x2F2F002F))
{
@@ -5043,7 +5043,7 @@ void opengl33_renderer::Update(double const Deltatime)
// adjust draw ranges etc, based on recent performance
if (Global.targetfps != 0.0f) {
float fps_diff = Global.targetfps - m_framerate;
const float fps_diff = Global.targetfps - m_framerate;
if (fps_diff > 0.0f)
Global.fDistanceFactor = std::max(0.5f, Global.fDistanceFactor - 0.05f);
else
@@ -5291,9 +5291,9 @@ void opengl33_renderer::Update_Lights(light_array &Lights)
bool opengl33_renderer::Init_caps()
{
std::string gl_renderer((char *)glGetString(GL_RENDERER));
std::string gl_vendor((char *)glGetString(GL_VENDOR));
std::string gl_version((char *)glGetString(GL_VERSION));
const std::string gl_renderer((char *)glGetString(GL_RENDERER));
const std::string gl_vendor((char *)glGetString(GL_VENDOR));
const std::string gl_version((char *)glGetString(GL_VERSION));
crashreport_add_info("gl_renderer", gl_renderer);
crashreport_add_info("gl_vendor", gl_vendor);
@@ -5314,7 +5314,7 @@ bool opengl33_renderer::Init_caps()
WriteLog("Supported extensions:");
for (int i = 0; i < extCount; i++)
{
auto ext = (const char *)glGetStringi(GL_EXTENSIONS, i);
const auto ext = (const char *)glGetStringi(GL_EXTENSIONS, i);
WriteLog(ext);
}
WriteLog("--------");

View File

@@ -249,7 +249,7 @@ opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned i
::glDisableClientState( GL_COLOR_ARRAY );
}
if( Streams & gfx::stream::texture ) {
for( auto unit : Units.texture ) {
for (const auto unit : Units.texture ) {
::glClientActiveTexture( GL_TEXTURE0 + unit );
::glTexCoordPointer( 2, GL_FLOAT, sizeof( gfx::basic_vertex ), reinterpret_cast<void const *>( offsetof(gfx::basic_vertex, texture) + sizeof( gfx::basic_vertex ) * offset ) );
::glEnableClientState( GL_TEXTURE_COORD_ARRAY );
@@ -257,7 +257,7 @@ opengl_vbogeometrybank::bind_streams( gfx::stream_units const &Units, unsigned i
m_activetexturearrays = Units.texture;
}
else {
for( auto unit : Units.texture ) {
for (const auto unit : Units.texture ) {
::glClientActiveTexture( GL_TEXTURE0 + unit );
::glDisableClientState( GL_TEXTURE_COORD_ARRAY );
}
@@ -273,7 +273,7 @@ opengl_vbogeometrybank::release_streams() {
::glDisableClientState( GL_VERTEX_ARRAY );
::glDisableClientState( GL_NORMAL_ARRAY );
::glDisableClientState( GL_COLOR_ARRAY );
for( auto unit : m_activetexturearrays ) {
for (const auto unit : m_activetexturearrays ) {
::glClientActiveTexture( GL_TEXTURE0 + unit );
::glDisableClientState( GL_TEXTURE_COORD_ARRAY );
}
@@ -321,7 +321,7 @@ opengl_dlgeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_
auto const &vertex { chunk.vertices[ index ] };
if( Streams & gfx::stream::normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); }
else if( Streams & gfx::stream::color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); }
if( Streams & gfx::stream::texture ) { for( auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } }
if( Streams & gfx::stream::texture ) { for (const auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } }
if( Streams & gfx::stream::position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); }
}
}
@@ -330,7 +330,7 @@ opengl_dlgeometrybank::draw_( gfx::geometry_handle const &Geometry, gfx::stream_
for( auto const &vertex : chunk.vertices ) {
if( Streams & gfx::stream::normal ) { ::glNormal3fv( glm::value_ptr( vertex.normal ) ); }
else if( Streams & gfx::stream::color ) { ::glColor3fv( glm::value_ptr( vertex.normal ) ); }
if( Streams & gfx::stream::texture ) { for( auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } }
if( Streams & gfx::stream::texture ) { for (const auto unit : Units.texture ) { ::glMultiTexCoord2fv( unit, glm::value_ptr( vertex.texture ) ); } }
if( Streams & gfx::stream::position ) { ::glVertex3fv( glm::value_ptr( vertex.position ) ); }
}
}

View File

@@ -87,7 +87,7 @@ public:
opengl_dlgeometrybank() = default;
// destructor:
~opengl_dlgeometrybank() {
for( auto &chunkrecord : m_chunkrecords ) {
for (const auto &chunkrecord : m_chunkrecords ) {
::glDeleteLists( chunkrecord.list, 1 ); } }
private:

View File

@@ -39,8 +39,8 @@ opengl_precipitation::create( int const Tesselation ) {
std::uint16_t index = 0;
// auto const radius { 25.f }; // cylinder radius
std::vector<float> radii { 25.f, 10.f, 5.f, 1.f };
for( auto radius : radii ) {
const std::vector<float> radii { 25.f, 10.f, 5.f, 1.f };
for (const auto radius : radii ) {
for( int i = 0; i <= latitudes; ++i ) {
@@ -57,7 +57,7 @@ opengl_precipitation::create( int const Tesselation ) {
m_vertices.emplace_back( glm::vec3( -x * zr, -z * heightfactor, -y * zr ) * radius );
// uvs
// NOTE: first and last row receives modified u values to deal with limitation of mapping onto triangles
auto u = (
const auto u = (
i == 0 ? longitude + longitudehalfstep :
i == latitudes ? longitude - longitudehalfstep :
longitude );

View File

@@ -143,7 +143,7 @@ opengl_renderer::Init( GLFWwindow *Window ) {
::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_picktexture, 0 );
::glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_pickdepthbuffer );
// check if we got it working
GLenum status = ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
const GLenum status = ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
if( status == GL_FRAMEBUFFER_COMPLETE_EXT ) {
WriteLog( "Picking framebuffer setup complete" );
}
@@ -288,7 +288,7 @@ opengl_renderer::Init( GLFWwindow *Window ) {
::glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, m_environmentcubetexture, 0 );
::glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_environmentdepthbuffer );
// check if we got it working
GLenum status = ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
const GLenum status = ::glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
if( status == GL_FRAMEBUFFER_COMPLETE_EXT ) {
WriteLog( "Reflections framebuffer setup complete" );
m_environmentcubetexturesupport = true;
@@ -3738,7 +3738,7 @@ opengl_renderer::Render_Alpha( TDynamicObject *Dynamic ) {
bool
opengl_renderer::Render_Alpha( TModel3d *Model, material_data const *Material, float const Squaredistance ) {
auto alpha =
const auto alpha =
( Material != nullptr ?
Material->textures_alpha :
0x30300030 );
@@ -4393,9 +4393,9 @@ opengl_renderer::Disable_Lights() {
bool
opengl_renderer::Init_caps() {
std::string gl_renderer((char *)glGetString(GL_RENDERER));
std::string gl_vendor((char *)glGetString(GL_VENDOR));
std::string gl_version((char *)glGetString(GL_VERSION));
const std::string gl_renderer((char *)glGetString(GL_RENDERER));
const std::string gl_vendor((char *)glGetString(GL_VENDOR));
const std::string gl_version((char *)glGetString(GL_VERSION));
crashreport_add_info("gl_renderer", gl_renderer);
crashreport_add_info("gl_vendor", gl_vendor);
@@ -4414,7 +4414,7 @@ opengl_renderer::Init_caps() {
m_isATI = (gl_vendor.find("ATI") != -1);
auto extensions = (char*)glGetString( GL_EXTENSIONS );
const auto extensions = (char*)glGetString( GL_EXTENSIONS );
if (extensions)
WriteLog( "Supported extensions: \n" + std::string(extensions));

View File

@@ -57,7 +57,7 @@ void opengl_skydome::update() {
if( true == skydome.is_dirty() ) {
if( ( m_coloursbuffer > 0 ) && ( m_coloursbuffer != (GLuint)-1 ) ) {
::glBindBuffer( GL_ARRAY_BUFFER, m_coloursbuffer );
auto &colors{ skydome.colors() };
const auto &colors{ skydome.colors() };
/*
float twilightfactor = std::clamp( -simulation::Environment.sun().getAngle(), 0.0f, 18.0f ) / 18.0f;
auto gamma = std::lerp( glm::vec3( 0.45f ), glm::vec3( 1.0f ), twilightfactor );

View File

@@ -21,7 +21,7 @@ bool gfx_renderer_factory::register_backend(const std::string &backend, gfx_rend
std::unique_ptr<gfx_renderer> gfx_renderer_factory::create(const std::string &backend)
{
auto it = backends.find(backend);
const auto it = backends.find(backend);
if (it != backends.end())
return it->second();

View File

@@ -44,7 +44,7 @@ void screenshot_manager::screenshot_save_thread( char *img, int w, int h )
perf = ts.tv_nsec;
#endif
std::string filename = Global.screenshot_dir + "/" + std::string(datetime) +
const std::string filename = Global.screenshot_dir + "/" + std::string(datetime) +
"_" + std::to_string(perf) + ".png";
if (png_image_write_to_file(&png, filename.c_str(), 0, img, stride, nullptr) == 1)