mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Modernize source code: last part (#6285)
* Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes
This commit is contained in:
parent
50669cd282
commit
1c1c97cbd1
72 changed files with 446 additions and 584 deletions
|
@ -146,10 +146,8 @@ public:
|
|||
// Destructor
|
||||
virtual ~ExtrusionMeshCache()
|
||||
{
|
||||
for (std::map<int, scene::IMesh*>::iterator
|
||||
it = m_extrusion_meshes.begin();
|
||||
it != m_extrusion_meshes.end(); ++it) {
|
||||
it->second->drop();
|
||||
for (auto &extrusion_meshe : m_extrusion_meshes) {
|
||||
extrusion_meshe.second->drop();
|
||||
}
|
||||
m_cube->drop();
|
||||
}
|
||||
|
@ -309,14 +307,15 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
|
|||
m_base_color = idef->getItemstackColor(item, client);
|
||||
|
||||
// If wield_image is defined, it overrides everything else
|
||||
if (def.wield_image != "") {
|
||||
if (!def.wield_image.empty()) {
|
||||
setExtruded(def.wield_image, def.wield_scale, tsrc, 1);
|
||||
m_colors.push_back(ItemPartColor());
|
||||
m_colors.emplace_back();
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle nodes
|
||||
// See also CItemDefManager::createClientCached()
|
||||
else if (def.type == ITEM_NODE) {
|
||||
if (def.type == ITEM_NODE) {
|
||||
if (f.mesh_ptr[0]) {
|
||||
// e.g. mesh nodes and nodeboxes
|
||||
scene::SMesh *mesh = cloneMesh(f.mesh_ptr[0]);
|
||||
|
@ -377,9 +376,9 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client)
|
|||
}
|
||||
return;
|
||||
}
|
||||
else if (def.inventory_image != "") {
|
||||
else if (!def.inventory_image.empty()) {
|
||||
setExtruded(def.inventory_image, def.wield_scale, tsrc, 1);
|
||||
m_colors.push_back(ItemPartColor());
|
||||
m_colors.emplace_back();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -455,9 +454,9 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
|
|||
result->needs_shading = true;
|
||||
|
||||
// If inventory_image is defined, it overrides everything else
|
||||
if (def.inventory_image != "") {
|
||||
if (!def.inventory_image.empty()) {
|
||||
mesh = getExtrudedMesh(tsrc, def.inventory_image);
|
||||
result->buffer_colors.push_back(ItemPartColor());
|
||||
result->buffer_colors.emplace_back();
|
||||
// Items with inventory images do not need shading
|
||||
result->needs_shading = false;
|
||||
} else if (def.type == ITEM_NODE) {
|
||||
|
@ -560,7 +559,7 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc, const std::string &imagename
|
|||
}
|
||||
|
||||
void postProcessNodeMesh(scene::SMesh *mesh, const ContentFeatures &f,
|
||||
bool use_shaders, bool set_material, video::E_MATERIAL_TYPE *mattype,
|
||||
bool use_shaders, bool set_material, const video::E_MATERIAL_TYPE *mattype,
|
||||
std::vector<ItemPartColor> *colors)
|
||||
{
|
||||
u32 mc = mesh->getMeshBufferCount();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue