Merge branch 'master' into feat/gltf-loader

This commit is contained in:
JosiahWI
2023-05-15 09:59:59 -05:00
185 changed files with 6431 additions and 9257 deletions

View File

@ -1,9 +1,67 @@
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include <irrlicht.h>
#include <iostream>
using namespace std;
#include <sys/stat.h>
#include <cstddef>
#include <fstream>
#include <iostream>
#include <string>
class TestReadFile final : public irr::io::IReadFile
{
public:
TestReadFile(const irr::io::path& filepath)
: m_file { filepath.c_str() }
, m_filename { filepath }
, m_filesize {}
{
struct stat stat_buf {};
int rc = stat(filepath.c_str(), &stat_buf);
if (rc == 0) {
m_filesize = stat_buf.st_size;
} else {
m_filesize = -1;
}
}
std::size_t read(void* buffer, std::size_t bytes) override
{
m_file.read(static_cast<char*>(buffer), bytes);
return m_file.gcount();
}
bool seek(long finalPos, bool relativeMovement = false)
{
if (!relativeMovement) {
m_file.seekg(finalPos);
} else {
m_file.seekg(finalPos, std::ifstream::cur);
}
return m_file.fail();
}
long getSize() const
{
return m_filesize;
}
long getPos() const
{
return m_file.tellg();
}
const irr::io::path& getFileName() const
{
return m_filename;
}
private:
mutable std::ifstream m_file;
irr::io::path m_filename;
long m_filesize;
};
class ScopedMesh
{
@ -21,7 +79,8 @@ public:
, m_mesh { nullptr }
{
auto* smgr = m_device->getSceneManager();
m_mesh = smgr->getMesh(filepath, "");
TestReadFile file {filepath};
m_mesh = smgr->getMesh(&file);
}
~ScopedMesh()
@ -36,6 +95,7 @@ public:
}
private:
irr::IrrlichtDevice* m_device;
irr::scene::IAnimatedMesh* m_mesh;
};
@ -270,4 +330,4 @@ TEST_CASE("snow man") {
CHECK(vertices[20].TCoords == irr::core::vector2df{0.208333, 0.416667});
CHECK(vertices[22].TCoords == irr::core::vector2df{0.375, 0.416667});
}
}
}