Reorganize CGLTFMeshFileLoader help functions
I moved them all into static methods and changed the ordering in the source file so that createMesh() would be close to the top of the file. I also corrected formatting in some of the function declarations since I had to change them anyway.
This commit is contained in:
committed by
Josiah VanderZee
parent
2175cf6e1c
commit
7e0d57b4fe
@@ -1,4 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
#ifndef __C_GLTF_MESH_FILE_LOADER_INCLUDED__
|
||||
#define __C_GLTF_MESH_FILE_LOADER_INCLUDED__
|
||||
|
||||
@@ -6,6 +5,14 @@
|
||||
#include "IMeshLoader.h"
|
||||
#include "IReadFile.h"
|
||||
#include "path.h"
|
||||
#include "S3DVertex.h"
|
||||
#include "vector2d.h"
|
||||
#include "vector3d.h"
|
||||
|
||||
#include <tiny_gltf.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@@ -16,14 +23,72 @@ namespace scene
|
||||
class CGLTFMeshFileLoader : public IMeshLoader
|
||||
{
|
||||
public:
|
||||
CGLTFMeshFileLoader();
|
||||
CGLTFMeshFileLoader() noexcept;
|
||||
|
||||
bool isALoadableFileExtension(const io::path& filename) const override;
|
||||
|
||||
IAnimatedMesh* createMesh(io::IReadFile* file) override;
|
||||
|
||||
private:
|
||||
bool tryParseGLTF(io::IReadFile* file) const;
|
||||
template <typename T>
|
||||
struct Span
|
||||
{
|
||||
T* buffer = nullptr;
|
||||
std::size_t size = 0;
|
||||
};
|
||||
|
||||
class BufferOffset
|
||||
{
|
||||
public:
|
||||
BufferOffset(const std::vector<unsigned char>& buf,
|
||||
const std::size_t offset);
|
||||
|
||||
BufferOffset(const BufferOffset& other,
|
||||
const std::size_t fromOffset);
|
||||
|
||||
unsigned char at(const std::size_t fromOffset) const;
|
||||
private:
|
||||
const std::vector<unsigned char>& m_buf;
|
||||
std::size_t m_offset;
|
||||
int m_filesize;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static T readPrimitive(const BufferOffset& readFrom);
|
||||
|
||||
static core::vector2df readVec2DF(
|
||||
const BufferOffset& readFrom);
|
||||
|
||||
static core::vector3df readVec3DF(
|
||||
const BufferOffset& readFrom,
|
||||
const float scale);
|
||||
|
||||
static void copyPositions(const tinygltf::Model& model,
|
||||
const Span<video::S3DVertex> vertices,
|
||||
const std::size_t accessorId);
|
||||
|
||||
static void copyNormals(const tinygltf::Model& model,
|
||||
const Span<video::S3DVertex> vertices,
|
||||
const std::size_t accessorId);
|
||||
|
||||
static void copyTCoords(const tinygltf::Model& model,
|
||||
const Span<video::S3DVertex> vertices,
|
||||
const std::size_t accessorId);
|
||||
|
||||
static void getIndices(const tinygltf::Model& model,
|
||||
const std::size_t accessorId,
|
||||
std::vector<u16>& indicesBuffer);
|
||||
|
||||
static void getVertices(const tinygltf::Model& model,
|
||||
const std::size_t accessorId,
|
||||
Span<video::S3DVertex>& outVertices,
|
||||
std::size_t meshIndex,
|
||||
std::size_t primitiveIndex);
|
||||
|
||||
static bool tryParseGLTF(io::IReadFile* file,
|
||||
tinygltf::Model& model);
|
||||
|
||||
static float getScale(const tinygltf::Model& model);
|
||||
};
|
||||
|
||||
} // namespace scene
|
||||
@@ -31,3 +96,4 @@ private:
|
||||
} // namespace irr
|
||||
|
||||
#endif // __C_GLTF_MESH_FILE_LOADER_INCLUDED__
|
||||
|
||||
|
Reference in New Issue
Block a user