Fix backpack material artifact rebuild

This commit is contained in:
2026-04-08 02:53:12 +08:00
parent 0a392e1311
commit 2e961295bf
4 changed files with 88 additions and 3 deletions

View File

@@ -74,6 +74,16 @@ bool IsProjectRelativePath(const std::filesystem::path& path) {
generic.rfind("../", 0) != 0;
}
bool IsExplicitProjectRelativeDependencyPath(const std::filesystem::path& path) {
const std::string generic = path.lexically_normal().generic_string();
return generic == "Assets" ||
generic.rfind("Assets/", 0) == 0 ||
generic == "Library" ||
generic.rfind("Library/", 0) == 0 ||
generic == "Packages" ||
generic.rfind("Packages/", 0) == 0;
}
Containers::String ToProjectRelativeIfPossible(const std::filesystem::path& path) {
const Containers::String& resourceRoot = ResourceManager::Get().GetResourceRoot();
const std::filesystem::path normalizedPath = path.lexically_normal();
@@ -96,16 +106,26 @@ Containers::String ResolveSourceDependencyPath(const Containers::String& depende
}
std::filesystem::path dependencyFsPath(dependencyPath.CStr());
dependencyFsPath = dependencyFsPath.lexically_normal();
if (dependencyFsPath.is_absolute()) {
return NormalizePathString(dependencyFsPath);
}
const Containers::String& resourceRoot = ResourceManager::Get().GetResourceRoot();
if (!resourceRoot.Empty()) {
const std::filesystem::path projectRoot(resourceRoot.CStr());
const std::filesystem::path projectRelativeCandidate = projectRoot / dependencyFsPath;
if (IsExplicitProjectRelativeDependencyPath(dependencyFsPath) ||
std::filesystem::exists(projectRelativeCandidate)) {
return ToProjectRelativeIfPossible(projectRelativeCandidate);
}
}
const std::filesystem::path sourceFsPath(sourcePath.CStr());
if (sourceFsPath.is_absolute()) {
return ToProjectRelativeIfPossible(sourceFsPath.parent_path() / dependencyFsPath);
}
const Containers::String& resourceRoot = ResourceManager::Get().GetResourceRoot();
if (!resourceRoot.Empty()) {
return ToProjectRelativeIfPossible(
std::filesystem::path(resourceRoot.CStr()) /