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

[#79] Change function signatures for consistency.

parent fd4f55ec
No related branches found
No related tags found
1 merge request!69Resolve "Rework Asset Loader API"
...@@ -81,7 +81,7 @@ enum IndexType getIndexType(const enum fx::gltf::Accessor::ComponentType &type) ...@@ -81,7 +81,7 @@ enum IndexType getIndexType(const enum fx::gltf::Accessor::ComponentType &type)
* @return ASSET_ERROR if at least one texture could not be constructed * @return ASSET_ERROR if at least one texture could not be constructed
* properly, otherwise ASSET_SUCCESS * properly, otherwise ASSET_SUCCESS
*/ */
int loadTextures(const std::vector<fx::gltf::Texture> &tex_src, int createTextures(const std::vector<fx::gltf::Texture> &tex_src,
const std::vector<fx::gltf::Image> &img_src, const std::vector<fx::gltf::Image> &img_src,
const std::string &dir, std::vector<Texture> &dst) const std::string &dir, std::vector<Texture> &dst)
{ {
...@@ -131,14 +131,15 @@ int loadTextures(const std::vector<fx::gltf::Texture> &tex_src, ...@@ -131,14 +131,15 @@ int loadTextures(const std::vector<fx::gltf::Texture> &tex_src,
* @return ASSET_ERROR when at least one VertexAttribute could not be * @return ASSET_ERROR when at least one VertexAttribute could not be
* constructed properly, otherwise ASSET_SUCCESS * constructed properly, otherwise ASSET_SUCCESS
*/ */
int getVertexAttributes(const fx::gltf::Attributes &src, int createVertexAttributes(const fx::gltf::Attributes &src,
const fx::gltf::Document &gltf, const std::vector<fx::gltf::Accessor> &accessors,
const std::vector<fx::gltf::BufferView> &bufferViews,
std::vector<VertexAttribute> &dst) std::vector<VertexAttribute> &dst)
{ {
dst.clear(); dst.clear();
dst.reserve(src.size()); dst.reserve(src.size());
for (const auto &attrib : src) { for (const auto &attrib : src) {
const fx::gltf::Accessor &accessor = gltf.accessors[attrib.second]; const fx::gltf::Accessor &accessor = accessors[attrib.second];
dst.push_back({}); dst.push_back({});
VertexAttribute &att = dst.back(); VertexAttribute &att = dst.back();
...@@ -162,7 +163,7 @@ int getVertexAttributes(const fx::gltf::Attributes &src, ...@@ -162,7 +163,7 @@ int getVertexAttributes(const fx::gltf::Attributes &src,
att.type = PrimitiveType::UNDEFINED; att.type = PrimitiveType::UNDEFINED;
return ASSET_ERROR; return ASSET_ERROR;
} }
const fx::gltf::BufferView &buf = gltf.bufferViews[accessor.bufferView]; const fx::gltf::BufferView &buf = bufferViews[accessor.bufferView];
att.offset = buf.byteOffset; att.offset = buf.byteOffset;
att.length = buf.byteLength; att.length = buf.byteLength;
att.stride = buf.byteStride; att.stride = buf.byteStride;
...@@ -334,8 +335,11 @@ int loadScene(const std::string &path, Scene &scene){ ...@@ -334,8 +335,11 @@ int loadScene(const std::string &path, Scene &scene){
vertexAttributes.clear(); vertexAttributes.clear();
vertexAttributes.reserve(objectPrimitive.attributes.size()); vertexAttributes.reserve(objectPrimitive.attributes.size());
if (getVertexAttributes(objectPrimitive.attributes, sceneObjects, if (createVertexAttributes(objectPrimitive.attributes,
vertexAttributes) != ASSET_SUCCESS) { sceneObjects.accessors,
sceneObjects.bufferViews,
vertexAttributes)
!= ASSET_SUCCESS) {
vkcv_log(LogLevel::ERROR, "Failed to get vertex attributes"); vkcv_log(LogLevel::ERROR, "Failed to get vertex attributes");
return ASSET_ERROR; return ASSET_ERROR;
} }
...@@ -430,7 +434,7 @@ int loadScene(const std::string &path, Scene &scene){ ...@@ -430,7 +434,7 @@ int loadScene(const std::string &path, Scene &scene){
sceneObjects.nodes[m].matrix); sceneObjects.nodes[m].matrix);
} }
if (loadTextures(sceneObjects.textures, sceneObjects.images, dir, textures) != ASSET_SUCCESS) { if (createTextures(sceneObjects.textures, sceneObjects.images, dir, textures) != ASSET_SUCCESS) {
size_t missing = sceneObjects.textures.size() - textures.size(); size_t missing = sceneObjects.textures.size() - textures.size();
vkcv_log(LogLevel::ERROR, "Failed to get %lu textures from glTF source '%s'", vkcv_log(LogLevel::ERROR, "Failed to get %lu textures from glTF source '%s'",
missing, path.c_str()); missing, path.c_str());
......
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