Drop all legacy matrix stuff.

This commit is contained in:
UnknownShadow200 2015-04-06 11:33:13 +10:00
parent 4c91096747
commit b1eb7a8695
4 changed files with 6 additions and 73 deletions

View file

@ -239,12 +239,9 @@ namespace ClassicalSharp {
LocalPlayer.SetInterpPosition( t );
Graphics.Clear();
Graphics.SetMatrixMode( MatrixType.Modelview );
Matrix4 modelView = Camera.GetView();
View = modelView;
mvp = modelView * Projection;
Graphics.LoadMatrix( ref modelView );
Culling.CalcFrustumEquations( ref Projection, ref modelView );
View = Camera.GetView();
mvp = View * Projection;
Culling.CalcFrustumEquations( ref mvp );
bool visible = activeScreen == null || !activeScreen.BlocksWorld;
if( visible ) {
@ -325,11 +322,7 @@ namespace ClassicalSharp {
}
public void UpdateProjection() {
Matrix4 projection = Camera.GetProjection();
Projection = projection;
Graphics.SetMatrixMode( MatrixType.Projection );
Graphics.LoadMatrix( ref projection );
Graphics.SetMatrixMode( MatrixType.Modelview );
Projection = Camera.GetProjection();
}
protected override void OnResize( EventArgs e ) {

View file

@ -366,63 +366,6 @@ namespace ClassicalSharp.GraphicsAPI {
#endregion
#region Matrix manipulation
MatrixMode lastMode = 0;
MatrixMode[] matrixModes = new MatrixMode[] {
MatrixMode.Projection, MatrixMode.Modelview, MatrixMode.Texture,
};
public void SetMatrixMode( MatrixType mode ) {
MatrixMode glMode = matrixModes[(int)mode];
if( glMode != lastMode ) {
GL.MatrixMode( glMode );
lastMode = glMode;
}
}
public void LoadMatrix( ref Matrix4 matrix ) {
GL.LoadMatrix( ref matrix );
}
public void LoadIdentityMatrix() {
GL.LoadIdentity();
}
public void PushMatrix() {
GL.PushMatrix();
}
public void PopMatrix() {
GL.PopMatrix();
}
public void MultiplyMatrix( ref Matrix4 matrix ) {
GL.MultMatrix( ref matrix );
}
public void Translate( float x, float y, float z ) {
GL.Translate( x, y, z );
}
public void RotateX( float degrees ) {
GL.Rotate( degrees, 1f, 0f, 0f );
}
public void RotateY( float degrees ) {
GL.Rotate( degrees, 0f, 1f, 0f );
}
public void RotateZ( float degrees ) {
GL.Rotate( degrees, 0f, 0f, 1f );
}
public void Scale( float x, float y, float z ) {
GL.Scale( x, y, z );
}
#endregion
#if TRACK_RESOURCES
public void CheckResources() {
if( textures.Count > 0 ) {

View file

@ -124,7 +124,6 @@ namespace ClassicalSharp.Model {
protected void DrawRotate( float x, float y, float z, float angleX, float angleY, float angleZ, MapShader shader, ref Matrix4 mvp, ModelPart part ) {
Matrix4 tempMvp = mvp;
tempMvp = Matrix4.CreateTranslation( x, y, z ) * tempMvp;
graphics.Translate( x, y, z );
if( angleZ != 0 ) {
tempMvp = Matrix4.CreateRotationZ( angleZ ) * tempMvp;
}

View file

@ -31,10 +31,8 @@ namespace ClassicalSharp {
return true;
}
public unsafe void CalcFrustumEquations( ref Matrix4 projection, ref Matrix4 modelView ) {
Matrix4 clipMatrix;
Matrix4.Mult( ref modelView, ref projection, out clipMatrix );
public unsafe void CalcFrustumEquations( ref Matrix4 mvp ) {
Matrix4 clipMatrix = mvp;
float* clip = (float*)&clipMatrix;
// Extract the numbers for the RIGHT plane
frustum00 = clip[3] - clip[0];