perf: removed old position flipping on MonoGame
This commit is contained in:
@@ -73,7 +73,7 @@ public class MonoGameCamera2D : Behaviour, ICamera2D, IFirstFrameUpdate, ILastFr
|
||||
public Vector2D ScreenToWorldPosition(Vector2D screenPosition)
|
||||
{
|
||||
float x = 2f * screenPosition.X / Viewport.Width - 1f;
|
||||
float y = 2f * screenPosition.Y / Viewport.Height - 1f;
|
||||
float y = 1f - 2f * screenPosition.Y / Viewport.Height;
|
||||
Vector4D normalizedCoordinates = new(x, y, 0f, 1f);
|
||||
|
||||
Matrix4x4 invertedViewProjectionMatrix = (ProjectionMatrix * ViewMatrix).Inverse;
|
||||
@@ -97,7 +97,7 @@ public class MonoGameCamera2D : Behaviour, ICamera2D, IFirstFrameUpdate, ILastFr
|
||||
clip /= clip.W;
|
||||
|
||||
float screenX = (clip.X + 1f) * .5f * Viewport.Width;
|
||||
float screenY = (clip.Y + 1f) * .5f * Viewport.Height;
|
||||
float screenY = (1f - clip.Y) * .5f * Viewport.Height;
|
||||
|
||||
return new(screenX, screenY);
|
||||
}
|
||||
@@ -112,9 +112,9 @@ public class MonoGameCamera2D : Behaviour, ICamera2D, IFirstFrameUpdate, ILastFr
|
||||
|
||||
public void PreDraw()
|
||||
{
|
||||
ProjectionMatrix = Matrix4x4.CreateOrthographicViewCentered(Viewport.Width, -Viewport.Height);
|
||||
ProjectionMatrix = Matrix4x4.CreateOrthographicViewCentered(Viewport.Width, Viewport.Height);
|
||||
ViewMatrix =
|
||||
Matrix4x4.CreateTranslation(new Vector3D(-Transform.Position.X, Transform.Position.Y, 0f))
|
||||
Matrix4x4.CreateTranslation(new Vector3D(-Transform.Position.X, -Transform.Position.Y, 0f))
|
||||
.ApplyRotationZ(Transform.Rotation * Math.DegreeToRadian)
|
||||
.ApplyScale(Transform.Scale.X.Max(Transform.Scale.Y))
|
||||
.ApplyScale(Zoom);
|
||||
|
||||
Reference in New Issue
Block a user