Removing conversionBuffer caching from OpenMetaverseTypes to avoid interop issues and save memory for the 99.9% use case
git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@2187 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -43,14 +43,10 @@ namespace OpenMetaverse
|
||||
/// <summary>W value</summary>
|
||||
public float W;
|
||||
|
||||
// Used for little to big endian conversion on big endian architectures
|
||||
private byte[] conversionBuffer;
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Quaternion(float x, float y, float z, float w)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
@@ -59,7 +55,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Quaternion(Vector3 vectorPart, float scalarPart)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = vectorPart.X;
|
||||
Y = vectorPart.Y;
|
||||
Z = vectorPart.Z;
|
||||
@@ -74,7 +69,6 @@ namespace OpenMetaverse
|
||||
/// <param name="z">Z value from -1.0 to 1.0</param>
|
||||
public Quaternion(float x, float y, float z)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
@@ -93,14 +87,12 @@ namespace OpenMetaverse
|
||||
/// be read.</param>
|
||||
public Quaternion(byte[] byteArray, int pos, bool normalized)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = Y = Z = W = 0;
|
||||
FromBytes(byteArray, pos, normalized);
|
||||
}
|
||||
|
||||
public Quaternion(Quaternion q)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = q.X;
|
||||
Y = q.Y;
|
||||
Z = q.Z;
|
||||
@@ -144,8 +136,7 @@ namespace OpenMetaverse
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Big endian architecture
|
||||
if (conversionBuffer == null)
|
||||
conversionBuffer = new byte[16];
|
||||
byte[] conversionBuffer = new byte[16];
|
||||
|
||||
Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 16);
|
||||
|
||||
@@ -173,8 +164,7 @@ namespace OpenMetaverse
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Big endian architecture
|
||||
if (conversionBuffer == null)
|
||||
conversionBuffer = new byte[16];
|
||||
byte[] conversionBuffer = new byte[16];
|
||||
|
||||
Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 12);
|
||||
|
||||
@@ -360,7 +350,6 @@ namespace OpenMetaverse
|
||||
float c = (float)Math.Cos(angle);
|
||||
float s = (float)Math.Sin(angle);
|
||||
|
||||
q.conversionBuffer = null;
|
||||
q.X = axis.X * s;
|
||||
q.Y = axis.Y * s;
|
||||
q.Z = axis.Z * s;
|
||||
@@ -413,7 +402,6 @@ namespace OpenMetaverse
|
||||
public static Quaternion CreateFromRotationMatrix(Matrix4 m)
|
||||
{
|
||||
Quaternion quat;
|
||||
quat.conversionBuffer = null;
|
||||
|
||||
float trace = m.Trace();
|
||||
|
||||
|
||||
@@ -42,28 +42,22 @@ namespace OpenMetaverse
|
||||
/// <summary>Y value</summary>
|
||||
public float Y;
|
||||
|
||||
// Used for little to big endian conversion on big endian architectures
|
||||
private byte[] conversionBuffer;
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Vector2(float x, float y)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public Vector2(float value)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value;
|
||||
Y = value;
|
||||
}
|
||||
|
||||
public Vector2(Vector2 vector)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = vector.X;
|
||||
Y = vector.Y;
|
||||
}
|
||||
@@ -113,8 +107,7 @@ namespace OpenMetaverse
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Big endian architecture
|
||||
if (conversionBuffer == null)
|
||||
conversionBuffer = new byte[8];
|
||||
byte[] conversionBuffer = new byte[8];
|
||||
|
||||
Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 8);
|
||||
|
||||
|
||||
@@ -44,14 +44,10 @@ namespace OpenMetaverse
|
||||
/// <summary>Z value</summary>
|
||||
public float Z;
|
||||
|
||||
// Used for little to big endian conversion on big endian architectures
|
||||
private byte[] conversionBuffer;
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Vector3(float x, float y, float z)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
@@ -59,7 +55,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector3(float value)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value;
|
||||
Y = value;
|
||||
Z = value;
|
||||
@@ -67,7 +62,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector3(Vector2 value, float z)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
Z = z;
|
||||
@@ -75,7 +69,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector3(Vector3d vector)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = (float)vector.X;
|
||||
Y = (float)vector.Y;
|
||||
Z = (float)vector.Z;
|
||||
@@ -88,14 +81,12 @@ namespace OpenMetaverse
|
||||
/// <param name="pos">Beginning position in the byte array</param>
|
||||
public Vector3(byte[] byteArray, int pos)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = Y = Z = 0f;
|
||||
FromBytes(byteArray, pos);
|
||||
}
|
||||
|
||||
public Vector3(Vector3 vector)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = vector.X;
|
||||
Y = vector.Y;
|
||||
Z = vector.Z;
|
||||
@@ -161,8 +152,7 @@ namespace OpenMetaverse
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Big endian architecture
|
||||
if (conversionBuffer == null)
|
||||
conversionBuffer = new byte[12];
|
||||
byte[] conversionBuffer = new byte[12];
|
||||
|
||||
Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 12);
|
||||
|
||||
@@ -521,7 +511,6 @@ namespace OpenMetaverse
|
||||
public static Vector3 operator *(Vector3 vec, Quaternion rot)
|
||||
{
|
||||
Vector3 vec2;
|
||||
vec2.conversionBuffer = null;
|
||||
|
||||
vec2.X =
|
||||
rot.W * rot.W * vec.X +
|
||||
|
||||
@@ -44,14 +44,10 @@ namespace OpenMetaverse
|
||||
/// <summary>Z value</summary>
|
||||
public double Z;
|
||||
|
||||
// Used for little to big endian conversion on big endian architectures
|
||||
private byte[] conversionBuffer;
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Vector3d(double x, double y, double z)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
@@ -59,7 +55,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector3d(double value)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value;
|
||||
Y = value;
|
||||
Z = value;
|
||||
@@ -72,14 +67,12 @@ namespace OpenMetaverse
|
||||
/// <param name="pos">Beginning position in the byte array</param>
|
||||
public Vector3d(byte[] byteArray, int pos)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = Y = Z = 0d;
|
||||
FromBytes(byteArray, pos);
|
||||
}
|
||||
|
||||
public Vector3d(Vector3 vector)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = vector.X;
|
||||
Y = vector.Y;
|
||||
Z = vector.Z;
|
||||
@@ -87,7 +80,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector3d(Vector3d vector)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = vector.X;
|
||||
Y = vector.Y;
|
||||
Z = vector.Z;
|
||||
@@ -153,8 +145,7 @@ namespace OpenMetaverse
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Big endian architecture
|
||||
if (conversionBuffer == null)
|
||||
conversionBuffer = new byte[24];
|
||||
byte[] conversionBuffer = new byte[24];
|
||||
|
||||
Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 24);
|
||||
|
||||
|
||||
@@ -43,14 +43,10 @@ namespace OpenMetaverse
|
||||
/// <summary>W value</summary>
|
||||
public float W;
|
||||
|
||||
// Used for little to big endian conversion on big endian architectures
|
||||
private byte[] conversionBuffer;
|
||||
|
||||
#region Constructors
|
||||
|
||||
public Vector4(float x, float y, float z, float w)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = x;
|
||||
Y = y;
|
||||
Z = z;
|
||||
@@ -59,7 +55,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector4(Vector2 value, float z, float w)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
Z = z;
|
||||
@@ -68,7 +63,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector4(Vector3 value, float w)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
Z = value.Z;
|
||||
@@ -77,7 +71,6 @@ namespace OpenMetaverse
|
||||
|
||||
public Vector4(float value)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value;
|
||||
Y = value;
|
||||
Z = value;
|
||||
@@ -91,14 +84,12 @@ namespace OpenMetaverse
|
||||
/// <param name="pos">Beginning position in the byte array</param>
|
||||
public Vector4(byte[] byteArray, int pos)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = Y = Z = W = 0f;
|
||||
FromBytes(byteArray, pos);
|
||||
}
|
||||
|
||||
public Vector4(Vector4 value)
|
||||
{
|
||||
conversionBuffer = null;
|
||||
X = value.X;
|
||||
Y = value.Y;
|
||||
Z = value.Z;
|
||||
@@ -165,8 +156,7 @@ namespace OpenMetaverse
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
// Big endian architecture
|
||||
if (conversionBuffer == null)
|
||||
conversionBuffer = new byte[16];
|
||||
byte[] conversionBuffer = new byte[16];
|
||||
|
||||
Buffer.BlockCopy(byteArray, pos, conversionBuffer, 0, 16);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user