summaryrefslogtreecommitdiff
path: root/src/port
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2025-06-18 12:32:55 -0600
committerGitHub <noreply@github.com>2025-06-18 12:32:55 -0600
commit5011f932c2349d75e609612af4e5e8395c1f75eb (patch)
tree8bdb046f3aae3542b8921ce1b24b72e094c07015 /src/port
parentd3a3e761cff650c8a4b707377dd17f70dc4e9ca0 (diff)
Interpolate hm intro (#228)
* Interpolation ApplyMatrixTransformations * Fix scenefile saving and add skybox export --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com>
Diffstat (limited to 'src/port')
-rw-r--r--src/port/Game.cpp7
-rw-r--r--src/port/Game.h2
-rw-r--r--src/port/interpolation/FrameInterpolation.cpp22
-rw-r--r--src/port/interpolation/FrameInterpolation.h2
-rw-r--r--src/port/resource/importers/TrackSectionsFactory.cpp5
-rw-r--r--src/port/ui/ContentBrowser.cpp11
-rw-r--r--src/port/ui/ContentBrowser.h3
7 files changed, 36 insertions, 16 deletions
diff --git a/src/port/Game.cpp b/src/port/Game.cpp
index 4cea9c5e2..63faab45c 100644
--- a/src/port/Game.cpp
+++ b/src/port/Game.cpp
@@ -141,7 +141,8 @@ void CustomEngineInit() {
gWorldInstance.AddCup(gBattleCup);
/* Set default course; mario raceway */
- SelectMarioRaceway();
+ //SelectMarioRaceway(); // This results in a nullptr
+ gWorldInstance.CurrentCourse = mario;
gWorldInstance.CurrentCup = gMushroomCup;
gWorldInstance.CurrentCup->CursorPosition = 3;
gWorldInstance.CupIndex = 0;
@@ -601,10 +602,6 @@ void* GetCourse(void) {
return gWorldInstance.CurrentCourse;
}
-void SetCourseByClass(void* course) {
- gWorldInstance.CurrentCourse = (Course*) course;
-}
-
struct Actor* CM_GetActor(size_t index) {
if (index < gWorldInstance.Actors.size()) {
AActor* actor = gWorldInstance.Actors[index];
diff --git a/src/port/Game.h b/src/port/Game.h
index 14cc0edf6..3cc63afc0 100644
--- a/src/port/Game.h
+++ b/src/port/Game.h
@@ -143,8 +143,6 @@ void* GetCourse(void);
void SetCourseById(s32 course);
-void SetCourseByClass(void* course);
-
struct Actor* CM_GetActor(size_t index);
void CM_DeleteActor(size_t index);
struct Actor* CM_AddBaseActor();
diff --git a/src/port/interpolation/FrameInterpolation.cpp b/src/port/interpolation/FrameInterpolation.cpp
index 438c10c0a..b11eb0391 100644
--- a/src/port/interpolation/FrameInterpolation.cpp
+++ b/src/port/interpolation/FrameInterpolation.cpp
@@ -8,6 +8,7 @@
#include "FrameInterpolation.h"
#include "matrix.h"
#include "engine/Matrix.h"
+#include "src/engine/CoreMath.h"
extern "C" {
#include "math_util.h"
@@ -85,6 +86,7 @@ enum class Op {
SetTranslateRotate,
SetTextMatrix,
SetMatrixPosRotScaleXY,
+ SetApplyMatrixTransformations,
};
typedef pair<const void*, uintptr_t> label;
@@ -110,6 +112,13 @@ union Data {
struct {
Mat4* matrix;
+ FVector pos;
+ IRotator rot;
+ FVector scale;
+ } matrix_applytransformations;
+
+ struct {
+ Mat4* matrix;
Vec3fInterp b;
} matrix_translate;
@@ -578,6 +587,13 @@ struct InterpolateCtx {
mtxf_translation_x_y_rotate_z_scale_x_y(*gInterpolationMatrix, tmp32[0], tmp32[1], tmp_vec3s[0], tmp_vec3f[0]);
break;
}
+ case Op::SetApplyMatrixTransformations: {
+ lerp_vec3f(&tmp_vec3f, (Vec3f*)&old_op.matrix_applytransformations.pos, (Vec3f*)&new_op.matrix_applytransformations.pos);
+ lerp_vec3s(&tmp_vec3s, (int16_t*)&old_op.matrix_applytransformations.rot, (int16_t*)&new_op.matrix_applytransformations.rot);
+ lerp_vec3f(&tmp_vec3f2, (Vec3f*)&old_op.matrix_applytransformations.scale, (Vec3f*)&new_op.matrix_applytransformations.scale);
+
+ ApplyMatrixTransformations(*gInterpolationMatrix, *(FVector*)&tmp_vec3f, *(IRotator*)&tmp_vec3s, *(FVector*)&tmp_vec3f2);
+ }
}
}
}
@@ -694,6 +710,12 @@ void FrameInterpolation_RecordMatrixMult(Mat4* matrix, MtxF* mf, u8 mode) {
append(Op::MatrixMult).matrix_mult = { matrix, *mf, mode };
}
+void FrameInterpolation_ApplyMatrixTransformations(Mat4* matrix, FVector pos, IRotator rot, FVector scale) {
+ if (!is_recording)
+ return;
+ append(Op::SetApplyMatrixTransformations).matrix_applytransformations = { matrix, pos, rot, scale };
+}
+
void FrameInterpolation_RecordMatrixTranslate(Mat4* matrix, Vec3f b) {
if (!is_recording)
return;
diff --git a/src/port/interpolation/FrameInterpolation.h b/src/port/interpolation/FrameInterpolation.h
index 30187c808..8acb0a83a 100644
--- a/src/port/interpolation/FrameInterpolation.h
+++ b/src/port/interpolation/FrameInterpolation.h
@@ -7,11 +7,13 @@
#ifdef __cplusplus
+#include "src/engine/CoreMath.h"
#include <unordered_map>
std::unordered_map<Mtx*, MtxF> FrameInterpolation_Interpolate(float step);
+void FrameInterpolation_ApplyMatrixTransformations(Mat4* matrix, FVector pos, IRotator rot, FVector scale);
extern "C" {
#endif
diff --git a/src/port/resource/importers/TrackSectionsFactory.cpp b/src/port/resource/importers/TrackSectionsFactory.cpp
index 2abce35d4..64a3b0a2f 100644
--- a/src/port/resource/importers/TrackSectionsFactory.cpp
+++ b/src/port/resource/importers/TrackSectionsFactory.cpp
@@ -44,9 +44,10 @@ ResourceFactoryXMLTrackSectionsV0::ReadResource(std::shared_ptr<Ship::File> file
if (!FileHasValidFormatAndReader(file, initData)) {
return nullptr;
}
-
+
auto section = std::make_shared<TrackSectionsO2RClass>(initData);
- auto child = std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement("TrackSections");
+ auto child =
+ std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement()->FirstChildElement();
while (child != nullptr) {
std::string childName = std::string(child->Name());
diff --git a/src/port/ui/ContentBrowser.cpp b/src/port/ui/ContentBrowser.cpp
index 5390d8a9d..ee109d290 100644
--- a/src/port/ui/ContentBrowser.cpp
+++ b/src/port/ui/ContentBrowser.cpp
@@ -127,7 +127,7 @@ namespace Editor {
if (!track.SceneFile.empty()) { // has scene file
std::string label = fmt::format("{}##{}", track.Name, i_track);
if (ImGui::Button(label.c_str())) {
- SetCourseByClass(track.course);
+ gWorldInstance.CurrentCourse = track.course;
gGamestateNext = RACING;
SetSceneFile(track.Archive, track.SceneFile);
break;
@@ -136,7 +136,7 @@ namespace Editor {
std::string label = fmt::format("{} {}", ICON_FA_EXCLAMATION_TRIANGLE, track.Name);
if (ImGui::Button(label.c_str())) {
track.SceneFile = track.Dir + "/scene.json";
- SetCourseByClass(track.course);
+ gWorldInstance.CurrentCourse = track.invalidTrack.get();
SetSceneFile(track.Archive, track.SceneFile);
SaveLevel();
Refresh = true;
@@ -240,10 +240,10 @@ namespace Editor {
auto course = std::make_unique<Course>();
course->LoadO2R(dir);
- gWorldInstance.Courses.push_back(std::move(course));
LoadLevel(archive, course.get(), sceneFile);
LoadMinimap(archive, course.get(), minimapFile);
- Tracks.push_back({course.get(), sceneFile, name, dir, archive});
+ Tracks.push_back({nullptr, course.get(), sceneFile, name, dir, archive});
+ gWorldInstance.Courses.push_back(std::move(course));
} else { // The track does not have a valid scene file
const std::string file = dir + "/data_track_sections";
@@ -256,9 +256,8 @@ namespace Editor {
course->Id = (std::string("mods:") + name).c_str();
course->Props.SetText(course->Props.Name, name.c_str(), sizeof(course->Props.Name));
course->Props.SetText(course->Props.DebugName, name.c_str(), sizeof(course->Props.Name));
-
auto archive = manager->GetArchiveFromFile(file);
- Tracks.push_back({course.get(), "", name, dir, archive});
+ Tracks.push_back({std::move(course), nullptr, "", name, dir, archive});
} else {
printf("ContentBrowser.cpp: Track '%s' missing required track files. Cannot add to game\n Missing %s/data_track_sections file\n", name.c_str(), dir.c_str());
}
diff --git a/src/port/ui/ContentBrowser.h b/src/port/ui/ContentBrowser.h
index f077f7283..001d1a3b3 100644
--- a/src/port/ui/ContentBrowser.h
+++ b/src/port/ui/ContentBrowser.h
@@ -10,7 +10,8 @@ public:
~ContentBrowserWindow();
struct Tracks {
- Course* course;
+ std::unique_ptr<Course> invalidTrack; // If not nullptr, user needs to create a scene file for this track.
+ Course* course; // A valid custom track. Used to reset the Courses array on a file system refresh.
std::string SceneFile;
std::string Name;
std::string Dir; // Directory