1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-09-30 19:22:14 +00:00
This commit is contained in:
sfan5 2025-09-16 20:24:45 +02:00
parent 6def80c5a1
commit 45e723d298
2 changed files with 12 additions and 12 deletions

View file

@ -635,7 +635,9 @@ void Camera::drawNametags()
// the user's font size preference... // the user's font size preference...
const u32 default_font_size = 16; const u32 default_font_size = 16;
// ...by multiplying this in. // ...by multiplying this in.
const float font_size_mult = g_fontengine->getFontSize(FM_Unspecified) / (float)default_font_size; const f32 font_size_mult = g_fontengine->getFontSize(FM_Unspecified) / (float)default_font_size;
// Minimum distance until z-scaled nametags actually become smaller
const f32 minimum_d = 1.0f * BS;
video::IVideoDriver *driver = RenderingEngine::get_video_driver(); video::IVideoDriver *driver = RenderingEngine::get_video_driver();
v2u32 screensize = driver->getScreenSize(); v2u32 screensize = driver->getScreenSize();
@ -654,8 +656,10 @@ void Camera::drawNametags()
// Higher default since nametag should be reasonably visible // Higher default since nametag should be reasonably visible
// even at distance. // even at distance.
u32 base_size = nametag->textsize.value_or(default_font_size * 4); u32 base_size = nametag->textsize.value_or(default_font_size * 4);
f32 adjusted_d = std::max(transformed_pos[3] - minimum_d, 0.0f);
f32 adjusted_zDiv = adjusted_d == 0.0f ? 1.0f : (1.0f / adjusted_d);
font_size = myround(font_size_mult * font_size = myround(font_size_mult *
rangelim(base_size * BS * zDiv, 0, base_size)); rangelim(base_size * BS * adjusted_zDiv, 0, base_size));
} else { } else {
font_size = myround(font_size_mult * nametag->textsize.value_or(default_font_size)); font_size = myround(font_size_mult * nametag->textsize.value_or(default_font_size));
} }

View file

@ -582,20 +582,16 @@ void push_object_properties(lua_State *L, const ObjectProperties *prop)
lua_setfield(L, -2, "nametag"); lua_setfield(L, -2, "nametag");
push_ARGB8(L, prop->nametag_color); push_ARGB8(L, prop->nametag_color);
lua_setfield(L, -2, "nametag_color"); lua_setfield(L, -2, "nametag_color");
if (prop->nametag_bgcolor) { if (prop->nametag_bgcolor)
push_ARGB8(L, prop->nametag_bgcolor.value()); push_ARGB8(L, prop->nametag_bgcolor.value());
lua_setfield(L, -2, "nametag_bgcolor"); else
} else {
lua_pushboolean(L, false); lua_pushboolean(L, false);
lua_setfield(L, -2, "nametag_bgcolor"); lua_setfield(L, -2, "nametag_bgcolor");
} if (prop->nametag_fontsize)
if (prop->nametag_fontsize) {
lua_pushinteger(L, prop->nametag_fontsize.value()); lua_pushinteger(L, prop->nametag_fontsize.value());
lua_setfield(L, -2, "nametag_fontsize"); else
} else {
lua_pushboolean(L, false); lua_pushboolean(L, false);
lua_setfield(L, -2, "nametag_fontsize"); lua_setfield(L, -2, "nametag_fontsize");
}
lua_pushboolean(L, prop->nametag_scale_z); lua_pushboolean(L, prop->nametag_scale_z);
lua_setfield(L, -2, "nametag_scale_z"); lua_setfield(L, -2, "nametag_scale_z");
lua_pushlstring(L, prop->infotext.c_str(), prop->infotext.size()); lua_pushlstring(L, prop->infotext.c_str(), prop->infotext.size());