mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
Merge pull request #1035 from pohky/master
This commit is contained in:
commit
a4c2547549
1 changed files with 7 additions and 17 deletions
|
|
@ -8,6 +8,7 @@ using Dalamud.Interface;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
|
||||||
using FFXIVClientStructs.FFXIV.Client.System.String;
|
using FFXIVClientStructs.FFXIV.Client.System.String;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Component.GUI;
|
using FFXIVClientStructs.FFXIV.Component.GUI;
|
||||||
|
|
@ -190,25 +191,14 @@ public sealed unsafe class GameGui : IDisposable, IServiceType
|
||||||
var matrixSingleton = this.getMatrixSingleton();
|
var matrixSingleton = this.getMatrixSingleton();
|
||||||
|
|
||||||
// Read current ViewProjectionMatrix plus game window size
|
// Read current ViewProjectionMatrix plus game window size
|
||||||
var viewProjectionMatrix = default(SharpDX.Matrix);
|
|
||||||
float width, height;
|
|
||||||
var windowPos = ImGuiHelpers.MainViewport.Pos;
|
var windowPos = ImGuiHelpers.MainViewport.Pos;
|
||||||
|
var viewProjectionMatrix = *(Matrix4x4*)(matrixSingleton + 0x1b4);
|
||||||
|
var device = Device.Instance();
|
||||||
|
float width = device->Width;
|
||||||
|
float height = device->Height;
|
||||||
|
|
||||||
unsafe
|
var pCoords = Vector3.Transform(worldPos, viewProjectionMatrix);
|
||||||
{
|
screenPos = new Vector2(pCoords.X / MathF.Abs(pCoords.Z), pCoords.Y / MathF.Abs(pCoords.Z));
|
||||||
var rawMatrix = (float*)(matrixSingleton + 0x1b4).ToPointer();
|
|
||||||
|
|
||||||
for (var i = 0; i < 16; i++, rawMatrix++)
|
|
||||||
viewProjectionMatrix[i] = *rawMatrix;
|
|
||||||
|
|
||||||
width = *rawMatrix;
|
|
||||||
height = *(rawMatrix + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
var worldPosDx = worldPos.ToSharpDX();
|
|
||||||
SharpDX.Vector3.Transform(ref worldPosDx, ref viewProjectionMatrix, out SharpDX.Vector3 pCoords);
|
|
||||||
|
|
||||||
screenPos = new Vector2(pCoords.X / pCoords.Z, pCoords.Y / pCoords.Z);
|
|
||||||
|
|
||||||
screenPos.X = (0.5f * width * (screenPos.X + 1f)) + windowPos.X;
|
screenPos.X = (0.5f * width * (screenPos.X + 1f)) + windowPos.X;
|
||||||
screenPos.Y = (0.5f * height * (1f - screenPos.Y)) + windowPos.Y;
|
screenPos.Y = (0.5f * height * (1f - screenPos.Y)) + windowPos.Y;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue