sead icon indicating copy to clipboard operation
sead copied to clipboard

RFC Projection try 2

Open Esras opened this issue 5 months ago • 4 comments

Try 2.

This PR attempts to implement many of the Projection libraries and tries to update their dependencies where needed and from @aboood40091's repo.

Goals

  • Implement more of the Projection libraries, including what appear to be the Perspective, Ortho, Frustum, and Direct projections.
  • Include the Graphics, Viewport, and DrawContext library updates that @aboood40091 had worked on.

Addresses 0xB1D898 - 0xB1F2B0 are the bulk of the Projection functions in BotW. 0xB1FFF0 - 0xB20718 are the sead::Viewport functions

Waiting on dependencies

Projection::unproject(Ray<>, ...)

Non-Matching Functions

Viewport::apply Viewport::applyViewport Viewport::applyScissor

Projection::doScreenPosToCameraPosTo(sead::Vector3<float>*, sead::Vector3<float> const&) const In trying to remember from when I was doing this originally, this looks like it's mostly just registers moving around?

Projection::project(sead::Vector2<float>*, sead::Vector3<float> const&, sead::Viewport const&) const If I'm reading this right, it's just loading an offset into the register and using that to jump instead of jumping to the absolute address - could be because of other function sizes messed up?

Projection::unproject(sead::Vector3<float>*, sead::Vector3<float> const&, sead::Camera const&) const Projection::doUpdateDeviceMatrix(sead::Matrix44<float>*, sead::Matrix44<float> const&, sead::Graphics::DevicePosture) const

PerspectiveProjection::PerspectiveProjection()

OrthoProjection::OrthoProjection() OrthoProjection::OrthoProjection(float, float, sead::Viewport const&) OrthoProjection::setByViewport(sead::Viewport const&) OrthoProjection::doUpdateMatrix(sead::Matrix44<float>*) const FrustumProjection::doScreenPosToCameraPosTo(Vector3f, Vector3f) DirectProjection::DirectProjection() DirectProjection::DirectProjection(sead::Matrix44<float> const*, sead::Graphics::DevicePosture) DirectProjection::setDirectProjectionMatrix(sead::Matrix44<float> const*, sead::Graphics::DevicePosture) DirectProjection::updateAttributesForDirectProjection() DirectProjection::doUpdateMatrix(sead::Matrix44<float>*) const DirectProjection::doScreenPosToCameraPosTo(sead::Vector3<float>*, sead::Vector3<float> const&) const

In the prior PR, the static_assert in seadGraphicsNvn.h had been commented out because it was failing while editing. I'm not entirely sure if that's related to the work here.

Next Steps I'm looking for feedback on the non-matching functions, and which of the library files that have been modified that need to be updated here.

Note that in the two years since I wrote the initial one, I'm not entirely sure about what I mean by the library files anymore. I think mostly Ray.


This change is Reviewable

Esras avatar Jul 28 '25 03:07 Esras

I just pushed an update that added some things to the Camera, Projection, and Viewport libs. In a few cases, the matrix math can likely be simplified by some of the internal CalcCommon functions, in other cases I'm looking for, "What am I missing?"

For instance, I think once sead::Projection::doScreenPosToCameraPosTo is fixed, some of the other non-matching functions in the Projection lib will match.

Esras avatar Aug 07 '25 21:08 Esras

I have an implementation of Ray that I currently have in seadGeometry.h (though not in the sead::Geometry namespace) as part of some WIP. Should it just be its own seadRay.h? As I dug around, I definitely think it's "position" and "direction" for the vector type, done right now without any other complexity as:

template <typename T>
struct Ray
{
    Ray();

    T position;
    T direction;
};

I've changed the constructors, is there something I'm missing in terms of when they're = default; in the header vs. the trivial implementation in the cpp, or is it more that they aren't the trivial constructor (and I just created them for purposes of making names for uking_functions.csv?

Esras avatar Aug 23 '25 21:08 Esras

Should be in geom/seadLine.h. It's a class with two members: mP and mD. I recommend adding two typedefs: Ray2f and Ray3f.

aboood40091 avatar Aug 24 '25 02:08 aboood40091

I just noticed you implemented projection here. I just did just the base projection implementation in #228

Since it wasn't my intention to "steal" any of your work I can either add you as a co-autor or close my PR and help this PR so is up to standard and get it merged.

german77 avatar Nov 20 '25 19:11 german77