Skip to content
Snippets Groups Projects
Commit 52005c96 authored by Trevor Hollmann's avatar Trevor Hollmann
Browse files

[#79] Fix error handling in accessor type component counter.

parent ed16003f
No related branches found
No related tags found
1 merge request!69Resolve "Rework Asset Loader API"
......@@ -14,17 +14,13 @@
namespace vkcv::asset {
/**
* convert the accessor type from the fx-gltf library to an unsigned int
* @param type
* @return unsigned integer representation
*/
// TODO Return proper error code (we need to define those as macros or enums,
// will discuss during the next core meeting if that should happen on the scope
// of the vkcv framework or just this module)
uint8_t convertTypeToInt(const fx::gltf::Accessor::Type type) {
* Computes the component count for an accessor type of the fx-gltf library.
* @param type The accessor type
* @return An unsigned integer count
*/
// TODO add cases for matrices (or maybe change the type in the struct itself)
uint8_t getCompCount(const fx::gltf::Accessor::Type type) {
switch (type) {
case fx::gltf::Accessor::Type::None :
return 0;
case fx::gltf::Accessor::Type::Scalar :
return 1;
case fx::gltf::Accessor::Type::Vec2 :
......@@ -33,7 +29,8 @@ uint8_t convertTypeToInt(const fx::gltf::Accessor::Type type) {
return 3;
case fx::gltf::Accessor::Type::Vec4 :
return 4;
default: return 10; // TODO add cases for matrices (or maybe change the type in the struct itself)
case fx::gltf::Accessor::Type::None :
default: return ASSET_ERROR;
}
}
......@@ -250,11 +247,8 @@ int loadScene(const std::string &path, Scene &scene){
attribute.stride = sceneObjects.bufferViews[accessor.bufferView].byteStride;
attribute.componentType = static_cast<ComponentType>(accessor.componentType);
if (convertTypeToInt(accessor.type) != 10) {
attribute.componentCount = convertTypeToInt(accessor.type);
} else {
return ASSET_ERROR;
}
if ((attribute.componentCount = getCompCount(accessor.type) == ASSET_ERROR))
return ASSET_ERROR;
vertexAttributes.push_back(attribute);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment