Skip to content
Permalink
Browse files

[Bullet] Remove bullet refs within mathematics

  • Loading branch information
Eideren committed Apr 18, 2019
1 parent 45a89aa commit 9b22e548b339764d1690c617dc83b73a17bfaf66
@@ -3478,71 +3478,5 @@ public override bool Equals(object value)
};
}
#endif

/// <summary>
/// Performs an implicit conversion from <see cref="Xenko.Core.Mathematics.Matrix"/> to <see cref="BulletSharp.Math.Matrix"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator BulletSharp.Math.Matrix(Matrix value)
{
// 11, 22, 33 & 44's offsets are shared, ~10% faster
BulletSharp.Math.Matrix d;
unsafe
{
d = *(BulletSharp.Math.Matrix*)&value;
}
//11
d.M12 = value.M12;
d.M13 = value.M13;
d.M14 = value.M14;
d.M21 = value.M21;
//22
d.M23 = value.M23;
d.M24 = value.M24;
d.M31 = value.M31;
d.M32 = value.M32;
//33
d.M34 = value.M34;
d.M41 = value.M41;
d.M42 = value.M42;
d.M43 = value.M43;
//44
return d;
}

/// <summary>
/// Performs an implicit conversion from <see cref="BulletSharp.Math.Matrix"/> to <see cref="Xenko.Core.Mathematics.Matrix"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Matrix(BulletSharp.Math.Matrix value)
{
// 11, 22, 33 & 44's offsets are shared, ~10% faster
Matrix d;
unsafe
{
d = *(Matrix*)&value;
}
//11
d.M12 = value.M12;
d.M13 = value.M13;
d.M14 = value.M14;
d.M21 = value.M21;
//22
d.M23 = value.M23;
d.M24 = value.M24;
d.M31 = value.M31;
d.M32 = value.M32;
//33
d.M34 = value.M34;
d.M41 = value.M41;
d.M42 = value.M42;
d.M43 = value.M43;
//44
return d;
}
}
}
@@ -1420,27 +1420,5 @@ public override bool Equals(object value)
return new Quaternion(value.X, value.Y, value.Z, value.W);
}
#endif

/// <summary>
/// Performs an implicit conversion from <see cref="Xenko.Core.Mathematics.Vector3"/> to <see cref="BulletSharp.Math.Quaternion"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator BulletSharp.Math.Quaternion(Quaternion value)
{
unsafe { return *(BulletSharp.Math.Quaternion*)&value; }
}

/// <summary>
/// Performs an implicit conversion from <see cref="BulletSharp.Math.Quaternion"/> to <see cref="Xenko.Core.Mathematics.Quaternion"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Quaternion(BulletSharp.Math.Quaternion value)
{
unsafe { return *(Quaternion*)&value; }
}
}
}
@@ -1732,27 +1732,5 @@ public override bool Equals(object value)
return new Vector3(value.X, value.Y, value.Z);
}
#endif

/// <summary>
/// Performs an implicit conversion from <see cref="Xenko.Core.Mathematics.Vector3"/> to <see cref="BulletSharp.Math.Vector3"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator BulletSharp.Math.Vector3(Vector3 value)
{
unsafe { return *(BulletSharp.Math.Vector3*)&value; }
}

/// <summary>
/// Performs an implicit conversion from <see cref="BulletSharp.Math.Vector3"/> to <see cref="Xenko.Core.Mathematics.Vector3"/>.
/// </summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3(BulletSharp.Math.Vector3 value)
{
unsafe { return *(Vector3*)&value; }
}
}
}
@@ -0,0 +1,84 @@
// Copyright (c) Xenko contributors (https://xenko.com) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

using Xenko.Core.Mathematics;

namespace Xenko.Physics
{
public static class Utils
{
public static BulletSharp.Math.Matrix ToBullet(this Matrix value)
{
// 11, 22, 33 & 44's offsets are shared, ~10% faster
BulletSharp.Math.Matrix d;
unsafe
{
d = *(BulletSharp.Math.Matrix*)&value;
}
//11
d.M12 = value.M12;
d.M13 = value.M13;
d.M14 = value.M14;
d.M21 = value.M21;
//22
d.M23 = value.M23;
d.M24 = value.M24;
d.M31 = value.M31;
d.M32 = value.M32;
//33
d.M34 = value.M34;
d.M41 = value.M41;
d.M42 = value.M42;
d.M43 = value.M43;
//44
return d;
}

public static Matrix ToXenko(this BulletSharp.Math.Matrix value)
{
// 11, 22, 33 & 44's offsets are shared, ~10% faster
Matrix d;
unsafe
{
d = *(Matrix*)&value;
}
//11
d.M12 = value.M12;
d.M13 = value.M13;
d.M14 = value.M14;
d.M21 = value.M21;
//22
d.M23 = value.M23;
d.M24 = value.M24;
d.M31 = value.M31;
d.M32 = value.M32;
//33
d.M34 = value.M34;
d.M41 = value.M41;
d.M42 = value.M42;
d.M43 = value.M43;
//44
return d;
}

public static BulletSharp.Math.Quaternion ToBullet(this Quaternion value)
{
unsafe { return *(BulletSharp.Math.Quaternion*)&value; }
}

public static Quaternion ToXenko(this BulletSharp.Math.Quaternion value)
{
unsafe { return *(Quaternion*)&value; }
}

public static BulletSharp.Math.Vector3 ToBullet(this Vector3 value)
{
unsafe { return *(BulletSharp.Math.Vector3*)&value; }
}

public static Vector3 ToXenko(this BulletSharp.Math.Vector3 value)
{
unsafe { return *(Vector3*)&value; }
}
}
}

0 comments on commit 9b22e54

Please sign in to comment.
You can’t perform that action at this time.