Skip to content

Commit 3f8c0f2

Browse files
committed
dynamic resolution fix
1 parent 323f623 commit 3f8c0f2

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

Ktisis/Structs/FFXIV/WorldMatrix.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ public bool WorldToScreen(Vector3 v, out Vector2 pos2d) {
2222
public bool WorldToScreenDepth(Vector3 v, out Vector3 pos2d) {
2323
var m = Matrix;
2424

25-
var windowPos = ImGuiHelpers.MainViewport.Pos;
26-
27-
float x = (m.M11 * v.X) + (m.M21 * v.Y) + (m.M31 * v.Z) + m.M41;
28-
float y = (m.M12 * v.X) + (m.M22 * v.Y) + (m.M32 * v.Z) + m.M42;
29-
float w = (m.M14 * v.X) + (m.M24 * v.Y) + (m.M34 * v.Z) + m.M44;
30-
31-
float camX = (Width / 2f);
32-
float camY = (Height / 2f);
25+
var x = (m.M11 * v.X) + (m.M21 * v.Y) + (m.M31 * v.Z) + m.M41;
26+
var y = (m.M12 * v.X) + (m.M22 * v.Y) + (m.M32 * v.Z) + m.M42;
27+
var w = (m.M14 * v.X) + (m.M24 * v.Y) + (m.M34 * v.Z) + m.M44;
3328

29+
var view = ImGuiHelpers.MainViewport;
30+
var camX = (view.Size.X / 2f);
31+
var camY = (view.Size.Y / 2f);
3432
pos2d = new Vector3(
35-
camX + (camX * x / w) + windowPos.X,
36-
camY - (camY * y / w) + windowPos.Y,
33+
camX + (camX * x / w) + view.Pos.X,
34+
camY - (camY * y / w) + view.Pos.Y,
3735
w
3836
);
3937

0 commit comments

Comments
 (0)