mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
eliminate pointless M11-M44 get/set in Matrix4
This commit is contained in:
parent
7a77a34b14
commit
38ea2919c2
@ -371,7 +371,7 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
|
||||
public unsafe override void LoadMatrix(ref Matrix4 matrix) {
|
||||
if (curStack == texStack) {
|
||||
matrix.M31 = matrix.M41; // NOTE: this hack fixes the texture movements.
|
||||
matrix.Row2.X = matrix.Row3.X; // NOTE: this hack fixes the texture movements.
|
||||
device.SetTextureStageState(0, TextureStage.TextureTransformFlags, (int)TextureTransform.Count2);
|
||||
}
|
||||
curStack.SetTop(ref matrix);
|
||||
@ -567,9 +567,8 @@ namespace ClassicalSharp.GraphicsAPI {
|
||||
Matrix4 matrix;
|
||||
Matrix4.CreateOrthographicOffCenter(0, width, height, 0, -10000, 10000, out matrix);
|
||||
const float zN = -10000, zF = 10000;
|
||||
matrix.M33 = 1 / (zN - zF);
|
||||
matrix.M43 = zN / (zN - zF);
|
||||
matrix.M44 = 1;
|
||||
matrix.Row2.Z = 1 / (zN - zF);
|
||||
matrix.Row3.Z = zN / (zN - zF);
|
||||
curStack.SetTop(ref matrix);
|
||||
}
|
||||
|
||||
|
@ -60,54 +60,6 @@ namespace OpenTK {
|
||||
Row3 = new Vector4(m30, m31, m32, m33);
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the value at row 1, column 1 of this instance. </summary>
|
||||
public float M11 { get { return Row0.X; } set { Row0.X = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 1, column 2 of this instance. </summary>
|
||||
public float M12 { get { return Row0.Y; } set { Row0.Y = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 1, column 3 of this instance. </summary>
|
||||
public float M13 { get { return Row0.Z; } set { Row0.Z = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 1, column 4 of this instance. </summary>
|
||||
public float M14 { get { return Row0.W; } set { Row0.W = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 2, column 1 of this instance. </summary>
|
||||
public float M21 { get { return Row1.X; } set { Row1.X = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 2, column 2 of this instance. </summary>
|
||||
public float M22 { get { return Row1.Y; } set { Row1.Y = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 2, column 3 of this instance. </summary>
|
||||
public float M23 { get { return Row1.Z; } set { Row1.Z = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 2, column 4 of this instance. </summary>
|
||||
public float M24 { get { return Row1.W; } set { Row1.W = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 3, column 1 of this instance. </summary>
|
||||
public float M31 { get { return Row2.X; } set { Row2.X = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 3, column 2 of this instance. </summary>
|
||||
public float M32 { get { return Row2.Y; } set { Row2.Y = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 3, column 3 of this instance. </summary>
|
||||
public float M33 { get { return Row2.Z; } set { Row2.Z = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 3, column 4 of this instance. </summary>
|
||||
public float M34 { get { return Row2.W; } set { Row2.W = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 4, column 1 of this instance. </summary>
|
||||
public float M41 { get { return Row3.X; } set { Row3.X = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 4, column 2 of this instance. </summary>
|
||||
public float M42 { get { return Row3.Y; } set { Row3.Y = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 4, column 3 of this instance. </summary>
|
||||
public float M43 { get { return Row3.Z; } set { Row3.Z = value; } }
|
||||
|
||||
/// <summary> Gets or sets the value at row 4, column 4 of this instance. </summary>
|
||||
public float M44 { get { return Row3.W; } set { Row3.W = value; } }
|
||||
|
||||
public static void RotateX(out Matrix4 result, float angle) {
|
||||
float cos = (float)Math.Cos(angle);
|
||||
float sin = (float)Math.Sin(angle);
|
||||
@ -157,14 +109,14 @@ namespace OpenTK {
|
||||
float invTB = 1 / (top - bottom);
|
||||
float invFN = 1 / (zFar - zNear);
|
||||
|
||||
result.M11 = 2 * invRL;
|
||||
result.M22 = 2 * invTB;
|
||||
result.M33 = -2 * invFN;
|
||||
result.Row0.X = 2 * invRL;
|
||||
result.Row1.Y = 2 * invTB;
|
||||
result.Row2.Z = -2 * invFN;
|
||||
|
||||
result.M41 = -(right + left) * invRL;
|
||||
result.M42 = -(top + bottom) * invTB;
|
||||
result.M43 = -(zFar + zNear) * invFN;
|
||||
result.M44 = 1;
|
||||
result.Row3.X = -(right + left) * invRL;
|
||||
result.Row3.Y = -(top + bottom) * invTB;
|
||||
result.Row3.Z = -(zFar + zNear) * invFN;
|
||||
result.Row3.W = 1;
|
||||
}
|
||||
|
||||
public static void CreatePerspectiveFieldOfView(float fovy, float aspect, float zNear, float zFar, out Matrix4 result) {
|
||||
|
@ -114,10 +114,10 @@ namespace OpenTK.Platform.MacOS {
|
||||
{
|
||||
IntPtr windowRef = carbonWindow.WindowRef;
|
||||
|
||||
if (!CarbonGLNative.WindowRefMap.ContainsKey(windowRef))
|
||||
if (!CarbonGLNative.WindowRefs.ContainsKey(windowRef))
|
||||
return IntPtr.Zero;
|
||||
|
||||
WeakReference nativeRef = CarbonGLNative.WindowRefMap[windowRef];
|
||||
WeakReference nativeRef = CarbonGLNative.WindowRefs[windowRef];
|
||||
if (!nativeRef.IsAlive)
|
||||
return IntPtr.Zero;
|
||||
|
||||
@ -176,7 +176,7 @@ namespace OpenTK.Platform.MacOS {
|
||||
|
||||
private CarbonGLNative GetCarbonWindow(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
WeakReference r = CarbonGLNative.WindowRefMap[carbonWindow.WindowRef];
|
||||
WeakReference r = CarbonGLNative.WindowRefs[carbonWindow.WindowRef];
|
||||
return r.IsAlive ? (CarbonGLNative)r.Target : null;
|
||||
}
|
||||
|
||||
|
@ -48,20 +48,17 @@ namespace OpenTK.Platform.MacOS
|
||||
Rectangle windowedBounds;
|
||||
bool mIsDisposed = false;
|
||||
bool mExists = true;
|
||||
DisplayDevice mDisplayDevice;
|
||||
internal DisplayDevice TargetDisplayDevice;
|
||||
|
||||
WindowPositionMethod mPositionMethod = WindowPositionMethod.CenterOnMainScreen;
|
||||
int mTitlebarHeight;
|
||||
private WindowState windowState = WindowState.Normal;
|
||||
static Dictionary<IntPtr, WeakReference> mWindows = new Dictionary<IntPtr, WeakReference>();
|
||||
WindowState windowState = WindowState.Normal;
|
||||
internal static Dictionary<IntPtr, WeakReference> WindowRefs = new Dictionary<IntPtr, WeakReference>();
|
||||
KeyPressEventArgs mKeyPressArgs = new KeyPressEventArgs();
|
||||
bool mMouseIn = false;
|
||||
bool mIsActive = false;
|
||||
Icon mIcon;
|
||||
|
||||
static internal Dictionary<IntPtr, WeakReference> WindowRefMap { get { return mWindows; } }
|
||||
internal DisplayDevice TargetDisplayDevice { get { return mDisplayDevice; } }
|
||||
|
||||
static CarbonGLNative() {
|
||||
Application.Initialize();
|
||||
}
|
||||
@ -74,7 +71,7 @@ namespace OpenTK.Platform.MacOS
|
||||
WindowAttributes.InWindowMenu | WindowAttributes.LiveResize,
|
||||
new Rect((short)x, (short)y, (short)width, (short)height));
|
||||
|
||||
mDisplayDevice = device;
|
||||
TargetDisplayDevice = device;
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
@ -95,7 +92,7 @@ namespace OpenTK.Platform.MacOS
|
||||
mExists = false;
|
||||
|
||||
if (disposing) {
|
||||
mWindows.Remove(window.WindowRef);
|
||||
WindowRefs.Remove(window.WindowRef);
|
||||
window = null;
|
||||
}
|
||||
DisposeUPP();
|
||||
@ -132,7 +129,7 @@ namespace OpenTK.Platform.MacOS
|
||||
window = new CarbonWindowInfo(windowRef);
|
||||
SetLocation(r.X, r.Y);
|
||||
SetSize(r.Width, r.Height);
|
||||
mWindows.Add(windowRef, new WeakReference(this));
|
||||
WindowRefs.Add(windowRef, new WeakReference(this));
|
||||
LoadSize();
|
||||
|
||||
Rect titleSize = API.GetWindowBounds(window.WindowRef, WindowRegionCode.TitleBarRegion);
|
||||
@ -196,7 +193,7 @@ namespace OpenTK.Platform.MacOS
|
||||
Debug.Print("New Size: {0}, {1}", ClientRectangle.Width, ClientRectangle.Height);
|
||||
|
||||
// TODO: if we go full screen we need to make this use the device specified.
|
||||
bounds = mDisplayDevice.Bounds;
|
||||
bounds = TargetDisplayDevice.Bounds;
|
||||
windowState = WindowState.Fullscreen;
|
||||
}
|
||||
|
||||
@ -231,14 +228,14 @@ namespace OpenTK.Platform.MacOS
|
||||
{
|
||||
// bail out if the window passed in is not actually our window.
|
||||
// I think this happens if using winforms with a GameWindow sometimes.
|
||||
if (!mWindows.ContainsKey(userData))
|
||||
if (!WindowRefs.ContainsKey(userData))
|
||||
return OSStatus.EventNotHandled;
|
||||
|
||||
WeakReference reference = mWindows[userData];
|
||||
WeakReference reference = WindowRefs[userData];
|
||||
|
||||
// bail out if the CarbonGLNative window has been garbage collected.
|
||||
if (!reference.IsAlive) {
|
||||
mWindows.Remove(userData);
|
||||
WindowRefs.Remove(userData);
|
||||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user