17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 03:59:19 +02:00

refactor: sonar c++20 changes (#185)

This commit is contained in:
jerrrrycho
2026-09-28 21:08:15 +02:00
committed by GitHub
parent 4137f5504a
commit 176427f96b
18 changed files with 111 additions and 106 deletions

View File

@@ -24,6 +24,8 @@ Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
#include "world/mtable.h"
#include "scene/sn_utils.h"
#include <bit>
//---------------------------------------------------------------------------
using namespace Mtable;
@@ -224,16 +226,13 @@ inline void readMatrix(cParser &parser, float4x4 &matrix)
template <typename T> void UserdataParse(cParser &parser, gfx::vertex_userdata &vertex)
{
static_assert(sizeof(T) == sizeof(float), "userdata is stored as raw 32-bit values");
parser.getTokens(4);
union
{
T InType;
float FloatType;
} buf{};
for (int i = 0; i < 4; ++i)
{
parser >> buf.InType;
vertex.data[i] = buf.FloatType;
T value{};
parser >> value;
vertex.data[i] = std::bit_cast<float>(value);
}
}

View File

@@ -394,12 +394,12 @@ opengl_texture::make_from_memory(size_t width, size_t height, const uint8_t *raw
void opengl_texture::update_from_memory(size_t width, size_t height, const uint8_t *raw)
{
if (id != -1 && (width != data_width || height != data_height || GL_SRGB8_ALPHA8 != data_format || GL_RGBA != data_components))
if (id != (GLuint)-1 && (width != data_width || height != data_height || GL_SRGB8_ALPHA8 != data_format || GL_RGBA != data_components))
{
glDeleteTextures(1, &id);
id = -1;
id = (GLuint)-1;
}
if (id == -1)
if (id == (GLuint)-1)
{
data_width = width;
data_height = height;