summaryrefslogtreecommitdiffstats
path: root/AssetLoader/src/GLTFLoader.cpp
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-24 02:54:14 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-24 02:54:14 +0000
commit6b7ae76649682a034351a41b5027ef57f3607dd4 (patch)
treeed95dc47abbf6ca21b1e97d26a8e834e1aed9de2 /AssetLoader/src/GLTFLoader.cpp
parentGLTF loader: enabled 8-bit joint indices (fixed https://github.com/DiligentGr... (diff)
downloadDiligentTools-6b7ae76649682a034351a41b5027ef57f3607dd4.tar.gz
DiligentTools-6b7ae76649682a034351a41b5027ef57f3607dd4.zip
Few more minor updates to GLTF loader
Diffstat (limited to 'AssetLoader/src/GLTFLoader.cpp')
-rw-r--r--AssetLoader/src/GLTFLoader.cpp55
1 files changed, 28 insertions, 27 deletions
diff --git a/AssetLoader/src/GLTFLoader.cpp b/AssetLoader/src/GLTFLoader.cpp
index 3e3dd7f..c278a34 100644
--- a/AssetLoader/src/GLTFLoader.cpp
+++ b/AssetLoader/src/GLTFLoader.cpp
@@ -309,34 +309,35 @@ void Model::LoadNode(IRenderDevice* pDevice,
int jointsStride = -1;
int weightsStride = -1;
- auto position_it = primitive.attributes.find("POSITION");
- VERIFY(position_it != primitive.attributes.end(), "Position attribute is required");
-
- const tinygltf::Accessor& posAccessor = gltf_model.accessors[position_it->second];
- const tinygltf::BufferView& posView = gltf_model.bufferViews[posAccessor.bufferView];
- VERIFY(posAccessor.componentType == TINYGLTF_COMPONENT_TYPE_FLOAT, "Position component type is expected to be float");
- VERIFY(posAccessor.type == TINYGLTF_TYPE_VEC3, "Position type is expected to be vec3");
-
- bufferPos = reinterpret_cast<const float*>(&(gltf_model.buffers[posView.buffer].data[posAccessor.byteOffset + posView.byteOffset]));
- PosMin =
- float3 //
- {
- static_cast<float>(posAccessor.minValues[0]),
- static_cast<float>(posAccessor.minValues[1]),
- static_cast<float>(posAccessor.minValues[2]) //
- };
- PosMax =
- float3 //
- {
- static_cast<float>(posAccessor.maxValues[0]),
- static_cast<float>(posAccessor.maxValues[1]),
- static_cast<float>(posAccessor.maxValues[2]) //
- };
- posStride = posAccessor.ByteStride(posView) / tinygltf::GetComponentSizeInBytes(posAccessor.componentType);
- VERIFY(posStride > 0, "Position stride is invalid");
+ {
+ auto position_it = primitive.attributes.find("POSITION");
+ VERIFY(position_it != primitive.attributes.end(), "Position attribute is required");
+ const tinygltf::Accessor& posAccessor = gltf_model.accessors[position_it->second];
+ const tinygltf::BufferView& posView = gltf_model.bufferViews[posAccessor.bufferView];
+ VERIFY(posAccessor.componentType == TINYGLTF_COMPONENT_TYPE_FLOAT, "Position component type is expected to be float");
+ VERIFY(posAccessor.type == TINYGLTF_TYPE_VEC3, "Position type is expected to be vec3");
- vertexCount = static_cast<uint32_t>(posAccessor.count);
+ bufferPos = reinterpret_cast<const float*>(&(gltf_model.buffers[posView.buffer].data[posAccessor.byteOffset + posView.byteOffset]));
+ PosMin =
+ float3 //
+ {
+ static_cast<float>(posAccessor.minValues[0]),
+ static_cast<float>(posAccessor.minValues[1]),
+ static_cast<float>(posAccessor.minValues[2]) //
+ };
+ PosMax =
+ float3 //
+ {
+ static_cast<float>(posAccessor.maxValues[0]),
+ static_cast<float>(posAccessor.maxValues[1]),
+ static_cast<float>(posAccessor.maxValues[2]) //
+ };
+ posStride = posAccessor.ByteStride(posView) / tinygltf::GetComponentSizeInBytes(posAccessor.componentType);
+ VERIFY(posStride > 0, "Position stride is invalid");
+
+ vertexCount = static_cast<uint32_t>(posAccessor.count);
+ }
if (primitive.attributes.find("NORMAL") != primitive.attributes.end())
{
@@ -414,7 +415,7 @@ void Model::LoadNode(IRenderDevice* pDevice,
hasSkin = bufferWeights != nullptr && (bufferJoints8 != nullptr || bufferJoints16 != nullptr);
- for (size_t v = 0; v < posAccessor.count; v++)
+ for (uint32_t v = 0; v < vertexCount; v++)
{
VertexAttribs0 vert0{};
vert0.pos = float4(float3::MakeVector(bufferPos + v * posStride), 1.0f);