Working commit, do byte based copy

This commit is contained in:
Xiao Qi 2023-02-25 23:32:51 +08:00
parent bc8347a161
commit 1e17e17594
4 changed files with 43 additions and 4 deletions

View File

@ -30,6 +30,24 @@ enum class ACCESSOR_DATA_TYPE : int
FLOAT = 5126 FLOAT = 5126
}; };
constexpr size_t SizeOfType(ACCESSOR_DATA_TYPE type)
{
switch(type)
{
case ACCESSOR_DATA_TYPE::BYTE:
case ACCESSOR_DATA_TYPE::U_BYTE:
return sizeof(char);
case ACCESSOR_DATA_TYPE::SHORT:
case ACCESSOR_DATA_TYPE::U_SHORT:
return sizeof(short);
case ACCESSOR_DATA_TYPE::U_INT:
case ACCESSOR_DATA_TYPE::FLOAT:
return sizeof(float);
default:
return 0;
}
}
enum class ACCESSOR_COMPONENT_TYPE : int enum class ACCESSOR_COMPONENT_TYPE : int
{ {
SCALAR = 64 + 1, SCALAR = 64 + 1,

View File

@ -44,7 +44,7 @@ namespace SH_COMP
static BufferViewReference bufferViews; static BufferViewReference bufferViews;
static BufferData buffer; static BufferData buffer;
static void LoadFromFile(AssetPath path, ModelRef asset) noexcept; static inline void LoadFromFile(AssetPath path, ModelRef asset) noexcept;
static inline void ProcessModel(ModelData const&, ModelRef asset) noexcept; static inline void ProcessModel(ModelData const&, ModelRef asset) noexcept;
static inline void BuildHeaders(ModelRef asset) noexcept; static inline void BuildHeaders(ModelRef asset) noexcept;
@ -54,3 +54,5 @@ namespace SH_COMP
static void LoadAndCompile(AssetPath path) noexcept; static void LoadAndCompile(AssetPath path) noexcept;
}; };
} }
#include "MeshCompiler.hpp"

View File

@ -118,13 +118,30 @@ namespace SH_COMP
{ {
auto const& accessor = (*accessors)[accessorID]; auto const& accessor = (*accessors)[accessorID];
auto const& view = (*bufferViews)[accessor.bufferView]; auto const& view = (*bufferViews)[accessor.bufferView];
dst.resize(3484); auto const typeIdentifier{ static_cast<ACCESSOR_DATA_TYPE>(accessor.componentType) };
std::cout << "buffer line\n"; auto const sizeIdentifier{ SizeOfType(typeIdentifier) };
if (sizeof(T) == sizeIdentifier)
{
dst.resize(accessor.count);
std::memcpy( std::memcpy(
dst.data(), dst.data(),
buffer + view.byteOffset, buffer + view.byteOffset,
view.byteLength view.byteLength
); );
return;
}
std::vector<std::byte> tempData(view.byteLength);
std::memcpy(
tempData.data(),
buffer + view.byteOffset,
view.byteLength
);
for (auto i{0}; i < accessor.count; i += sizeIdentifier)
{
}
} }
inline void MeshCompiler::BuildHeaders(ModelRef asset) noexcept inline void MeshCompiler::BuildHeaders(ModelRef asset) noexcept

View File

@ -57,6 +57,8 @@ int main(int argc, char* argv[])
} }
#else #else
(void)argc;
(void)argv;
SH_COMP::MeshCompiler::LoadAndCompile("racoon_tiny.gltf"); SH_COMP::MeshCompiler::LoadAndCompile("racoon_tiny.gltf");
#endif #endif