Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/gltfio/src/JitShaderProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class JitShaderProvider : public MaterialProvider {
std::vector<Material*> mMaterials;
Engine* const mEngine;
const bool mOptimizeShaders;
filament::UserVariantFilterMask mVariantFilter;
filament::UserVariantFilterMask mVariantFilter{};
};

JitShaderProvider::JitShaderProvider(Engine* engine, bool optimizeShaders,
Expand Down
27 changes: 26 additions & 1 deletion libs/gltfio/src/ResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,34 @@ inline void uploadBuffers(FFilamentAsset* asset, Engine& engine,
auto& slots = std::get<FFilamentAsset::ResourceInfo>(asset->mResourceInfo).mBufferSlots;
for (auto const& slot: slots) {
const cgltf_accessor* accessor = slot.accessor;
if (!accessor->buffer_view) {
// Morph target accessors may not have a buffer_view (data is directly in the accessor)
bool isMorphTarget = (slot.morphTargetBuffer != nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const bool


if (!accessor->buffer_view && !isMorphTarget) {
continue;
}

// For morph targets without buffer_view, use cgltf_accessor_unpack_floats to unpack data directly
if (!accessor->buffer_view && isMorphTarget) {
const size_t floatsCount = accessor->count * cgltf_num_components(accessor->type);
const size_t floatsByteCount = sizeof(float) * floatsCount;
float* floatsData = (float*)malloc(floatsByteCount);
cgltf_accessor_unpack_floats(accessor, floatsData, floatsCount);

if (accessor->type == cgltf_type_vec3) {
slot.morphTargetBuffer->setPositionsAt(engine, slot.bufferIndex,
(const float3*)floatsData, slot.morphTargetCount, slot.morphTargetOffset);
}
else {
assert_invariant(accessor->type == cgltf_type_vec4);
slot.morphTargetBuffer->setPositionsAt(engine, slot.bufferIndex,
(const float4*)floatsData, slot.morphTargetCount, slot.morphTargetOffset);
}

free(floatsData);
continue;
}

const uint8_t* bufferData = nullptr;
const uint8_t* data = nullptr;
if (accessor->buffer_view->has_meshopt_compression) {
Expand Down
Loading