Refactor engine to support double-precision vectors
This commit is contained in:
@@ -14,7 +14,7 @@ namespace FlaxEngine
|
||||
/// <summary>
|
||||
/// The vertex position.
|
||||
/// </summary>
|
||||
public Vector3 Position;
|
||||
public Float3 Position;
|
||||
|
||||
/// <summary>
|
||||
/// The texture coordinates (packed).
|
||||
@@ -50,27 +50,27 @@ namespace FlaxEngine
|
||||
/// <summary>
|
||||
/// The vertex position.
|
||||
/// </summary>
|
||||
public Vector3 Position;
|
||||
public Float3 Position;
|
||||
|
||||
/// <summary>
|
||||
/// The texture coordinates.
|
||||
/// </summary>
|
||||
public Vector2 TexCoord;
|
||||
public Float2 TexCoord;
|
||||
|
||||
/// <summary>
|
||||
/// The normal vector.
|
||||
/// </summary>
|
||||
public Vector3 Normal;
|
||||
public Float3 Normal;
|
||||
|
||||
/// <summary>
|
||||
/// The tangent vector.
|
||||
/// </summary>
|
||||
public Vector3 Tangent;
|
||||
public Float3 Tangent;
|
||||
|
||||
/// <summary>
|
||||
/// The tangent vector.
|
||||
/// </summary>
|
||||
public Vector3 Bitangent;
|
||||
public Float3 Bitangent;
|
||||
|
||||
/// <summary>
|
||||
/// The blend indices. Up to 4 bones.
|
||||
@@ -80,7 +80,7 @@ namespace FlaxEngine
|
||||
/// <summary>
|
||||
/// The blend weights (normalized). Up to 4 bones.
|
||||
/// </summary>
|
||||
public Vector4 BlendWeights;
|
||||
public Float4 BlendWeights;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,9 +110,8 @@ namespace FlaxEngine
|
||||
/// <param name="normals">The normal vectors (per vertex).</param>
|
||||
/// <param name="tangents">The normal vectors (per vertex). Use null to compute them from normal vectors.</param>
|
||||
/// <param name="uv">The texture coordinates (per vertex).</param>
|
||||
public void UpdateMesh(Vector3[] vertices, int[] triangles, Int4[] blendIndices, Vector4[] blendWeights, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null)
|
||||
public void UpdateMesh(Float3[] vertices, int[] triangles, Int4[] blendIndices, Float4[] blendWeights, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null)
|
||||
{
|
||||
// Validate state and input
|
||||
if (!ParentSkinnedModel.IsVirtual)
|
||||
throw new InvalidOperationException("Only virtual skinned models can be updated at runtime.");
|
||||
if (vertices == null)
|
||||
@@ -146,9 +145,8 @@ namespace FlaxEngine
|
||||
/// <param name="normals">The normal vectors (per vertex).</param>
|
||||
/// <param name="tangents">The normal vectors (per vertex). Use null to compute them from normal vectors.</param>
|
||||
/// <param name="uv">The texture coordinates (per vertex).</param>
|
||||
public void UpdateMesh(Vector3[] vertices, uint[] triangles, Int4[] blendIndices, Vector4[] blendWeights, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null)
|
||||
public void UpdateMesh(Float3[] vertices, uint[] triangles, Int4[] blendIndices, Float4[] blendWeights, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null)
|
||||
{
|
||||
// Validate state and input
|
||||
if (!ParentSkinnedModel.IsVirtual)
|
||||
throw new InvalidOperationException("Only virtual skinned models can be updated at runtime.");
|
||||
if (vertices == null)
|
||||
@@ -182,9 +180,8 @@ namespace FlaxEngine
|
||||
/// <param name="normals">The normal vectors (per vertex).</param>
|
||||
/// <param name="tangents">The tangent vectors (per vertex). Use null to compute them from normal vectors.</param>
|
||||
/// <param name="uv">The texture coordinates (per vertex).</param>
|
||||
public void UpdateMesh(Vector3[] vertices, ushort[] triangles, Int4[] blendIndices, Vector4[] blendWeights, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null)
|
||||
public void UpdateMesh(Float3[] vertices, ushort[] triangles, Int4[] blendIndices, Float4[] blendWeights, Float3[] normals = null, Float3[] tangents = null, Float2[] uv = null)
|
||||
{
|
||||
// Validate state and input
|
||||
if (!ParentSkinnedModel.IsVirtual)
|
||||
throw new InvalidOperationException("Only virtual skinned models can be updated at runtime.");
|
||||
if (vertices == null)
|
||||
@@ -206,6 +203,63 @@ namespace FlaxEngine
|
||||
throw new Exception("Failed to update mesh data.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the skinned model mesh vertex and index buffer data.
|
||||
/// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
|
||||
/// Mesh data will be cached and uploaded to the GPU with a delay.
|
||||
/// [Deprecated on 26.05.2022, expires on 26.05.2024]
|
||||
/// </summary>
|
||||
/// <param name="vertices">The mesh vertices positions. Cannot be null.</param>
|
||||
/// <param name="triangles">The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null.</param>
|
||||
/// <param name="blendIndices">The skinned mesh blend indices buffer. Contains indices of the skeleton bones (up to 4 bones per vertex) to use for vertex position blending. Cannot be null.</param>
|
||||
/// <param name="blendWeights">The skinned mesh blend weights buffer (normalized). Contains weights per blend bone (up to 4 bones per vertex) of the skeleton bones to mix for vertex position blending. Cannot be null.</param>
|
||||
/// <param name="normals">The normal vectors (per vertex).</param>
|
||||
/// <param name="tangents">The normal vectors (per vertex). Use null to compute them from normal vectors.</param>
|
||||
/// <param name="uv">The texture coordinates (per vertex).</param>
|
||||
[Obsolete("Deprecated in 1.4")]
|
||||
public void UpdateMesh(Vector3[] vertices, int[] triangles, Int4[] blendIndices, Vector4[] blendWeights, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null)
|
||||
{
|
||||
UpdateMesh(Utils.ConvertCollection(vertices), triangles, blendIndices, Utils.ConvertCollection(blendWeights), Utils.ConvertCollection(normals), Utils.ConvertCollection(tangents), Utils.ConvertCollection(uv));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the skinned model mesh vertex and index buffer data.
|
||||
/// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
|
||||
/// Mesh data will be cached and uploaded to the GPU with a delay.
|
||||
/// [Deprecated on 26.05.2022, expires on 26.05.2024]
|
||||
/// </summary>
|
||||
/// <param name="vertices">The mesh vertices positions. Cannot be null.</param>
|
||||
/// <param name="triangles">The mesh index buffer (clockwise triangles). Uses 32-bit stride buffer. Cannot be null.</param>
|
||||
/// <param name="blendIndices">The skinned mesh blend indices buffer. Contains indices of the skeleton bones (up to 4 bones per vertex) to use for vertex position blending. Cannot be null.</param>
|
||||
/// <param name="blendWeights">The skinned mesh blend weights buffer (normalized). Contains weights per blend bone (up to 4 bones per vertex) of the skeleton bones to mix for vertex position blending. Cannot be null.</param>
|
||||
/// <param name="normals">The normal vectors (per vertex).</param>
|
||||
/// <param name="tangents">The normal vectors (per vertex). Use null to compute them from normal vectors.</param>
|
||||
/// <param name="uv">The texture coordinates (per vertex).</param>
|
||||
[Obsolete("Deprecated in 1.4")]
|
||||
public void UpdateMesh(Vector3[] vertices, uint[] triangles, Int4[] blendIndices, Vector4[] blendWeights, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null)
|
||||
{
|
||||
UpdateMesh(Utils.ConvertCollection(vertices), triangles, blendIndices, Utils.ConvertCollection(blendWeights), Utils.ConvertCollection(normals), Utils.ConvertCollection(tangents), Utils.ConvertCollection(uv));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the skinned model mesh vertex and index buffer data.
|
||||
/// Can be used only for virtual assets (see <see cref="Asset.IsVirtual"/> and <see cref="Content.CreateVirtualAsset{T}"/>).
|
||||
/// Mesh data will be cached and uploaded to the GPU with a delay.
|
||||
/// [Deprecated on 26.05.2022, expires on 26.05.2024]
|
||||
/// </summary>
|
||||
/// <param name="vertices">The mesh vertices positions. Cannot be null.</param>
|
||||
/// <param name="triangles">The mesh index buffer (clockwise triangles). Uses 16-bit stride buffer. Cannot be null.</param>
|
||||
/// <param name="blendIndices">The skinned mesh blend indices buffer. Contains indices of the skeleton bones (up to 4 bones per vertex) to use for vertex position blending. Cannot be null.</param>
|
||||
/// <param name="blendWeights">The skinned mesh blend weights buffer (normalized). Contains weights per blend bone (up to 4 bones per vertex) of the skeleton bones to mix for vertex position blending. Cannot be null.</param>
|
||||
/// <param name="normals">The normal vectors (per vertex).</param>
|
||||
/// <param name="tangents">The tangent vectors (per vertex). Use null to compute them from normal vectors.</param>
|
||||
/// <param name="uv">The texture coordinates (per vertex).</param>
|
||||
[Obsolete("Deprecated in 1.4")]
|
||||
public void UpdateMesh(Vector3[] vertices, ushort[] triangles, Int4[] blendIndices, Vector4[] blendWeights, Vector3[] normals = null, Vector3[] tangents = null, Vector2[] uv = null)
|
||||
{
|
||||
UpdateMesh(Utils.ConvertCollection(vertices), triangles, blendIndices, Utils.ConvertCollection(blendWeights), Utils.ConvertCollection(normals), Utils.ConvertCollection(tangents), Utils.ConvertCollection(uv));
|
||||
}
|
||||
|
||||
internal enum InternalBufferType
|
||||
{
|
||||
VB0 = 0,
|
||||
@@ -246,12 +300,12 @@ namespace FlaxEngine
|
||||
float bitangentSign = v0.Tangent.A > Mathf.Epsilon ? -1.0f : +1.0f;
|
||||
|
||||
result[i].Position = v0.Position;
|
||||
result[i].TexCoord = (Vector2)v0.TexCoord;
|
||||
result[i].Normal = v0.Normal.ToVector3() * 2.0f - 1.0f;
|
||||
result[i].Tangent = v0.Tangent.ToVector3() * 2.0f - 1.0f;
|
||||
result[i].Bitangent = Vector3.Cross(result[i].Normal, result[i].Tangent) * bitangentSign;
|
||||
result[i].TexCoord = (Float2)v0.TexCoord;
|
||||
result[i].Normal = v0.Normal.ToFloat3() * 2.0f - 1.0f;
|
||||
result[i].Tangent = v0.Tangent.ToFloat3() * 2.0f - 1.0f;
|
||||
result[i].Bitangent = Float3.Cross(result[i].Normal, result[i].Tangent) * bitangentSign;
|
||||
result[i].BlendIndices = new Int4(v0.BlendIndices.R, v0.BlendIndices.G, v0.BlendIndices.B, v0.BlendIndices.A);
|
||||
result[i].BlendWeights = (Vector4)v0.BlendWeights;
|
||||
result[i].BlendWeights = (Float4)v0.BlendWeights;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user