Skip to content

Commit

Permalink
Fix: Explicitly initialize aggregate elements
Browse files Browse the repository at this point in the history
  • Loading branch information
spnda committed May 20, 2024
1 parent 7c21841 commit c88c64b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/fastgltf/tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ FASTGLTF_EXPORT template <typename ElementType, typename BufferDataAdapter = Def
#if FASTGLTF_HAS_CONCEPTS
requires Element<ElementType>
#endif
auto getAccessorElement(const Asset& asset, const Accessor& accessor, size_t index,
ElementType getAccessorElement(const Asset& asset, const Accessor& accessor, size_t index,
const BufferDataAdapter& adapter = {}) {
using Traits = ElementTraits<ElementType>;
static_assert(Traits::type != AccessorType::Invalid, "Accessor traits must provide a valid Accessor Type");
Expand Down Expand Up @@ -525,9 +525,9 @@ auto getAccessorElement(const Asset& asset, const Accessor& accessor, size_t ind
// property or extensions MAY override zeros with actual values.
if (!accessor.bufferViewIndex) {
if constexpr (std::is_aggregate_v<ElementType>) {
return {};
} else {
return ElementType{};
} else {
return ElementType();
}
}

Expand Down Expand Up @@ -689,9 +689,9 @@ void copyFromAccessor(const Asset& asset, const Accessor& accessor, void* dest,
auto* pDest = reinterpret_cast<ElementType*>(dstBytes + TargetStride * i);

if constexpr (std::is_aggregate_v<ElementType>) {
*pDest = {};
*pDest = ElementType {};
} else {
*pDest = ElementType{};
*pDest = ElementType();
}
}
}
Expand Down

0 comments on commit c88c64b

Please sign in to comment.