Skip to content

Commit

Permalink
dynamic resolution fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chirpxiv committed Jul 17, 2024
1 parent 323f623 commit 3f8c0f2
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions Ktisis/Structs/FFXIV/WorldMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ public bool WorldToScreen(Vector3 v, out Vector2 pos2d) {
public bool WorldToScreenDepth(Vector3 v, out Vector3 pos2d) {
var m = Matrix;

var windowPos = ImGuiHelpers.MainViewport.Pos;

float x = (m.M11 * v.X) + (m.M21 * v.Y) + (m.M31 * v.Z) + m.M41;
float y = (m.M12 * v.X) + (m.M22 * v.Y) + (m.M32 * v.Z) + m.M42;
float w = (m.M14 * v.X) + (m.M24 * v.Y) + (m.M34 * v.Z) + m.M44;

float camX = (Width / 2f);
float camY = (Height / 2f);
var x = (m.M11 * v.X) + (m.M21 * v.Y) + (m.M31 * v.Z) + m.M41;
var y = (m.M12 * v.X) + (m.M22 * v.Y) + (m.M32 * v.Z) + m.M42;
var w = (m.M14 * v.X) + (m.M24 * v.Y) + (m.M34 * v.Z) + m.M44;

var view = ImGuiHelpers.MainViewport;
var camX = (view.Size.X / 2f);
var camY = (view.Size.Y / 2f);
pos2d = new Vector3(
camX + (camX * x / w) + windowPos.X,
camY - (camY * y / w) + windowPos.Y,
camX + (camX * x / w) + view.Pos.X,
camY - (camY * y / w) + view.Pos.Y,
w
);

Expand Down

0 comments on commit 3f8c0f2

Please sign in to comment.