Correct UniqueId/FontFace implementations.
This commit is contained in:
@ -91,20 +91,14 @@ namespace RobloxFiles.DataTypes
|
||||
public CFrame(Vector3 eye, Vector3 look)
|
||||
{
|
||||
Vector3 zAxis = (eye - look).Unit,
|
||||
xAxis = Vector3.Up.Cross(zAxis),
|
||||
xAxis = Vector3.yAxis.Cross(zAxis),
|
||||
yAxis = zAxis.Cross(xAxis);
|
||||
|
||||
if (xAxis.Magnitude == 0)
|
||||
{
|
||||
xAxis = Vector3.z;
|
||||
yAxis = Vector3.x;
|
||||
zAxis = Vector3.y;
|
||||
|
||||
if (zAxis.Y < 0)
|
||||
{
|
||||
xAxis = -xAxis;
|
||||
zAxis = -zAxis;
|
||||
}
|
||||
xAxis = Vector3.zAxis;
|
||||
yAxis = Vector3.xAxis;
|
||||
zAxis = Vector3.yAxis;
|
||||
}
|
||||
|
||||
m11 = xAxis.X; m12 = yAxis.X; m13 = zAxis.X; m14 = eye.X;
|
||||
@ -299,18 +293,18 @@ namespace RobloxFiles.DataTypes
|
||||
|
||||
public static CFrame FromAxisAngle(Vector3 axis, float theta)
|
||||
{
|
||||
Vector3 r = VectorAxisAngle(axis, Vector3.x, theta),
|
||||
u = VectorAxisAngle(axis, Vector3.y, theta),
|
||||
b = VectorAxisAngle(axis, Vector3.z, theta);
|
||||
Vector3 r = VectorAxisAngle(axis, Vector3.xAxis, theta),
|
||||
u = VectorAxisAngle(axis, Vector3.yAxis, theta),
|
||||
b = VectorAxisAngle(axis, Vector3.zAxis, theta);
|
||||
|
||||
return new CFrame(0, 0, 0, r.X, u.X, b.X, r.Y, u.Y, b.Y, r.Z, u.Z, b.Z);
|
||||
}
|
||||
|
||||
public static CFrame FromEulerAnglesXYZ(float x, float y, float z)
|
||||
{
|
||||
CFrame cfx = FromAxisAngle(Vector3.x, x),
|
||||
cfy = FromAxisAngle(Vector3.y, y),
|
||||
cfz = FromAxisAngle(Vector3.z, z);
|
||||
CFrame cfx = FromAxisAngle(Vector3.xAxis, x),
|
||||
cfy = FromAxisAngle(Vector3.yAxis, y),
|
||||
cfz = FromAxisAngle(Vector3.zAxis, z);
|
||||
|
||||
return cfx * cfy * cfz;
|
||||
}
|
||||
@ -410,9 +404,9 @@ namespace RobloxFiles.DataTypes
|
||||
{
|
||||
var tests = new float[3]
|
||||
{
|
||||
XVector.Dot(Vector3.x),
|
||||
YVector.Dot(Vector3.y),
|
||||
ZVector.Dot(Vector3.z)
|
||||
XVector.Dot(Vector3.xAxis),
|
||||
YVector.Dot(Vector3.yAxis),
|
||||
ZVector.Dot(Vector3.zAxis)
|
||||
};
|
||||
|
||||
foreach (var test in tests)
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
// Implementation of Roblox's Font datatype.
|
||||
// Renamed to FontFace to avoid disambiguation with System.Font and the Font enum.
|
||||
// Implementation of Roblox's FontFace datatype.
|
||||
// In Luau this type is named Font, but we avoid that name
|
||||
// to avoid ambiguity with System.Font and Roblox's Font enum.
|
||||
|
||||
public class FontFace
|
||||
{
|
||||
@ -11,8 +12,16 @@ namespace RobloxFiles.DataTypes
|
||||
public readonly FontWeight Weight = FontWeight.Regular;
|
||||
public readonly FontStyle Style = FontStyle.Normal;
|
||||
|
||||
public FontFace(Content family, FontWeight weight = FontWeight.Regular, FontStyle style = FontStyle.Normal)
|
||||
// Roblox caches the asset of the font's face to make it
|
||||
// load faster. At runtime both the Family and the CachedFaceId
|
||||
// are loaded in parallel. If the CachedFaceId doesn't match with
|
||||
// the family file's face asset, then the correct one will be loaded late.
|
||||
// Setting this is not required, it's just a throughput optimization.
|
||||
public Content CachedFaceId { get; set; } = "";
|
||||
|
||||
public FontFace(Content family, FontWeight weight = FontWeight.Regular, FontStyle style = FontStyle.Normal, string cachedFaceId = "")
|
||||
{
|
||||
CachedFaceId = cachedFaceId;
|
||||
Family = family;
|
||||
Weight = weight;
|
||||
Style = style;
|
||||
|
@ -1,16 +1,27 @@
|
||||
namespace RobloxFiles.DataTypes
|
||||
using System;
|
||||
|
||||
namespace RobloxFiles.DataTypes
|
||||
{
|
||||
public struct UniqueId
|
||||
{
|
||||
public readonly uint Time;
|
||||
public readonly uint Index;
|
||||
public readonly ulong Random;
|
||||
public readonly long Random;
|
||||
|
||||
public UniqueId(uint time, uint index, ulong random)
|
||||
public UniqueId(long random, uint time, uint index)
|
||||
{
|
||||
Time = time;
|
||||
Index = index;
|
||||
Random = random;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string random = Random.ToString("x2").PadLeft(16, '0');
|
||||
string index = Index.ToString("x2").PadLeft(8, '0');
|
||||
string time = Time.ToString("x2").PadLeft(8, '0');
|
||||
|
||||
return $"{random}{time}{index}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,13 +98,13 @@ namespace RobloxFiles.DataTypes
|
||||
public static readonly Vector3 zero = new Vector3(0, 0, 0);
|
||||
public static readonly Vector3 one = new Vector3(1, 1, 1);
|
||||
|
||||
public static readonly Vector3 x = new Vector3(1, 0, 0);
|
||||
public static readonly Vector3 y = new Vector3(0, 1, 0);
|
||||
public static readonly Vector3 z = new Vector3(0, 0, 1);
|
||||
public static readonly Vector3 xAxis = new Vector3(1, 0, 0);
|
||||
public static readonly Vector3 yAxis = new Vector3(0, 1, 0);
|
||||
public static readonly Vector3 zAxis = new Vector3(0, 0, 1);
|
||||
|
||||
public static Vector3 Right => x;
|
||||
public static Vector3 Up => y;
|
||||
public static Vector3 Back => z;
|
||||
public static Vector3 Right => xAxis;
|
||||
public static Vector3 Up => yAxis;
|
||||
public static Vector3 Back => zAxis;
|
||||
|
||||
public float Dot(Vector3 other)
|
||||
{
|
||||
|
Reference in New Issue
Block a user