mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Optimise isometric block drawing.
This commit is contained in:
parent
d50476e760
commit
b1f69e7c25
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
@ -180,8 +180,7 @@ namespace ClassicalSharp {
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the x axis. </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||
@ -196,8 +195,7 @@ namespace ClassicalSharp {
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the y axis. </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the z axis. </summary>
|
||||
@ -212,8 +210,7 @@ namespace ClassicalSharp {
|
||||
|
||||
/// <summary> Rotates the given 3D coordinates around the z axis. </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> Returns the square of the euclidean distance between two points. </summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user