muffin v7.5.5
This commit is contained in:
parent
a8f2c1df37
commit
6266f9e6b7
110 changed files with 14907 additions and 6073 deletions
64
Auspex/Auspex.Rendering.ImGuiFallback/FallbackClipMath.cs
Normal file
64
Auspex/Auspex.Rendering.ImGuiFallback/FallbackClipMath.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Dalamud.Interface.Utility;
|
||||
|
||||
namespace Auspex.Rendering.ImGuiFallback;
|
||||
|
||||
internal static class FallbackClipMath
|
||||
{
|
||||
public enum LineClipStatus
|
||||
{
|
||||
NotVisible,
|
||||
NotClipped,
|
||||
A_Clipped,
|
||||
B_Clipped
|
||||
}
|
||||
|
||||
public static Vector3 XYZ(this Vector4 v)
|
||||
{
|
||||
return new Vector3(v.X, v.Y, v.Z);
|
||||
}
|
||||
|
||||
public static LineClipStatus ClipLineToPlane(Vector4 plane, ref Vector3 a, ref Vector3 b, out float t)
|
||||
{
|
||||
t = 0f;
|
||||
float num = Vector4.Dot(new Vector4(a, 1f), plane);
|
||||
float num2 = Vector4.Dot(new Vector4(b, 1f), plane);
|
||||
bool flag = num < 0f;
|
||||
bool flag2 = num2 < 0f;
|
||||
if (flag && flag2)
|
||||
{
|
||||
return LineClipStatus.NotClipped;
|
||||
}
|
||||
if (!flag && !flag2)
|
||||
{
|
||||
return LineClipStatus.NotVisible;
|
||||
}
|
||||
Vector3 vector = b - a;
|
||||
t = (0f - num) / Vector3.Dot(vector, plane.XYZ());
|
||||
Vector3 vector2 = a + vector * t;
|
||||
if (flag)
|
||||
{
|
||||
b = vector2;
|
||||
return LineClipStatus.B_Clipped;
|
||||
}
|
||||
a = vector2;
|
||||
return LineClipStatus.A_Clipped;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void TransformCoordinate(in Vector3 coordinate, in Matrix4x4 transform, out Vector3 result)
|
||||
{
|
||||
result.X = coordinate.X * transform.M11 + coordinate.Y * transform.M21 + coordinate.Z * transform.M31 + transform.M41;
|
||||
result.Y = coordinate.X * transform.M12 + coordinate.Y * transform.M22 + coordinate.Z * transform.M32 + transform.M42;
|
||||
result.Z = coordinate.X * transform.M13 + coordinate.Y * transform.M23 + coordinate.Z * transform.M33 + transform.M43;
|
||||
float num = 1f / (coordinate.X * transform.M14 + coordinate.Y * transform.M24 + coordinate.Z * transform.M34 + transform.M44);
|
||||
result *= num;
|
||||
}
|
||||
|
||||
public static Vector2 WorldToScreenOld(in Matrix4x4 viewProj, in Vector3 worldPos)
|
||||
{
|
||||
TransformCoordinate(in worldPos, in viewProj, out var result);
|
||||
return new Vector2(0.5f * ImGuiHelpers.MainViewport.Size.X * (1f + result.X), 0.5f * ImGuiHelpers.MainViewport.Size.Y * (1f - result.Y)) + ImGuiHelpers.MainViewport.Pos;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using Dalamud.Bindings.ImGui;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game.Control;
|
||||
using FFXIVClientStructs.FFXIV.Client.Graphics.Render;
|
||||
|
||||
namespace Auspex.Rendering.ImGuiFallback;
|
||||
|
||||
internal sealed class ImGuiFallbackRenderer
|
||||
{
|
||||
private readonly ImDrawListPtr drawList;
|
||||
|
||||
private readonly Matrix4x4 viewProj;
|
||||
|
||||
private readonly Vector4 nearPlane;
|
||||
|
||||
public unsafe ImGuiFallbackRenderer(ImDrawListPtr drawList)
|
||||
{
|
||||
this.drawList = drawList;
|
||||
viewProj = Control.Instance()->ViewProjectionMatrix;
|
||||
FFXIVClientStructs.FFXIV.Client.Game.Camera* activeCamera = Control.Instance()->CameraManager.GetActiveCamera();
|
||||
FFXIVClientStructs.FFXIV.Client.Graphics.Render.Camera* ptr = ((activeCamera != null) ? activeCamera->SceneCamera.RenderCamera : null);
|
||||
if (ptr == null)
|
||||
{
|
||||
nearPlane = new Vector4(viewProj.M13, viewProj.M23, viewProj.M33, viewProj.M43);
|
||||
return;
|
||||
}
|
||||
if (!Matrix4x4.Invert(ptr->ProjectionMatrix, out var result))
|
||||
{
|
||||
nearPlane = new Vector4(viewProj.M13, viewProj.M23, viewProj.M33, viewProj.M43);
|
||||
return;
|
||||
}
|
||||
Matrix4x4 matrix4x = viewProj * result;
|
||||
nearPlane = new Vector4(matrix4x.M13, matrix4x.M23, matrix4x.M33, matrix4x.M43 + ptr->NearPlane);
|
||||
}
|
||||
|
||||
public void DrawStroke(List<Vector3> world, float thickness, uint color, bool closed = false, float dashLength = 0f, float gapLength = 0f, float dashOffset = 0f, uint? colorEnd = null, AxLineCap cap = AxLineCap.Butt, AxLineJoin join = AxLineJoin.None)
|
||||
{
|
||||
if (world.Count != 0)
|
||||
{
|
||||
for (int i = 1; i < world.Count; i++)
|
||||
{
|
||||
DrawStroke(world[i - 1], world[i], thickness, color);
|
||||
}
|
||||
if (closed)
|
||||
{
|
||||
DrawStroke(world[world.Count - 1], world[0], thickness, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawStroke(Vector3 start, Vector3 stop, float thickness, uint color)
|
||||
{
|
||||
if (FallbackClipMath.ClipLineToPlane(nearPlane, ref start, ref stop, out var _) != FallbackClipMath.LineClipStatus.NotVisible)
|
||||
{
|
||||
drawList.PathClear();
|
||||
drawList.PathLineTo(FallbackClipMath.WorldToScreenOld(in viewProj, in start));
|
||||
drawList.PathLineTo(FallbackClipMath.WorldToScreenOld(in viewProj, in stop));
|
||||
drawList.PathStroke(color, ImDrawFlags.None, thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue