diff --git a/ClassicalSharp/2D/IsometricBlockDrawer.cs b/ClassicalSharp/2D/IsometricBlockDrawer.cs index 66c73f839..deb08a6fb 100644 --- a/ClassicalSharp/2D/IsometricBlockDrawer.cs +++ b/ClassicalSharp/2D/IsometricBlockDrawer.cs @@ -50,7 +50,8 @@ namespace ClassicalSharp { scale = size / (2 * cosY); // screen to isometric coords (cos(-x) = cos(x), sin(-x) = -sin(x)) pos.X = x; pos.Y = y; pos.Z = 0; - pos = Utils.RotateY( Utils.RotateX( pos, cosX, -sinX ), cosY, -sinY ); + Utils.RotateX( ref pos.Y, ref pos.Z, cosX, -sinX ); + Utils.RotateY( ref pos.X, ref pos.Z, cosY, -sinY ); if( info.IsSprite[block] ) { SpriteXQuad( block, TileSide.Right, false ); @@ -171,16 +172,19 @@ namespace ClassicalSharp { index = 0; } lastTexId = texId; - api.BindTexture( texId ); + api.BindTexture( texId ); } - static void TransformVertex( ref VertexP3fT2fC4b vertex ) { - Vector3 p = new Vector3( vertex.X, vertex.Y, vertex.Z ) + pos; + static void TransformVertex( ref VertexP3fT2fC4b v ) { + v.X += pos.X; v.Y += pos.Y; v.Z += pos.Z; + //Vector3 p = new Vector3( v.X, v.Y, v.Z ) + pos; //p = Utils.RotateY( p - pos, time ) + pos; + //v coords = p + // See comment in IGraphicsApi.Draw2DTexture() - p.X -= 0.5f; p.Y -= 0.5f; - p = Utils.RotateX( Utils.RotateY( p, cosY, sinY ), cosX, sinX ); - vertex.X = p.X; vertex.Y = p.Y; vertex.Z = p.Z; + v.X -= 0.5f; v.Y -= 0.5f; + Utils.RotateY( ref v.X, ref v.Z, cosY, sinY ); + Utils.RotateX( ref v.Y, ref v.Z, cosX, sinX ); } } } \ No newline at end of file diff --git a/ClassicalSharp/Utils/Utils.cs b/ClassicalSharp/Utils/Utils.cs index 6541a50a9..e9e448e04 100644 --- a/ClassicalSharp/Utils/Utils.cs +++ b/ClassicalSharp/Utils/Utils.cs @@ -180,8 +180,7 @@ namespace ClassicalSharp { /// Rotates the given 3D coordinates around the x axis. public static void RotateX( ref float y, ref float z, float cosA, float sinA ) { - float y2 = cosA * y + sinA * z, z2 = -sinA * y + cosA * z; - y = y2; z = z2; + float y2 = cosA * y + sinA * z; z = -sinA * y + cosA * z; y = y2; } /// Rotates the given 3D coordinates around the y axis. @@ -196,8 +195,7 @@ namespace ClassicalSharp { /// Rotates the given 3D coordinates around the y axis. public static void RotateY( ref float x, ref float z, float cosA, float sinA ) { - float x2 = cosA * x - sinA * z, z2 = sinA * x + cosA * z; - x = x2; z = z2; + float x2 = cosA * x - sinA * z; z = sinA * x + cosA * z; x = x2; } /// Rotates the given 3D coordinates around the z axis. @@ -212,8 +210,7 @@ namespace ClassicalSharp { /// Rotates the given 3D coordinates around the z axis. public static void RotateZ( ref float x, ref float y, float cosA, float sinA ) { - float x2 = cosA * x + sinA * y, y2 = -sinA * x + cosA * y; - x = x2; y = y2; + float x2 = cosA * x + sinA * y; y = -sinA * x + cosA * y; x = x2; } /// Returns the square of the euclidean distance between two points.