Fix virtual texture loading and VT code tiny cleanup
parent
31cc7363da
commit
35106691a1
|
@ -55,14 +55,14 @@ static inline unsigned int lodOffset(unsigned int lod)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
VirtualTexture::VirtualTexture(fs::path _tilePath,
|
VirtualTexture::VirtualTexture(const fs::path& _tilePath,
|
||||||
unsigned int _baseSplit,
|
unsigned int _baseSplit,
|
||||||
unsigned int _tileSize,
|
unsigned int _tileSize,
|
||||||
string _tilePrefix,
|
const string& _tilePrefix,
|
||||||
const string& _tileType) :
|
const string& _tileType) :
|
||||||
Texture(_tileSize << (_baseSplit + 1), _tileSize << _baseSplit),
|
Texture(_tileSize << (_baseSplit + 1), _tileSize << _baseSplit),
|
||||||
tilePath(std::move(_tilePath)),
|
tilePath(_tilePath),
|
||||||
tilePrefix(std::move(_tilePrefix)),
|
tilePrefix(_tilePrefix),
|
||||||
baseSplit(_baseSplit),
|
baseSplit(_baseSplit),
|
||||||
tileSize(_tileSize),
|
tileSize(_tileSize),
|
||||||
ticks(0),
|
ticks(0),
|
||||||
|
@ -71,7 +71,7 @@ VirtualTexture::VirtualTexture(fs::path _tilePath,
|
||||||
assert(tileSize != 0 && isPow2(tileSize));
|
assert(tileSize != 0 && isPow2(tileSize));
|
||||||
tileTree[0] = new TileQuadtreeNode();
|
tileTree[0] = new TileQuadtreeNode();
|
||||||
tileTree[1] = new TileQuadtreeNode();
|
tileTree[1] = new TileQuadtreeNode();
|
||||||
tileExt = string(".") + _tileType;
|
tileExt = fmt::sprintf(".%s", _tileType);
|
||||||
populateTileTree();
|
populateTileTree();
|
||||||
|
|
||||||
if (DetermineFileType(tileExt) == Content_DXT5NormalMap)
|
if (DetermineFileType(tileExt) == Content_DXT5NormalMap)
|
||||||
|
@ -204,8 +204,9 @@ ImageTexture* VirtualTexture::loadTileTexture(unsigned int lod, unsigned int u,
|
||||||
lod >>= baseSplit;
|
lod >>= baseSplit;
|
||||||
assert(lod < (unsigned)MaxResolutionLevels);
|
assert(lod < (unsigned)MaxResolutionLevels);
|
||||||
|
|
||||||
auto path = fs::path(fmt::sprintf("%slevel%d", tilePath, lod)) /
|
auto path = tilePath /
|
||||||
fmt::sprintf("%s%d_%d%s", tilePrefix, u, v, tileExt);
|
fmt::sprintf("level%d", lod) /
|
||||||
|
fmt::sprintf("%s%d_%d%s", tilePrefix, u, v, tileExt.string());
|
||||||
|
|
||||||
Image* img = LoadImageFromFile(path);
|
Image* img = LoadImageFromFile(path);
|
||||||
if (img == nullptr)
|
if (img == nullptr)
|
||||||
|
@ -258,7 +259,7 @@ void VirtualTexture::populateTileTree()
|
||||||
|
|
||||||
for (int i = 0; i < MaxResolutionLevels; i++)
|
for (int i = 0; i < MaxResolutionLevels; i++)
|
||||||
{
|
{
|
||||||
fs::path path(fmt::sprintf("%slevel%d", tilePath, i));
|
fs::path path = tilePath / fmt::sprintf("level%d", i);
|
||||||
if (fs::is_directory(path))
|
if (fs::is_directory(path))
|
||||||
{
|
{
|
||||||
maxLevel = i + baseSplit;
|
maxLevel = i + baseSplit;
|
||||||
|
@ -268,7 +269,7 @@ void VirtualTexture::populateTileTree()
|
||||||
for (auto& d : fs::directory_iterator(path))
|
for (auto& d : fs::directory_iterator(path))
|
||||||
{
|
{
|
||||||
int u = -1, v = -1;
|
int u = -1, v = -1;
|
||||||
if (sscanf(d.path().string().c_str(), pattern.c_str(), &u, &v) == 2)
|
if (sscanf(d.path().filename().string().c_str(), pattern.c_str(), &u, &v) == 2)
|
||||||
{
|
{
|
||||||
if (u >= 0 && v >= 0 && u < uLimit && v < vLimit)
|
if (u >= 0 && v >= 0 && u < uLimit && v < vLimit)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
class VirtualTexture : public Texture
|
class VirtualTexture : public Texture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
VirtualTexture(fs::path _tilePath,
|
VirtualTexture(const fs::path& _tilePath,
|
||||||
unsigned int _baseSplit,
|
unsigned int _baseSplit,
|
||||||
unsigned int _tileSize,
|
unsigned int _tileSize,
|
||||||
std::string _tilePrefix,
|
const std::string& _tilePrefix,
|
||||||
const std::string& _tileType);
|
const std::string& _tileType);
|
||||||
~VirtualTexture() = default;
|
~VirtualTexture() = default;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue