Performance #190
@ -252,11 +252,14 @@ namespace TrueCraft.API
|
|||||||
{
|
{
|
||||||
if (Empty)
|
if (Empty)
|
||||||
return "(Empty)";
|
return "(Empty)";
|
||||||
string result = "ID: " + ID;
|
|
||||||
if (Count != 1) result += "; Count: " + Count;
|
StringBuilder resultBuilder = new StringBuilder("ID: " + ID);
|
||||||
if (Metadata != 0) result += "; Metadata: " + Metadata;
|
|
||||||
if (Nbt != null) result += Environment.NewLine + Nbt.ToString();
|
if (Count != 1) resultBuilder.Append("; Count: " + Count);
|
||||||
return "(" + result + ")";
|
if (Metadata != 0) resultBuilder.Append("; Metadata: " + Metadata);
|
||||||
|
if (Nbt != null) resultBuilder.Append(Environment.NewLine + Nbt.ToString());
|
||||||
|
|
||||||
|
return "(" + resultBuilder.ToString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -94,18 +94,29 @@ namespace TrueCraft.API
|
|||||||
Vector3 maxT = new Vector3(-1.0f);
|
Vector3 maxT = new Vector3(-1.0f);
|
||||||
//Vector3 minT = new Vector3(-1.0f);
|
//Vector3 minT = new Vector3(-1.0f);
|
||||||
//calcul intersection with each faces
|
//calcul intersection with each faces
|
||||||
if (Position.X < box.Min.X && Direction.X != 0.0f)
|
if (Direction.X != 0.0f)
|
||||||
maxT.X = (box.Min.X - Position.X) / Direction.X;
|
{
|
||||||
else if (Position.X > box.Max.X && Direction.X != 0.0f)
|
if (Position.X < box.Min.X)
|
||||||
maxT.X = (box.Max.X - Position.X) / Direction.X;
|
maxT.X = (box.Min.X - Position.X) / Direction.X;
|
||||||
if (Position.Y < box.Min.Y && Direction.Y != 0.0f)
|
else if (Position.X > box.Max.X)
|
||||||
maxT.Y = (box.Min.Y - Position.Y) / Direction.Y;
|
maxT.X = (box.Max.X - Position.X) / Direction.X;
|
||||||
else if (Position.Y > box.Max.Y && Direction.Y != 0.0f)
|
}
|
||||||
maxT.Y = (box.Max.Y - Position.Y) / Direction.Y;
|
|
||||||
if (Position.Z < box.Min.Z && Direction.Z != 0.0f)
|
if (Direction.Y != 0.0f)
|
||||||
maxT.Z = (box.Min.Z - Position.Z) / Direction.Z;
|
{
|
||||||
else if (Position.Z > box.Max.Z && Direction.Z != 0.0f)
|
if (Position.Y < box.Min.Y)
|
||||||
maxT.Z = (box.Max.Z - Position.Z) / Direction.Z;
|
maxT.Y = (box.Min.Y - Position.Y) / Direction.Y;
|
||||||
|
else if (Position.Y > box.Max.Y)
|
||||||
|
maxT.Y = (box.Max.Y - Position.Y) / Direction.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Direction.Z != 0.0f)
|
||||||
|
{
|
||||||
|
if (Position.Z < box.Min.Z)
|
||||||
|
maxT.Z = (box.Min.Z - Position.Z) / Direction.Z;
|
||||||
|
else if (Position.Z > box.Max.Z)
|
||||||
|
maxT.Z = (box.Max.Z - Position.Z) / Direction.Z;
|
||||||
|
}
|
||||||
|
|
||||||
//get the maximum maxT
|
//get the maximum maxT
|
||||||
if (maxT.X > maxT.Y && maxT.X > maxT.Z)
|
if (maxT.X > maxT.Y && maxT.X > maxT.Z)
|
||||||
|
@ -73,6 +73,14 @@ namespace TrueCraft.Client.Rendering
|
|||||||
using (var contents = File.OpenRead(Path.Combine(contentManager.RootDirectory, definitionPath)))
|
using (var contents = File.OpenRead(Path.Combine(contentManager.RootDirectory, definitionPath)))
|
||||||
_definition = FontLoader.Load(contents);
|
_definition = FontLoader.Load(contents);
|
||||||
|
|
||||||
|
if (_textures != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _textures.Length; i++)
|
||||||
|
{
|
||||||
|
_textures[i].Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We need to support multiple texture pages for more than plain ASCII text.
|
// We need to support multiple texture pages for more than plain ASCII text.
|
||||||
_textures = new Texture2D[_definition.Pages.Count];
|
_textures = new Texture2D[_definition.Pages.Count];
|
||||||
for (int i = 0; i < _definition.Pages.Count; i++)
|
for (int i = 0; i < _definition.Pages.Count; i++)
|
||||||
|
@ -101,11 +101,12 @@ namespace TrueCraft.Client.Rendering
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var ms = new MemoryStream();
|
using (var ms = new MemoryStream())
|
||||||
CopyStream(stream, ms);
|
{
|
||||||
ms.Seek(0, SeekOrigin.Begin);
|
CopyStream(stream, ms);
|
||||||
AddTexture(key, new PngReader().Read(ms, Device));
|
ms.Seek(0, SeekOrigin.Begin);
|
||||||
ms.Dispose();
|
AddTexture(key, new PngReader().Read(ms, Device));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) { Console.WriteLine("Exception occured while loading {0} from texture pack:\n\n{1}", key, ex); }
|
catch (Exception ex) { Console.WriteLine("Exception occured while loading {0} from texture pack:\n\n{1}", key, ex); }
|
||||||
}
|
}
|
||||||
@ -184,7 +185,6 @@ namespace TrueCraft.Client.Rendering
|
|||||||
foreach (var pair in Customs)
|
foreach (var pair in Customs)
|
||||||
pair.Value.Dispose();
|
pair.Value.Dispose();
|
||||||
|
|
||||||
Customs.Clear();
|
|
||||||
Customs = null;
|
Customs = null;
|
||||||
Device = null;
|
Device = null;
|
||||||
IsDisposed = true;
|
IsDisposed = true;
|
||||||
|
Reference in New Issue
Block a user