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