summaryrefslogtreecommitdiff
path: root/src/engine/editor
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-12-13 17:28:44 -0700
committerGitHub <noreply@github.com>2025-12-13 17:28:44 -0700
commit7bc8d6f4be2bc22f7f4815d3c5eac691c4b92c0f (patch)
treeea7bed88faf5f3bb0788c698fd0252d3f624548a /src/engine/editor
parent4e51b7d5b6a9b89deb5ef135deec0ee5f0087e7c (diff)
Refactor Field-of-view into the Camera Struct (#590)
* Fix finishline for toads turnpike in extra * Fixed trash bin in extra * Refactor fov * Update scene.json * Allow setting fog * impl fog save & load
Diffstat (limited to 'src/engine/editor')
-rw-r--r--src/engine/editor/EditorMath.cpp2
-rw-r--r--src/engine/editor/SceneManager.cpp58
-rw-r--r--src/engine/editor/SceneManager.h2
3 files changed, 61 insertions, 1 deletions
diff --git a/src/engine/editor/EditorMath.cpp b/src/engine/editor/EditorMath.cpp
index 620aa2b48..02932a5a7 100644
--- a/src/engine/editor/EditorMath.cpp
+++ b/src/engine/editor/EditorMath.cpp
@@ -62,7 +62,7 @@ FVector ScreenRayTrace() {
Mat4 perspMtx;
u16 perspNorm;
- guPerspectiveF(perspMtx, &perspNorm, 40, OTRGetAspectRatio(), CM_GetProps()->NearPersp, CM_GetProps()->FarPersp, 1.0f);
+ guPerspectiveF(perspMtx, &perspNorm, camera->fieldOfView, OTRGetAspectRatio(), CM_GetProps()->NearPersp, CM_GetProps()->FarPersp, 1.0f);
Mat4 inversePerspMtx;
if (InverseMatrix((float*)&perspMtx, (float*)&inversePerspMtx) != 2) {
diff --git a/src/engine/editor/SceneManager.cpp b/src/engine/editor/SceneManager.cpp
index 135079a57..b8e3d93e0 100644
--- a/src/engine/editor/SceneManager.cpp
+++ b/src/engine/editor/SceneManager.cpp
@@ -29,6 +29,8 @@ extern "C" {
#include "actors.h"
#include "actor_types.h"
#include "code_80005FD0.h"
+#include "code_800029B0.h"
+#include "render_courses.h"
}
namespace Editor {
@@ -56,6 +58,10 @@ namespace Editor {
data["Tour"] = tour;
}
+ nlohmann::json fog;
+ SaveFog(fog);
+ data["Fog"] = fog;
+
if (nullptr == track->Archive) {
SPDLOG_INFO("[SceneManager] [SaveLevel] Track archive nullptr");
return;
@@ -297,6 +303,19 @@ namespace Editor {
}
}
+ void SaveFog(nlohmann::json& fog) {
+ if (bFog) {
+ fog["EnableFog"] = bFog;
+ fog["Colour"]["R"] = gFogColour.r;
+ fog["Colour"]["G"] = gFogColour.g;
+ fog["Colour"]["B"] = gFogColour.b;
+ fog["Colour"]["A"] = gFogColour.a;
+
+ fog["Min"] = gFogMin;
+ fog["Max"] = gFogMax;
+ }
+ }
+
void LoadProps(Track* track, nlohmann::json& data) {
if (!data.contains("Props") || !data["Props"].is_object()) {
SPDLOG_INFO("Track is missing props data. Is the scene.json file corrupt?");
@@ -415,4 +434,43 @@ namespace Editor {
}
}
}
+
+ void LoadFog(nlohmann::json& data) {
+ if (!data.contains("Fog") || !data["Fog"].is_object()) {
+ SPDLOG_INFO(" This track does not contain fog");
+ return;
+ }
+
+ nlohmann::json& fog = data["Fog"];
+
+ bFog = fog.value("Enabled", false);
+
+ if (!bFog) return;
+
+ // Load color
+ if (fog.contains("Colour") && fog["Colour"].is_object()) {
+ nlohmann::json& c = fog["Colour"];
+ gFogColour.r = c.value("R", 255);
+ gFogColour.g = c.value("G", 255);
+ gFogColour.b = c.value("B", 255);
+ gFogColour.a = c.value("A", 255);
+ }
+
+ // Load min/max with safety clamps
+ int minVal = fog.value("Min", 0);
+ int maxVal = fog.value("Max", 500);
+
+ // Ensure min < max
+ if (minVal >= maxVal) {
+ minVal = maxVal - 1;
+ }
+
+ // Clamp to valid ranges
+ minVal = std::clamp(minVal, 0, 999);
+ maxVal = std::clamp(maxVal, 1, 1000);
+
+ gFogMin = static_cast<int16_t>(minVal);
+ gFogMax = static_cast<int16_t>(maxVal);
+
+ }
}
diff --git a/src/engine/editor/SceneManager.h b/src/engine/editor/SceneManager.h
index 48b52a1e2..551d79e32 100644
--- a/src/engine/editor/SceneManager.h
+++ b/src/engine/editor/SceneManager.h
@@ -17,6 +17,7 @@ namespace Editor {
void SaveActors(nlohmann::json& actorList);
void SaveStaticMeshActors(nlohmann::json& actorList);
void SaveTour(Track* track, nlohmann::json& tour);
+ void SaveFog(nlohmann::json& fog);
void LoadProps(Track* track, nlohmann::json& data);
void LoadPaths(Track* track, const std::string& trackPath);
@@ -24,6 +25,7 @@ namespace Editor {
void LoadActors(Track* track, nlohmann::json& data);
void LoadStaticMeshActors(Track* track, nlohmann::json& data);
void LoadTour(Track* track, nlohmann::json& data);
+ void LoadFog(nlohmann::json& data);
void SpawnActors(std::vector<std::pair<std::string, SpawnParams>> spawnList);