From de9c5d510175bba11ab8704e67be3a3a94f9149e Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 9 Nov 2025 19:07:44 -0700 Subject: Implement SpawnParams struct (#536) * Impl SpawnParams * Added json submodule * Update json * Update * Works * Remove comment * Works refactor * Snowman and thwomp working * Impl hot air balloon * More progress * All OObjects are done * cleanup * Refactor 2Dpath to normal path * Update nlohmann json & fix compile * Rest of actors * MORE CHANGES * Finish actors * Done PR, some fix to collision viewer * Impl falling rocks * Add const * wip editor refactor * Property work * continue * Overridable editor properties * Actor saving/loading works now * Fix light alignment * Clarification * Impl penguin * params impl signs * properties impl falling rock * More property impls * impl air balloon * Add spawnParams to OObject Translate * Snowman translate better * impl hedgehog properly * properties impl trophy * thwomp progress * Finish impl properties * Fix compile * Fix cursor collisions * Move registered actors * Rename pathPoint XYZ to xyz * Fix editor pause bug * Clean up * Review comments * Remove SpawnParams struct from actor classes * Rename * Player Label First Iteration * Work now * Working 3d text * Fix boo bug * Finish AText actor * Fix spawnparams compile * Register AText * Finish Text Actor * Fix thwomp interpolation * Fix compile * Fix crab and hedgehog * Fix loading flagpole * Fix Hot Air Balloon * Turn zbuffer on for AText * Update --------- Co-authored-by: MegaMech <7255464+MegaMech@users.noreply.github.com> --- src/engine/editor/EditorMath.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/engine/editor/EditorMath.cpp') diff --git a/src/engine/editor/EditorMath.cpp b/src/engine/editor/EditorMath.cpp index f541d92f2..38a1fff5e 100644 --- a/src/engine/editor/EditorMath.cpp +++ b/src/engine/editor/EditorMath.cpp @@ -42,12 +42,13 @@ bool IsInGameScreen() { FVector ScreenRayTrace() { auto wnd = GameEngine::Instance->context->GetWindow(); - Camera* camera = &cameras[0]; + Camera* camera = gEditor.eCamera; Ship::Coords mouse = wnd->GetMousePos(); auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport; mouse.x -= gfx_current_game_window_viewport.x; mouse.y -= gfx_current_game_window_viewport.y; + // Get screen dimensions uint32_t width = OTRGetGameViewportWidth(); uint32_t height = OTRGetGameViewportHeight(); @@ -285,7 +286,6 @@ std::optional QueryHandleIntersection(MtxF mtx, Ray ray, const Triangle if (IntersectRayTriangle(localRay, tri, t)) { FVector localClickPosition = localRay.Origin + localRay.Direction * t; FVector worldClickPosition = TransformVecByMatrix(localClickPosition, (float(*)[4])&mtx); - return worldClickPosition; // Stop checking objects if we selected a Gizmo handle } return std::nullopt; @@ -381,8 +381,9 @@ float CalculateAngle(const FVector& start, const FVector& end) { } void SetDirectionFromRotator(IRotator rot, s8 direction[3]) { + rot.yaw += 0xC000; //! @warning dumb hack to align the light properly float yaw = (rot.yaw) * (M_PI / 32768.0f); // Convert from n64 binary angles 0-0xFFFF 0-360 degrees to radians - float pitch = rot.pitch * (M_PI / 32768.0f); + float pitch = rot.pitch * (M_PI / 32768.0f); // Compute unit direction vector float x = cosf(yaw) * cosf(pitch); @@ -411,10 +412,11 @@ void SetRotatorFromDirection(FVector direction, IRotator* rot) { } FVector GetPositionAheadOfCamera(f32 dist) { - FVector pos = FVector(cameras[0].pos[0], cameras[0].pos[1], cameras[0].pos[2]); + Camera* camera = gEditor.eCamera; + FVector pos = FVector(camera->pos[0], camera->pos[1], camera->pos[2]); - f32 pitch = (cameras[0].rot[2] / 65535.0f) * 360.0f; - f32 yaw = (cameras[0].rot[1] / 65535.0f) * 360.0f; + f32 pitch = (camera->rot[2] / 65535.0f) * 360.0f; + f32 yaw = (camera->rot[1] / 65535.0f) * 360.0f; // Convert degrees to radians pitch = pitch * M_PI / 180.0f; @@ -422,7 +424,7 @@ FVector GetPositionAheadOfCamera(f32 dist) { // Compute forward vector FVector forward( - -sinf(yaw), // X + sinf(yaw), // X -sinf(pitch), // Y cosf(yaw) // Z (vertical component) ); -- cgit v1.2.3