Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions Axiom/Assets/CookedAssetRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@

namespace Axiom::Assets {

bool IsCookedOnlyContentPath(const std::filesystem::path &Path) {
const auto ContentRoot = FindContentRootForPath(Path);
if (!ContentRoot.has_value()) {
return false;
}

const auto PackageManifestPath = ContentRoot->parent_path() / "package.wraith.json";
return std::filesystem::exists(PackageManifestPath);
}

std::optional<std::filesystem::path>
FindContentRootForPath(const std::filesystem::path &Path) {
if (Path.empty()) {
Expand Down
2 changes: 2 additions & 0 deletions Axiom/Assets/CookedAssetRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace Axiom::Assets {
std::optional<std::filesystem::path>
FindContentRootForPath(const std::filesystem::path &Path);

bool IsCookedOnlyContentPath(const std::filesystem::path &Path);

std::optional<MeshSceneData>
LoadCookedMeshAssetIfAvailable(const std::filesystem::path &Path);

Expand Down
14 changes: 14 additions & 0 deletions Axiom/Assets/MeshAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,13 @@ std::optional<MeshSceneData> LoadBasicMeshAsset(const std::filesystem::path &Pat
return CookedScene;
}

if (IsCookedOnlyContentPath(Path)) {
A_CORE_WARN(
"Cooked runtime: missing cooked mesh asset for '{}' and source fallback is disabled",
Path.string());
return std::nullopt;
}

return LoadBasicMeshAssetFromSource(Path);
}

Expand All @@ -556,6 +563,13 @@ TextureSourceDataRef LoadTextureFromFile(const std::filesystem::path &Path) {
return CookedTexture;
}

if (IsCookedOnlyContentPath(Path)) {
A_CORE_WARN(
"Cooked runtime: missing cooked texture asset for '{}' and source fallback is disabled",
Path.string());
return nullptr;
}

return LoadTextureFromSourceFile(Path);
}

Expand Down
13 changes: 10 additions & 3 deletions Axiom/Assets/SceneFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ EditorSceneItemKind KindFromStr(std::string_view S) {
std::optional<EditorSceneState>
LoadSceneFromFile(const std::filesystem::path &Path) {
const std::filesystem::path ContentRoot = ResolveContentRootForScenePath(Path);
const bool CookedOnlyContent = IsCookedOnlyContentPath(ContentRoot);

std::ifstream File(Path);
if (!File.is_open()) return std::nullopt;
Expand Down Expand Up @@ -827,7 +828,9 @@ LoadSceneFromFile(const std::filesystem::path &Path) {
std::unordered_set<std::string> LoadedByAssetPath;
for (const auto &[ObjId, Data] : Objects) {
if (Data.Kind != EditorSceneItemKind::Mesh || Data.AssetRelativePath.empty()) continue;
CookMeshAsset(ContentRoot, Data.AssetRelativePath);
if (!CookedOnlyContent) {
CookMeshAsset(ContentRoot, Data.AssetRelativePath);
}
const auto FullPath = ContentRoot / Data.AssetRelativePath;
auto SceneData = LoadBasicMeshAsset(FullPath);
if (!SceneData.has_value() || SceneData->Instances.empty()) {
Expand Down Expand Up @@ -857,7 +860,9 @@ LoadSceneFromFile(const std::filesystem::path &Path) {
}
}
if (!Data.TextureAssetPath.empty()) {
CookTextureAsset(ContentRoot, Data.TextureAssetPath);
if (!CookedOnlyContent) {
CookTextureAsset(ContentRoot, Data.TextureAssetPath);
}
const auto TexPath = ContentRoot / Data.TextureAssetPath;
auto Tex = LoadTextureFromFile(TexPath);
if (Tex) {
Expand Down Expand Up @@ -902,7 +907,9 @@ LoadSceneFromFile(const std::filesystem::path &Path) {

// --- Stage 4b: reload remaining mesh instances from the global mesh asset ---
if (!MeshAsset.empty() && !MeshNameToObjectId.empty()) {
CookMeshAsset(ContentRoot, MeshAsset);
if (!CookedOnlyContent) {
CookMeshAsset(ContentRoot, MeshAsset);
}
const auto MeshPath = ContentRoot / MeshAsset;
const auto SceneData = LoadBasicMeshAsset(MeshPath);
if (SceneData.has_value()) {
Expand Down
3 changes: 3 additions & 0 deletions Axiom/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(ENGINE_SOURCES
Project/ProjectSystem.cpp
Scripting/ScriptHost.cpp
Scripting/InternalCalls.cpp
Assets/AssetCookManifest.cpp
Expand Down Expand Up @@ -303,6 +304,8 @@ target_link_libraries(AxiomCore PUBLIC
target_compile_definitions(AxiomCore PUBLIC
VK_NO_PROTOTYPES
AXIOM_CONTENT_DIR="${CMAKE_SOURCE_DIR}/Content"
AXIOM_PROJECTS_DIR="${CMAKE_SOURCE_DIR}/Projects"
AXIOM_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
)

if(AXIOM_ENABLE_WEBRTC)
Expand Down
Loading
Loading