mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-20 06:47:44 +01:00
Merge #277
This commit is contained in:
commit
5baf0b6d8b
7 changed files with 73 additions and 37 deletions
|
|
@ -24,7 +24,7 @@ namespace Dalamud.Game.Internal.DXGI
|
|||
// This(code after the function head - offset of it) was picked to avoid running into issues with other hooks being installed into this function.
|
||||
Present = scanner.ScanModule("41 8B F0 8B FA 89 54 24 ?? 48 8B D9 48 89 4D ?? C6 44 24 ?? 00") - 0x37;
|
||||
|
||||
ResizeBuffers = scanner.ScanModule("45 8B CC 45 8B C5 33 D2 48 8B CF E8 ?? ?? ?? ?? 44 8B C0 48 8D 55 ?? 48 8D 4D ?? E8 ?? ?? ?? ?? 38 9F E8 02 00 00") - 0xA9;
|
||||
ResizeBuffers = scanner.ScanModule("48 8B C4 55 41 54 41 55 41 56 41 57 48 8D 68 B1 48 81 EC ?? ?? ?? ?? 48 C7 45 ?? ?? ?? ?? ?? 48 89 58 10 48 89 70 18 48 89 78 20 45 8B F9 45 8B E0 44 8B EA 48 8B F9 8B 45 7F 89 44 24 30 8B 75 77 89 74 24 28 44 89 4C 24");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Runtime.InteropServices;
|
||||
using Dalamud.Game.Chat.SeStringHandling.Payloads;
|
||||
using Dalamud.Hooking;
|
||||
using ImGuiNET;
|
||||
using Serilog;
|
||||
using SharpDX;
|
||||
|
||||
|
|
@ -289,6 +290,8 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
// Read current ViewProjectionMatrix plus game window size
|
||||
var viewProjectionMatrix = new Matrix();
|
||||
float width, height;
|
||||
var windowPos = ImGui.GetMainViewport().Pos;
|
||||
|
||||
unsafe {
|
||||
var rawMatrix = (float*) (matrixSingleton + 0x1b4).ToPointer();
|
||||
|
||||
|
|
@ -303,10 +306,12 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
|
||||
screenPos = new Vector2(pCoords.X / pCoords.Z, pCoords.Y / pCoords.Z);
|
||||
|
||||
screenPos.X = 0.5f * width * (screenPos.X + 1f);
|
||||
screenPos.Y = 0.5f * height * (1f - screenPos.Y);
|
||||
screenPos.X = 0.5f * width * (screenPos.X + 1f) + windowPos.X;
|
||||
screenPos.Y = 0.5f * height * (1f - screenPos.Y) + windowPos.Y;
|
||||
|
||||
return pCoords.Z > 0;
|
||||
return pCoords.Z > 0 &&
|
||||
screenPos.X > windowPos.X && screenPos.X < windowPos.X + width &&
|
||||
screenPos.Y > windowPos.Y && screenPos.Y < windowPos.Y + height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -318,6 +323,18 @@ namespace Dalamud.Game.Internal.Gui {
|
|||
/// <returns>True if successful. On false, worldPos's contents are undefined</returns>
|
||||
public bool ScreenToWorld(Vector2 screenPos, out Vector3 worldPos, float rayDistance = 100000.0f)
|
||||
{
|
||||
// The game is only visible in the main viewport, so if the cursor is outside
|
||||
// of the game window, do not bother calculating anything
|
||||
var windowPos = ImGui.GetMainViewport().Pos;
|
||||
var windowSize = ImGui.GetMainViewport().Size;
|
||||
|
||||
if (screenPos.X < windowPos.X || screenPos.X > windowPos.X + windowSize.X ||
|
||||
screenPos.Y < windowPos.Y || screenPos.Y > windowPos.Y + windowSize.Y)
|
||||
{
|
||||
worldPos = new Vector3();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get base object with matrices
|
||||
var matrixSingleton = this.getMatrixSingleton();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue