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

[#63] Use newly defined component types instead of uint16.

parent e006dbe6
No related branches found
No related tags found
1 merge request!51Resolve "Laden mehrer Meshes mit Materials und Textures"
Pipeline #25477 passed
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
namespace vkcv{ namespace vkcv {
/* With these enums, 0 is reserved to signal uninitialized or invalid data. */ /* With these enums, 0 is reserved to signal uninitialized or invalid data. */
enum class PrimitiveType : uint32_t { enum class PrimitiveType : uint32_t {
...@@ -19,7 +19,7 @@ enum class PrimitiveType : uint32_t { ...@@ -19,7 +19,7 @@ enum class PrimitiveType : uint32_t {
* convenience (easier to read in if/switch statements etc). While this enum * convenience (easier to read in if/switch statements etc). While this enum
* exists in (almost) the same definition in the fx-gltf library, we want to * exists in (almost) the same definition in the fx-gltf library, we want to
* avoid exposing that dependency, thus it is re-defined here. */ * avoid exposing that dependency, thus it is re-defined here. */
enum class VertexComponentType : uint16_t { enum class ComponentType : uint16_t {
NONE=0, INT8=5120, UINT8=5121, INT16=5122, UINT16=5123, NONE=0, INT8=5120, UINT8=5121, INT16=5122, UINT16=5123,
UINT32=5125, FLOAT32=5126 UINT32=5125, FLOAT32=5126
}; };
...@@ -30,7 +30,7 @@ typedef struct { ...@@ -30,7 +30,7 @@ typedef struct {
uint32_t offset; // offset in bytes uint32_t offset; // offset in bytes
uint32_t length; // length of ... in bytes uint32_t length; // length of ... in bytes
uint32_t stride; // stride in bytes uint32_t stride; // stride in bytes
uint16_t componentType; // eg. 5126 for float ComponentType componentType; // eg. 5126 for float
uint8_t componentCount; // eg. 3 for vec3 uint8_t componentCount; // eg. 3 for vec3
} VertexAttribute; } VertexAttribute;
......
...@@ -118,7 +118,7 @@ int loadMesh(const std::string &path, Mesh &mesh) { ...@@ -118,7 +118,7 @@ int loadMesh(const std::string &path, Mesh &mesh) {
attribute.offset = object.bufferViews[accessor.bufferView].byteOffset; attribute.offset = object.bufferViews[accessor.bufferView].byteOffset;
attribute.length = object.bufferViews[accessor.bufferView].byteLength; attribute.length = object.bufferViews[accessor.bufferView].byteLength;
attribute.stride = object.bufferViews[accessor.bufferView].byteStride; attribute.stride = object.bufferViews[accessor.bufferView].byteStride;
attribute.componentType = static_cast<uint16_t>(accessor.componentType); attribute.componentType = static_cast<ComponentType>(accessor.componentType);
if (convertTypeToInt(accessor.type) != 10) { if (convertTypeToInt(accessor.type) != 10) {
attribute.componentCount = convertTypeToInt(accessor.type); attribute.componentCount = convertTypeToInt(accessor.type);
...@@ -304,8 +304,7 @@ int loadScene(const std::string &path, Scene &scene){ ...@@ -304,8 +304,7 @@ int loadScene(const std::string &path, Scene &scene){
attribute.offset = sceneObjects.bufferViews[accessor.bufferView].byteOffset; attribute.offset = sceneObjects.bufferViews[accessor.bufferView].byteOffset;
attribute.length = sceneObjects.bufferViews[accessor.bufferView].byteLength; attribute.length = sceneObjects.bufferViews[accessor.bufferView].byteLength;
attribute.stride = sceneObjects.bufferViews[accessor.bufferView].byteStride; attribute.stride = sceneObjects.bufferViews[accessor.bufferView].byteStride;
// TODO use enums instead of only integer representation for types (defined in VertexLayout.hpp) attribute.componentType = static_cast<ComponentType>(accessor.componentType);
attribute.componentType = static_cast<uint16_t>(accessor.componentType);
if (convertTypeToInt(accessor.type) != 10) { if (convertTypeToInt(accessor.type) != 10) {
attribute.componentCount = convertTypeToInt(accessor.type); attribute.componentCount = convertTypeToInt(accessor.type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment