remove pool alloc, fix bad optional access, renaming

This commit is contained in:
Skarn
2021-12-14 01:16:41 +03:00
parent f3659a6ce8
commit 15011583fc
8 changed files with 24 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
// This file is part of Noggit3, licensed under GNU General Public License (version 3).
#include <noggit/alphamap.hpp>
#include <noggit/Alphamap.hpp>
#include <opengl/context.hpp>
#include <opengl/context.inl>
#include <ClientFile.hpp>

View File

@@ -19,9 +19,12 @@ public:
void setAlpha(size_t offset, unsigned char value);
void setAlpha(unsigned char *pAmap);
[[nodiscard]]
unsigned char getAlpha(size_t offset) const;
const unsigned char *getAlpha();
[[nodiscard]]
std::vector<uint8_t> compress() const;
private:

View File

@@ -21,7 +21,7 @@ struct pair_hash
std::size_t operator() (const std::pair<int, BlizzardArchive::Listfile::FileKey> &p) const noexcept
{
auto h1 = std::hash<int>{}(p.first);
auto h2 = std::hash<std::string>{}(p.second.filepath());
auto h2 = std::hash<std::string>{}(p.second.hasFilepath() ? p.second.filepath() : "");
auto h3 = std::hash<int>{}(p.second.fileDataID());
return h1 ^ h2 ^ h3;

View File

@@ -5,9 +5,6 @@
#include <opengl/context.inl>
#include <noggit/DBC.h>
#include <noggit/application/NoggitApplication.hpp>
#include <boost/format.hpp>
#include <glm/vec2.hpp>
LiquidTextureManager::LiquidTextureManager(Noggit::NoggitRenderContext context)
: _context(context)
@@ -46,7 +43,7 @@ void LiquidTextureManager::upload()
}
catch (...) // fallback for malformed DBC
{
filename = "XTextures\\river\\lake_a.%d.blp";
filename = "XTextures\\river\\lake_a.";
}
}
@@ -57,7 +54,7 @@ void LiquidTextureManager::upload()
// init 2D texture array
// loading a texture is required to get its dimensions and format
blp_texture tex(boost::str(boost::format(filename) % 1), _context);
blp_texture tex(filename + "1.blp", _context);
tex.finishLoading();
int width_ = tex.width();
@@ -94,13 +91,13 @@ void LiquidTextureManager::upload()
unsigned n_frames = 30;
for (int j = 0; j < N_FRAMES; ++j)
{
if (!NOGGIT_APP->clientData()->exists(boost::str(boost::format(filename) % (j + 1))))
if (!NOGGIT_APP->clientData()->exists(filename + std::to_string((j + 1)) + ".blp"))
{
n_frames = j;
break;
}
blp_texture tex_frame(boost::str(boost::format(filename) % (j + 1)), _context);
blp_texture tex_frame(filename + std::to_string(j + 1) + ".blp", _context);
tex_frame.finishLoading();
// error checking

View File

@@ -7,7 +7,7 @@
#include <noggit/MapHeaders.h>
#include <noggit/Misc.h>
#include <noggit/World.h>
#include <noggit/alphamap.hpp>
#include <noggit/Alphamap.hpp>
#include <noggit/texture_set.hpp>
#include <noggit/tool_enums.hpp>
#include <noggit/ui/TexturingGUI.h>

View File

@@ -9,7 +9,7 @@
#include <noggit/TileWater.hpp>
#include <noggit/WMOInstance.h> // WMOInstance
#include <noggit/World.h>
#include <noggit/alphamap.hpp>
#include <noggit/Alphamap.hpp>
#include <noggit/texture_set.hpp>
#include <noggit/ui/TexturingGUI.h>
#include <noggit/application/NoggitApplication.hpp>

View File

@@ -29,9 +29,6 @@
#include <external/PNG2BLP/Png2Blp.h>
#include <external/tracy/Tracy.hpp>
#include <boost/format.hpp>
#include <boost/pool/pool_alloc.hpp>
#include <QtWidgets/QMessageBox>
#include <QDir>
#include <QBuffer>
@@ -58,8 +55,6 @@
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#define BOOST_POOL_NO_MT
bool World::IsEditableWorld(int pMapId)
{
ZoneScoped;
@@ -1381,8 +1376,8 @@ void World::draw (glm::mat4x4 const& model_view
std::unordered_map<Model*, std::size_t> model_with_particles;
tsl::robin_map<Model*, std::vector<glm::mat4x4, boost::pool_allocator<glm::mat4x4>>> models_to_draw;
std::vector<WMOInstance*, boost::pool_allocator<WMOInstance*>> wmos_to_draw;
tsl::robin_map<Model*, std::vector<glm::mat4x4>> models_to_draw;
std::vector<WMOInstance*> wmos_to_draw;
static int frame = 0;
@@ -1689,11 +1684,6 @@ void World::draw (glm::mat4x4 const& model_view
models_to_draw.clear();
wmos_to_draw.clear();
boost::singleton_pool<boost::pool_allocator_tag
, sizeof(std::vector<glm::mat4x4, boost::pool_allocator<glm::mat4x4>>)>::purge_memory();
boost::singleton_pool<boost::pool_allocator_tag
, sizeof(std::vector<WMOInstance*, boost::pool_allocator<WMOInstance*>>)>::purge_memory();
if(draw_models_with_box || (draw_hidden_models && !model_boxes_to_draw.empty()))
{
@@ -2599,8 +2589,16 @@ bool World::saveMinimap(tile_index const& tile_idx, MinimapRenderSettings* setti
// Register in md5translate.trs
std::string map_name = gMapDB.getByID(mapIndex._map_id).getString(MapDB::InternalName);
std::string tilename_left = (boost::format("%s\\map%02d_%02d.blp") % map_name % tile_idx.x % tile_idx.z).str();
mapIndex._minimap_md5translate[map_name][tilename_left] = tex_name;
std::stringstream ss;
ss << map_name;
ss << "\\map";
ss << std::setw(2) << std::setfill('0') << tile_idx.x;
ss << "_";
ss << std::setw(2) << std::setfill('0') << tile_idx.z;
ss << ".blp";
mapIndex._minimap_md5translate[map_name][ss.str()] = tex_name;
if (unload)
{
@@ -4608,4 +4606,3 @@ void World::setupOccluderBuffers()
}
#undef BOOST_POOL_NO_MT

View File

@@ -2,7 +2,7 @@
#pragma once
#include <noggit/alphamap.hpp>
#include <noggit/Alphamap.hpp>
#include <noggit/MapHeaders.h>
#include <noggit/ContextObject.hpp>