diff --git a/src/animation/controller.cpp b/src/animation/controller.cpp index 58970406ac..019b11264e 100644 --- a/src/animation/controller.cpp +++ b/src/animation/controller.cpp @@ -27,7 +27,10 @@ Controller::~Controller() { void Controller::unload() { for (const AnimationEntry& entry : m_animation_entries) { - if (entry.animation) entry.animation->decRefCount(); + if (entry.animation) { + removeDependency(*entry.animation); + entry.animation->decRefCount(); + } } m_animation_entries.clear(); m_bone_masks.clear(); @@ -122,6 +125,9 @@ bool Controller::deserialize(InputMemoryStream& stream) { stream.read(entry.set); const char* path = stream.readString(); entry.animation = path[0] ? m_resource_manager.getOwner().load(Path(path)) : nullptr; + if(entry.animation) { + addDependency(*entry.animation); + } } NodeType type; diff --git a/src/editor/asset_compiler.cpp b/src/editor/asset_compiler.cpp index f506e9ba74..bfebc1efae 100644 --- a/src/editor/asset_compiler.cpp +++ b/src/editor/asset_compiler.cpp @@ -212,8 +212,8 @@ struct AssetCompilerImpl : AssetCompiler { OutputMemoryStream compressed(m_allocator); if (data.length() > COMPRESSION_SIZE_LIMIT) { if (!m_app.getEngine().compress(data, compressed)) { - logError("Could not compress ", path); - return false; + logWarning("Could not compress ", path, ", using uncompressed file."); + compressed.clear(); } } @@ -227,7 +227,7 @@ struct AssetCompilerImpl : AssetCompiler { CompiledResourceHeader header; header.decompressed_size = data.length(); const u32 compressed_size = (u32)compressed.size(); - if (data.length() > COMPRESSION_SIZE_LIMIT && compressed_size < i32(data.length() / 4 * 3)) { + if (data.length() > COMPRESSION_SIZE_LIMIT && compressed_size > 0 && compressed_size < i32(data.length() / 4 * 3)) { header.flags |= CompiledResourceHeader::COMPRESSED; (void)file.write(&header, sizeof(header)); (void)file.write(compressed.data(), compressed_size); @@ -238,6 +238,13 @@ struct AssetCompilerImpl : AssetCompiler { } file.close(); if (file.isError()) logError("Could not write ", out_path); + jobs::MutexGuard guard(m_resources_mutex); + auto iter = m_resources.find(path.getHash()); + if (!iter.isValid()) { + // Resource scane is async, so it's not guaranteed that the resource is in the m_resources list at this point + // If it's not, we don't need to add it to the list + m_resources.insert(path.getHash(), {path, getResourceType(path), dirHash(path)}); + } return !file.isError(); } diff --git a/src/editor/profiler_ui.cpp b/src/editor/profiler_ui.cpp index 83f1856fd1..eb4a6be492 100644 --- a/src/editor/profiler_ui.cpp +++ b/src/editor/profiler_ui.cpp @@ -900,13 +900,22 @@ struct ProfilerUIImpl final : StudioApp::GUIPlugin { ImGui::DragScalar("##fs", ImGuiDataType_U64, &m_resource_size_filter, 1000); ImGui::Indent(); + // TODO multiple plugins can handle the same resource type (e.g. fbx plugin and gltf plugin) + // this duplicates the UI for that resource type for (const AssetBrowser::IPlugin* plugin : m_app.getAssetBrowser().getPlugins()) { ResourceManager* resource_manager = m_engine.getResourceManager().get(plugin->getResourceType()); if (!resource_manager) continue; - if (!ImGui::CollapsingHeader(plugin->getLabel())) continue; + ImGui::PushID(plugin); + if (!ImGui::CollapsingHeader(plugin->getLabel())) { + ImGui::PopID(); + continue; + } ResourceManager::ResourceTable& resources = resource_manager->getResourceTable(); - if (!ImGui::BeginTable("resc", 4)) continue; + if (!ImGui::BeginTable("resc", 4)) { + ImGui::PopID(); + continue; + } ImGui::TableSetupColumn("Path"); ImGui::TableSetupColumn("Size"); @@ -916,7 +925,6 @@ struct ProfilerUIImpl final : StudioApp::GUIPlugin { u64 sum = 0; for (const Resource* res : resources) { - if (res->isEmpty()) continue; if (!m_resource_filter.pass(res->getPath())) continue; if (m_resource_size_filter > res->getFileSize() / 1024) continue; @@ -951,6 +959,7 @@ struct ProfilerUIImpl final : StudioApp::GUIPlugin { ImGui::TableNextColumn(); ImGui::EndTable(); + ImGui::PopID(); } ImGui::Unindent(); } diff --git a/src/renderer/editor/fbx_importer.cpp b/src/renderer/editor/fbx_importer.cpp index 59d7ae19df..f453db7cf5 100644 --- a/src/renderer/editor/fbx_importer.cpp +++ b/src/renderer/editor/fbx_importer.cpp @@ -350,7 +350,6 @@ struct FBXImporter : ModelImporter { if (mesh_idx >= m_meshes.size()) break; ImportMesh& import_mesh = m_meshes[mesh_idx]; - import_mesh.index_size = areIndices16Bit(import_mesh) ? 2 : 4; const ofbx::Mesh* mesh = m_fbx_meshes[import_mesh.mesh_index]; import_mesh.vertex_size = getVertexSize(*mesh, import_mesh.is_skinned, meta); const ofbx::GeometryData& geom = mesh->getGeometryData(); @@ -469,6 +468,7 @@ struct FBXImporter : ModelImporter { } remap(unindexed_triangles, import_mesh); + import_mesh.index_size = areIndices16Bit(import_mesh) ? 2 : 4; } }); diff --git a/src/renderer/editor/model_importer.cpp b/src/renderer/editor/model_importer.cpp index 094cd076ba..3e017d64b8 100644 --- a/src/renderer/editor/model_importer.cpp +++ b/src/renderer/editor/model_importer.cpp @@ -582,7 +582,7 @@ void ModelImporter::createImpostorTextures(Model* model, ImpostorTexturesContext bool ModelImporter::write(const Path& src, const ModelMeta& meta) { const Path filepath = Path(ResourcePath::getResource(src)); - if (!writeModel(src, meta)) return false; + if (!meta.split && !writeModel(src, meta)) return false; if (!writeMaterials(filepath, meta, false)) return false; if (!writeAnimations(filepath, meta)) return false; if (meta.split) { @@ -1274,7 +1274,7 @@ bool ModelImporter::writeModel(const Path& src, const ModelMeta& meta) { writeLODs(meta); AssetCompiler& compiler = m_app.getAssetCompiler(); - return compiler.writeCompiledResource(Path(src), Span(m_out_file.data(), (i32)m_out_file.size())); + return compiler.writeCompiledResource(Path(src), Span(m_out_file.data(), m_out_file.size())); } bool ModelImporter::writeAnimations(const Path& src, const ModelMeta& meta) { diff --git a/src/renderer/editor/model_importer.h b/src/renderer/editor/model_importer.h index 092c0a0cbe..397ba35f42 100644 --- a/src/renderer/editor/model_importer.h +++ b/src/renderer/editor/model_importer.h @@ -74,7 +74,7 @@ struct ModelImporter { u32 vertex_size = 0xffFFffFF; Array attributes; Array indices; - u32 index_size; + u32 index_size = 0; Local> autolod_indices[4]; AABB aabb; float origin_radius_squared;