Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
cc15b22
Fix the header declaration of the Matrix44<T>::setRow function.
Jul 28, 2025
41ce93d
Try 2 at the Projection libraries. Copying over from the prior PR (#1…
Jul 28, 2025
e473dc2
engine/geom: Add Segment
aboood40091 Apr 17, 2023
20a9e8e
Add a vectorized copy function for 4x4 f32 Matrices, guarded by NNSDK…
Aug 9, 2026
8dfce9d
With copious help from GRAnimated (read: linked me the matched functi…
Aug 10, 2026
b3dbe2a
Minor fixing up to names / templates for Geometry and Segment.
Aug 10, 2026
6a91967
Match PerspectiveProjection::getOffset, does assignment based on indi…
Aug 10, 2026
1169fbc
Match the remaining Projection functions in sead against BotW.
Aug 11, 2026
467ccf6
Minor corrections based on earlier feedback on the PR.
Aug 11, 2026
3950cb4
Move PerspectiveProjection::get* functions from the header to the cpp…
Aug 12, 2026
9c7ec64
Move more header functions into the CPP for Projection functions. Add…
Aug 12, 2026
f720a83
Update the getOffsetX and getOffsetY functions according to the SMO d…
Aug 12, 2026
d00a838
Match the remaining camera functions, at least as they show up in Bot…
Aug 12, 2026
594dbbd
Rename the mDepthBound -> mDepthRange, based on the nvn commands bein…
Aug 12, 2026
0f1c9a6
Add a guard for the mDepthRange on the Viewport function so that it w…
Aug 12, 2026
8c1a68c
Remove the base Projection::doScreenPos... function - it's supposed t…
Aug 12, 2026
ba7cf04
Move functions out of the CPP and into the header - they're all inlined.
Aug 12, 2026
63d9f32
Remove the normalizeUp function in favor of folding its usage directl…
Aug 12, 2026
8d1bc9e
Remove unused GraphicsContext port and dead FrustumProjection(BoundBo…
Aug 14, 2026
136aa69
Restore LookAtCamera::normalizeUp() for SMO compat
Aug 14, 2026
2d9f2e5
Revert "Restore LookAtCamera::normalizeUp() for SMO compat"
Aug 14, 2026
e0013cb
Add back an empty LookAtCamera::normalizeUp() so SMO compiles.
Aug 14, 2026
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ add_library(sead OBJECT
include/gfx/seadDrawContext.h
include/gfx/seadDrawLockContext.h
include/gfx/seadFrameBuffer.h
include/gfx/seadGraphics.h
include/gfx/seadViewport.h
include/gfx/seadPrimitiveRenderer.h
include/gfx/seadPrimitiveRendererUtil.h
include/gfx/seadProjection.h
Expand All @@ -112,6 +114,8 @@ add_library(sead OBJECT
modules/src/gfx/seadColor.cpp
modules/src/gfx/seadDrawLockContext.cpp
modules/src/gfx/seadFrameBuffer.cpp
modules/src/gfx/seadGraphics.cpp
modules/src/gfx/seadViewport.cpp
# modules/src/gfx/seadPrimitiveRenderer.cpp
# modules/src/gfx/seadPrimitiveRendererUtil.cpp
modules/src/gfx/seadProjection.cpp
Expand Down Expand Up @@ -155,6 +159,8 @@ add_library(sead OBJECT
modules/src/math/seadQuat.cpp
modules/src/math/seadVector.cpp

include/geom/seadLine.h

include/mc/seadCoreInfo.h
include/mc/seadJob.h
include/mc/seadJobQueue.h
Expand Down
55 changes: 55 additions & 0 deletions include/geom/seadLine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once

#include <math/seadVector.h>

namespace sead
{

template <typename T>
class Segment
{
public:
Segment() = default;
Segment(const T& p0, const T& p1) : mP0(p0), mP1(p1) {}

const T& getPos0() const { return mP0; }
void setPos0(const T& p0) { mP0 = p0; }

const T& getPos1() const { return mP1; }
void setPos1(const T& p1) { mP1 = p1; }

private:
T mP0 = T::zero;
T mP1 = T::ex;
};

using Segment2f = Segment<Vector2f>;
using Segment3f = Segment<Vector3f>;

#ifdef cafe
static_assert(sizeof(Segment2f) == 0x10, "sead::Segment<T> size mismatch");
static_assert(sizeof(Segment3f) == 0x18, "sead::Segment<T> size mismatch");
#endif // cafe

template <typename T>
class Ray
{
public:
Ray() = default;
Ray(const T& p, const T& d) : mP(p), mD(d) {}

const T& getPos() const { return mP; }
void setPos(const T& p) { mP = p; }

const T& getDir() const { return mD; }
void setDir(const T& d) { mD = d; }

private:
T mP;
T mD;
};

using Ray2f = Ray<Vector2f>;
using Ray3f = Ray<Vector3f>;

} // namespace sead
16 changes: 10 additions & 6 deletions include/gfx/seadCamera.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <geom/seadLine.h>
#include <math/seadMatrix.h>
#include <math/seadVector.h>
#include <prim/seadRuntimeTypeInfo.h>
Expand All @@ -9,8 +10,6 @@ namespace sead
class OrthoProjection;
class Projection;
class Viewport;
template <typename T>
class Ray;

class Camera
{
Expand All @@ -32,7 +31,7 @@ class Camera

void projectByMatrix(Vector2f* dst, const Vector3f& world_pos, const Projection& projection,
const Viewport& viewport) const;
void unprojectRayByMatrix(Ray<Vector3f>* dst, const Vector3f& camera_pos) const;
void unprojectRayByMatrix(Ray3f* dst, const Vector3f& camera_pos) const;

Matrix34f& getMatrix() { return mMatrix; }
const Matrix34f& getMatrix() const { return mMatrix; }
Expand All @@ -59,14 +58,18 @@ class LookAtCamera : public Camera

void setPos(const Vector3f& pos) { mPos = pos; }
void setAt(const Vector3f& at) { mAt = at; }
void setUp(const Vector3f& up) { mUp = up; }
void setUp(const Vector3f& up)
{
mUp = up;
mUp.normalize();
}
void normalizeUp() {}

void normalizeUp() { mUp.normalize(); }
void addPos(const Vector3f& pos) { mPos += pos; }
void addAt(const Vector3f& at) { mAt += at; }

private:
Vector3f mPos = {0.0f, 0.0f, 10.0f};
Vector3f mPos = {0.0f, 0.0f, 1.0f};
Vector3f mAt = {0.0f, 0.0f, 0.0f};
Vector3f mUp = {0.0f, 1.0f, 0.0f};
};
Expand All @@ -75,6 +78,7 @@ class DirectCamera : public Camera
{
SEAD_RTTI_OVERRIDE(DirectCamera, Camera)
public:
DirectCamera() = default;
~DirectCamera() override;

void doUpdateMatrix(Matrix34f* dst) const override;
Expand Down
8 changes: 8 additions & 0 deletions include/gfx/seadGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ class Graphics : public IDisposer
virtual void setPolygonOffsetEnableImpl(bool, bool, bool) = 0;

static Graphics* instance() { return sInstance; }

static DevicePosture getDefaultDevicePosture() { return sDefaultDevicePosture; }
static f32 getDefaultDeviceZScale() { return sDefaultDeviceZScale; }
static f32 getDefaultDeviceZOffset() { return sDefaultDeviceZOffset; }

void setViewportRealPosition(f32 x, f32 y, f32 w, f32 h) { setViewportImpl(x, y, w, h); }
void setScissorRealPosition(f32 x, f32 y, f32 w, f32 h) { setScissorImpl(x, y, w, h); }

static DevicePosture sDefaultDevicePosture;
static f32 sDefaultDeviceZScale;
static f32 sDefaultDeviceZOffset;
Expand Down
Loading