Fix bug with StringBuffer/UnsafeString being drawn way too wide on some Windows versions, fixes #46. (Thanks Cheesse)

This commit is contained in:
UnknownShadow200 2015-09-03 18:40:25 +10:00
parent 4371246f96
commit ad18567f69
12 changed files with 10 additions and 15 deletions

View File

@ -44,11 +44,10 @@ namespace ClassicalSharp {
Vector3 pos = Position;
pos.Y += Model.NameYOffset;
// Inlined translation + rotation Y axis
api.texVerts[0] = new VertexPos3fTex2f( cosA * x1 + pos.X, y1 + pos.Y, sinA * x1 + pos.Z, nameTex.U1, nameTex.V1 );
api.texVerts[1] = new VertexPos3fTex2f( cosA * x2 + pos.X, y1 + pos.Y, sinA * x2 + pos.Z, nameTex.U2, nameTex.V1 );
api.texVerts[2] = new VertexPos3fTex2f( cosA * x2 + pos.X, y2 + pos.Y, sinA * x2 + pos.Z, nameTex.U2, nameTex.V2 );
api.texVerts[3] = new VertexPos3fTex2f( cosA * x1 + pos.X, y2 + pos.Y, sinA * x1 + pos.Z, nameTex.U1, nameTex.V2 );
api.texVerts[0] = new VertexPos3fTex2f( Utils.RotateY( x1, y1, 0, pos, cosA, sinA ), nameTex.U1, nameTex.V1 );
api.texVerts[1] = new VertexPos3fTex2f( Utils.RotateY( x2, y1, 0, pos, cosA, sinA ), nameTex.U2, nameTex.V1 );
api.texVerts[2] = new VertexPos3fTex2f( Utils.RotateY( x2, y2, 0, pos, cosA, sinA ), nameTex.U2, nameTex.V2 );
api.texVerts[3] = new VertexPos3fTex2f( Utils.RotateY( x1, y2, 0, pos, cosA, sinA ), nameTex.U1, nameTex.V2 );
api.BeginVbBatch( VertexFormat.Pos3fTex2f );
api.DrawDynamicIndexedVb( DrawMode.Triangles, api.texVb, api.texVerts, 4, 6 );

View File

@ -1,6 +1,5 @@
using System;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -1,6 +1,5 @@
using System;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -1,6 +1,5 @@
using System;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -1,6 +1,5 @@
using System;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -1,7 +1,6 @@
using System;
using System.Drawing;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -1,6 +1,5 @@
using System;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -1,6 +1,5 @@
using System;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -1,6 +1,5 @@
using System;
using ClassicalSharp.GraphicsAPI;
using ClassicalSharp.Renderers;
using OpenTK;
namespace ClassicalSharp.Model {

View File

@ -144,7 +144,7 @@ namespace ClassicalSharp {
/// <returns> The underlying string - ***do not*** store this because it is mutable!
/// You should only use this string for temporary measuring and drawing. </returns>
public string UpdateCachedString() {
return supportsLengthSetting ? value : value.TrimEnd( trimEnd );
return supportsLengthSetting ? SetLength( Length ) : value.TrimEnd( trimEnd );
}
static char[] trimEnd = { '\0' };

View File

@ -128,6 +128,10 @@ namespace ClassicalSharp {
return new Vector3( cosA * x - sinA * z, y, sinA * x + cosA * z );
}
public static Vector3 RotateY( float x, float y, float z, Vector3 translate, float cosA, float sinA ) {
return new Vector3( cosA * x - sinA * z + translate.X, y + translate.Y, sinA * x + cosA * z + translate.Z );
}
public static float DistanceSquared( Vector3 p1, Vector3 p2 ) {
float dx = p2.X - p1.X;
float dy = p2.Y - p1.Y;