1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fix some (MSVC) compiler warnings

This commit is contained in:
Lars Mueller 2025-04-04 17:09:12 +02:00 committed by Lars Müller
parent 695d526764
commit e1143783e5
8 changed files with 13 additions and 15 deletions

View file

@ -25,7 +25,7 @@ constexpr f64 ROUNDING_ERROR_f64 = 0.00000001;
#undef PI
#endif
//! Constant for PI.
constexpr f32 PI = M_PI;
constexpr f32 PI = static_cast<f32>(M_PI);
#ifdef PI64 // make sure we don't collide with a define
#undef PI64

View file

@ -549,12 +549,10 @@ void SelfType::MeshExtractor::deferAddMesh(
static core::matrix4 loadTransform(const tiniergltf::Node::Matrix &m, SkinnedMesh::SJoint *joint)
{
// Note: Under the hood, this casts these doubles to floats.
core::matrix4 mat = convertHandedness(core::matrix4(
m[0], m[1], m[2], m[3],
m[4], m[5], m[6], m[7],
m[8], m[9], m[10], m[11],
m[12], m[13], m[14], m[15]));
core::matrix4 mat;
for (size_t i = 0; i < m.size(); ++i)
mat[i] = static_cast<f32>(m[i]);
mat = convertHandedness(mat);
// Decompose the matrix into translation, scale, and rotation.
joint->Animatedposition = mat.getTranslation();

View file

@ -166,7 +166,7 @@ public:
inline void irrGlObjectLabel(GLenum identifier, GLuint name, const char *label)
{
if (KHRDebugSupported) {
u32 len = strlen(label);
u32 len = static_cast<u32>(strlen(label));
// Since our texture strings can get quite long we also truncate
// to a hardcoded limit of 82
len = std::min(len, std::min(MaxLabelLength, 82U));

View file

@ -704,8 +704,8 @@ void Minimap::updateActiveMarkers()
continue;
}
m_active_markers.emplace_back(((float)pos.X / (float)MINIMAP_MAX_SX) - 0.5,
(1.0 - (float)pos.Z / (float)MINIMAP_MAX_SY) - 0.5);
m_active_markers.emplace_back(((float)pos.X / (float)MINIMAP_MAX_SX) - 0.5f,
(1.0f - (float)pos.Z / (float)MINIMAP_MAX_SY) - 0.5f);
}
}

View file

@ -36,7 +36,7 @@ ShadowRenderer::ShadowRenderer(IrrlichtDevice *device, Client *client) :
m_shadow_map_max_distance = g_settings->getFloat("shadow_map_max_distance");
m_shadow_map_texture_size = g_settings->getFloat("shadow_map_texture_size");
m_shadow_map_texture_size = g_settings->getU32("shadow_map_texture_size");
m_shadow_map_texture_32bit = g_settings->getBool("shadow_map_texture_32bit");
m_shadow_map_colored = g_settings->getBool("shadow_map_color");
@ -273,7 +273,7 @@ void ShadowRenderer::updateSMTextures()
// Static shader values.
for (auto cb : {m_shadow_depth_cb, m_shadow_depth_entity_cb, m_shadow_depth_trans_cb}) {
if (cb) {
cb->MapRes = (f32)m_shadow_map_texture_size;
cb->MapRes = (u32)m_shadow_map_texture_size;
cb->MaxFar = (f32)m_shadow_map_max_distance * BS;
cb->PerspectiveBiasXY = getPerspectiveBiasXY();
cb->PerspectiveBiasZ = getPerspectiveBiasZ();

View file

@ -124,7 +124,7 @@ private:
video::SColor m_shadow_tint;
float m_shadow_strength_gamma;
float m_shadow_map_max_distance;
float m_shadow_map_texture_size;
u32 m_shadow_map_texture_size;
float m_time_day;
int m_shadow_samples;
bool m_shadow_map_texture_32bit;

View file

@ -104,7 +104,7 @@ void read_item_definition(lua_State* L, int index,
} else if (lua_isstring(L, -1)) {
video::SColor color;
read_color(L, -1, &color);
def.wear_bar_params = WearBarParams({{0.0, color}},
def.wear_bar_params = WearBarParams({{0.0f, color}},
WearBarParams::BLEND_MODE_CONSTANT);
}

View file

@ -320,7 +320,7 @@ void TestUtilities::testUTF8()
// try to check that the conversion function does not accidentally keep
// its internal state across invocations.
// \xC4\x81 is UTF-8 for \u0101
utf8_to_wide("\xC4");
static_cast<void>(utf8_to_wide("\xC4"));
UASSERT(utf8_to_wide("\x81") != L"\u0101");
}